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
"right-sidebar-#{sidebar_gutter_collapsed? ? 'collapsed' : 'expanded'}"
end
def multi_label_name(current_labels, selected_param, default_label)
if current_labels.any?
def multi_label_name(current_labels, default_label)
if !current_labels.nil? && current_labels.any?
title = current_labels.first.try(:title)
if current_labels.count > 1
"#{title} +#{current_labels.count - 1} more"
if current_labels.size > 1
"#{title} +#{current_labels.size - 1} more"
else
title
end
else
selected_param.presence || default_label
default_label
end
end
......@@ -66,10 +66,6 @@ module IssuablesHelper
end
end
def selected_labels(project, label_query)
Label.where(label_query.merge(project_id: project)).pluck(:title).uniq
end
private
def sidebar_gutter_collapsed?
......
......@@ -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
.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
= render 'shared/sort_dropdown'
......
......@@ -15,13 +15,11 @@
- if selected
- selected.each do |label|
- id = label.try(:id) || label
- title = label.try(:title) || label
= hidden_field_tag data_options[:field_name], use_id ? id : title, id: nil
= hidden_field_tag data_options[:field_name], use_id ? label.try(:id) : label.try(:title), id: nil
.dropdown
%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?) }
= h(multi_label_name(selected, selected_toggle.to_a.first, "Labels"))
= h(multi_label_name(selected, "Labels"))
= icon('chevron-down')
.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 }
......
......@@ -108,30 +108,30 @@
.js-due-date-calendar
- if issuable.project.labels.any?
- selected_labels = issuable.labels
.block.labels
.sidebar-collapsed-icon
= icon('tags')
%span
= issuable.labels_array.size
= selected_labels.size
.title.hide-collapsed
Labels
= icon('spinner spin', class: 'block-loading')
- if can_edit_issuable
= link_to 'Edit', '#', class: 'edit-link pull-right'
.value.bold.issuable-show-labels.hide-collapsed{ class: ("has-labels" if issuable.labels_array.any?) }
- if issuable.labels_array.any?
- issuable.labels_array.each do |label|
.value.bold.issuable-show-labels.hide-collapsed{ class: ("has-labels" if selected_labels.any?) }
- if selected_labels.any?
- selected_labels.each do |label|
= link_to_label(label, type: issuable.to_ability_name)
- else
%span.no-value None
.selectbox.hide-collapsed
- selected_labels = issuable.labels
- issuable.labels.each do |label|
- selected_labels.each do |label|
= hidden_field_tag "#{issuable.to_ability_name}[label_names][]", label.id, id: nil
.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)}}
%span.dropdown-toggle-text{ class: ("is-default" if issuable.labels.empty?)}
= h(multi_label_name(selected_labels, selected_labels.first, "Labels"))
%span.dropdown-toggle-text{ class: ("is-default" if selected_labels.empty?)}
= h(multi_label_name(selected_labels, "Labels"))
= icon('chevron-down')
.dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable
= 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