Commit 234b86c97fa576d406201a032d2cb72e60ee21b7
1 parent
4a5e4b18
Exists in
spb-stable
and in
3 other branches
Use FilteringService for project issuus, mrs
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
3 changed files
with
17 additions
and
8 deletions
Show diff stats
app/controllers/projects/issues_controller.rb
| ... | ... | @@ -116,7 +116,10 @@ class Projects::IssuesController < Projects::ApplicationController |
| 116 | 116 | end |
| 117 | 117 | |
| 118 | 118 | def issues_filtered |
| 119 | - @issues = Issues::ListContext.new(project, current_user, params).execute | |
| 119 | + params[:scope] = 'all' if params[:scope].blank? | |
| 120 | + params[:state] = 'opened' if params[:state].blank? | |
| 121 | + params[:project_id] = @project.id | |
| 122 | + @issues = FilteringService.new.execute(Issue, current_user, params) | |
| 120 | 123 | end |
| 121 | 124 | |
| 122 | 125 | # Since iids are implemented only in 6.1 | ... | ... |
app/controllers/projects/merge_requests_controller.rb
| ... | ... | @@ -17,9 +17,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController |
| 17 | 17 | before_filter :authorize_modify_merge_request!, only: [:close, :edit, :update, :sort] |
| 18 | 18 | |
| 19 | 19 | def index |
| 20 | - sort_param = params[:sort] || 'newest' | |
| 21 | - @sort = sort_param.humanize unless sort_param.empty? | |
| 22 | - @merge_requests = MergeRequestsLoadContext.new(project, current_user, params).execute | |
| 20 | + params[:sort] ||= 'newest' | |
| 21 | + params[:scope] = 'all' if params[:scope].blank? | |
| 22 | + params[:state] = 'opened' if params[:state].blank? | |
| 23 | + params[:project_id] = @project.id | |
| 24 | + | |
| 25 | + @merge_requests = FilteringService.new.execute(MergeRequest, current_user, params) | |
| 26 | + @merge_requests = @merge_requests.page(params[:page]).per(20) | |
| 27 | + | |
| 28 | + @sort = params[:sort].humanize | |
| 23 | 29 | assignee_id, milestone_id = params[:assignee_id], params[:milestone_id] |
| 24 | 30 | @assignee = @project.team.find(assignee_id) if assignee_id.present? && !assignee_id.to_i.zero? |
| 25 | 31 | @milestone = @project.milestones.find(milestone_id) if milestone_id.present? && !milestone_id.to_i.zero? | ... | ... |
app/views/shared/_project_filter.html.haml
| ... | ... | @@ -3,8 +3,8 @@ |
| 3 | 3 | - if current_user |
| 4 | 4 | %fieldset |
| 5 | 5 | %ul.nav.nav-pills.nav-stacked |
| 6 | - %li{class: ("active" if params[:scope].blank?)} | |
| 7 | - = link_to project_filter_path(scope: nil) do | |
| 6 | + %li{class: ("active" if params[:scope] == 'all')} | |
| 7 | + = link_to project_filter_path(scope: 'all') do | |
| 8 | 8 | Everyone's |
| 9 | 9 | %li{class: ("active" if params[:scope] == 'assigned-to-me')} |
| 10 | 10 | = link_to project_filter_path(scope: 'assigned-to-me') do |
| ... | ... | @@ -16,8 +16,8 @@ |
| 16 | 16 | %fieldset |
| 17 | 17 | %legend State |
| 18 | 18 | %ul.nav.nav-pills |
| 19 | - %li{class: ("active" if params[:state].blank?)} | |
| 20 | - = link_to project_filter_path(state: nil) do | |
| 19 | + %li{class: ("active" if params[:state] == 'opened')} | |
| 20 | + = link_to project_filter_path(state: 'opened') do | |
| 21 | 21 | Open |
| 22 | 22 | %li{class: ("active" if params[:state] == 'closed')} |
| 23 | 23 | = link_to project_filter_path(state: 'closed') do | ... | ... |