From e9fadf6fa5dda695ad4292eca58bbce650ad8b6a Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Thu, 4 Sep 2025 14:34:53 -0500 Subject: [PATCH 1/9] This frame is unnecessary, just redirect --- app/views/workflows/edit.html.erb | 2 +- app/views/workflows/index.html.erb | 8 +++----- app/views/workflows/new.html.erb | 20 +++++++++----------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/app/views/workflows/edit.html.erb b/app/views/workflows/edit.html.erb index b8405698b..7ee4555e6 100644 --- a/app/views/workflows/edit.html.erb +++ b/app/views/workflows/edit.html.erb @@ -17,7 +17,7 @@ Cancel <% end %> - <%= button_to workflow_path(@workflow), method: :delete, class: "btn txt-small btn--negative", data: { turbo_frame: :workflows, turbo_confirm: "Are you sure you want to delete this workflow?" } do %> + <%= button_to workflow_path(@workflow), method: :delete, class: "btn txt-small btn--negative", data: { turbo_frame: "_top", turbo_confirm: "Are you sure you want to delete this workflow?" } do %> <%= icon_tag "minus" %> Delete <%= @workflow.name %> <% end %> diff --git a/app/views/workflows/index.html.erb b/app/views/workflows/index.html.erb index 5f0717262..6726cb0dc 100644 --- a/app/views/workflows/index.html.erb +++ b/app/views/workflows/index.html.erb @@ -11,8 +11,6 @@ <% end %> -<%= turbo_frame_tag :workflows do %> -
- <%= render partial: "workflows/workflow", collection: @workflows %> -
-<% end %> +
+ <%= render partial: "workflows/workflow", collection: @workflows %> +
diff --git a/app/views/workflows/new.html.erb b/app/views/workflows/new.html.erb index 0009e46a4..2fc3e1de4 100644 --- a/app/views/workflows/new.html.erb +++ b/app/views/workflows/new.html.erb @@ -5,15 +5,13 @@

<%= @page_title %>

<% end %> -<%= turbo_frame_tag :workflows do %> -
- <%= form_with model: @workflow, url: workflows_path, data: { controller: "form" } do |form| %> - <%= form.text_field :name, required: true, autofocus: true, class: "input txt-large", placeholder: "Name your Workflow…", data: { action: "keydown.esc@document->form#cancel" } %> - <%= form.button type: :submit, class: "btn btn--reversed center margin-block-start txt-large" do %> - <%= icon_tag "check" %> - Create Workflow - <% end %> - <%= link_to "Go back", workflows_path, data: { form_target: "cancel", turbo_frame: "_top" }, hidden: true %> +
+ <%= form_with model: @workflow, url: workflows_path, data: { controller: "form" } do |form| %> + <%= form.text_field :name, required: true, autofocus: true, class: "input txt-large", placeholder: "Name your Workflow…", data: { action: "keydown.esc@document->form#cancel" } %> + <%= form.button type: :submit, class: "btn btn--reversed center margin-block-start txt-large" do %> + <%= icon_tag "check" %> + Create Workflow <% end %> -
-<% end %> + <%= link_to "Go back", workflows_path, data: { form_target: "cancel" }, hidden: true %> + <% end %> +
From 96ec2f698e33a04f139d1f8495b21ebd3de297fb Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Thu, 4 Sep 2025 15:14:04 -0500 Subject: [PATCH 2/9] Fix that in-use Workflows couldn't be deleted --- app/models/workflow.rb | 3 ++- app/models/workflow/stage.rb | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/workflow.rb b/app/models/workflow.rb index 54d82d6ff..f385c5dd0 100644 --- a/app/models/workflow.rb +++ b/app/models/workflow.rb @@ -4,7 +4,8 @@ class Workflow < ApplicationRecord { name: "In progress", color: "var(--color-card-3)" } ] - has_many :stages, dependent: :delete_all + has_many :stages, dependent: :destroy + has_many :collections, dependent: :nullify after_create_commit :create_default_stages diff --git a/app/models/workflow/stage.rb b/app/models/workflow/stage.rb index 8966d0000..4eb08828d 100644 --- a/app/models/workflow/stage.rb +++ b/app/models/workflow/stage.rb @@ -1,6 +1,8 @@ class Workflow::Stage < ApplicationRecord belongs_to :workflow, touch: true + has_many :cards, dependent: :nullify + before_validation :assign_random_color, on: :create private From 65d965bc5ee238fae9997d3726a0c1f81b5fc240 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Thu, 4 Sep 2025 15:24:55 -0500 Subject: [PATCH 3/9] Add a blank slate --- app/views/workflows/index.html.erb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/views/workflows/index.html.erb b/app/views/workflows/index.html.erb index 6726cb0dc..60e8723b6 100644 --- a/app/views/workflows/index.html.erb +++ b/app/views/workflows/index.html.erb @@ -12,5 +12,19 @@ <% end %>
- <%= render partial: "workflows/workflow", collection: @workflows %> + <% if @workflows.any? %> + <%= render partial: "workflows/workflow", collection: @workflows %> + <% else %> +
+

