diff options
author | Felipe Artur <fcardozo@gitlab.com> | 2019-08-28 20:18:40 +0000 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2019-08-28 20:18:40 +0000 |
commit | 8f6a433c416f8fb052468f4ecf1141afd5e5ef6b (patch) | |
tree | 0771446e24329132f6beed3b3101d192b92d113e /app/controllers/boards | |
parent | 148c5ccbb444f3c630e3b3cf4350bb4f74d6d2ab (diff) | |
download | gitlab-ce-8f6a433c416f8fb052468f4ecf1141afd5e5ef6b.tar.gz |
Save board lists collapsed setting
Persists if a board list is collapsed for each user.
Diffstat (limited to 'app/controllers/boards')
-rw-r--r-- | app/controllers/boards/lists_controller.rb | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/app/controllers/boards/lists_controller.rb b/app/controllers/boards/lists_controller.rb index ccd02144671..08b4748d7e1 100644 --- a/app/controllers/boards/lists_controller.rb +++ b/app/controllers/boards/lists_controller.rb @@ -4,7 +4,7 @@ module Boards class ListsController < Boards::ApplicationController include BoardsResponses - before_action :authorize_admin_list, only: [:create, :update, :destroy, :generate] + before_action :authorize_admin_list, only: [:create, :destroy, :generate] before_action :authorize_read_list, only: [:index] skip_before_action :authenticate_user!, only: [:index] @@ -15,7 +15,7 @@ module Boards end def create - list = Boards::Lists::CreateService.new(board.parent, current_user, list_params).execute(board) + list = Boards::Lists::CreateService.new(board.parent, current_user, create_list_params).execute(board) if list.valid? render json: serialize_as_json(list) @@ -26,12 +26,13 @@ module Boards def update list = board.lists.movable.find(params[:id]) - service = Boards::Lists::MoveService.new(board_parent, current_user, move_params) + service = Boards::Lists::UpdateService.new(board_parent, current_user, update_list_params) + result = service.execute(list) - if service.execute(list) + if result[:status] == :success head :ok else - head :unprocessable_entity + head result[:http_status] end end @@ -50,7 +51,8 @@ module Boards service = Boards::Lists::GenerateService.new(board_parent, current_user) if service.execute(board) - render json: serialize_as_json(board.lists.movable) + lists = board.lists.movable.preload_associations(current_user) + render json: serialize_as_json(lists) else head :unprocessable_entity end @@ -62,12 +64,12 @@ module Boards %i[label_id] end - def list_params + def create_list_params params.require(:list).permit(list_creation_attrs) end - def move_params - params.require(:list).permit(:position) + def update_list_params + params.require(:list).permit(:collapsed, :position) end def serialize_as_json(resource) @@ -78,7 +80,9 @@ module Boards { only: [:id, :list_type, :position], methods: [:title], - label: true + label: true, + collapsed: true, + current_user: current_user } end end |