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