Commit 9d96b9eb authored by Alfredo Sumaran's avatar Alfredo Sumaran

Fixes icon state when selecting issues that have the same labels assigned

parent 84632f0a
...@@ -302,6 +302,9 @@ class GitLabDropdown ...@@ -302,6 +302,9 @@ class GitLabDropdown
if @options.setIndeterminateIds if @options.setIndeterminateIds
@options.setIndeterminateIds.call(@) @options.setIndeterminateIds.call(@)
if @options.setActiveIds
@options.setActiveIds.call(@)
# Makes indeterminate items effective # Makes indeterminate items effective
if @fullData and @dropdown.find('.dropdown-menu-toggle').hasClass('js-filter-bulk-update') if @fullData and @dropdown.find('.dropdown-menu-toggle').hasClass('js-filter-bulk-update')
@parseData @fullData @parseData @fullData
......
...@@ -210,9 +210,21 @@ class @LabelsSelect ...@@ -210,9 +210,21 @@ class @LabelsSelect
if $dropdown.hasClass('js-filter-bulk-update') if $dropdown.hasClass('js-filter-bulk-update')
indeterminate = instance.indeterminateIds indeterminate = instance.indeterminateIds
active = instance.activeIds
if indeterminate.indexOf(label.id) isnt -1 if indeterminate.indexOf(label.id) isnt -1
selectedClass.push 'is-indeterminate' selectedClass.push 'is-indeterminate'
if active.indexOf(label.id) isnt -1
# Remove is-indeterminate class if the item will be marked as active
i = selectedClass.indexOf 'is-indeterminate'
selectedClass.splice i, 1 unless i is -1
selectedClass.push 'is-active'
# Add input manually
instance.addInput @fieldName, label.id
if $form.find("input[type='hidden']\ if $form.find("input[type='hidden']\
[name='#{$dropdown.data('fieldName')}']\ [name='#{$dropdown.data('fieldName')}']\
[value='#{this.id(label)}']").length [value='#{this.id(label)}']").length
...@@ -328,6 +340,10 @@ class @LabelsSelect ...@@ -328,6 +340,10 @@ class @LabelsSelect
setIndeterminateIds: -> setIndeterminateIds: ->
if @dropdown.find('.dropdown-menu-toggle').hasClass('js-filter-bulk-update') if @dropdown.find('.dropdown-menu-toggle').hasClass('js-filter-bulk-update')
@indeterminateIds = _this.getIndeterminateIds() @indeterminateIds = _this.getIndeterminateIds()
setActiveIds: ->
if @dropdown.find('.dropdown-menu-toggle').hasClass('js-filter-bulk-update')
@activeIds = _this.getActiveIds()
) )
@bindEvents() @bindEvents()
...@@ -352,3 +368,12 @@ class @LabelsSelect ...@@ -352,3 +368,12 @@ class @LabelsSelect
label_ids.push $("#issue_#{issue_id}").data('labels') label_ids.push $("#issue_#{issue_id}").data('labels')
_.flatten(label_ids) _.flatten(label_ids)
getActiveIds: ->
label_ids = []
$('.selected_issue:checked').each (i, el) ->
issue_id = $(el).data('id')
label_ids.push $("#issue_#{issue_id}").data('labels')
_.intersection.apply _, label_ids
...@@ -190,7 +190,8 @@ feature 'Issues > Labels bulk assignment', feature: true do ...@@ -190,7 +190,8 @@ feature 'Issues > Labels bulk assignment', feature: true do
end end
if unmark if unmark
items.map do |item| items.map do |item|
click_link item # Make sure we are unmarking the item no matter the state it has currently
click_link item while find('a', text: item)[:class] == 'label-item'
end end
end end
end end
......
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