Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-07-17 00:10:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-07-17 00:10:05 +0300
commit831b6108d2aa46aca9bdce39a9bda33718d61fa7 (patch)
tree7578cc0f30fb75af82238cf7bf66c92a1c07e052 /app/assets/javascripts/issuable_bulk_update_actions.js
parent3a9076e0a4c28af9a1a40ed5e181b70fb1b659de (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/issuable_bulk_update_actions.js')
-rw-r--r--app/assets/javascripts/issuable_bulk_update_actions.js79
1 files changed, 21 insertions, 58 deletions
diff --git a/app/assets/javascripts/issuable_bulk_update_actions.js b/app/assets/javascripts/issuable_bulk_update_actions.js
index 94df5fe53f8..d968e9e5235 100644
--- a/app/assets/javascripts/issuable_bulk_update_actions.js
+++ b/app/assets/javascripts/issuable_bulk_update_actions.js
@@ -1,7 +1,5 @@
-/* eslint-disable consistent-return, func-names, array-callback-return */
-
import $ from 'jquery';
-import { intersection } from 'lodash';
+import { difference, intersection, union } from 'lodash';
import axios from './lib/utils/axios_utils';
import Flash from './flash';
import { __ } from './locale';
@@ -36,43 +34,6 @@ export default {
return new Flash(__('Issue update failed'));
},
- getSelectedIssues() {
- return this.issues.has('.selected-issuable:checked');
- },
-
- getLabelsFromSelection() {
- const labels = [];
- this.getSelectedIssues().map(function() {
- const labelsData = $(this).data('labels');
- if (labelsData) {
- return labelsData.map(labelId => {
- if (labels.indexOf(labelId) === -1) {
- return labels.push(labelId);
- }
- });
- }
- });
- return labels;
- },
-
- /**
- * Will return only labels that were marked previously and the user has unmarked
- * @return {Array} Label IDs
- */
-
- getUnmarkedIndeterminedLabels() {
- const result = [];
- const labelsToKeep = this.$labelDropdown.data('indeterminate');
-
- this.getLabelsFromSelection().forEach(id => {
- if (labelsToKeep.indexOf(id) === -1) {
- result.push(id);
- }
- });
-
- return result;
- },
-
/**
* Simple form serialization, it will return just what we need
* Returns key/value pairs from form data
@@ -93,35 +54,37 @@ export default {
},
};
if (this.willUpdateLabels) {
- formData.update.add_label_ids = this.$labelDropdown.data('marked');
- formData.update.remove_label_ids = this.$labelDropdown.data('unmarked');
+ formData.update.add_label_ids = this.$labelDropdown.data('user-checked');
+ formData.update.remove_label_ids = this.$labelDropdown.data('user-unchecked');
}
return formData;
},
setOriginalDropdownData() {
const $labelSelect = $('.bulk-update .js-label-select');
- const dirtyLabelIds = $labelSelect.data('marked') || [];
- const chosenLabelIds = [...this.getOriginalMarkedIds(), ...dirtyLabelIds];
-
- $labelSelect.data('common', this.getOriginalCommonIds());
- $labelSelect.data('marked', chosenLabelIds);
- $labelSelect.data('indeterminate', this.getOriginalIndeterminateIds());
+ const userCheckedIds = $labelSelect.data('user-checked') || [];
+ const userUncheckedIds = $labelSelect.data('user-unchecked') || [];
+
+ // Common labels plus user checked labels minus user unchecked labels
+ const checkedIdsToShow = difference(
+ union(this.getOriginalCommonIds(), userCheckedIds),
+ userUncheckedIds,
+ );
+
+ // Indeterminate labels minus user checked labels minus user unchecked labels
+ const indeterminateIdsToShow = difference(
+ this.getOriginalIndeterminateIds(),
+ userCheckedIds,
+ userUncheckedIds,
+ );
+
+ $labelSelect.data('marked', checkedIdsToShow);
+ $labelSelect.data('indeterminate', indeterminateIdsToShow);
},
// From issuable's initial bulk selection
getOriginalCommonIds() {
const labelIds = [];
-
- this.getElement('.selected-issuable:checked').each((i, el) => {
- labelIds.push(this.getElement(`#${this.prefixId}${el.dataset.id}`).data('labels'));
- });
- return intersection.apply(this, labelIds);
- },
-
- // From issuable's initial bulk selection
- getOriginalMarkedIds() {
- const labelIds = [];
this.getElement('.selected-issuable:checked').each((i, el) => {
labelIds.push(this.getElement(`#${this.prefixId}${el.dataset.id}`).data('labels'));
});