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

23 lines
489 B
Ruby
Raw Normal View History

2016-09-13 17:45:13 +05:30
module Boards
module Lists
class CreateService < Boards::BaseService
def execute
List.transaction do
create_list_at(next_position)
end
end
private
def next_position
max_position = board.lists.movable.maximum(:position)
max_position.nil? ? 0 : max_position.succ
end
def create_list_at(position)
board.lists.create(params.merge(list_type: :label, position: position))
end
end
end
end