Merge branch '18714_bulk_assign_labels_icon' into 'master'
Fixes item icon state when for issues that have the same labels assigned ## What does this MR do? Previously if all issues had the same labels the dropdown was showing the labels with indeterminate stated which is wrong. This MR fixes that and shows the correct state. ## What are the relevant issue numbers? Fixes #18714 ## Screenshots (if relevant) **Before** ![label-before](/uploads/c65aa051e773dfea898a0d19767d6ade/label-before.gif) **After** ![label](/uploads/73fd657d104d1081e189e0a9547d483b/label.gif) ## Does this MR meet the acceptance criteria? - [ ] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md) - [ ] API support added - [ ] Tests - [ ] Added for this feature/bug - [ ] All builds are passing - [ ] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !4721
This commit is contained in:
commit
204da39685
3 changed files with 30 additions and 1 deletions
|
@ -302,6 +302,9 @@ class GitLabDropdown
|
|||
if @options.setIndeterminateIds
|
||||
@options.setIndeterminateIds.call(@)
|
||||
|
||||
if @options.setActiveIds
|
||||
@options.setActiveIds.call(@)
|
||||
|
||||
# Makes indeterminate items effective
|
||||
if @fullData and @dropdown.find('.dropdown-menu-toggle').hasClass('js-filter-bulk-update')
|
||||
@parseData @fullData
|
||||
|
|
|
@ -210,9 +210,21 @@ class @LabelsSelect
|
|||
|
||||
if $dropdown.hasClass('js-filter-bulk-update')
|
||||
indeterminate = instance.indeterminateIds
|
||||
active = instance.activeIds
|
||||
|
||||
if indeterminate.indexOf(label.id) isnt -1
|
||||
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']\
|
||||
[name='#{$dropdown.data('fieldName')}']\
|
||||
[value='#{this.id(label)}']").length
|
||||
|
@ -328,6 +340,10 @@ class @LabelsSelect
|
|||
setIndeterminateIds: ->
|
||||
if @dropdown.find('.dropdown-menu-toggle').hasClass('js-filter-bulk-update')
|
||||
@indeterminateIds = _this.getIndeterminateIds()
|
||||
|
||||
setActiveIds: ->
|
||||
if @dropdown.find('.dropdown-menu-toggle').hasClass('js-filter-bulk-update')
|
||||
@activeIds = _this.getActiveIds()
|
||||
)
|
||||
|
||||
@bindEvents()
|
||||
|
@ -352,3 +368,12 @@ class @LabelsSelect
|
|||
label_ids.push $("#issue_#{issue_id}").data('labels')
|
||||
|
||||
_.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
|
|||
end
|
||||
if unmark
|
||||
items.map do |item|
|
||||
click_link item
|
||||
# Make sure we are unmarking the item no matter the state it has currently
|
||||
click_link item until find('a', text: item)[:class] == 'label-item'
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue