Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
603d60a2
Commit
603d60a2
authored
Sep 09, 2016
by
Bryce Johnson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor IssuesBulkAssignment to ES6.
parent
b3917d48
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
83 deletions
+63
-83
app/assets/javascripts/dispatcher.js
app/assets/javascripts/dispatcher.js
+1
-1
app/assets/javascripts/issues-bulk-assignment.js.es6
app/assets/javascripts/issues-bulk-assignment.js.es6
+56
-76
app/assets/javascripts/search_autocomplete.js.es6
app/assets/javascripts/search_autocomplete.js.es6
+6
-6
No files found.
app/assets/javascripts/dispatcher.js
View file @
603d60a2
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
case
'
projects:merge_requests:index
'
:
case
'
projects:merge_requests:index
'
:
case
'
projects:issues:index
'
:
case
'
projects:issues:index
'
:
Issuable
.
init
();
Issuable
.
init
();
new
IssuableBulkActions
();
new
gl
.
IssuableBulkActions
();
shortcut_handler
=
new
ShortcutsNavigation
();
shortcut_handler
=
new
ShortcutsNavigation
();
break
;
break
;
case
'
projects:issues:show
'
:
case
'
projects:issues:show
'
:
...
...
app/assets/javascripts/issues-bulk-assignment.js.es6
View file @
603d60a2
(function() {
((global) => {
this.IssuableBulkActions = (function() {
function IssuableBulkActions(opts) {
class IssuableBulkActions {
// Set defaults
constructor({ container, form, issues } = {}) {
var ref, ref1, ref2;
this.container = container || $('.content'),
if (opts == null) {
this.form = form || this.getElement('.bulk-update');
opts = {};
this.issues = issues || this.getElement('.issues-list .issue');
}
this.container = (ref = opts.container) != null ? ref : $('.content'), this.form = (ref1 = opts.form) != null ? ref1 : this.getElement('.bulk-update'), this.issues = (ref2 = opts.issues) != null ? ref2 : this.getElement('.issuable-list > li');
// Save instance
this.form.data('bulkActions', this);
this.form.data('bulkActions', this);
this.willUpdateLabels = false;
this.willUpdateLabels = false;
this.bindEvents();
this.bindEvents();
...
@@ -15,53 +12,46 @@
...
@@ -15,53 +12,46 @@
Issuable.initChecks();
Issuable.initChecks();
}
}
IssuableBulkActions.prototype.getElement = function
(selector) {
getElement
(selector) {
return this.container.find(selector);
return this.container.find(selector);
}
;
}
IssuableBulkActions.prototype.bindEvents = function
() {
bindEvents
() {
return this.form.off('submit').on('submit', this.onFormSubmit.bind(this));
return this.form.off('submit').on('submit', this.onFormSubmit.bind(this));
}
;
}
IssuableBulkActions.prototype.onFormSubmit = function
(e) {
onFormSubmit
(e) {
e.preventDefault();
e.preventDefault();
return this.submit();
return this.submit();
}
;
}
IssuableBulkActions.prototype.submit = function() {
submit() {
var _this, xhr;
const _this = this;
_this = this;
const xhr = $.ajax({
xhr = $.ajax({
url: this.form.attr('action'),
url: this.form.attr('action'),
method: this.form.attr('method'),
method: this.form.attr('method'),
dataType: 'JSON',
dataType: 'JSON',
data: this.getFormDataAsObject()
data: this.getFormDataAsObject()
});
});
xhr.done(function(response, status, xhr) {
xhr.done(() => window.location.reload());
return location.reload();
xhr.fail(() => new Flash("Issue update failed"));
});
xhr.fail(function() {
return new Flash("Issue update failed");
});
return xhr.always(this.onFormSubmitAlways.bind(this));
return xhr.always(this.onFormSubmitAlways.bind(this));
}
;
}
IssuableBulkActions.prototype.onFormSubmitAlways = function
() {
onFormSubmitAlways
() {
return this.form.find('[type="submit"]').enable();
return this.form.find('[type="submit"]').enable();
}
;
}
IssuableBulkActions.prototype.getSelectedIssues = function
() {
getSelectedIssues
() {
return this.issues.has('.selected_issue:checked');
return this.issues.has('.selected_issue:checked');
}
;
}
IssuableBulkActions.prototype.getLabelsFromSelection = function() {
getLabelsFromSelection() {
var labels;
const labels = [];
labels = [];
this.getSelectedIssues().map(function() {
this.getSelectedIssues().map(function() {
var _labels;
const labelsData = $(this).data('labels');
_labels = $(this).data('labels');
if (labelsData) {
if (_labels) {
return labelsData.map(function(labelId) {
return _labels.map(function(labelId) {
if (labels.indexOf(labelId) === -1) {
if (labels.indexOf(labelId) === -1) {
return labels.push(labelId);
return labels.push(labelId);
}
}
...
@@ -69,7 +59,7 @@
...
@@ -69,7 +59,7 @@
}
}
});
});
return labels;
return labels;
}
;
}
/**
/**
...
@@ -77,25 +67,19 @@
...
@@ -77,25 +67,19 @@
* @return {Array} Label IDs
* @return {Array} Label IDs
*/
*/
IssuableBulkActions.prototype.getUnmarkedIndeterminedLabels = function() {
getUnmarkedIndeterminedLabels() {
var el, i, id, j, labelsToKeep, len, len1, ref, ref1, result;
const result = [];
result = [];
const elements = this.getElement('.labels-filter .is-indeterminate');
labelsToKeep = [];
const labelsToKeep = elements.map((el) => labelsToKeep.push($(el).data('labelId')));
ref = this.getElement('.labels-filter .is-indeterminate');
const selectedLabels = this.getLabelsFromSelection()
for (i = 0, len = ref.length; i < len; i++) {
.forEach(() => {
el = ref[i];
const id = selectedLabels[j];
labelsToKeep.push($(el).data('labelId'));
}
ref1 = this.getLabelsFromSelection();
for (j = 0, len1 = ref1.length; j < len1; j++) {
id = ref1[j];
// Only the ones that we are not going to keep
if (labelsToKeep.indexOf(id) === -1) {
if (labelsToKeep.indexOf(id) === -1) {
result.push(id);
result.push(id);
}
}
}
});
return result;
return result;
}
;
}
/**
/**
...
@@ -103,9 +87,8 @@
...
@@ -103,9 +87,8 @@
* Returns key/value pairs from form data
* Returns key/value pairs from form data
*/
*/
IssuableBulkActions.prototype.getFormDataAsObject = function() {
getFormDataAsObject() {
var formData;
const formData = {
formData = {
update: {
update: {
state_event: this.form.find('input[name="update[state_event]"]').val(),
state_event: this.form.find('input[name="update[state_event]"]').val(),
assignee_id: this.form.find('input[name="update[assignee_id]"]').val(),
assignee_id: this.form.find('input[name="update[assignee_id]"]').val(),
...
@@ -125,19 +108,18 @@
...
@@ -125,19 +108,18 @@
});
});
}
}
return formData;
return formData;
}
;
}
IssuableBulkActions.prototype.getLabelsToApply = function() {
getLabelsToApply() {
var $labels, labelIds;
const labelIds = [];
labelIds = [];
const $labels = this.form.find('.labels-filter input[name="update[label_ids][]"]');
$labels = this.form.find('.labels-filter input[name="update[label_ids][]"]');
$labels.each(function(k, label) {
$labels.each(function(k, label) {
if (label) {
if (label) {
return labelIds.push(parseInt($(label).val()));
return labelIds.push(parseInt($(label).val()));
}
}
});
});
return labelIds;
return labelIds;
}
;
}
/**
/**
...
@@ -145,11 +127,10 @@
...
@@ -145,11 +127,10 @@
* @return {Array} Array of labels IDs
* @return {Array} Array of labels IDs
*/
*/
IssuableBulkActions.prototype.getLabelsToRemove = function() {
getLabelsToRemove() {
var indeterminatedLabels, labelsToApply, result;
const result = [];
result = [];
const indeterminatedLabels = this.getUnmarkedIndeterminedLabels();
indeterminatedLabels = this.getUnmarkedIndeterminedLabels();
const labelsToApply = this.getLabelsToApply();
labelsToApply = this.getLabelsToApply();
indeterminatedLabels.map(function(id) {
indeterminatedLabels.map(function(id) {
// We need to exclude label IDs that will be applied
// We need to exclude label IDs that will be applied
// By not doing this will cause issues from selection to not add labels at all
// By not doing this will cause issues from selection to not add labels at all
...
@@ -158,10 +139,9 @@
...
@@ -158,10 +139,9 @@
}
}
});
});
return result;
return result;
};
}
}
return IssuableBulkActions;
})()
;
global.IssuableBulkActions = IssuableBulkActions
;
})
.call(this
);
})
(window.gl || (window.gl = {})
);
app/assets/javascripts/search_autocomplete.js.es6
View file @
603d60a2
...
@@ -9,14 +9,14 @@
...
@@ -9,14 +9,14 @@
};
};
class SearchAutocomplete {
class SearchAutocomplete {
constructor({ wrap, optsEl, autocompletePath, projectId, projectRef }) {
constructor({ wrap, optsEl, autocompletePath, projectId, projectRef }
= {}
) {
this.bindEventContext();
this.bindEventContext();
this.wrap = wrap || $('.search');
this.wrap = wrap || $('.search');
this.optsEl = optsEl || wrap.find('.search-autocomplete-opts');
this.optsEl = optsEl ||
this.
wrap.find('.search-autocomplete-opts');
this.autocompletePath = autocompletePath || optsEl.data('autocomplete-path');
this.autocompletePath = autocompletePath ||
this.
optsEl.data('autocomplete-path');
this.projectId = projectId || (optsEl.data('autocomplete-project-id') || '');
this.projectId = projectId || (
this.
optsEl.data('autocomplete-project-id') || '');
this.projectRef = projectRef || (optsEl.data('autocomplete-project-ref') || '');
this.projectRef = projectRef || (
this.
optsEl.data('autocomplete-project-ref') || '');
this.dropdown = wrap.find('.dropdown');
this.dropdown =
this.
wrap.find('.dropdown');
this.dropdownContent = this.dropdown.find('.dropdown-content');
this.dropdownContent = this.dropdown.find('.dropdown-content');
this.locationBadgeEl = this.getElement('.location-badge');
this.locationBadgeEl = this.getElement('.location-badge');
this.scopeInputEl = this.getElement('#scope');
this.scopeInputEl = this.getElement('#scope');
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment