From 3a28bc330065162bb3409798e56933fa6819b1d2 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Fri, 5 Sep 2025 10:49:14 -0500 Subject: [PATCH] Add confirmations to warn about destructive consequences --- app/helpers/workflows_helper.rb | 10 ++++++++++ app/views/collections/edit/_workflows.html.erb | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/helpers/workflows_helper.rb b/app/helpers/workflows_helper.rb index cf97fbe18..f60e9d7f8 100644 --- a/app/helpers/workflows_helper.rb +++ b/app/helpers/workflows_helper.rb @@ -22,4 +22,14 @@ module WorkflowsHelper "It's not being used in any collections." end end + + def workflow_switch_confirmation_message(workflow, collection) + if workflow == collection.workflow + "Stop using #{workflow.name}? Cards you're working on will lose their current stage." + elsif collection.workflow.present? + "Switch to #{workflow.name}? This will return all cards you're working on to the first stage." + else + nil + end + end end diff --git a/app/views/collections/edit/_workflows.html.erb b/app/views/collections/edit/_workflows.html.erb index 180b6a4c6..3460c4f35 100644 --- a/app/views/collections/edit/_workflows.html.erb +++ b/app/views/collections/edit/_workflows.html.erb @@ -7,7 +7,10 @@
<% Workflow.all.each do |workflow| %>
- <%= button_to collection_workflow_path(collection), method: :patch, aria: { label: workflow == collection.workflow ? "Stop using this workflow" : "Use this workflow" } do %> + <% confirmation_message = workflow_switch_confirmation_message(workflow, collection) %> + <%= button_to collection_workflow_path(collection), method: :patch, + aria: { label: workflow == collection.workflow ? "Stop using this workflow" : "Use this workflow" }, + data: confirmation_message ? { turbo_confirm: confirmation_message } : {} do %> <%= hidden_field_tag "collection[workflow_id]", workflow == collection.workflow ? "" : workflow.id %> <%= workflow.name %>
    @@ -22,5 +25,6 @@
<% end %>
+ <%= link_to "Manage workflows", workflows_path, class: "btn btn--plain txt-link", data: { turbo_frame: "_top" } %> <% end %>