Skip to content
Snippets Groups Projects
Commit c9cd2715 authored by Phil Hughes's avatar Phil Hughes
Browse files

Fixed failing label dropdown tests

parent eb49e28c
No related branches found
No related tags found
1 merge request!5293Updated issuable form with GL dropdowns
Loading
Loading
@@ -306,7 +306,7 @@ class @LabelsSelect
$labelInputs = $dropdownParent.find "input[name='#{@fieldName}']"
 
# 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
whereQuery = { id: parseInt $labelInputs.first().val() }
else
Loading
Loading
Loading
Loading
@@ -7,7 +7,7 @@ module IssuablesHelper
"right-sidebar-#{sidebar_gutter_collapsed? ? 'collapsed' : 'expanded'}"
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
if current_labels.is_a?(Array) && current_labels.any?
title = current_labels[0].try(:title) || current_labels[0]
Loading
Loading
@@ -23,7 +23,11 @@ module IssuablesHelper
current_labels
end
else
default_label
if !param.empty?
param
else
default_label
end
end
end
 
Loading
Loading
@@ -73,6 +77,10 @@ module IssuablesHelper
end
end
 
def selected_labels(project, labelQuery)
Label.where(labelQuery.merge(project_id: project))
end
private
 
def sidebar_gutter_collapsed?
Loading
Loading
- project = @target_project || @project
- project = @target_project || @project || @projects
- show_create = local_assigns.fetch(:show_create, true)
- extra_options = local_assigns.fetch(:extra_options, true)
- filter_submit = local_assigns.fetch(:filter_submit, true)
Loading
Loading
@@ -18,15 +18,15 @@
- if selected_toggle.present?
- labelQuery = { title: selected_toggle }
- if labelQuery
- selected = project.labels.where(labelQuery)
- selected = selected_labels(project, labelQuery)
- selected.each do |label|
- id = label.try(:id) || label
- title = label.try(:title) || label
= hidden_field_tag data_options[:field_name], useId ? id : title, id: nil, data: { title: title }
.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?) }
= h(multi_label_name(selected.to_a, "Label"))
%span.dropdown-toggle-text{ class: ("is-default" if selected.nil? || selected.to_a.size == 0) }
= h(multi_label_name(selected.to_a, h(selected_toggle.to_a[0]), "Label"))
= 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 }
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment