summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-08-30 12:10:05 +0100
committerPhil Hughes <me@iamphill.com>2016-08-30 12:10:05 +0100
commit2d38d35b0d367dd6e7ef493005afc87d3c4be416 (patch)
treef95e0643eff75be15c900598a4abab10b9858e8f /app
parent7418873b41acb142d33443fcbbe45e4ca6bdfd08 (diff)
downloadgitlab-ce-2d38d35b0d367dd6e7ef493005afc87d3c4be416.tar.gz
Fixed label toggle text
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/labels_select.js31
1 files changed, 17 insertions, 14 deletions
diff --git a/app/assets/javascripts/labels_select.js b/app/assets/javascripts/labels_select.js
index 4c3514e3f23..a81aae2cee3 100644
--- a/app/assets/javascripts/labels_select.js
+++ b/app/assets/javascripts/labels_select.js
@@ -212,21 +212,24 @@
},
selectable: true,
filterable: true,
+ selected: $dropdown.data('selected') || [],
toggleLabel: function(selected, el) {
- var selected_labels;
- selected_labels = $('.js-label-select').siblings('.dropdown-menu-labels').find('.is-active');
- if (selected && (selected.title != null)) {
- if (selected_labels.length > 1) {
- return selected.title + " +" + (selected_labels.length - 1) + " more";
- } else {
- return selected.title;
- }
- } else if (!selected && selected_labels.length !== 0) {
- if (selected_labels.length > 1) {
- return ($(selected_labels[0]).text()) + " +" + (selected_labels.length - 1) + " more";
- } else if (selected_labels.length === 1) {
- return $(selected_labels).text();
- }
+ var isSelected = el !== null ? el.hasClass('is-active') : false,
+ title = selected.title;
+
+ if (isSelected) {
+ this.selected.push(title);
+ } else {
+ var index = this.selected.indexOf(title);
+ this.selected.splice(index, 1);
+ }
+
+ var selectedLabels = this.selected;
+
+ if (selectedLabels.length === 1) {
+ return selectedLabels;
+ } else if (selectedLabels.length > 1) {
+ return selectedLabels[0] + " +" + (selectedLabels.length - 1) + " more";
} else {
return defaultLabel;
}