+ Workflows are for organizing Cards you're working on into stages. +

+

+ <%= link_to new_workflow_path, class: "btn btn--link" do %> + <%= icon_tag "add" %> + Create a new workflow + <% end %> +

+
+ <% end %>
From d46c3d4163c2a7ff9c282907e2c296c689ba3971 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Thu, 4 Sep 2025 15:59:56 -0500 Subject: [PATCH 4/9] Improve the /new view so creating workflows feels seamless --- app/views/workflows/_workflow.html.erb | 2 +- app/views/workflows/new.html.erb | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/views/workflows/_workflow.html.erb b/app/views/workflows/_workflow.html.erb index 3c19658ed..a5362a032 100644 --- a/app/views/workflows/_workflow.html.erb +++ b/app/views/workflows/_workflow.html.erb @@ -1,5 +1,5 @@ <%= turbo_frame_tag workflow do %> -
+
<%= turbo_frame_tag dom_id(workflow, :header) do %> <%= link_to edit_workflow_path(workflow) do %> diff --git a/app/views/workflows/new.html.erb b/app/views/workflows/new.html.erb index 2fc3e1de4..cec65033f 100644 --- a/app/views/workflows/new.html.erb +++ b/app/views/workflows/new.html.erb @@ -1,17 +1,20 @@ -<% @page_title = "Create a new Workflow" %> +<% @page_title = "Workflows" %> <% content_for :header do %> <%= render "filters/menu", user_filtering: @user_filtering %>

<%= @page_title %>

<% end %> -
- <%= form_with model: @workflow, url: workflows_path, data: { controller: "form" } do |form| %> - <%= form.text_field :name, required: true, autofocus: true, class: "input txt-large", placeholder: "Name your Workflow…", data: { action: "keydown.esc@document->form#cancel" } %> - <%= form.button type: :submit, class: "btn btn--reversed center margin-block-start txt-large" do %> - <%= icon_tag "check" %> - Create Workflow +
+
+ <%= form_with model: @workflow, url: workflows_path, data: { controller: "form" } do |form| %> +

+ <%= form.text_field :name, required: true, autofocus: true, class: "input", placeholder: "Name your Workflow…", data: { action: "keydown.esc@document->form#cancel" } %> +

+ <%= form.button type: :submit, class: "btn btn--reversed center margin-block-start txt-medium" do %> + Create Workflow + <% end %> + <%= link_to "Go back", workflows_path, data: { form_target: "cancel" }, hidden: true %> <% end %> - <%= link_to "Go back", workflows_path, data: { form_target: "cancel" }, hidden: true %> - <% end %> +
From 8726bb5fe52fd5fc84845d3076a21e5312dab2b9 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Thu, 4 Sep 2025 16:06:40 -0500 Subject: [PATCH 5/9] Move delete to a more obvious place --- app/views/workflows/_workflow.html.erb | 7 +++++++ app/views/workflows/edit.html.erb | 5 ----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/views/workflows/_workflow.html.erb b/app/views/workflows/_workflow.html.erb index a5362a032..f63d9fe0f 100644 --- a/app/views/workflows/_workflow.html.erb +++ b/app/views/workflows/_workflow.html.erb @@ -5,6 +5,13 @@ <%= link_to edit_workflow_path(workflow) do %>

<%= workflow.name %>

<% end %> + + <%= button_to workflow_path(workflow), method: :delete, class: "btn txt-small borderless txt-subtle", + data: { turbo_frame: "_top", turbo_confirm: "Are you sure you want to delete this workflow?" }, + form: { class: "flex-item-justify-end" } do %> + <%= icon_tag "trash" %> + Delete <%= workflow.name %> + <% end %> <% end %>
diff --git a/app/views/workflows/edit.html.erb b/app/views/workflows/edit.html.erb index 7ee4555e6..75e9c55b9 100644 --- a/app/views/workflows/edit.html.erb +++ b/app/views/workflows/edit.html.erb @@ -16,10 +16,5 @@ <%= icon_tag "remove-med" %> Cancel <% end %> - - <%= button_to workflow_path(@workflow), method: :delete, class: "btn txt-small btn--negative", data: { turbo_frame: "_top", turbo_confirm: "Are you sure you want to delete this workflow?" } do %> - <%= icon_tag "minus" %> - Delete <%= @workflow.name %> - <% end %> <% end %> From 0caabc3bd4d5476443a4142fc56180ad85ca291a Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Thu, 4 Sep 2025 16:07:38 -0500 Subject: [PATCH 6/9] Typo Just remove the class, it obviously wasn't doing anything anyway :) --- app/views/workflows/_workflow.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/workflows/_workflow.html.erb b/app/views/workflows/_workflow.html.erb index f63d9fe0f..c47d31b57 100644 --- a/app/views/workflows/_workflow.html.erb +++ b/app/views/workflows/_workflow.html.erb @@ -1,6 +1,6 @@ <%= turbo_frame_tag workflow do %>
-
+
<%= turbo_frame_tag dom_id(workflow, :header) do %> <%= link_to edit_workflow_path(workflow) do %>

