Commit 4472fd8d authored by leiminghuan's avatar leiminghuan

verify using this

parent bfce0ad8
...@@ -27,9 +27,10 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -27,9 +27,10 @@ function UsersSelect(currentUser, els, options = {}) {
} }
const { handleClick } = options; const { handleClick } = options;
const userSelect = this;
$els.each( (i, dropdown) => { $els.each( (i, dropdown) => {
const _this = this; const userSelect = this;
const options = {}; const options = {};
const $dropdown = $(dropdown); const $dropdown = $(dropdown);
options.projectId = $dropdown.data('projectId'); options.projectId = $dropdown.data('projectId');
...@@ -74,7 +75,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -74,7 +75,7 @@ function UsersSelect(currentUser, els, options = {}) {
// Save current selected user to the DOM // Save current selected user to the DOM
const currentUserInfo = $dropdown.data('currentUserInfo') || {}; const currentUserInfo = $dropdown.data('currentUserInfo') || {};
const currentUser = _this.currentUser || {}; const currentUser = userSelect.currentUser || {};
const fieldName = $dropdown.data('fieldName'); const fieldName = $dropdown.data('fieldName');
const userName = currentUserInfo.name; const userName = currentUserInfo.name;
const userId = currentUserInfo.id || currentUser.id; const userId = currentUserInfo.id || currentUser.id;
...@@ -180,7 +181,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -180,7 +181,7 @@ function UsersSelect(currentUser, els, options = {}) {
$block.on('click', '.js-assign-yourself', e => { $block.on('click', '.js-assign-yourself', e => {
e.preventDefault(); e.preventDefault();
return assignTo(_this.currentUser.id); return assignTo(userSelect.currentUser.id);
}); });
assignTo = function(selected) { assignTo = function(selected) {
...@@ -228,7 +229,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -228,7 +229,7 @@ function UsersSelect(currentUser, els, options = {}) {
return $dropdown.glDropdown({ return $dropdown.glDropdown({
showMenuAbove, showMenuAbove,
data(term, callback) { data(term, callback) {
return _this.users(term, options, users => { return userSelect.users(term, options, users => {
// GitLabDropdownFilter returns this.instance // GitLabDropdownFilter returns this.instance
// GitLabDropdownRemote returns this.options.instance // GitLabDropdownRemote returns this.options.instance
const glDropdown = this.instance || this.options.instance; const glDropdown = this.instance || this.options.instance;
...@@ -550,7 +551,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -550,7 +551,7 @@ function UsersSelect(currentUser, els, options = {}) {
img = `<img src='${avatar}' class='avatar avatar-inline m-0' width='32' />`; img = `<img src='${avatar}' class='avatar avatar-inline m-0' width='32' />`;
} }
return _this.renderRow(options.issuableType, user, selected, username, img); return userSelect.renderRow(options.issuableType, user, selected, username, img);
}, },
}); });
}); });
...@@ -558,7 +559,6 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -558,7 +559,6 @@ function UsersSelect(currentUser, els, options = {}) {
.then(() => { .then(() => {
$('.ajax-users-select').each( $('.ajax-users-select').each(
(i, select) => { (i, select) => {
const _this = this;
const options = {}; const options = {};
options.skipLdap = $(select).hasClass('skip_ldap'); options.skipLdap = $(select).hasClass('skip_ldap');
options.projectId = $(select).data('projectId'); options.projectId = $(select).data('projectId');
...@@ -575,7 +575,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -575,7 +575,7 @@ function UsersSelect(currentUser, els, options = {}) {
multiple: $(select).hasClass('multiselect'), multiple: $(select).hasClass('multiselect'),
minimumInputLength: 0, minimumInputLength: 0,
query(query) { query(query) {
return _this.users(query.term, options, users => { return userSelect.users(query.term, options, users => {
let name; let name;
const data = { const data = {
results: users, results: users,
...@@ -632,15 +632,15 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -632,15 +632,15 @@ function UsersSelect(currentUser, els, options = {}) {
}, },
initSelection() { initSelection() {
const args = 1 <= arguments.length ? [].slice.call(arguments, 0) : []; const args = 1 <= arguments.length ? [].slice.call(arguments, 0) : [];
return _this.initSelection.apply(_this, args); return userSelect.initSelection.apply(userSelect, args);
}, },
formatResult() { formatResult() {
const args = 1 <= arguments.length ? [].slice.call(arguments, 0) : []; const args = 1 <= arguments.length ? [].slice.call(arguments, 0) : [];
return _this.formatResult.apply(_this, args); return userSelect.formatResult.apply(userSelect, args);
}, },
formatSelection() { formatSelection() {
const args = 1 <= arguments.length ? [].slice.call(arguments, 0) : []; const args = 1 <= arguments.length ? [].slice.call(arguments, 0) : [];
return _this.formatSelection.apply(_this, args); return userSelect.formatSelection.apply(userSelect, args);
}, },
dropdownCssClass: 'ajax-users-dropdown', dropdownCssClass: 'ajax-users-dropdown',
// we do not want to escape markup since we are displaying html in results // we do not want to escape markup since we are displaying html in results
......
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