Commit 5b126d9b authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'leipert-eslint-object-shorthand' into 'master'

Fix eslints for the object-shorthand rule

See merge request gitlab-org/gitlab!16991
parents 05a9ccc3 8df7fa38
/* eslint-disable func-names, no-var, object-shorthand, prefer-arrow-callback */
/* eslint-disable func-names, no-var, prefer-arrow-callback */
import $ from 'jquery';
import axios from '~/lib/utils/axios_utils';
......@@ -82,7 +82,7 @@ MarkdownPreview.prototype.fetchMarkdownPreview = function(text, url, success) {
})
.then(({ data }) => {
this.ajaxCache = {
text: text,
text,
response: data,
};
success(data);
......
/* eslint-disable func-names, object-shorthand, prefer-arrow-callback */
/* eslint-disable func-names, prefer-arrow-callback */
import $ from 'jquery';
import Dropzone from 'dropzone';
......@@ -32,7 +32,7 @@ export default class BlobFileDropzone {
url: form.attr('action'),
// Rails uses a hidden input field for PUT
// http://stackoverflow.com/questions/21056482/how-to-set-method-put-in-form-tag-in-rails
method: method,
method,
clickable: true,
uploadMultiple: false,
paramName: 'file',
......@@ -42,7 +42,7 @@ export default class BlobFileDropzone {
addRemoveLinks: true,
previewsContainer: '.dropzone-previews',
headers: csrf.headers,
init: function() {
init() {
this.on('addedfile', function() {
toggleLoading(submitButton, submitButtonLoadingIcon, false);
dropzoneMessage.addClass(HIDDEN_CLASS);
......@@ -69,7 +69,7 @@ export default class BlobFileDropzone {
});
},
// Override behavior of adding error underneath preview
error: function(file, errorMessage) {
error(file, errorMessage) {
const stripped = $('<div/>')
.html(errorMessage)
.text();
......
/* eslint-disable func-names, one-var, no-var, object-shorthand, no-else-return */
/* eslint-disable func-names, one-var, no-var, no-else-return */
import $ from 'jquery';
import { __ } from './locale';
......@@ -15,7 +15,7 @@ export default function initCompareAutocomplete(limitTo = null, clickHandler = (
const $fieldInput = $(`input[name="${$dropdown.data('fieldName')}"]`, $dropdownContainer);
const $filterInput = $('input[type="search"]', $dropdownContainer);
$dropdown.glDropdown({
data: function(term, callback) {
data(term, callback) {
const params = {
ref: $dropdown.data('ref'),
search: term,
......@@ -43,7 +43,7 @@ export default function initCompareAutocomplete(limitTo = null, clickHandler = (
filterRemote: Boolean($dropdown.data('refsUrl')),
fieldName: $dropdown.data('fieldName'),
filterInput: 'input[type="search"]',
renderRow: function(ref) {
renderRow(ref) {
var link;
if (ref.header != null) {
return $('<li />')
......@@ -58,10 +58,10 @@ export default function initCompareAutocomplete(limitTo = null, clickHandler = (
return $('<li />').append(link);
}
},
id: function(obj, $el) {
id(obj, $el) {
return $el.attr('data-ref');
},
toggleLabel: function(obj, $el) {
toggleLabel(obj, $el) {
return $el.text().trim();
},
clicked: () => clickHandler($dropdown),
......
/* eslint-disable object-shorthand, func-names, no-else-return, no-lonely-if */
/* eslint-disable no-else-return, no-lonely-if */
/* global CommentsStore */
import $ from 'jquery';
......@@ -19,17 +19,17 @@ const CommentAndResolveBtn = Vue.extend({
};
},
computed: {
showButton: function() {
showButton() {
if (this.discussion) {
return this.discussion.isResolvable();
} else {
return false;
}
},
isDiscussionResolved: function() {
isDiscussionResolved() {
return this.discussion.isResolved();
},
buttonText: function() {
buttonText() {
if (this.isDiscussionResolved) {
if (this.textareaIsEmpty) {
return __('Unresolve thread');
......@@ -50,7 +50,7 @@ const CommentAndResolveBtn = Vue.extend({
this.discussion = CommentsStore.state[this.discussionId];
}
},
mounted: function() {
mounted() {
if (!this.discussionId) return;
const $textarea = $(
......@@ -62,7 +62,7 @@ const CommentAndResolveBtn = Vue.extend({
this.textareaIsEmpty = $textarea.val() === '';
});
},
destroyed: function() {
destroyed() {
if (!this.discussionId) return;
$(`.js-discussion-note-form[data-discussion-id=${this.discussionId}] .note-textarea`).off(
......
/* eslint-disable object-shorthand, func-names, no-else-return, guard-for-in, no-restricted-syntax, no-lonely-if, no-continue */
/* eslint-disable func-names, no-else-return, guard-for-in, no-restricted-syntax, no-lonely-if, no-continue */
/* global CommentsStore */
import $ from 'jquery';
......@@ -15,24 +15,24 @@ const JumpToDiscussion = Vue.extend({
required: true,
},
},
data: function() {
data() {
return {
discussions: CommentsStore.state,
discussion: {},
};
},
computed: {
buttonText: function() {
buttonText() {
if (this.discussionId) {
return __('Jump to next unresolved discussion');
} else {
return __('Jump to first unresolved discussion');
}
},
allResolved: function() {
allResolved() {
return this.unresolvedDiscussionCount === 0;
},
showButton: function() {
showButton() {
if (this.discussionId) {
if (this.unresolvedDiscussionCount > 1) {
return true;
......@@ -43,7 +43,7 @@ const JumpToDiscussion = Vue.extend({
return this.unresolvedDiscussionCount >= 1;
}
},
lastResolvedId: function() {
lastResolvedId() {
let lastId;
for (const discussionId in this.discussions) {
const discussion = this.discussions[discussionId];
......@@ -59,7 +59,7 @@ const JumpToDiscussion = Vue.extend({
this.discussion = this.discussions[this.discussionId];
},
methods: {
jumpToNextUnresolvedDiscussion: function() {
jumpToNextUnresolvedDiscussion() {
let discussionsSelector;
let discussionIdsInScope;
let firstUnresolvedDiscussionId;
......
/* eslint-disable object-shorthand, func-names */
/* global CommentsStore */
import Vue from 'vue';
......@@ -13,13 +12,13 @@ window.ResolveCount = Vue.extend({
required: true,
},
},
data: function() {
data() {
return {
discussions: CommentsStore.state,
};
},
computed: {
allResolved: function() {
allResolved() {
return this.resolvedDiscussionCount === this.discussionCount;
},
resolvedCountText() {
......
/* eslint-disable object-shorthand, func-names, no-else-return */
/* eslint-disable no-else-return */
/* global CommentsStore */
/* global ResolveService */
......@@ -20,34 +20,34 @@ const ResolveDiscussionBtn = Vue.extend({
required: true,
},
},
data: function() {
data() {
return {
discussion: {},
};
},
computed: {
showButton: function() {
showButton() {
if (this.discussion) {
return this.discussion.isResolvable();
} else {
return false;
}
},
isDiscussionResolved: function() {
isDiscussionResolved() {
if (this.discussion) {
return this.discussion.isResolved();
} else {
return false;
}
},
buttonText: function() {
buttonText() {
if (this.isDiscussionResolved) {
return __('Unresolve discussion');
} else {
return __('Resolve discussion');
}
},
loading: function() {
loading() {
if (this.discussion) {
return this.discussion.loading;
} else {
......@@ -55,13 +55,13 @@ const ResolveDiscussionBtn = Vue.extend({
}
},
},
created: function() {
created() {
CommentsStore.createDiscussion(this.discussionId, this.canResolve);
this.discussion = CommentsStore.state[this.discussionId];
},
methods: {
resolve: function() {
resolve() {
ResolveService.toggleResolveForDiscussion(this.mergeRequestId, this.discussionId);
},
},
......
/* eslint-disable object-shorthand, func-names, guard-for-in, no-restricted-syntax, */
/* eslint-disable guard-for-in, no-restricted-syntax, */
const DiscussionMixins = {
computed: {
discussionCount: function() {
discussionCount() {
return Object.keys(this.discussions).length;
},
resolvedDiscussionCount: function() {
resolvedDiscussionCount() {
let resolvedCount = 0;
for (const discussionId in this.discussions) {
......@@ -18,7 +18,7 @@ const DiscussionMixins = {
return resolvedCount;
},
unresolvedDiscussionCount: function() {
unresolvedDiscussionCount() {
let unresolvedCount = 0;
for (const discussionId in this.discussions) {
......
/* eslint-disable object-shorthand, func-names, camelcase, no-restricted-syntax, guard-for-in */
/* eslint-disable camelcase, no-restricted-syntax, guard-for-in */
/* global DiscussionModel */
import Vue from 'vue';
window.CommentsStore = {
state: {},
get: function(discussionId, noteId) {
get(discussionId, noteId) {
return this.state[discussionId].getNote(noteId);
},
createDiscussion: function(discussionId, canResolve) {
createDiscussion(discussionId, canResolve) {
let discussion = this.state[discussionId];
if (!this.state[discussionId]) {
discussion = new DiscussionModel(discussionId);
......@@ -21,18 +21,18 @@ window.CommentsStore = {
return discussion;
},
create: function(noteObj) {
create(noteObj) {
const discussion = this.createDiscussion(noteObj.discussionId);
discussion.createNote(noteObj);
},
update: function(discussionId, noteId, resolved, resolved_by) {
update(discussionId, noteId, resolved, resolved_by) {
const discussion = this.state[discussionId];
const note = discussion.getNote(noteId);
note.resolved = resolved;
note.resolved_by = resolved_by;
},
delete: function(discussionId, noteId) {
delete(discussionId, noteId) {
const discussion = this.state[discussionId];
discussion.deleteNote(noteId);
......@@ -40,7 +40,7 @@ window.CommentsStore = {
Vue.delete(this.state, discussionId);
}
},
unresolvedDiscussionIds: function() {
unresolvedDiscussionIds() {
const ids = [];
for (const discussionId in this.state) {
......
/* eslint-disable no-useless-return, func-names, no-var, no-underscore-dangle, prefer-arrow-callback, one-var, prefer-template, no-new, consistent-return, object-shorthand, no-shadow, no-param-reassign, vars-on-top, no-lonely-if, no-else-return, dot-notation, no-empty */
/* eslint-disable no-useless-return, func-names, no-var, no-underscore-dangle, prefer-arrow-callback, one-var, prefer-template, no-new, consistent-return, no-shadow, no-param-reassign, vars-on-top, no-lonely-if, no-else-return, dot-notation, no-empty */
/* global Issuable */
/* global ListLabel */
......@@ -197,8 +197,8 @@ export default class LabelsSelect {
.catch(() => flash(__('Error saving label update.')));
};
$dropdown.glDropdown({
showMenuAbove: showMenuAbove,
data: function(term, callback) {
showMenuAbove,
data(term, callback) {
labelUrl = $dropdown.attr('data-labels');
axios
.get(labelUrl)
......@@ -231,7 +231,7 @@ export default class LabelsSelect {
})
.catch(() => flash(__('Error fetching labels.')));
},
renderRow: function(label) {
renderRow(label) {
var linkEl,
listItemEl,
colorEl,
......@@ -316,7 +316,7 @@ export default class LabelsSelect {
selectable: true,
filterable: true,
selected: $dropdown.data('selected') || [],
toggleLabel: function(selected, el) {
toggleLabel(selected, el) {
var $dropdownParent = $dropdown.parent();
var $dropdownInputField = $dropdownParent.find('.dropdown-input-field');
var isSelected = el !== null ? el.hasClass('is-active') : false;
......@@ -350,7 +350,7 @@ export default class LabelsSelect {
}
},
fieldName: $dropdown.data('fieldName'),
id: function(label) {
id(label) {
if (label.id <= 0) return label.title;
if ($dropdown.hasClass('js-issuable-form-dropdown')) {
......@@ -363,7 +363,7 @@ export default class LabelsSelect {
return label.id;
}
},
hidden: function() {
hidden() {
var isIssueIndex, isMRIndex, page;
page = $('body').attr('data-page');
isIssueIndex = page === 'projects:issues:index';
......@@ -394,7 +394,7 @@ export default class LabelsSelect {
},
multiSelect: $dropdown.hasClass('js-multiselect'),
vue: $dropdown.hasClass('js-issue-board-sidebar'),
clicked: function(clickEvent) {
clicked(clickEvent) {
const { $el, e, isMarking } = clickEvent;
const label = clickEvent.selectedObj;
......@@ -478,7 +478,7 @@ export default class LabelsSelect {
}
}
},
opened: function() {
opened() {
if ($dropdown.hasClass('js-issue-board-sidebar')) {
const previousSelection = $dropdown.attr('data-selected');
this.selected = previousSelection ? previousSelection.split(',') : [];
......
/* eslint-disable func-names, no-var, consistent-return, prefer-arrow-callback, no-return-assign, object-shorthand */
/* eslint-disable func-names, no-var, consistent-return, prefer-arrow-callback, no-return-assign */
function notificationGranted(message, opts, onclick) {
var notification;
......@@ -21,8 +21,8 @@ function notifyPermissions() {
function notifyMe(message, body, icon, onclick) {
var opts;
opts = {
body: body,
icon: icon,
body,
icon,
};
// Let's check if the browser supports notifications
/* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */
......
/* eslint-disable no-useless-computed-key, object-shorthand, no-param-reassign */
/* eslint-disable no-param-reassign */
/* global ace */
import Vue from 'vue';
......@@ -42,7 +42,7 @@ import getModeByFileExtension from '~/lib/utils/ace_utils';
},
},
watch: {
['file.showEditor'](val) {
'file.showEditor': function showEditorWatcher(val) {
this.resetEditorContent();
if (!val || this.fileLoaded || this.loading) {
......
/* eslint-disable object-shorthand, no-param-reassign, camelcase, no-nested-ternary, no-continue */
/* eslint-disable no-param-reassign, camelcase, no-nested-ternary, no-continue */
import $ from 'jquery';
import Vue from 'vue';
......@@ -31,7 +31,7 @@ import { s__ } from '~/locale';
hasError: false,
isSubmitting: false,
isParallel: diffViewType === VIEW_TYPES.PARALLEL,
diffViewType: diffViewType,
diffViewType,
conflictsData: {},
},
......@@ -188,7 +188,7 @@ import { s__ } from '~/locale';
getHeadHeaderLine(id) {
return {
id: id,
id,
richText: HEAD_HEADER_TEXT,
buttonTitle: HEAD_BUTTON_TITLE,
type: 'new',
......@@ -233,7 +233,7 @@ import { s__ } from '~/locale';
getOriginHeaderLine(id) {
return {
id: id,
id,
richText: ORIGIN_HEADER_TEXT,
buttonTitle: ORIGIN_BUTTON_TITLE,
type: 'old',
......
/* eslint-disable one-var, object-shorthand, no-else-return, no-self-compare, consistent-return, no-param-reassign, no-shadow */
/* eslint-disable one-var, no-else-return, no-self-compare, consistent-return, no-param-reassign, no-shadow */
/* global Issuable */
/* global ListMilestone */
......@@ -65,7 +65,7 @@ export default class MilestoneSelect {
milestoneLinkNoneTemplate = `<span class="no-value">${__('None')}</span>`;
}
return $dropdown.glDropdown({
showMenuAbove: showMenuAbove,
showMenuAbove,
data: (term, callback) =>
axios.get(milestonesUrl).then(({ data }) => {
const extraOptions = [];
......@@ -126,7 +126,7 @@ export default class MilestoneSelect {
return defaultLabel;
}
},
defaultLabel: defaultLabel,
defaultLabel,
fieldName: $dropdown.data('fieldName'),
text: milestone => _.escape(milestone.title),
id: milestone => {
......
/* eslint-disable func-names, object-shorthand, no-else-return, prefer-template, prefer-arrow-callback */
/* eslint-disable func-names, no-else-return, prefer-template, prefer-arrow-callback */
import $ from 'jquery';
import Api from './api';
......@@ -18,15 +18,15 @@ export default class NamespaceSelect {
search: {
fields: ['path'],
},
fieldName: fieldName,
toggleLabel: function(selected) {
fieldName,
toggleLabel(selected) {
if (selected.id == null) {
return selected.text;
} else {
return selected.kind + ': ' + selected.full_path;
}
},
data: function(term, dataCallback) {
data(term, dataCallback) {
return Api.namespaces(term, function(namespaces) {
if (isFilter) {
const anyNamespace = {
......@@ -39,7 +39,7 @@ export default class NamespaceSelect {
return dataCallback(namespaces);
});
},
text: function(namespace) {
text(namespace) {
if (namespace.id == null) {
return namespace.text;
} else {
......
/* eslint-disable func-names, object-shorthand, no-var, one-var, camelcase, no-param-reassign, no-return-assign, prefer-arrow-callback, consistent-return, no-cond-assign, no-else-return */
/* eslint-disable func-names, no-var, one-var, camelcase, no-param-reassign, no-return-assign, prefer-arrow-callback, consistent-return, no-cond-assign, no-else-return */
import _ from 'underscore';
export default {
parse_log: function(log) {
parse_log(log) {
var by_author, by_email, data, entry, i, len, total, normalized_email;
total = {};
by_author = {};
......@@ -25,15 +25,15 @@ export default {
total = _.toArray(total);
by_author = _.toArray(by_author);
return {
total: total,
by_author: by_author,
total,
by_author,
};
},
add_date: function(date, collection) {
add_date(date, collection) {
collection[date] = {};
return (collection[date].date = date);
},
add_author: function(author, by_author, by_email) {
add_author(author, by_author, by_email) {
var data, normalized_email;
data = {};
data.author_name = author.author_name;
......@@ -43,36 +43,36 @@ export default {
by_email[normalized_email] = data;
return data;
},
store_data: function(entry, total, by_author) {
store_data(entry, total, by_author) {
this.store_commits(total, by_author);
this.store_additions(entry, total, by_author);
return this.store_deletions(entry, total, by_author);
},
store_commits: function(total, by_author) {
store_commits(total, by_author) {
this.add(total, 'commits', 1);
return this.add(by_author, 'commits', 1);
},
add: function(collection, field, value) {
add(collection, field, value) {
if (collection[field] == null) {
collection[field] = 0;
}
return (collection[field] += value);
},
store_additions: function(entry, total, by_author) {
store_additions(entry, total, by_author) {
if (entry.additions == null) {
entry.additions = 0;
}
this.add(total, 'additions', entry.additions);
return this.add(by_author, 'additions', entry.additions);
},
store_deletions: function(entry, total, by_author) {
store_deletions(entry, total, by_author) {
if (entry.deletions == null) {
entry.deletions = 0;
}
this.add(total, 'deletions', entry.deletions);
return this.add(by_author, 'deletions', entry.deletions);
},
get_total_data: function(parsed_log, field) {
get_total_data(parsed_log, field) {
var log, total_data;
log = parsed_log.total;
total_data = this.pick_field(log, field);
......@@ -80,7 +80,7 @@ export default {
return d.date;
});
},
pick_field: function(log, field) {
pick_field(log, field) {
var total_data;
total_data = [];
_.each(log, function(d) {
......@@ -88,7 +88,7 @@ export default {
});
return total_data;
},
get_author_data: function(parsed_log, field, date_range) {
get_author_data(parsed_log, field, date_range) {
var author_data, log;
if (date_range == null) {
date_range = null;
......@@ -111,7 +111,7 @@ export default {
return d[field];
}).reverse();
},
parse_log_entry: function(log_entry, field, date_range) {
parse_log_entry(log_entry, field, date_range) {
var parsed_entry;
parsed_entry = {};
......@@ -138,7 +138,7 @@ export default {
);
return parsed_entry;
},
in_range: function(date, date_range) {
in_range(date, date_range) {
var ref;
if (date_range === null || (date_range[0] <= (ref = new Date(date)) && ref <= date_range[1])) {
return true;
......
/* eslint-disable func-names, no-var, no-return-assign, object-shorthand, vars-on-top */
/* eslint-disable func-names, no-var, no-return-assign, vars-on-top */
import $ from 'jquery';
import Cookies from 'js-cookie';
......@@ -123,7 +123,7 @@ export default class Project {
filterByText: true,
inputFieldName: $dropdown.data('inputFieldName'),
fieldName,
renderRow: function(ref) {
renderRow(ref) {
var li = refListItem.cloneNode(false);
if (ref.header != null) {
......@@ -144,13 +144,13 @@ export default class Project {
return li;
},
id: function(obj, $el) {
id(obj, $el) {
return $el.attr('data-ref');
},
toggleLabel: function(obj, $el) {
toggleLabel(obj, $el) {
return $el.text().trim();
},
clicked: function(options) {
clicked(options) {
const { e } = options;
e.preventDefault();
if ($(`input[name="${fieldName}"]`).length) {
......
/* eslint-disable no-useless-escape, no-var, no-underscore-dangle, func-names, no-return-assign, object-shorthand, one-var, consistent-return, class-methods-use-this */
/* eslint-disable no-useless-escape, no-var, no-underscore-dangle, func-names, no-return-assign, one-var, consistent-return, class-methods-use-this */
import $ from 'jquery';
import 'cropper';
......@@ -100,7 +100,7 @@ import _ from 'underscore';
cropBoxMovable: false,
cropBoxResizable: false,
toggleDragModeOnDblclick: false,
built: function() {
built() {
const $image = $(this);
const container = $image.cropper('getContainerData');
const { cropBoxWidth, cropBoxHeight } = _this;
......
/* eslint-disable func-names, no-var, object-shorthand, one-var, no-else-return */
/* eslint-disable func-names, no-var, one-var, no-else-return */
import $ from 'jquery';
import Api from './api';
......@@ -28,7 +28,7 @@ export default function projectSelect() {
}
$(select).select2({
placeholder: placeholder,
placeholder,
minimumInputLength: 0,
query: (function(_this) {
return function(query) {
......@@ -79,18 +79,18 @@ export default function projectSelect() {
}
};
})(this),
id: function(project) {
id(project) {
if (simpleFilter) return project.id;
return JSON.stringify({
name: project.name,
url: project.web_url,
});
},
text: function(project) {
text(project) {
return project.name_with_namespace || project.name;
},
initSelection: function(el, callback) {
initSelection(el, callback) {
return Api.project(el.val()).then(({ data }) => callback(data));
},
......
/* eslint-disable no-return-assign, one-var, no-var, consistent-return, object-shorthand, prefer-template, class-methods-use-this, no-lonely-if, vars-on-top */
/* eslint-disable no-return-assign, one-var, no-var, consistent-return, prefer-template, class-methods-use-this, no-lonely-if, vars-on-top */
import $ from 'jquery';
import { escape, throttle } from 'underscore';
......@@ -171,7 +171,7 @@ export class SearchAutocomplete {
params: {
project_id: this.projectId,
project_ref: this.projectRef,
term: term,
term,
},
})
.then(response => {
......
/* eslint-disable func-names, one-var, no-var, prefer-rest-params, vars-on-top, prefer-arrow-callback, consistent-return, object-shorthand, no-shadow, no-else-return, no-self-compare, prefer-template, no-unused-expressions, yoda, prefer-spread, camelcase, no-param-reassign */
/* eslint-disable func-names, one-var, no-var, prefer-rest-params, vars-on-top, prefer-arrow-callback, consistent-return, no-shadow, no-else-return, no-self-compare, prefer-template, no-unused-expressions, yoda, prefer-spread, camelcase, no-param-reassign */
/* global Issuable */
/* global emitSidebarEvent */
......@@ -248,8 +248,8 @@ function UsersSelect(currentUser, els, options = {}) {
})}</span> <% } %>`,
);
return $dropdown.glDropdown({
showMenuAbove: showMenuAbove,
data: function(term, callback) {
showMenuAbove,
data(term, callback) {
return _this.users(
term,
options,
......@@ -261,7 +261,7 @@ function UsersSelect(currentUser, els, options = {}) {
}.bind(this),
);
},
processData: function(term, data, callback) {
processData(term, data, callback) {
let users = data;
// Only show assigned user list when there is no search term
......@@ -326,7 +326,7 @@ function UsersSelect(currentUser, els, options = {}) {
}
anyUser = {
beforeDivider: true,
name: name,
name,
id: null,
};
users.unshift(anyUser);
......@@ -376,7 +376,7 @@ function UsersSelect(currentUser, els, options = {}) {
},
selectable: true,
fieldName: $dropdown.data('fieldName'),
toggleLabel: function(selected, el, glDropdown) {
toggleLabel(selected, el, glDropdown) {
const inputValue = glDropdown.filterInput.val();
if (this.multiSelect && inputValue === '') {
......@@ -404,8 +404,8 @@ function UsersSelect(currentUser, els, options = {}) {
return defaultLabel;
}
},
defaultLabel: defaultLabel,
hidden: function() {
defaultLabel,
hidden() {
if ($dropdown.hasClass('js-multiselect')) {
emitSidebarEvent('sidebar.saveAssignees');
}
......@@ -422,7 +422,7 @@ function UsersSelect(currentUser, els, options = {}) {
},
multiSelect: $dropdown.hasClass('js-multiselect'),
inputMeta: $dropdown.data('inputMeta'),
clicked: function(options) {
clicked(options) {
const { $el, e, isMarking } = options;
const user = options.selectedObj;
......@@ -522,10 +522,10 @@ function UsersSelect(currentUser, els, options = {}) {
$dropdown.dropdown('toggle');
}
},
id: function(user) {
id(user) {
return user.id;
},
opened: function(e) {
opened(e) {
const $el = $(e.currentTarget);
const selected = getSelected();
if ($dropdown.hasClass('js-issue-board-sidebar') && selected.length === 0) {
......@@ -546,7 +546,7 @@ function UsersSelect(currentUser, els, options = {}) {
}
},
updateLabel: $dropdown.data('dropdownTitle'),
renderRow: function(user) {
renderRow(user) {
var avatar, img, username;
username = user.username ? '@' + user.username : '';
avatar = user.avatar_url ? user.avatar_url : gon.default_avatar_url;
......@@ -605,7 +605,7 @@ function UsersSelect(currentUser, els, options = {}) {
placeholder: __('Search for a user'),
multiple: $(select).hasClass('multiselect'),
minimumInputLength: 0,
query: function(query) {
query(query) {
return _this.users(query.term, options, function(users) {
var anyUser, data, emailUser, index, len, name, nullUser, obj, ref;
data = {
......@@ -638,7 +638,7 @@ function UsersSelect(currentUser, els, options = {}) {
name = s__('UsersSelect|Any User');
}
anyUser = {
name: name,
name,
id: null,
};
data.results.unshift(anyUser);
......@@ -661,24 +661,24 @@ function UsersSelect(currentUser, els, options = {}) {
return query.callback(data);
});
},
initSelection: function() {
initSelection() {
var args;
args = 1 <= arguments.length ? [].slice.call(arguments, 0) : [];
return _this.initSelection.apply(_this, args);
},
formatResult: function() {
formatResult() {
var args;
args = 1 <= arguments.length ? [].slice.call(arguments, 0) : [];
return _this.formatResult.apply(_this, args);
},
formatSelection: function() {
formatSelection() {
var args;
args = 1 <= arguments.length ? [].slice.call(arguments, 0) : [];
return _this.formatSelection.apply(_this, args);
},
dropdownCssClass: 'ajax-users-dropdown',
// we do not want to escape markup since we are displaying html in results
escapeMarkup: function(m) {
escapeMarkup(m) {
return m;
},
});
......
/* eslint-disable prefer-arrow-callback, no-var, one-var, object-shorthand, consistent-return, func-names */
/* eslint-disable prefer-arrow-callback, no-var, one-var, consistent-return, func-names */
import $ from 'jquery';
import Api from 'ee/api';
......@@ -16,12 +16,12 @@ export default function initLDAPGroupsSelect() {
.then(() => {
$('.ajax-ldap-groups-select').each(function(i, select) {
return $(select).select2({
id: function(group) {
id(group) {
return group.cn;
},
placeholder: __('Search for a LDAP group'),
minimumInputLength: 1,
query: function(query) {
query(query) {
var provider;
provider = $('#ldap_group_link_provider').val();
return Api.ldapGroups(query.term, provider, function(groups) {
......@@ -32,7 +32,7 @@ export default function initLDAPGroupsSelect() {
return query.callback(data);
});
},
initSelection: function(element, callback) {
initSelection(element, callback) {
var id;
id = $(element).val();
if (id !== '') {
......@@ -44,7 +44,7 @@ export default function initLDAPGroupsSelect() {
formatResult: ldapGroupResult,
formatSelection: groupFormatSelection,
dropdownCssClass: 'ajax-groups-dropdown',
formatNoMatches: function() {
formatNoMatches() {
return __('Match not found; try refining your search query.');
},
});
......
/* eslint-disable no-var, func-names, object-shorthand, one-var, prefer-arrow-callback, prefer-template, no-else-return */
/* eslint-disable no-var, func-names, one-var, prefer-arrow-callback, prefer-template, no-else-return */
import $ from 'jquery';
import Api from '~/api';
......@@ -14,7 +14,7 @@ function AdminEmailSelect() {
placeholder: __('Select group or project'),
multiple: $(select).hasClass('multiselect'),
minimumInputLength: 0,
query: function(query) {
query(query) {
const groupsFetch = Api.groups(query.term, {});
const projectsFetch = Api.projects(query.term, {
order_by: 'id',
......@@ -31,7 +31,7 @@ function AdminEmailSelect() {
});
});
},
id: function(object) {
id(object) {
if (object.path_with_namespace) {
return 'project-' + object.id;
} else if (object.path) {
......@@ -47,7 +47,7 @@ function AdminEmailSelect() {
return _this.formatSelection(...args);
},
dropdownCssClass: 'ajax-admin-email-dropdown',
escapeMarkup: function(m) {
escapeMarkup(m) {
return m;
},
});
......
/* eslint-disable prefer-arrow-callback, one-var, no-var, object-shorthand, no-shadow, no-else-return, func-names */
/* eslint-disable prefer-arrow-callback, one-var, no-var, no-shadow, no-else-return, func-names */
import $ from 'jquery';
import '~/gl_dropdown';
......@@ -23,21 +23,21 @@ function WeightSelect(els, options = {}) {
return $dropdown.glDropdown({
selectable: true,
fieldName,
toggleLabel: function(selected, el) {
toggleLabel(selected, el) {
return $(el).data('id');
},
hidden: function() {
hidden() {
$selectbox.hide();
return $value.css('display', '');
},
id: function(obj, el) {
id(obj, el) {
if ($(el).data('none') == null) {
return $(el).data('id');
} else {
return '';
}
},
clicked: function(glDropdownEvt) {
clicked(glDropdownEvt) {
const { e } = glDropdownEvt;
let selected = glDropdownEvt.selectedObj;
const inputField = $dropdown.closest('.selectbox').find(`input[name='${fieldName}']`);
......
/* eslint-disable no-var, object-shorthand */
/* eslint-disable no-var */
import $ from 'jquery';
import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
......@@ -28,7 +28,7 @@ describe('MergeRequestTabs', function() {
beforeEach(function() {
mrPageMock = initMrPage();
this.class = new MergeRequestTabs({ stubLocation: stubLocation });
this.class = new MergeRequestTabs({ stubLocation });
setLocation();
this.spies = {
......@@ -57,10 +57,10 @@ describe('MergeRequestTabs', function() {
metaKey: false,
ctrlKey: false,
which: 1,
stopImmediatePropagation: function() {},
preventDefault: function() {},
stopImmediatePropagation() {},
preventDefault() {},
currentTarget: {
getAttribute: function(attr) {
getAttribute(attr) {
return attr === 'href' ? tabUrl : null;
},
},
......
/* eslint-disable no-var, one-var, no-unused-expressions, consistent-return, no-param-reassign, default-case, no-return-assign, object-shorthand, vars-on-top */
/* eslint-disable no-var, one-var, no-unused-expressions, consistent-return, no-param-reassign, default-case, no-return-assign, vars-on-top */
import $ from 'jquery';
import '~/gl_dropdown';
......@@ -91,7 +91,7 @@ describe('Search autocomplete dropdown', () => {
'gitlab-ce': {
issuesPath: projectIssuesPath,
mrPath: projectMRsPath,
projectName: projectName,
projectName,
},
});
};
......
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