2016-10-04 16:41:00 -04:00
|
|
|
module Boards
|
|
|
|
module Issues
|
2017-08-28 17:56:49 -04:00
|
|
|
class CreateService < Boards::BaseService
|
|
|
|
attr_accessor :project
|
|
|
|
|
|
|
|
def initialize(parent, project, user, params = {})
|
|
|
|
@project = project
|
|
|
|
|
|
|
|
super(parent, user, params)
|
|
|
|
end
|
|
|
|
|
2016-10-06 16:13:33 -04:00
|
|
|
def execute
|
2018-05-22 12:34:06 -04:00
|
|
|
create_issue(params.merge(issue_params))
|
2016-10-04 16:41:00 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-05-22 12:34:06 -04:00
|
|
|
def issue_params
|
|
|
|
{ label_ids: [list.label_id] }
|
|
|
|
end
|
|
|
|
|
2016-10-06 16:13:33 -04:00
|
|
|
def board
|
2017-08-28 17:56:49 -04:00
|
|
|
@board ||= parent.boards.find(params.delete(:board_id))
|
2016-10-06 16:13:33 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def list
|
|
|
|
@list ||= board.lists.find(params.delete(:list_id))
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_issue(params)
|
2016-10-04 16:41:00 -04:00
|
|
|
::Issues::CreateService.new(project, current_user, params).execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|