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

Fix issue with label select not correctly showing selected values

parent 7f0ccbac
No related branches found
No related tags found
1 merge request!5293Updated issuable form with GL dropdowns
Loading
@@ -486,7 +486,7 @@ class GitLabDropdown
Loading
@@ -486,7 +486,7 @@ class GitLabDropdown
   
# Toggle the dropdown label # Toggle the dropdown label
if @options.toggleLabel if @options.toggleLabel
@updateLabel(selectedObject, el, @) @updateLabel(selectedObject, el, @, false)
else else
selectedObject selectedObject
else if el.hasClass(INDETERMINATE_CLASS) else if el.hasClass(INDETERMINATE_CLASS)
Loading
@@ -515,7 +515,7 @@ class GitLabDropdown
Loading
@@ -515,7 +515,7 @@ class GitLabDropdown
   
# Toggle the dropdown label # Toggle the dropdown label
if @options.toggleLabel if @options.toggleLabel
@updateLabel(selectedObject, el, @) @updateLabel(selectedObject, el, @, true)
if value? if value?
if !field.length and fieldName if !field.length and fieldName
@addInput(fieldName, value) @addInput(fieldName, value)
Loading
@@ -616,8 +616,8 @@ class GitLabDropdown
Loading
@@ -616,8 +616,8 @@ class GitLabDropdown
# Scroll the dropdown content up # Scroll the dropdown content up
$dropdownContent.scrollTop(listItemTop - dropdownContentTop) $dropdownContent.scrollTop(listItemTop - dropdownContentTop)
   
updateLabel: (selected = null, el = null, instance = null) => updateLabel: (selected = null, el = null, instance = null, added = false) =>
$(@el).find(".dropdown-toggle-text").text @options.toggleLabel(selected, el, instance) $(@el).find(".dropdown-toggle-text").text @options.toggleLabel(selected, el, instance, added)
   
$.fn.glDropdown = (opts) -> $.fn.glDropdown = (opts) ->
return @.each -> return @.each ->
Loading
Loading
Loading
@@ -24,6 +24,7 @@ class @LabelsSelect
Loading
@@ -24,6 +24,7 @@ class @LabelsSelect
$newLabelError = $('.js-label-error') $newLabelError = $('.js-label-error')
$colorPreview = $('.js-dropdown-label-color-preview') $colorPreview = $('.js-dropdown-label-color-preview')
$newLabelCreateButton = $('.js-new-label-btn') $newLabelCreateButton = $('.js-new-label-btn')
selectedLabels = []
   
$newLabelError.hide() $newLabelError.hide()
$loading = $block.find('.block-loading').fadeOut() $loading = $block.find('.block-loading').fadeOut()
Loading
@@ -272,19 +273,17 @@ class @LabelsSelect
Loading
@@ -272,19 +273,17 @@ class @LabelsSelect
fields: ['title'] fields: ['title']
selectable: true selectable: true
filterable: true filterable: true
toggleLabel: (selected, el) -> toggleLabel: (selected, el, e, added) ->
selected_labels = $('.js-label-select').siblings('.dropdown-menu-labels').find('.is-active') if added
selectedLabels.push selected.title
else
index = selectedLabels.indexOf selected.title
selectedLabels.splice index, 1
   
if selected and selected.title? if selectedLabels.length > 1
if selected_labels.length > 1 "#{selectedLabels[0]} +#{selectedLabels.length - 1} more"
"#{selected.title} +#{selected_labels.length - 1} more" else if selectedLabels.length is 1
else selectedLabels[0]
selected.title
else if not selected and selected_labels.length isnt 0
if selected_labels.length > 1
"#{$(selected_labels[0]).text()} +#{selected_labels.length - 1} more"
else if selected_labels.length is 1
$(selected_labels).text()
else else
defaultLabel defaultLabel
fieldName: $dropdown.data('field-name') fieldName: $dropdown.data('field-name')
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment