gitlab-org--gitlab-foss/app/services/boards/lists/destroy_service.rb

30 lines
584 B
Ruby
Raw Normal View History

module Boards
module Lists
2017-08-31 13:48:57 -04:00
class DestroyService < Boards::BaseService
def execute(list)
return false unless list.destroyable?
@board = list.board
list.with_lock do
decrement_higher_lists(list)
remove_list(list)
end
end
private
attr_reader :board
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