diff --git a/app/components/workflows/status_matrix_form_component.html.erb b/app/components/workflows/status_matrix_form_component.html.erb index cfeae115265..b84b2e25fae 100644 --- a/app/components/workflows/status_matrix_form_component.html.erb +++ b/app/components/workflows/status_matrix_form_component.html.erb @@ -77,7 +77,7 @@ See COPYRIGHT and LICENSE files for more details. <% if @statuses.any? %> <%= form_tag( workflow_tab_path(@type), - id: "workflow_form", + id: form_id, method: :patch, autocomplete: "off", data: { diff --git a/app/components/workflows/status_matrix_form_component.rb b/app/components/workflows/status_matrix_form_component.rb index d9e31dba4ab..5af6570d32f 100644 --- a/app/components/workflows/status_matrix_form_component.rb +++ b/app/components/workflows/status_matrix_form_component.rb @@ -33,6 +33,8 @@ module Workflows include OpTurbo::Streamable include OpPrimer::ComponentHelpers + FORM_ID = "workflow_form" + def initialize(tab:, roles:, type:, available_roles:, statuses:, has_status_changes:) super @tab = tab @@ -45,12 +47,14 @@ module Workflows private + def form_id = FORM_ID + def data_attributes { controller: "admin--workflow-role-select", "admin--workflow-role-select-base-url-value": helpers.edit_workflow_tab_path(@type, @tab), - "admin--workflow-role-select-current-role-ids-value": @roles.map(&:id).join(","), - "admin--workflow-role-select-admin--workflow-checkbox-state-outlet": "#workflow_form" + "admin--workflow-role-select-current-role-ids-value": @roles.map(&:id), + "admin--workflow-role-select-admin--workflow-checkbox-state-outlet": "##{form_id}" } end end diff --git a/app/controllers/workflows_controller.rb b/app/controllers/workflows_controller.rb index 90650d70b8a..3de82fd8d54 100644 --- a/app/controllers/workflows_controller.rb +++ b/app/controllers/workflows_controller.rb @@ -56,10 +56,6 @@ class WorkflowsController < ApplicationController @types = ::Type.order(:position) end - def find_role - @role = eligible_roles.find(params[:role_id]) - end - def find_type @type = ::Type.find(params[:type_id]) end diff --git a/frontend/src/stimulus/controllers/dynamic/admin/workflow-role-select.controller.ts b/frontend/src/stimulus/controllers/dynamic/admin/workflow-role-select.controller.ts index 75cbdd3dc65..bbf429027fe 100644 --- a/frontend/src/stimulus/controllers/dynamic/admin/workflow-role-select.controller.ts +++ b/frontend/src/stimulus/controllers/dynamic/admin/workflow-role-select.controller.ts @@ -38,12 +38,12 @@ import WorkflowCheckboxStateController from './workflow-checkbox-state.controlle */ export default class WorkflowRoleSelectController extends Controller { static outlets = ['admin--workflow-checkbox-state']; - static values = { baseUrl: String, currentRoleIds: String }; + static values = { baseUrl: String, currentRoleIds: Array }; declare readonly adminWorkflowCheckboxStateOutlet:WorkflowCheckboxStateController; declare readonly hasAdminWorkflowCheckboxStateOutlet:boolean; declare baseUrlValue:string; - declare currentRoleIdsValue:string; + declare currentRoleIdsValue:unknown[]; connect() { this.element.addEventListener('panelClosed', this.handlePanelClosed); @@ -66,8 +66,7 @@ export default class WorkflowRoleSelectController extends Controller { return; } - const currentIds = this.currentRoleIdsValue.split(',').filter(Boolean); - if (selectedIds.slice().sort().join(',') === currentIds.slice().sort().join(',')) return; + if (selectedIds.slice().sort().join(',') === this.currentRoleIdsValue.slice().sort().join(',')) return; this.navigateTo(this.buildUrl(selectedIds as string[])); };