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

26 lines
588 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
2016-09-29 09:46:39 +05:30
label = project.labels.find(params[:label_id])
position = next_position
create_list(label, position)
2016-09-13 17:45:13 +05:30
end
end
private
def next_position
max_position = board.lists.movable.maximum(:position)
max_position.nil? ? 0 : max_position.succ
end
2016-09-29 09:46:39 +05:30
def create_list(label, position)
board.lists.create(label: label, list_type: :label, position: position)
2016-09-13 17:45:13 +05:30
end
end
end
end