Allow deselecting a Workflow

This commit is contained in:
Jason Zimdars
2025-07-03 10:11:36 -05:00
parent 277965e8dc
commit 1dfe541bd4
2 changed files with 4 additions and 3 deletions
@@ -10,6 +10,7 @@ class Collections::WorkflowsController < ApplicationController
private
def set_workflow
@workflow = Workflow.find(params[:collection][:workflow_id])
workflow_id = params[:collection][:workflow_id]
@workflow = workflow_id.present? ? Workflow.find(workflow_id) : nil
end
end
@@ -4,8 +4,8 @@
<div class="flex flex-wrap gap justify-center">
<% Workflow.all.each do |workflow| %>
<div class="workflow-preview txt-align-start border border-radius <%= 'workflow-preview--selected' if workflow == collection.workflow %>">
<%= button_to collection_workflow_path(collection), method: :patch do %>
<%= hidden_field_tag "collection[workflow_id]", workflow.id %>
<%= button_to collection_workflow_path(collection), method: :patch, aria: { label: workflow == collection.workflow ? "Stop using this workflow" : "Use this workflow" } do %>
<%= hidden_field_tag "collection[workflow_id]", workflow == collection.workflow ? "" : workflow.id %>
<strong class="txt-small overflow-ellipsis flex-item-no-shrink"><%= workflow.name %></strong>
<ul class="list-style-none txt-xx-small margin-none flex flex-column gap-half">
<% workflow.stages.each do |stage| %>