2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
module Boards
|
|
|
|
module Issues
|
2018-03-17 18:26:18 +05:30
|
|
|
class CreateService < Boards::BaseService
|
|
|
|
attr_accessor :project
|
|
|
|
|
|
|
|
def initialize(parent, project, user, params = {})
|
|
|
|
@project = project
|
|
|
|
|
|
|
|
super(parent, user, params)
|
|
|
|
end
|
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
def execute
|
2018-11-08 19:23:39 +05:30
|
|
|
create_issue(params.merge(issue_params))
|
2016-11-03 12:29:30 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
def issue_params
|
|
|
|
{ label_ids: [list.label_id] }
|
|
|
|
end
|
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
def board
|
2018-03-17 18:26:18 +05:30
|
|
|
@board ||= parent.boards.find(params.delete(:board_id))
|
2016-11-03 12:29:30 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def list
|
|
|
|
@list ||= board.lists.find(params.delete(:list_id))
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_issue(params)
|
2021-06-08 01:23:25 +05:30
|
|
|
::Issues::CreateService.new(project: project, current_user: current_user, params: params).execute
|
2016-11-03 12:29:30 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
Boards::Issues::CreateService.prepend_mod_with('Boards::Issues::CreateService')
|