[#369] update a project issues/pull_requests page
This commit is contained in:
parent
c6c4a9628b
commit
975ae2e314
|
@ -78,9 +78,7 @@ IssuesController = (dataservice, $http, $location, Issue, $rootScope) ->
|
|||
|
||||
init = (dataservice) ->
|
||||
vm.project = dataservice.project
|
||||
vm.issues = dataservice.issues
|
||||
vm.filter = dataservice.filter
|
||||
|
||||
vm.labels = dataservice.labels
|
||||
|
||||
vm.filter[dataservice.filter.filter] = true
|
||||
|
@ -91,6 +89,7 @@ IssuesController = (dataservice, $http, $location, Issue, $rootScope) ->
|
|||
vm.filter.status_open = true
|
||||
|
||||
setSortClass()
|
||||
getIssues()
|
||||
|
||||
init(dataservice)
|
||||
true
|
||||
|
|
|
@ -10,10 +10,18 @@ class Projects::IssuesController < Projects::BaseController
|
|||
layout false, only: [:update, :search_collaborators]
|
||||
|
||||
def index
|
||||
params[:kind] ||= 'issues'
|
||||
params[:filter] ||= 'all'
|
||||
params[:sort] ||= :updated
|
||||
params[:kind] = params[:kind] == 'issues' ? 'issues' : 'pull_requests'
|
||||
params[:filter] = params[:filter].in?(['created', 'assigned']) ? params[:filter] : 'all'
|
||||
params[:sort] = params[:sort] == 'submitted' ? 'submitted' : 'updated'
|
||||
params[:direction] = params[:direction] == 'asc' ? :asc : :desc
|
||||
params[:status] = params[:status] == 'closed' ? :closed : :open
|
||||
if !params[:labels].is_a?(Array) || params[:labels].blank?
|
||||
params[:labels] = []
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render 'index' }
|
||||
format.json do
|
||||
if params[:kind] == 'pull_requests'
|
||||
all_issues = @project.issues.joins(:pull_request)
|
||||
else
|
||||
|
@ -37,16 +45,11 @@ class Projects::IssuesController < Projects::BaseController
|
|||
|
||||
if params[:labels].is_a?(Array) && params[:labels].present?
|
||||
@issues = @issues.joins(:labels).where(labels: {name: params[:labels]})
|
||||
else
|
||||
params[:labels] = []
|
||||
end
|
||||
|
||||
@opened_issues, @closed_issues = @issues.not_closed_or_merged, @issues.closed_or_merged
|
||||
|
||||
params[:status] = params[:status] == 'closed' ? :closed : :open
|
||||
@issues = @issues.send( params[:status] == :closed ? :closed_or_merged : :not_closed_or_merged )
|
||||
|
||||
params[:direction] = params[:direction] == 'asc' ? :asc : :desc
|
||||
if params[:sort] == 'submitted'
|
||||
@issues = @issues.order(created_at: params[:direction])
|
||||
else
|
||||
|
@ -58,6 +61,8 @@ class Projects::IssuesController < Projects::BaseController
|
|||
|
||||
render 'index'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pull_requests
|
||||
params[:kind] = 'pull_requests'
|
||||
|
|
|
@ -3,10 +3,7 @@
|
|||
angular.module('RosaABF').service('IssuesInitializer', function(){
|
||||
return {
|
||||
project: '<%= @project.name_with_owner %>',
|
||||
<% all_issue_ids = @all_issues.not_closed_or_merged.pluck(:id) %>
|
||||
labels: <%= render('labels.json', project: @project, all_issue_ids: all_issue_ids).html_safe %>,
|
||||
filter: <%= render('filter.json', all_issues: @all_issues, params: params).html_safe %>,
|
||||
issues: <%= render('issues.json', issues: @issues).html_safe %>
|
||||
filter: <%= render('filter.json', all_issues: @all_issues, params: params).html_safe %>
|
||||
};
|
||||
});
|
||||
<% elsif action_name.in?(['new', 'create']) %>
|
||||
|
|
Loading…
Reference in New Issue