Commit bed774a8 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Move EE changes from Boards::BaseService to its own module

parent c7edc332
module Boards
class BaseService < ::BaseService
prepend EE::Boards::BaseService
# Parent can either a group or a project
attr_accessor :parent, :current_user, :params
def initialize(parent, user, params = {})
@parent, @current_user, @params = parent, user, params.dup
end
def set_assignee
assignee = User.find_by(id: params.delete(:assignee_id))
params.merge!(assignee: assignee)
end
def set_milestone
milestone_id = params[:milestone_id]
return unless milestone_id
return if [::Milestone::None.id,
::Milestone::Upcoming.id,
::Milestone::Started.id].include?(milestone_id)
finder_params =
case parent
when Group
{ group_ids: [parent.id] }
when Project
{ project_ids: [parent.id], group_ids: [parent.group&.id] }
end
milestone = MilestonesFinder.new(finder_params).find_by(id: milestone_id)
params[:milestone_id] = milestone&.id
end
end
end
module EE
module Boards
module BaseService
def set_assignee
assignee = ::User.find_by(id: params.delete(:assignee_id))
params.merge!(assignee: assignee)
end
def set_milestone
milestone_id = params[:milestone_id]
return unless milestone_id
return if [::Milestone::None.id,
::Milestone::Upcoming.id,
::Milestone::Started.id].include?(milestone_id)
finder_params =
case parent
when Group
{ group_ids: [parent.id] }
when Project
{ project_ids: [parent.id], group_ids: [parent.group&.id] }
end
milestone = ::MilestonesFinder.new(finder_params).find_by(id: milestone_id)
params[:milestone_id] = milestone&.id
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment