summaryrefslogtreecommitdiff
path: root/app/services/boards
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-07-27 22:32:36 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-17 12:58:57 -0300
commitb23683b00b4bccad3b6f29d722b9e45a7264c1bd (patch)
tree15f14e1a27d20d86f9bba931b338581ead533019 /app/services/boards
parent279361fa16c52011ee0f565c79a47012fad9b03f (diff)
downloadgitlab-ce-b23683b00b4bccad3b6f29d722b9e45a7264c1bd.tar.gz
Add service to remove a list from board
Diffstat (limited to 'app/services/boards')
-rw-r--r--app/services/boards/lists/destroy_service.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/services/boards/lists/destroy_service.rb b/app/services/boards/lists/destroy_service.rb
new file mode 100644
index 00000000000..0913a898abd
--- /dev/null
+++ b/app/services/boards/lists/destroy_service.rb
@@ -0,0 +1,34 @@
+module Boards
+ module Lists
+ class DestroyService
+ def initialize(project, params = {})
+ @board = project.board
+ @params = params.dup
+ end
+
+ def execute
+ list.with_lock do
+ reorder_higher_lists
+ remove_list
+ end
+ end
+
+ private
+
+ attr_reader :board, :params
+
+ def list
+ @list ||= board.lists.find(params[:list_id])
+ end
+
+ def reorder_higher_lists
+ board.lists.where('position > ?', list.position)
+ .update_all('position = position - 1')
+ end
+
+ def remove_list
+ list.destroy
+ end
+ end
+ end
+end