Commit ccee2aea authored by Phil Hughes's avatar Phil Hughes

Removed duplicate labels from the dropdown on dashboard

parent 47d8fb84
...@@ -7,16 +7,16 @@ module IssuablesHelper ...@@ -7,16 +7,16 @@ module IssuablesHelper
"right-sidebar-#{sidebar_gutter_collapsed? ? 'collapsed' : 'expanded'}" "right-sidebar-#{sidebar_gutter_collapsed? ? 'collapsed' : 'expanded'}"
end end
def multi_label_name(current_labels, selected_param, default_label) def multi_label_name(current_labels, default_label)
if current_labels.any? if !current_labels.nil? && current_labels.any?
title = current_labels.first.try(:title) title = current_labels.first.try(:title)
if current_labels.count > 1 if current_labels.size > 1
"#{title} +#{current_labels.count - 1} more" "#{title} +#{current_labels.size - 1} more"
else else
title title
end end
else else
selected_param.presence || default_label default_label
end end
end end
...@@ -66,10 +66,6 @@ module IssuablesHelper ...@@ -66,10 +66,6 @@ module IssuablesHelper
end end
end end
def selected_labels(project, label_query)
Label.where(label_query.merge(project_id: project)).pluck(:title).uniq
end
private private
def sidebar_gutter_collapsed? def sidebar_gutter_collapsed?
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
= render "shared/issuable/milestone_dropdown", selected: (@issuable_finder.milestones.first unless @issuable_finder.milestones.nil?), name: :milestone_title, show_any: true, show_upcoming: true = render "shared/issuable/milestone_dropdown", selected: (@issuable_finder.milestones.first unless @issuable_finder.milestones.nil?), name: :milestone_title, show_any: true, show_upcoming: true
.filter-item.inline.labels-filter .filter-item.inline.labels-filter
= render "shared/issuable/label_dropdown", selected: @issuable_finder.labels, use_id: false, selected_toggle: params[:label_name], data_options: { field_name: "label_name[]" }, show_create: controller.controller_name != "groups" = render "shared/issuable/label_dropdown", selected: @issuable_finder.labels.select(:title).uniq, use_id: false, selected_toggle: params[:label_name], data_options: { field_name: "label_name[]" }, show_create: controller.controller_name != "groups"
.pull-right .pull-right
= render 'shared/sort_dropdown' = render 'shared/sort_dropdown'
......
...@@ -15,13 +15,11 @@ ...@@ -15,13 +15,11 @@
- if selected - if selected
- selected.each do |label| - selected.each do |label|
- id = label.try(:id) || label = hidden_field_tag data_options[:field_name], use_id ? label.try(:id) : label.try(:title), id: nil
- title = label.try(:title) || label
= hidden_field_tag data_options[:field_name], use_id ? id : title, id: nil
.dropdown .dropdown
%button.dropdown-menu-toggle.js-label-select.js-multiselect{class: classes.join(' '), type: "button", data: dropdown_data} %button.dropdown-menu-toggle.js-label-select.js-multiselect{class: classes.join(' '), type: "button", data: dropdown_data}
%span.dropdown-toggle-text{ class: ("is-default" if selected.nil? || selected.empty?) } %span.dropdown-toggle-text{ class: ("is-default" if selected.nil? || selected.empty?) }
= h(multi_label_name(selected, selected_toggle.to_a.first, "Labels")) = h(multi_label_name(selected, "Labels"))
= icon('chevron-down') = icon('chevron-down')
.dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable .dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable
= render partial: "shared/issuable/label_page_default", locals: { title: "Filter by label", show_footer: show_footer, show_create: show_create } = render partial: "shared/issuable/label_page_default", locals: { title: "Filter by label", show_footer: show_footer, show_create: show_create }
......
...@@ -108,30 +108,30 @@ ...@@ -108,30 +108,30 @@
.js-due-date-calendar .js-due-date-calendar
- if issuable.project.labels.any? - if issuable.project.labels.any?
- selected_labels = issuable.labels
.block.labels .block.labels
.sidebar-collapsed-icon .sidebar-collapsed-icon
= icon('tags') = icon('tags')
%span %span
= issuable.labels_array.size = selected_labels.size
.title.hide-collapsed .title.hide-collapsed
Labels Labels
= icon('spinner spin', class: 'block-loading') = icon('spinner spin', class: 'block-loading')
- if can_edit_issuable - if can_edit_issuable
= link_to 'Edit', '#', class: 'edit-link pull-right' = link_to 'Edit', '#', class: 'edit-link pull-right'
.value.bold.issuable-show-labels.hide-collapsed{ class: ("has-labels" if issuable.labels_array.any?) } .value.bold.issuable-show-labels.hide-collapsed{ class: ("has-labels" if selected_labels.any?) }
- if issuable.labels_array.any? - if selected_labels.any?
- issuable.labels_array.each do |label| - selected_labels.each do |label|
= link_to_label(label, type: issuable.to_ability_name) = link_to_label(label, type: issuable.to_ability_name)
- else - else
%span.no-value None %span.no-value None
.selectbox.hide-collapsed .selectbox.hide-collapsed
- selected_labels = issuable.labels - selected_labels.each do |label|
- issuable.labels.each do |label|
= hidden_field_tag "#{issuable.to_ability_name}[label_names][]", label.id, id: nil = hidden_field_tag "#{issuable.to_ability_name}[label_names][]", label.id, id: nil
.dropdown .dropdown
%button.dropdown-menu-toggle.js-label-select.js-multiselect.js-label-sidebar-dropdown{type: "button", data: {toggle: "dropdown", default_label: "Labels", field_name: "#{issuable.to_ability_name}[label_names][]", ability_name: issuable.to_ability_name, show_no: "true", show_any: "true", project_id: (@project.id if @project), issue_update: issuable_json_path(issuable), labels: (namespace_project_labels_path(@project.namespace, @project, :json) if @project)}} %button.dropdown-menu-toggle.js-label-select.js-multiselect.js-label-sidebar-dropdown{type: "button", data: {toggle: "dropdown", default_label: "Labels", field_name: "#{issuable.to_ability_name}[label_names][]", ability_name: issuable.to_ability_name, show_no: "true", show_any: "true", project_id: (@project.id if @project), issue_update: issuable_json_path(issuable), labels: (namespace_project_labels_path(@project.namespace, @project, :json) if @project)}}
%span.dropdown-toggle-text{ class: ("is-default" if issuable.labels.empty?)} %span.dropdown-toggle-text{ class: ("is-default" if selected_labels.empty?)}
= h(multi_label_name(selected_labels, selected_labels.first, "Labels")) = h(multi_label_name(selected_labels, "Labels"))
= icon('chevron-down') = icon('chevron-down')
.dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable .dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable
= render partial: "shared/issuable/label_page_default" = render partial: "shared/issuable/label_page_default"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment