Commit a835414b authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'fix/836-assign-merge-request-to-approver' into 'master'

Fix assigning merge request to a project approver

Scope the options of a user select, so the data attributes of a user select 
are respected within its scope

Fixes #836.

See merge request !604
parents 5b605eab c1d1204a
......@@ -5,6 +5,10 @@ v 8.11.0 (unreleased)
- Change LdapGroupSyncWorker to use new LDAP group sync classes
- [Elastic][Fix] Commit search breaks for some URLs on gitlab-ce project
v 8.10.4 (unreleased)
- Fix available users in userselect dropdown when there is more than one userselect on the page (Rik de Groot). !604
- Fix updating skipped approvers in search list on removal (Rik de Groot). !604
v 8.10.3
- Fix regression in Git Annex permission check. !599
- [Elastic] Fix commit search for some URLs. !605
......
(function() {
$(function() {
$(".approver-list").on("click", ".project-approvers .btn-remove", function() {
$(this).closest("li").remove();
var removeElement = $(this).closest("li");
var approverId = parseInt(removeElement.attr("id").replace("user_",""));
var approverIds = $("input#merge_request_approver_ids");
var skipUsers = approverIds.data("skip-users") || [];
var approverIndex = skipUsers.indexOf(approverId);
removeElement.remove();
if(approverIndex > -1) {
approverIds.data("skip-users", skipUsers.splice(approverIndex, 1));
}
return false;
});
$("form.merge-request-form").submit(function() {
......
......@@ -13,14 +13,15 @@
}
$('.js-user-search').each((function(_this) {
return function(i, dropdown) {
var options = {};
var $block, $collapsedSidebar, $dropdown, $loading, $selectbox, $value, abilityName, assignTo, assigneeTemplate, collapsedAssigneeTemplate, defaultLabel, firstUser, issueURL, selectedId, showAnyUser, showNullUser;
$dropdown = $(dropdown);
_this.projectId = $dropdown.data('project-id');
_this.showCurrentUser = $dropdown.data('current-user');
options.projectId = $dropdown.data('project-id');
options.showCurrentUser = $dropdown.data('current-user');
showNullUser = $dropdown.data('null-user');
showAnyUser = $dropdown.data('any-user');
firstUser = $dropdown.data('first-user');
_this.authorId = $dropdown.data('author-id');
options.authorId = $dropdown.data('author-id');
selectedId = $dropdown.data('selected');
defaultLabel = $dropdown.data('default-label');
issueURL = $dropdown.data('issueUpdate');
......@@ -75,7 +76,7 @@
data: function(term, callback) {
var isAuthorFilter;
isAuthorFilter = $('.js-author-search');
return _this.users(term, function(users) {
return _this.users(term, options, function(users) {
var anyUser, index, j, len, name, obj, showDivider;
if (term.length === 0) {
showDivider = 0;
......@@ -185,13 +186,14 @@
$('.ajax-users-select').each((function(_this) {
return function(i, select) {
var firstUser, showAnyUser, showEmailUser, showNullUser;
_this.skipLdap = $(select).hasClass('skip_ldap');
_this.projectId = $(select).data('project-id');
_this.groupId = $(select).data('group-id');
_this.showCurrentUser = $(select).data('current-user');
_this.pushCodeToProtectedBranches = $(select).data('push-code-to-protected-branches');
_this.authorId = $(select).data('author-id');
_this.skipUsers = $(select).data('skip-users');
var options = {};
options.skipLdap = $(select).hasClass('skip_ldap');
options.projectId = $(select).data('project-id');
options.groupId = $(select).data('group-id');
options.showCurrentUser = $(select).data('current-user');
options.pushCodeToProtectedBranches = $(select).data('push-code-to-protected-branches');
options.authorId = $(select).data('author-id');
options.skipUsers = $(select).data('skip-users');
showNullUser = $(select).data('null-user');
showAnyUser = $(select).data('any-user');
showEmailUser = $(select).data('email-user');
......@@ -201,7 +203,7 @@
multiple: $(select).hasClass('multiselect'),
minimumInputLength: 0,
query: function(query) {
return _this.users(query.term, function(users) {
return _this.users(query.term, options, function(users) {
var anyUser, data, emailUser, index, j, len, name, nullUser, obj, ref;
data = {
results: users
......@@ -311,7 +313,7 @@
});
};
UsersSelect.prototype.users = function(query, callback) {
UsersSelect.prototype.users = function(query, options, callback) {
var url;
url = this.buildUrl(this.usersPath);
return $.ajax({
......@@ -320,13 +322,13 @@
search: query,
per_page: 20,
active: true,
project_id: this.projectId,
group_id: this.groupId,
skip_ldap: this.skipLdap,
current_user: this.showCurrentUser,
push_code_to_protected_branches: this.pushCodeToProtectedBranches,
author_id: this.authorId,
skip_users: this.skipUsers
project_id: options.projectId || null,
group_id: options.groupId || null,
skip_ldap: options.skipLdap || null,
current_user: options.showCurrentUser || null,
push_code_to_protected_branches: options.pushCodeToProtectedBranches || null,
author_id: options.authorId || null,
skip_users: options.skipUsers || null
},
dataType: "json"
}).done(function(users) {
......
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