Commit d7c5885c3ddba13e77046913f91797e05d0f732f

Authored by Dmitriy Zaporozhets
1 parent ade80e5c

Improved Issues and MR filters

app/helpers/dashboard_helper.rb
1 module DashboardHelper 1 module DashboardHelper
2 def dashboard_filter_path(entity, options={}) 2 def dashboard_filter_path(entity, options={})
  3 + exist_opts = {
  4 + status: params[:status],
  5 + project_id: params[:project_id],
  6 + }
  7 +
  8 + options = exist_opts.merge(options)
  9 +
3 case entity 10 case entity
4 when 'issue' then 11 when 'issue' then
5 dashboard_issues_path(options) 12 dashboard_issues_path(options)
@@ -9,6 +16,17 @@ module DashboardHelper @@ -9,6 +16,17 @@ module DashboardHelper
9 end 16 end
10 17
11 def entities_per_project project, entity 18 def entities_per_project project, entity
12 - project.items_for(entity).where(assignee_id: current_user.id).count 19 + items = project.items_for(entity)
  20 +
  21 + items = case params[:status]
  22 + when 'closed'
  23 + items.closed
  24 + when 'all'
  25 + items
  26 + else
  27 + items.opened
  28 + end
  29 +
  30 + items.where(assignee_id: current_user.id).count
13 end 31 end
14 end 32 end
app/views/dashboard/_filter.html.haml
1 = form_tag dashboard_filter_path(entity), method: 'get' do 1 = form_tag dashboard_filter_path(entity), method: 'get' do
2 %fieldset.dashboard-search-filter 2 %fieldset.dashboard-search-filter
3 - = search_field_tag "search", nil, { placeholder: 'Search', class: 'search-text-input' } 3 + = search_field_tag "search", params[:search], { placeholder: 'Search', class: 'search-text-input' }
4 = button_tag type: 'submit', class: 'btn' do 4 = button_tag type: 'submit', class: 'btn' do
5 %i.icon-search 5 %i.icon-search
6 6
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 %legend Status: 8 %legend Status:
9 %ul.nav.nav-pills.nav-stacked 9 %ul.nav.nav-pills.nav-stacked
10 %li{class: ("active" if !params[:status])} 10 %li{class: ("active" if !params[:status])}
11 - = link_to dashboard_filter_path(entity) do 11 + = link_to dashboard_filter_path(entity, status: nil) do
12 Open 12 Open
13 %li{class: ("active" if params[:status] == 'closed')} 13 %li{class: ("active" if params[:status] == 'closed')}
14 = link_to dashboard_filter_path(entity, status: 'closed') do 14 = link_to dashboard_filter_path(entity, status: 'closed') do