Skip to content

Commit

Permalink
Merge branch 'fix-issue-filter-dropdown-labels' into 'master'
Browse files Browse the repository at this point in the history
Restore placeholders in issue filters from "Any" to "Milestone" and "Label"

1f11096 included new filters but made it hard to determine which dropdown did
what. This patch restores the original placeholders.

### Before

![image](https://gitlab.com/stanhu/gitlab-ce/uploads/2326b836e364275341ea0ad8c0a0926b/image.png)

### After

![image](https://gitlab.com/stanhu/gitlab-ce/uploads/b0e519f9cf8d1a3c0f054286e3b809cb/image.png)


See merge request !1554
  • Loading branch information
dzaporozhets committed Oct 9, 2015
2 parents df3ae4e + b60bc65 commit 1a881a7
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion app/helpers/labels_helper.rb
Expand Up @@ -95,7 +95,8 @@ def text_color_for_bg(bg_color)
def project_labels_options(project)
labels = project.labels.to_a
labels.unshift(Label::None)
options_from_collection_for_select(labels, 'name', 'name', params[:label_name])
labels.unshift(Label::Any)
options_from_collection_for_select(labels, 'name', 'title', params[:label_name])
end

# Required for Gitlab::Markdown::LabelReferenceFilter
Expand Down
3 changes: 2 additions & 1 deletion app/helpers/milestones_helper.rb
Expand Up @@ -30,7 +30,8 @@ def projects_milestones_options

grouped_milestones = Milestones::GroupService.new(milestones).execute
grouped_milestones.unshift(Milestone::None)
grouped_milestones.unshift(Milestone::Any)

options_from_collection_for_select(grouped_milestones, 'title', 'title', params[:milestone_title])
options_from_collection_for_select(grouped_milestones, 'name', 'title', params[:milestone_title])
end
end
2 changes: 2 additions & 0 deletions app/models/group_milestone.rb
@@ -1,5 +1,7 @@
class GroupMilestone

alias_attribute :name, :title

def initialize(title, milestones)
@title = title
@milestones = milestones
Expand Down
4 changes: 3 additions & 1 deletion app/models/label.rb
Expand Up @@ -14,7 +14,9 @@ class Label < ActiveRecord::Base
include Referable
# Represents a "No Label" state used for filtering Issues and Merge
# Requests that have no label assigned.
None = Struct.new(:title, :name).new('No Label', 'No Label')
LabelStruct = Struct.new(:title, :name)
None = LabelStruct.new('No Label', 'No Label')
Any = LabelStruct.new('Any', '')

DEFAULT_COLOR = '#428BCA'

Expand Down
6 changes: 5 additions & 1 deletion app/models/milestone.rb
Expand Up @@ -16,7 +16,9 @@
class Milestone < ActiveRecord::Base
# Represents a "No Milestone" state used for filtering Issues and Merge
# Requests that have no milestone assigned.
None = Struct.new(:title).new('No Milestone')
MilestoneStruct = Struct.new(:title, :name)
None = MilestoneStruct.new('No Milestone', 'No Milestone')
Any = MilestoneStruct.new('Any', '')

include InternalId
include Sortable
Expand Down Expand Up @@ -47,6 +49,8 @@ class Milestone < ActiveRecord::Base
state :active
end

alias_attribute :name, :title

class << self
def search(query)
query = "%#{query}%"
Expand Down
4 changes: 2 additions & 2 deletions app/views/shared/issuable/_filter.html.haml
Expand Up @@ -39,13 +39,13 @@

.filter-item.inline.milestone-filter
= select_tag('milestone_title', projects_milestones_options,
class: 'select2 trigger-submit', include_blank: 'Any',
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', include_blank: 'Any',
class: 'select2 trigger-submit', include_blank: true,
data: {placeholder: 'Label'})

.pull-right
Expand Down

0 comments on commit 1a881a7

Please sign in to comment.