feat(savings_goals/index): collapsed Archived section + archived-aware card

- Controller: @archived_goals exposes state=archived rows already pulled
  by the all_goals load. No extra query (sliced from the existing array).
- Index template: <details> disclosure under "Completed" so archived
  goals are reachable from the list without cluttering the active /
  completed sections. Collapsed by default.
- GoalCardComponent: uses display_status for the data attribute (so the
  card on the index reads as Archived instead of Behind), opacity-75
  applies to archived too, footer_line short-circuits to "Archived" and
  pace_line returns nil. Matches the show-page archived semantics
  shipped earlier.
- Locale: new savings_goals.index.archived_section.heading and
  savings_goals.goal_card.footer_archived.
This commit is contained in:
Guillem Arias
2026-05-11 19:52:52 +02:00
parent af41dcaf64
commit 560bff87d2
5 changed files with 28 additions and 4 deletions

View File

@@ -1,9 +1,9 @@
<%= link_to savings_goal_path(goal),
class: "group block bg-container rounded-xl shadow-border-xs hover:bg-surface-hover transition-colors p-6 #{"opacity-75" if goal.paused?}",
class: "group block bg-container rounded-xl shadow-border-xs hover:bg-surface-hover transition-colors p-6 #{"opacity-75" if goal.paused? || goal.archived?}",
data: {
savings_goals_filter_target: "card",
goal_name: goal.name,
goal_status: goal.paused? ? "paused" : goal.status
goal_status: goal.display_status
} do %>
<div class="flex items-start gap-3">
<%= render Savings::GoalAvatarComponent.new(goal: goal, size: "lg") %>

View File

@@ -58,7 +58,7 @@ class Savings::GoalCardComponent < ApplicationComponent
end
def pace_line
return nil if goal.paused? || goal.completed? || goal.status == :reached
return nil if goal.archived? || goal.paused? || goal.completed? || goal.status == :reached
avg = Money.new(goal.average_monthly_contribution, goal.currency).format
target = goal.monthly_target_amount ? Money.new(goal.monthly_target_amount, goal.currency).format : nil
@@ -70,7 +70,9 @@ class Savings::GoalCardComponent < ApplicationComponent
end
def footer_line
if goal.paused?
if goal.archived?
I18n.t("savings_goals.goal_card.footer_archived")
elsif goal.paused?
I18n.t("savings_goals.goal_card.footer_paused")
elsif goal.completed? || goal.status == :reached
I18n.t("savings_goals.goal_card.footer_reached")