diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-06-25 01:07:29 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-07-07 05:39:55 +0300 |
commit | 3ee3cb24d44e8a9a1284fbd0944b9fcfb938c494 (patch) | |
tree | 044374f3ccb2799eec70c6759e5e0c719eed74c5 /app | |
parent | ea565653a06125689cf30326bacfae812e1f2800 (diff) |
Allow user to filter by Issues/Merge Requests without a Milestone
Diffstat (limited to 'app')
-rw-r--r-- | app/finders/issuable_finder.rb | 9 | ||||
-rw-r--r-- | app/helpers/milestones_helper.rb | 2 | ||||
-rw-r--r-- | app/models/no_milestone.rb | 13 | ||||
-rw-r--r-- | app/views/shared/issuable/_filter.html.haml | 8 |
4 files changed, 28 insertions, 4 deletions
diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb index 2eccc0ee31f..872c63d82bd 100644 --- a/app/finders/issuable_finder.rb +++ b/app/finders/issuable_finder.rb @@ -76,7 +76,7 @@ class IssuableFinder return @milestones if defined?(@milestones) @milestones = - if milestones? && params[:milestone_title] != NONE + if milestones? && params[:milestone_title] != NoMilestone.title Milestone.where(title: params[:milestone_title]) else nil @@ -183,7 +183,12 @@ class IssuableFinder def by_milestone(items) if milestones? - items = items.where(milestone_id: milestones.try(:pluck, :id)) + # `milestone_title` will still be present when "No Milestone" is selected + if params[:milestone_title] != NoMilestone.title + items = items.where(milestone_id: milestones.try(:pluck, :id)) + else + items = items.where(milestone_id: NoMilestone.id) + end end items diff --git a/app/helpers/milestones_helper.rb b/app/helpers/milestones_helper.rb index 93e33ebefd8..3dedc405365 100644 --- a/app/helpers/milestones_helper.rb +++ b/app/helpers/milestones_helper.rb @@ -29,6 +29,8 @@ module MilestonesHelper end.active grouped_milestones = Milestones::GroupService.new(milestones).execute + grouped_milestones.unshift(NoMilestone) + options_from_collection_for_select(grouped_milestones, 'title', 'title', params[:milestone_title]) end end diff --git a/app/models/no_milestone.rb b/app/models/no_milestone.rb new file mode 100644 index 00000000000..0c7418b5e29 --- /dev/null +++ b/app/models/no_milestone.rb @@ -0,0 +1,13 @@ +# NoMilestone +# +# Represents a "No Milestone" state used for filtering Issues and Merge Requests +# that have no milestone assigned. +class NoMilestone + def self.id + nil + end + + def self.title + 'No Milestone' + end +end diff --git a/app/views/shared/issuable/_filter.html.haml b/app/views/shared/issuable/_filter.html.haml index a829782fc4f..0e8da8de723 100644 --- a/app/views/shared/issuable/_filter.html.haml +++ b/app/views/shared/issuable/_filter.html.haml @@ -43,11 +43,15 @@ placeholder: 'Author', class: 'trigger-submit', any_user: true, first_user: true) .filter-item.inline.milestone-filter - = select_tag('milestone_title', projects_milestones_options, class: "select2 trigger-submit", prompt: 'Milestone') + = select_tag('milestone_title', projects_milestones_options, + class: 'select2 trigger-submit', include_blank: true, + data: {placeholder: 'Milestone'}) - if @project .filter-item.inline.labels-filter - = select_tag('label_name', project_labels_options(@project), class: "select2 trigger-submit", prompt: 'Label') + = select_tag('label_name', project_labels_options(@project), + class: 'select2 trigger-submit', include_blank: true, + data: {placeholder: 'Label'}) .pull-right = render 'shared/sort_dropdown' |