Commit 58df72fa authored by Grzegorz Bizon's avatar Grzegorz Bizon

Make it possible to exclude project in projects select

parent bcd58069
......@@ -6,6 +6,7 @@ class @ProjectSelect
@orderBy = $(select).data('order-by') || 'id'
@selectId = $(select).data('select-id') || 'web_url'
@accessLevel = $(select).data('access-level')
@withoutId = $(select).data('without-id')
placeholder = "Search for project"
placeholder += " or group" if @includeGroups
......@@ -31,9 +32,11 @@ class @ProjectSelect
finalCallback = (projects) ->
options.callback({ results: projects })
@accessLevelCallbackDecorator(
@groupsCallbackDecorator(
finalCallback
@withoutIdCallbackDecorator(
@accessLevelCallbackDecorator(
@groupsCallbackDecorator(
finalCallback
)
)
)
......@@ -52,10 +55,22 @@ class @ProjectSelect
# Requires ECMAScript >= 5
#
(projects) =>
data = projects.filter (i) =>
max = Math.max(i.permissions.group_access?.access_level ? 0,
i.permissions.project_access?.access_level ? 0)
data = projects.filter (p) =>
max = Math.max(p.permissions.group_access?.access_level ? 0,
p.permissions.project_access?.access_level ? 0)
max >= @accessLevel
callback(data)
withoutIdCallbackDecorator: (callback) =>
return callback unless @withoutId
##
# Requires ECMAScript >= 5
#
(projects) =>
data = projects.filter (p) =>
p.id != @withoutId
callback(data)
......@@ -72,9 +72,9 @@
.form-group
= f.label :move_to_project_id, 'Move', class: 'control-label'
.col-sm-10
= project_select_tag("#{issuable.class.model_name.param_key}[move_to_project_id]",
placeholder: 'Select project', class: 'custom-form-control',
data: { 'select-id' => 'id', 'access-level' => Gitlab::Access::REPORTER })
= project_select_tag(:move_to_project_id, placeholder: 'Select project',
class: 'custom-form-control', data: { 'select-id' => 'id',
'access-level' => Gitlab::Access::REPORTER, 'without-id' => issuable.project.id })
- if issuable.is_a?(MergeRequest)
%hr
......
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