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': case 'projects:issues:index':
Issuable.init(); Issuable.init();
new gl.IssuableBulkActions({ new gl.IssuableBulkActions({
page prefixId: page === 'projects:merge_requests:index' ? 'merge_request_' : 'issue_'
}); });
shortcut_handler = new ShortcutsNavigation(); shortcut_handler = new ShortcutsNavigation();
break; break;
@ -108,10 +108,6 @@
new ZenMode(); new ZenMode();
new MergedButtons(); new MergedButtons();
break; break;
case 'projects:merge_requests:index':
shortcut_handler = new ShortcutsNavigation();
Issuable.init();
break;
case 'dashboard:activity': case 'dashboard:activity':
new gl.Activities(); new gl.Activities();
break; break;

View file

@ -605,7 +605,7 @@
}; };
GitLabDropdown.prototype.rowClicked = function(el) { 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; fieldName = this.options.fieldName;
isInput = $(this.el).is('input'); isInput = $(this.el).is('input');

View file

@ -2,8 +2,8 @@
((global) => { ((global) => {
class IssuableBulkActions { class IssuableBulkActions {
constructor({ container, form, issues, page } = {}) { constructor({ container, form, issues, prefixId } = {}) {
this.prefixId = page === 'projects:merge_requests:index' ? 'merge_request_' : 'issue_'; this.prefixId = prefixId || 'issue_';
this.form = form || this.getElement('.bulk-update'); this.form = form || this.getElement('.bulk-update');
this.$labelDropdown = this.form.find('.js-label-select'); this.$labelDropdown = this.form.find('.js-label-select');
this.issues = issues || this.getElement('.issues-list .issue'); this.issues = issues || this.getElement('.issues-list .issue');
@ -104,9 +104,10 @@
} }
setOriginalDropdownData() { setOriginalDropdownData() {
$('.bulk-update .js-label-select').data('common', this.getOriginalCommonIds()); let $labelSelect = $('.bulk-update .js-label-select');
$('.bulk-update .js-label-select').data('marked', this.getOriginalMarkedIds()); $labelSelect.data('common', this.getOriginalCommonIds());
$('.bulk-update .js-label-select').data('indeterminate', this.getOriginalIndeterminateIds()); $labelSelect.data('marked', this.getOriginalMarkedIds());
$labelSelect.data('indeterminate', this.getOriginalIndeterminateIds());
} }
// From issuable's initial bulk selection // From issuable's initial bulk selection
@ -153,7 +154,8 @@
} }
getElement(selector) { 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) { $('.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; 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); $dropdown = $(dropdown);
$dropdownContainer = $dropdown.closest('.labels-filter') $dropdownContainer = $dropdown.closest('.labels-filter');
$toggleText = $dropdown.find('.dropdown-toggle-text'); $toggleText = $dropdown.find('.dropdown-toggle-text');
namespacePath = $dropdown.data('namespace-path'); namespacePath = $dropdown.data('namespace-path');
projectPath = $dropdown.data('project-path'); projectPath = $dropdown.data('project-path');
@ -170,7 +170,7 @@
}); });
}, },
renderRow: function(label, instance) { 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>'); $li = $('<li>');
$a = $('<a href="#">'); $a = $('<a href="#">');
selectedClass = []; selectedClass = [];
@ -192,9 +192,14 @@
selectedClass.push('is-active'); selectedClass.push('is-active');
} }
} else { } 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'); selectedClass.push('is-active');
} }
}
if ($dropdown.hasClass('js-multiselect') && removesAll) { if ($dropdown.hasClass('js-multiselect') && removesAll) {
selectedClass.push('dropdown-clear-active'); selectedClass.push('dropdown-clear-active');
@ -423,6 +428,7 @@
}; };
LabelsSelect.prototype.setDropdownData = function($dropdown, isMarking, value) { LabelsSelect.prototype.setDropdownData = function($dropdown, isMarking, value) {
var i, markedIds, unmarkedIds, indeterminateIds;
var issuableBulkActions = $('.bulk-update').data('bulkActions'); var issuableBulkActions = $('.bulk-update').data('bulkActions');
markedIds = $dropdown.data('marked') || []; markedIds = $dropdown.data('marked') || [];
@ -467,7 +473,9 @@
LabelsSelect.prototype.setOriginalDropdownData = function($container, $dropdown) { LabelsSelect.prototype.setOriginalDropdownData = function($container, $dropdown) {
var labels = []; 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); $dropdown.data('marked', labels);
}; };