2013-05-14 07:34:34 -04:00
|
|
|
module Issues
|
2014-01-16 12:03:42 -05:00
|
|
|
class BulkUpdateService < BaseService
|
2013-05-14 07:34:34 -04:00
|
|
|
def execute
|
2015-03-06 09:01:13 -05:00
|
|
|
issues_ids = params.delete(:issues_ids).split(",")
|
|
|
|
issue_params = params
|
2013-05-14 07:34:34 -04:00
|
|
|
|
2016-07-12 19:18:13 -04:00
|
|
|
%i(state_event milestone_id assignee_id add_label_ids remove_label_ids subscription_event).each do |key|
|
2016-04-29 12:38:07 -04:00
|
|
|
issue_params.delete(key) unless issue_params[key].present?
|
|
|
|
end
|
2013-05-14 07:34:34 -04:00
|
|
|
|
2013-12-09 16:36:45 -05:00
|
|
|
issues = Issue.where(id: issues_ids)
|
2016-07-06 09:26:59 -04:00
|
|
|
|
2013-05-14 07:34:34 -04:00
|
|
|
issues.each do |issue|
|
2015-06-26 09:55:56 -04:00
|
|
|
next unless can?(current_user, :update_issue, issue)
|
2015-03-06 09:01:13 -05:00
|
|
|
|
|
|
|
Issues::UpdateService.new(issue.project, current_user, issue_params).execute(issue)
|
2013-05-14 07:34:34 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
{
|
2015-03-06 09:01:13 -05:00
|
|
|
count: issues.count,
|
|
|
|
success: !issues.count.zero?
|
2013-05-14 07:34:34 -04:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|