@@ -48,7 +48,7 @@ def edit
4848
4949 statuses_for_form
5050
51- if @type && @role && @statuses . any?
51+ if @type && @roles . any? && @statuses . any?
5252 workflows_for_form
5353 end
5454 end
@@ -100,7 +100,7 @@ def status_dialog
100100 current_statuses = if params [ :status_ids ] . present?
101101 Status . where ( id : params [ :status_ids ] . map ( &:to_i ) ) . order ( :position )
102102 elsif @type && @role
103- statuses_for_role_and_type
103+ statuses_for_roles_and_type
104104 else
105105 Status . none
106106 end
@@ -169,8 +169,8 @@ def statuses_for_form
169169 @has_status_changes = false
170170 @statuses = if @type && params [ :status_ids ] . present?
171171 statuses_from_params
172- elsif @type && @role
173- statuses_for_role_and_type
172+ elsif @type && @roles . any?
173+ statuses_for_roles_and_type
174174 elsif @type
175175 @type . statuses
176176 else
@@ -180,18 +180,19 @@ def statuses_for_form
180180
181181 def statuses_from_params
182182 status_ids = params [ :status_ids ] . map ( &:to_i )
183- saved_ids = statuses_for_role_and_type . pluck ( :id )
183+ saved_ids = statuses_for_roles_and_type . pluck ( :id )
184184 @added_status_ids = status_ids - saved_ids
185185 @has_status_changes = @added_status_ids . any? || ( saved_ids - status_ids ) . any?
186186 Status . where ( id : status_ids ) . order ( :position )
187187 end
188188
189- def statuses_for_role_and_type
190- @type . statuses ( role : @role , tab : @tab )
189+ def statuses_for_roles_and_type
190+ status_ids = @roles . map { |role | @type . statuses ( role :, tab : @tab ) . pluck ( :id ) } . flatten . uniq
191+ Status . where ( id : status_ids )
191192 end
192193
193194 def workflows_for_form
194- workflows = Workflow . where ( role_id : @role . id , type_id : @type . id )
195+ workflows = Workflow . where ( role_id : @roles . map ( & :id ) , type_id : @type . id )
195196 @workflows = { }
196197 @workflows [ "always" ] = workflows . select { |w | !w . author && !w . assignee }
197198 @workflows [ "author" ] = workflows . select ( &:author )
0 commit comments