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)
|
|
|
|
::Issues::CreateService.new(project, current_user, params).execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|