[#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) ->
|
init = (dataservice) ->
|
||||||
vm.project = dataservice.project
|
vm.project = dataservice.project
|
||||||
vm.issues = dataservice.issues
|
|
||||||
vm.filter = dataservice.filter
|
vm.filter = dataservice.filter
|
||||||
|
|
||||||
vm.labels = dataservice.labels
|
vm.labels = dataservice.labels
|
||||||
|
|
||||||
vm.filter[dataservice.filter.filter] = true
|
vm.filter[dataservice.filter.filter] = true
|
||||||
|
@ -91,6 +89,7 @@ IssuesController = (dataservice, $http, $location, Issue, $rootScope) ->
|
||||||
vm.filter.status_open = true
|
vm.filter.status_open = true
|
||||||
|
|
||||||
setSortClass()
|
setSortClass()
|
||||||
|
getIssues()
|
||||||
|
|
||||||
init(dataservice)
|
init(dataservice)
|
||||||
true
|
true
|
||||||
|
|
|
@ -10,53 +10,58 @@ class Projects::IssuesController < Projects::BaseController
|
||||||
layout false, only: [:update, :search_collaborators]
|
layout false, only: [:update, :search_collaborators]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
params[:kind] ||= 'issues'
|
params[:kind] = params[:kind] == 'issues' ? 'issues' : 'pull_requests'
|
||||||
params[:filter] ||= 'all'
|
params[:filter] = params[:filter].in?(['created', 'assigned']) ? params[:filter] : 'all'
|
||||||
params[:sort] ||= :updated
|
params[:sort] = params[:sort] == 'submitted' ? 'submitted' : 'updated'
|
||||||
|
params[:direction] = params[:direction] == 'asc' ? :asc : :desc
|
||||||
if params[:kind] == 'pull_requests'
|
params[:status] = params[:status] == 'closed' ? :closed : :open
|
||||||
all_issues = @project.issues.joins(:pull_request)
|
if !params[:labels].is_a?(Array) || params[:labels].blank?
|
||||||
else
|
|
||||||
all_issues = @project.issues.without_pull_requests
|
|
||||||
end
|
|
||||||
|
|
||||||
@all_issues = all_issues
|
|
||||||
if current_user
|
|
||||||
@created_issues = all_issues.where(user_id: current_user)
|
|
||||||
@assigned_issues = all_issues.where(assignee_id: current_user)
|
|
||||||
end
|
|
||||||
|
|
||||||
case params[:filter]
|
|
||||||
when 'created'
|
|
||||||
@issues = @created_issues
|
|
||||||
when 'assigned'
|
|
||||||
@issues = @assigned_issues
|
|
||||||
else
|
|
||||||
@issues = all_issues
|
|
||||||
end
|
|
||||||
|
|
||||||
if params[:labels].is_a?(Array) && params[:labels].present?
|
|
||||||
@issues = @issues.joins(:labels).where(labels: {name: params[:labels]})
|
|
||||||
else
|
|
||||||
params[:labels] = []
|
params[:labels] = []
|
||||||
end
|
end
|
||||||
|
|
||||||
@opened_issues, @closed_issues = @issues.not_closed_or_merged, @issues.closed_or_merged
|
respond_to do |format|
|
||||||
|
format.html { render 'index' }
|
||||||
|
format.json do
|
||||||
|
if params[:kind] == 'pull_requests'
|
||||||
|
all_issues = @project.issues.joins(:pull_request)
|
||||||
|
else
|
||||||
|
all_issues = @project.issues.without_pull_requests
|
||||||
|
end
|
||||||
|
|
||||||
params[:status] = params[:status] == 'closed' ? :closed : :open
|
@all_issues = all_issues
|
||||||
@issues = @issues.send( params[:status] == :closed ? :closed_or_merged : :not_closed_or_merged )
|
if current_user
|
||||||
|
@created_issues = all_issues.where(user_id: current_user)
|
||||||
|
@assigned_issues = all_issues.where(assignee_id: current_user)
|
||||||
|
end
|
||||||
|
|
||||||
params[:direction] = params[:direction] == 'asc' ? :asc : :desc
|
case params[:filter]
|
||||||
if params[:sort] == 'submitted'
|
when 'created'
|
||||||
@issues = @issues.order(created_at: params[:direction])
|
@issues = @created_issues
|
||||||
else
|
when 'assigned'
|
||||||
@issues = @issues.order(updated_at: params[:direction])
|
@issues = @assigned_issues
|
||||||
|
else
|
||||||
|
@issues = all_issues
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:labels].is_a?(Array) && params[:labels].present?
|
||||||
|
@issues = @issues.joins(:labels).where(labels: {name: params[:labels]})
|
||||||
|
end
|
||||||
|
|
||||||
|
@opened_issues, @closed_issues = @issues.not_closed_or_merged, @issues.closed_or_merged
|
||||||
|
@issues = @issues.send( params[:status] == :closed ? :closed_or_merged : :not_closed_or_merged )
|
||||||
|
|
||||||
|
if params[:sort] == 'submitted'
|
||||||
|
@issues = @issues.order(created_at: params[:direction])
|
||||||
|
else
|
||||||
|
@issues = @issues.order(updated_at: params[:direction])
|
||||||
|
end
|
||||||
|
|
||||||
|
@issues = @issues.includes(:assignee, :user, :pull_request).uniq
|
||||||
|
.paginate(page: current_page)
|
||||||
|
|
||||||
|
render 'index'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@issues = @issues.includes(:assignee, :user, :pull_request).uniq
|
|
||||||
.paginate(page: current_page)
|
|
||||||
|
|
||||||
render 'index'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pull_requests
|
def pull_requests
|
||||||
|
|
|
@ -3,10 +3,7 @@
|
||||||
angular.module('RosaABF').service('IssuesInitializer', function(){
|
angular.module('RosaABF').service('IssuesInitializer', function(){
|
||||||
return {
|
return {
|
||||||
project: '<%= @project.name_with_owner %>',
|
project: '<%= @project.name_with_owner %>',
|
||||||
<% all_issue_ids = @all_issues.not_closed_or_merged.pluck(:id) %>
|
filter: <%= render('filter.json', all_issues: @all_issues, params: params).html_safe %>
|
||||||
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 %>
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
<% elsif action_name.in?(['new', 'create']) %>
|
<% elsif action_name.in?(['new', 'create']) %>
|
||||||
|
|
Loading…
Reference in New Issue