Commit c9cd2715 authored by Phil Hughes's avatar Phil Hughes

Fixed failing label dropdown tests

parent eb49e28c
...@@ -306,7 +306,7 @@ class @LabelsSelect ...@@ -306,7 +306,7 @@ class @LabelsSelect
$labelInputs = $dropdownParent.find "input[name='#{@fieldName}']" $labelInputs = $dropdownParent.find "input[name='#{@fieldName}']"
# Find the label by its attribute according the dropdown settings # Find the label by its attribute according the dropdown settings
if $dropdown.hasClass 'js-issuable-form-dropdown' if $dropdown.hasClass('js-issuable-form-dropdown') or $dropdown.hasClass('js-filter-bulk-update')
# When settings labels to a issuable we find the label for its ID # When settings labels to a issuable we find the label for its ID
whereQuery = { id: parseInt $labelInputs.first().val() } whereQuery = { id: parseInt $labelInputs.first().val() }
else else
......
...@@ -7,7 +7,7 @@ module IssuablesHelper ...@@ -7,7 +7,7 @@ module IssuablesHelper
"right-sidebar-#{sidebar_gutter_collapsed? ? 'collapsed' : 'expanded'}" "right-sidebar-#{sidebar_gutter_collapsed? ? 'collapsed' : 'expanded'}"
end end
def multi_label_name(current_labels, default_label) def multi_label_name(current_labels, param, default_label)
# current_labels may be a string from before # current_labels may be a string from before
if current_labels.is_a?(Array) && current_labels.any? if current_labels.is_a?(Array) && current_labels.any?
title = current_labels[0].try(:title) || current_labels[0] title = current_labels[0].try(:title) || current_labels[0]
...@@ -23,7 +23,11 @@ module IssuablesHelper ...@@ -23,7 +23,11 @@ module IssuablesHelper
current_labels current_labels
end end
else else
default_label if !param.empty?
param
else
default_label
end
end end
end end
...@@ -73,6 +77,10 @@ module IssuablesHelper ...@@ -73,6 +77,10 @@ module IssuablesHelper
end end
end end
def selected_labels(project, labelQuery)
Label.where(labelQuery.merge(project_id: project))
end
private private
def sidebar_gutter_collapsed? def sidebar_gutter_collapsed?
......
- project = @target_project || @project - project = @target_project || @project || @projects
- show_create = local_assigns.fetch(:show_create, true) - show_create = local_assigns.fetch(:show_create, true)
- extra_options = local_assigns.fetch(:extra_options, true) - extra_options = local_assigns.fetch(:extra_options, true)
- filter_submit = local_assigns.fetch(:filter_submit, true) - filter_submit = local_assigns.fetch(:filter_submit, true)
...@@ -18,15 +18,15 @@ ...@@ -18,15 +18,15 @@
- if selected_toggle.present? - if selected_toggle.present?
- labelQuery = { title: selected_toggle } - labelQuery = { title: selected_toggle }
- if labelQuery - if labelQuery
- selected = project.labels.where(labelQuery) - selected = selected_labels(project, labelQuery)
- selected.each do |label| - selected.each do |label|
- id = label.try(:id) || label - id = label.try(:id) || label
- title = label.try(:title) || label - title = label.try(:title) || label
= hidden_field_tag data_options[:field_name], useId ? id : title, id: nil, data: { title: title } = hidden_field_tag data_options[:field_name], useId ? id : title, id: nil, data: { title: title }
.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?) } %span.dropdown-toggle-text{ class: ("is-default" if selected.nil? || selected.to_a.size == 0) }
= h(multi_label_name(selected.to_a, "Label")) = h(multi_label_name(selected.to_a, h(selected_toggle.to_a[0]), "Label"))
= 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 }
......
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