mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
Refactor and clean up
This commit is contained in:
@@ -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: {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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[]));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user