Don't choke when a card is missing its stage

This can happen if the stage was destroyed
This commit is contained in:
Jorge Manrubia
2025-06-19 08:25:48 +02:00
parent 631579c3e5
commit 6907d07d07
5 changed files with 8 additions and 6 deletions
+1 -1
View File
@@ -66,6 +66,6 @@ module CardsHelper
end
def cacheable_preview_parts_for(card, *options)
[ card, card.collection.workflow, card.collection.entropy_configuration, *options ]
[ card, card.workflow, card.collection.entropy_configuration, *options ]
end
end
+4
View File
@@ -13,6 +13,10 @@ module Card::Staged
stage&.workflow
end
def staged?
stage.present?
end
def change_stage_to(new_stage)
transaction do
update! stage: new_stage
+1 -1
View File
@@ -7,7 +7,7 @@
<%= render "cards/display/preview/collection", card: card %>
<%= render "cards/display/preview/tags", card: card %>
<% if workflow = card.collection.workflow %>
<% if card.staged? %>
<span class="btn justify-start workflow-stage workflow-stage--current txt-uppercase min-width max-width">
<span class="overflow-ellipsis "><%= card.stage.name %></span>
</span>
@@ -1,6 +1,4 @@
<% workflow = card.collection.workflow %>
<% if workflow %>
<% if workflow = card.workflow %>
<div class="card__stages">
<% workflow.stages.each do |stage| %>
<%= tag.span stage.name, class: ["overflow-ellipsis btn justify-start workflow-stage txt-uppercase", { "workflow-stage--current": stage == card.stage }] %>
@@ -1,4 +1,4 @@
<% if workflow = card.collection.workflow %>
<% if workflow = card.workflow %>
<div id="<%= dom_id(card, :stages) %>" class="card__stages">
<% workflow.stages.each do |stage| %>
<%= tag.div stage.name,