diff options
author | Phil Hughes <me@iamphill.com> | 2016-05-16 17:24:51 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-05-16 17:24:51 +0300 |
commit | 5c4416bb45c2c61e99517c594cdd3b8dea1dc829 (patch) | |
tree | 262ae78d14a007d89128900b514211aa6d4592fe /app/controllers/autocomplete_controller.rb | |
parent | 78a67fc48dab434b43a080e5b15491963656661a (diff) |
Loads move issue dropdown async
Closes #16563
Diffstat (limited to 'app/controllers/autocomplete_controller.rb')
-rw-r--r-- | app/controllers/autocomplete_controller.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/controllers/autocomplete_controller.rb b/app/controllers/autocomplete_controller.rb index eb0abc80ab4..155c78bcd8a 100644 --- a/app/controllers/autocomplete_controller.rb +++ b/app/controllers/autocomplete_controller.rb @@ -31,6 +31,21 @@ class AutocompleteController < ApplicationController render json: @user, only: [:name, :username, :id], methods: [:avatar_url] end + def projects + project = Project.find_by_id(params[:project_id]) + + projects = current_user.authorized_projects + projects = projects.select do |project| + current_user.can?(:admin_issue, project) + end + + no_project = OpenStruct.new(id: 0, name_with_namespace: 'No project') + projects.unshift(no_project.marshal_dump) + projects.delete(project) + + render json: projects.to_json(only: [:id, :name_with_namespace], methods: :name_with_namespace) + end + private def find_users |