Commit bf1d0cbe authored by Phil Hughes's avatar Phil Hughes

Fixed label dropdown not selecting no labels

parent 0a986081
......@@ -27,6 +27,10 @@ class @LabelsSelect
$newLabelCreateButton = $('.js-new-label-btn')
selectedLabels = []
$("input[name='#{$dropdown.data('field-name')}']").each ->
title = $(this).data('title')
selectedLabels.push($(this).data('title')) if title
$newLabelError.hide()
$loading = $block.find('.block-loading').fadeOut()
......
......@@ -66,10 +66,12 @@
- has_labels = issuable.project.labels.any?
- selected_labels = issuable.label_ids.any? ? issuable.label_ids : nil
- label_dropdown_toggle = issuable.labels.map { |label| label.title }
- field_name = "#{issuable.class.model_name.param_key}[label_ids][]"
= f.label :label_ids, "Labels", class: "control-label #{"col-lg-4" if has_due_date}"
= hidden_field_tag field_name, ""
.col-sm-10{ class: "#{"col-lg-8" if has_due_date} #{'issuable-form-padding-top' if !has_labels}" }
.issuable-form-select-holder
= render "shared/issuable/label_dropdown", classes: ["js-issuable-form-dropdown"], selected: selected_labels, selected_toggle: label_dropdown_toggle, data_options: { field_name: "#{issuable.class.model_name.param_key}[label_ids][]", show_any: "false" }
= render "shared/issuable/label_dropdown", classes: ["js-issuable-form-dropdown"], selected: selected_labels, selected_toggle: label_dropdown_toggle, data_options: { field_name: field_name, show_any: "false" }
- if has_due_date
.col-lg-6
.form-group
......
......@@ -14,11 +14,12 @@
- if selected.present?
- if selected.respond_to?('any?')
- selected = project.labels.find(selected)
- selected.each do |label|
= hidden_field_tag data_options[:field_name], label, id: nil
= hidden_field_tag data_options[:field_name], label.id, id: nil, data: { title: label.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_toggle) }
%span.dropdown-toggle-text{ class: ("is-default" if selected.nil?) }
= h(multi_label_name(selected_toggle || selected, "Label"))
= icon('chevron-down')
.dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable
......
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