Commit dcce0164 authored by Eugenia Grieff's avatar Eugenia Grieff

Filter bulk update service params

Filter params and change the health status value
from 0 to nil. This will remove the existing value
and set the attribute as 'no status.
parent ebc57b2d
......@@ -88,7 +88,7 @@ export default {
milestone_id: this.form.find('input[name="update[milestone_id]"]').val(),
issuable_ids: this.form.find('input[name="update[issuable_ids]"]').val(),
subscription_event: this.form.find('input[name="update[subscription_event]"]').val(),
health_status: healthStatusValue === 'null' ? null : healthStatusValue,
health_status: healthStatusValue === 'null' ? '0' : healthStatusValue,
add_label_ids: [],
remove_label_ids: [],
},
......
......@@ -16,18 +16,12 @@ module Issuable
ids = params.delete(:issuable_ids).split(",")
items = find_issuables(parent, model_class, ids)
params.slice!(*permitted_attrs(type))
params.delete_if { |k, v| v.blank? }
if params[:assignee_ids] == [IssuableFinder::Params::NONE.to_s]
params[:assignee_ids] = []
end
update_params = filter_update_params(type)
items.each do |issuable|
next unless can?(current_user, :"update_#{type}", issuable)
update_class.new(issuable.issuing_parent, current_user, params).execute(issuable)
update_class.new(issuable.issuing_parent, current_user, update_params).execute(issuable)
end
{
......@@ -52,6 +46,17 @@ module Issuable
end
end
def filter_update_params(type)
params.slice!(*permitted_attrs(type))
params.delete_if { |k, v| v.blank? }
if params[:assignee_ids] == [IssuableFinder::Params::NONE.to_s]
params[:assignee_ids] = []
end
params
end
def find_issuables(parent, model_class, ids)
if parent.is_a?(Project)
model_class.id_in(ids).of_projects(parent)
......
......@@ -20,6 +20,21 @@ module EE
super.push(:health_status, :epic)
end
override :filter_update_params
def filter_update_params(type)
super
set_health_status
params
end
def set_health_status
return unless params[:health_status].present?
params[:health_status] = nil if params[:health_status] == IssuableFinder::Params::NONE.to_s
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