Commit 51b2ffaf authored by Alfredo Sumaran's avatar Alfredo Sumaran

Address feedback

parent 518dc990
......@@ -37,7 +37,7 @@
case 'projects:issues:index':
Issuable.init();
new gl.IssuableBulkActions({
page
prefixId: page === 'projects:merge_requests:index' ? 'merge_request_' : 'issue_'
});
shortcut_handler = new ShortcutsNavigation();
break;
......@@ -108,10 +108,6 @@
new ZenMode();
new MergedButtons();
break;
case 'projects:merge_requests:index':
shortcut_handler = new ShortcutsNavigation();
Issuable.init();
break;
case 'dashboard:activity':
new gl.Activities();
break;
......
......@@ -605,7 +605,7 @@
};
GitLabDropdown.prototype.rowClicked = function(el) {
var field, fieldName, groupName, isInput, selectedIndex, selectedObject, value, markedIds, unmarkedIds, i, isMarking;
var field, fieldName, groupName, isInput, selectedIndex, selectedObject, value, isMarking;
fieldName = this.options.fieldName;
isInput = $(this.el).is('input');
......
......@@ -2,8 +2,8 @@
((global) => {
class IssuableBulkActions {
constructor({ container, form, issues, page } = {}) {
this.prefixId = page === 'projects:merge_requests:index' ? 'merge_request_' : 'issue_';
constructor({ container, form, issues, prefixId } = {}) {
this.prefixId = prefixId || 'issue_';
this.form = form || this.getElement('.bulk-update');
this.$labelDropdown = this.form.find('.js-label-select');
this.issues = issues || this.getElement('.issues-list .issue');
......@@ -104,9 +104,10 @@
}
setOriginalDropdownData() {
$('.bulk-update .js-label-select').data('common', this.getOriginalCommonIds());
$('.bulk-update .js-label-select').data('marked', this.getOriginalMarkedIds());
$('.bulk-update .js-label-select').data('indeterminate', this.getOriginalIndeterminateIds());
let $labelSelect = $('.bulk-update .js-label-select');
$labelSelect.data('common', this.getOriginalCommonIds());
$labelSelect.data('marked', this.getOriginalMarkedIds());
$labelSelect.data('indeterminate', this.getOriginalIndeterminateIds());
}
// From issuable's initial bulk selection
......@@ -153,7 +154,8 @@
}
getElement(selector) {
return $('.content').find(selector);
this.scopeEl = this.scopeEl || $('.content');
return this.scopeEl.find(selector);
}
}
......
......@@ -7,7 +7,7 @@
$('.js-label-select').each(function(i, dropdown) {
var $block, $colorPreview, $dropdown, $form, $loading, $selectbox, $sidebarCollapsedValue, $value, abilityName, defaultLabel, enableLabelCreateButton, issueURLSplit, issueUpdateURL, labelHTMLTemplate, labelNoneHTMLTemplate, labelUrl, namespacePath, projectPath, saveLabelData, selectedLabel, showAny, showNo, $sidebarLabelTooltip, initialSelected, $toggleText, fieldName, useId, propertyName, showMenuAbove, $container;
$dropdown = $(dropdown);
$dropdownContainer = $dropdown.closest('.labels-filter')
$dropdownContainer = $dropdown.closest('.labels-filter');
$toggleText = $dropdown.find('.dropdown-toggle-text');
namespacePath = $dropdown.data('namespace-path');
projectPath = $dropdown.data('project-path');
......@@ -170,7 +170,7 @@
});
},
renderRow: function(label, instance) {
var $a, $li, color, colorEl, indeterminate, removesAll, selectedClass, spacing, i, marked;
var $a, $li, color, colorEl, indeterminate, removesAll, selectedClass, spacing, i, marked, dropdownName, dropdownValue;
$li = $('<li>');
$a = $('<a href="#">');
selectedClass = [];
......@@ -192,8 +192,13 @@
selectedClass.push('is-active');
}
} else {
if (this.id(label) && $form.find("input[type='hidden'][name='" + ($dropdown.data('fieldName')) + "'][value='" + this.id(label).toString().replace(/'/g, '\\\'') + "']").length) {
selectedClass.push('is-active');
if (this.id(label)) {
dropdownName = $dropdown.data('fieldName');
dropdownValue = this.id(label).toString().replace(/'/g, '\\\'');
if ($form.find("input[type='hidden'][name='" + dropdownName + "'][value='" + dropdownValue + "']").length) {
selectedClass.push('is-active');
}
}
if ($dropdown.hasClass('js-multiselect') && removesAll) {
......@@ -423,6 +428,7 @@
};
LabelsSelect.prototype.setDropdownData = function($dropdown, isMarking, value) {
var i, markedIds, unmarkedIds, indeterminateIds;
var issuableBulkActions = $('.bulk-update').data('bulkActions');
markedIds = $dropdown.data('marked') || [];
......@@ -467,7 +473,9 @@
LabelsSelect.prototype.setOriginalDropdownData = function($container, $dropdown) {
var labels = [];
$container.find('[name="label_name[]"]').map(function() { return labels.push(this.value); });
$container.find('[name="label_name[]"]').map(function() {
return labels.push(this.value);
});
$dropdown.data('marked', labels);
};
......
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