summaryrefslogtreecommitdiff
path: root/app/services/boards
diff options
context:
space:
mode:
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