<%= workflow.name %>

From 3e92b44e051c57d5a194d3adc74b660dfe9f3c86 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Thu, 4 Sep 2025 16:25:33 -0500 Subject: [PATCH 7/9] Warn about collections using a workflow before deleting --- app/helpers/workflows_helper.rb | 10 ++++++++++ app/views/workflows/_workflow.html.erb | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/helpers/workflows_helper.rb b/app/helpers/workflows_helper.rb index 21b697531..cf97fbe18 100644 --- a/app/helpers/workflows_helper.rb +++ b/app/helpers/workflows_helper.rb @@ -12,4 +12,14 @@ module WorkflowsHelper def stage_color(stage) stage.color.presence || Card::DEFAULT_COLOR end + + def dependent_collections_sentence(workflow) + if workflow.collections.many? + "It will be removed from #{ workflow.collections.count } collections that are using it." + elsif workflow.collections.one? + "It will be removed from the only collection using it." + else + "It's not being used in any collections." + end + end end diff --git a/app/views/workflows/_workflow.html.erb b/app/views/workflows/_workflow.html.erb index c47d31b57..bdce1d13d 100644 --- a/app/views/workflows/_workflow.html.erb +++ b/app/views/workflows/_workflow.html.erb @@ -7,7 +7,7 @@ <% end %> <%= button_to workflow_path(workflow), method: :delete, class: "btn txt-small borderless txt-subtle", - data: { turbo_frame: "_top", turbo_confirm: "Are you sure you want to delete this workflow?" }, + data: { turbo_frame: "_top", turbo_confirm: "Are you sure you want to delete this Workflow? #{ dependent_collections_sentence(workflow) }" }, form: { class: "flex-item-justify-end" } do %> <%= icon_tag "trash" %> Delete <%= workflow.name %> From c9bd38560eba5c47a26a108ac6408fc8790aa94f Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Thu, 4 Sep 2025 16:35:22 -0500 Subject: [PATCH 8/9] Select field contents when editing --- app/views/workflows/edit.html.erb | 3 ++- app/views/workflows/stages/edit.html.erb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/workflows/edit.html.erb b/app/views/workflows/edit.html.erb index 75e9c55b9..a7efd1558 100644 --- a/app/views/workflows/edit.html.erb +++ b/app/views/workflows/edit.html.erb @@ -2,7 +2,8 @@
<%= form_with model: @workflow, url: workflow_path(@workflow), id: dom_id(@workflow, :form), class: "full-width", data: { controller: "form" } do |form| %>

- <%= form.text_field :name, required: true, autofocus: true, class: "input full-width", style: "--input-padding: 0.2em 0.5em;", data: { action: "keydown.esc@document->form#cancel" } %> + <%= form.text_field :name, required: true, autofocus: true, class: "input full-width", + style: "--input-padding: 0.2em 0.5em;", data: { action: "keydown.esc@document->form#cancel focus->form#select" } %>

<%= link_to "Cancel", workflow_path(@workflow), data: { form_target: "cancel", turbo_frame: dom_id(@workflow) }, hidden: true %> <% end %> diff --git a/app/views/workflows/stages/edit.html.erb b/app/views/workflows/stages/edit.html.erb index b1da71b60..10aa78514 100644 --- a/app/views/workflows/stages/edit.html.erb +++ b/app/views/workflows/stages/edit.html.erb @@ -1,6 +1,7 @@ <%= turbo_frame_tag @stage do %> <%= form_with model: @stage, url: workflow_stage_path(@stage.workflow, @stage), id: dom_id(@stage, :form), class: "full-width", data: { controller: "form" } do |form| %> - <%= form.text_field :name, required: true, autofocus: true, class: "input full-width", data: { action: "keydown.esc@document->form#cancel" } %> + <%= form.text_field :name, required: true, autofocus: true, class: "input full-width", + data: { action: "keydown.esc@document->form#cancel focus->form#select" } %> <%= link_to "Cancel", workflow_path(@workflow), data: { form_target: "cancel", turbo_frame: dom_id(@workflow) }, hidden: true %> <% end %> From 3a28bc330065162bb3409798e56933fa6819b1d2 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Fri, 5 Sep 2025 10:49:14 -0500 Subject: [PATCH 9/9] 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 %>