summaryrefslogtreecommitdiff
path: root/lib/api/boards_responses.rb
diff options
context:
space:
mode:
authorFelipe Artur <felipefac@gmail.com>2017-12-06 17:07:47 -0200
committerFelipe Artur <felipefac@gmail.com>2018-01-04 17:28:10 -0200
commit5e148d4e931792733400f59864e1aa886ef55953 (patch)
tree3e08b1776015895dcb242909df01f5db60265d7e /lib/api/boards_responses.rb
parente5a9b9a14d32d890dea20403c977dfd569eb3e17 (diff)
downloadgitlab-ce-5e148d4e931792733400f59864e1aa886ef55953.tar.gz
EE-BACKPORT group boards
Diffstat (limited to 'lib/api/boards_responses.rb')
-rw-r--r--lib/api/boards_responses.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/api/boards_responses.rb b/lib/api/boards_responses.rb
new file mode 100644
index 00000000000..ead0943a74d
--- /dev/null
+++ b/lib/api/boards_responses.rb
@@ -0,0 +1,50 @@
+module API
+ module BoardsResponses
+ extend ActiveSupport::Concern
+
+ included do
+ helpers do
+ def board
+ board_parent.boards.find(params[:board_id])
+ end
+
+ def board_lists
+ board.lists.destroyable
+ end
+
+ def create_list
+ create_list_service =
+ ::Boards::Lists::CreateService.new(board_parent, current_user, { label_id: params[:label_id] })
+
+ list = create_list_service.execute(board)
+
+ if list.valid?
+ present list, with: Entities::List
+ else
+ render_validation_error!(list)
+ end
+ end
+
+ def move_list(list)
+ move_list_service =
+ ::Boards::Lists::MoveService.new(board_parent, current_user, { position: params[:position].to_i })
+
+ if move_list_service.execute(list)
+ present list, with: Entities::List
+ else
+ render_api_error!({ error: "List could not be moved!" }, 400)
+ end
+ end
+
+ def destroy_list(list)
+ destroy_conditionally!(list) do |list|
+ service = ::Boards::Lists::DestroyService.new(board_parent, current_user)
+ unless service.execute(list)
+ render_api_error!({ error: 'List could not be deleted!' }, 400)
+ end
+ end
+ end
+ end
+ end
+ end
+end