Address feedback

This commit is contained in:
Alfredo Sumaran 2016-12-13 16:38:21 -05:00
parent 518dc9900c
commit 51b2ffaf7e
4 changed files with 23 additions and 17 deletions

View file

@ -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;

View file

@ -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');

View file

@ -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);
}
}

View file

@ -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,9 +192,14 @@
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) {
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) {
selectedClass.push('dropdown-clear-active');
@ -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);
};