Commit 9814c646 authored by Mike Greiling's avatar Mike Greiling

Merge branch...

Merge branch '44127-board-label-edit-drop-down-is-showing-incorrect-selected-labels-summary' into 'master'

Resolve "Board label edit drop down is showing incorrect selected labels summary"

Closes #44127

See merge request gitlab-org/gitlab-ce!20673
parents 821f1a64 0b3ff726
...@@ -51,6 +51,16 @@ gl.issueBoards.BoardSidebar = Vue.extend({ ...@@ -51,6 +51,16 @@ gl.issueBoards.BoardSidebar = Vue.extend({
canRemove() { canRemove() {
return !this.list.preset; return !this.list.preset;
}, },
hasLabels() {
return this.issue.labels && this.issue.labels.length;
},
labelDropdownTitle() {
return this.hasLabels ?
`${this.issue.labels[0].title} ${this.issue.labels.length - 1}+ more` : 'Label';
},
selectedLabels() {
return this.hasLabels ? this.issue.labels.map(l => l.title).join(',') : '';
}
}, },
watch: { watch: {
detail: { detail: {
......
...@@ -616,8 +616,12 @@ GitLabDropdown = (function() { ...@@ -616,8 +616,12 @@ GitLabDropdown = (function() {
} }
if (this.options.opened) { if (this.options.opened) {
if (this.options.preserveContext) {
this.options.opened(e);
} else {
this.options.opened.call(this, e); this.options.opened.call(this, e);
} }
}
return this.dropdown.trigger('shown.gl.dropdown'); return this.dropdown.trigger('shown.gl.dropdown');
}; };
......
...@@ -39,7 +39,7 @@ export default class LabelsSelect { ...@@ -39,7 +39,7 @@ export default class LabelsSelect {
showNo = $dropdown.data('showNo'); showNo = $dropdown.data('showNo');
showAny = $dropdown.data('showAny'); showAny = $dropdown.data('showAny');
showMenuAbove = $dropdown.data('showMenuAbove'); showMenuAbove = $dropdown.data('showMenuAbove');
defaultLabel = $dropdown.data('defaultLabel'); defaultLabel = $dropdown.data('defaultLabel') || 'Label';
abilityName = $dropdown.data('abilityName'); abilityName = $dropdown.data('abilityName');
$selectbox = $dropdown.closest('.selectbox'); $selectbox = $dropdown.closest('.selectbox');
$block = $selectbox.closest('.block'); $block = $selectbox.closest('.block');
...@@ -244,21 +244,21 @@ export default class LabelsSelect { ...@@ -244,21 +244,21 @@ export default class LabelsSelect {
var $dropdownInputField = $dropdownParent.find('.dropdown-input-field'); var $dropdownInputField = $dropdownParent.find('.dropdown-input-field');
var isSelected = el !== null ? el.hasClass('is-active') : false; var isSelected = el !== null ? el.hasClass('is-active') : false;
var { title } = selected; var title = selected ? selected.title : null;
var selectedLabels = this.selected; var selectedLabels = this.selected;
if ($dropdownInputField.length && $dropdownInputField.val().length) { if ($dropdownInputField.length && $dropdownInputField.val().length) {
$dropdownParent.find('.dropdown-input-clear').trigger('click'); $dropdownParent.find('.dropdown-input-clear').trigger('click');
} }
if (selected.id === 0) { if (selected && selected.id === 0) {
this.selected = []; this.selected = [];
return 'No Label'; return 'No Label';
} }
else if (isSelected) { else if (isSelected) {
this.selected.push(title); this.selected.push(title);
} }
else { else if (!isSelected && title) {
var index = this.selected.indexOf(title); var index = this.selected.indexOf(title);
this.selected.splice(index, 1); this.selected.splice(index, 1);
} }
...@@ -409,6 +409,14 @@ export default class LabelsSelect { ...@@ -409,6 +409,14 @@ export default class LabelsSelect {
} }
} }
}, },
opened: function(e) {
if ($dropdown.hasClass('js-issue-board-sidebar')) {
const previousSelection = $dropdown.attr('data-selected');
this.selected = previousSelection ? previousSelection.split(',') : [];
$dropdown.data('glDropdown').updateLabel();
}
},
preserveContext: true,
}); });
// Set dropdown data // Set dropdown data
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
":value" => "label.id" } ":value" => "label.id" }
.dropdown .dropdown
%button.dropdown-menu-toggle.js-label-select.js-multiselect.js-issue-board-sidebar{ type: "button", %button.dropdown-menu-toggle.js-label-select.js-multiselect.js-issue-board-sidebar{ type: "button",
"v-bind:data-selected" => "selectedLabels",
data: { toggle: "dropdown", data: { toggle: "dropdown",
field_name: "issue[label_names][]", field_name: "issue[label_names][]",
show_no: "true", show_no: "true",
...@@ -28,7 +29,7 @@ ...@@ -28,7 +29,7 @@
namespace_path: @namespace_path, namespace_path: @namespace_path,
project_path: @project.try(:path) } } project_path: @project.try(:path) } }
%span.dropdown-toggle-text %span.dropdown-toggle-text
= _("Label") {{ labelDropdownTitle }}
= icon('chevron-down') = icon('chevron-down')
.dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable .dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable
= render partial: "shared/issuable/label_page_default" = render partial: "shared/issuable/label_page_default"
......
---
title: Board label edit dropdown shows incorrect selected labels summary
merge_request: 20673
author:
type: fixed
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