debian-mirror-gitlab/app/services/boards/lists/destroy_service.rb

32 lines
615 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2016-09-13 17:45:13 +05:30
module Boards
module Lists
2018-03-17 18:26:18 +05:30
class DestroyService < Boards::BaseService
2016-09-13 17:45:13 +05:30
def execute(list)
return false unless list.destroyable?
2016-11-03 12:29:30 +05:30
@board = list.board
2016-09-13 17:45:13 +05:30
list.with_lock do
decrement_higher_lists(list)
remove_list(list)
end
end
private
2016-11-03 12:29:30 +05:30
attr_reader :board
2016-09-13 17:45:13 +05:30
def decrement_higher_lists(list)
board.lists.movable.where('position > ?', list.position)
.update_all('position = position - 1')
end
def remove_list(list)
list.destroy
end
end
end
end