From 560bff87d2814c5ece0de4e33d62ea3029f65e73 Mon Sep 17 00:00:00 2001 From: Guillem Arias Date: Mon, 11 May 2026 19:52:52 +0200 Subject: [PATCH] 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:
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. --- .../savings/goal_card_component.html.erb | 4 ++-- app/components/savings/goal_card_component.rb | 6 ++++-- app/controllers/savings_goals_controller.rb | 1 + app/views/savings_goals/index.html.erb | 18 ++++++++++++++++++ config/locales/views/savings_goals/en.yml | 3 +++ 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/app/components/savings/goal_card_component.html.erb b/app/components/savings/goal_card_component.html.erb index 97c725930..6baef987a 100644 --- a/app/components/savings/goal_card_component.html.erb +++ b/app/components/savings/goal_card_component.html.erb @@ -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 %>
<%= render Savings::GoalAvatarComponent.new(goal: goal, size: "lg") %> diff --git a/app/components/savings/goal_card_component.rb b/app/components/savings/goal_card_component.rb index 0abe159f3..cf406643d 100644 --- a/app/components/savings/goal_card_component.rb +++ b/app/components/savings/goal_card_component.rb @@ -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") diff --git a/app/controllers/savings_goals_controller.rb b/app/controllers/savings_goals_controller.rb index bf7a4963c..6fa076058 100644 --- a/app/controllers/savings_goals_controller.rb +++ b/app/controllers/savings_goals_controller.rb @@ -13,6 +13,7 @@ class SavingsGoalsController < ApplicationController @active_goals = all_goals.reject { |g| %w[completed archived].include?(g.state) } .sort_by { |g| [ g.paused? ? 3 : ACTIVE_STATUS_RANK.fetch(g.status, 4), g.name.downcase ] } @completed_goals = all_goals.select { |g| g.state == "completed" } + @archived_goals = all_goals.select { |g| g.state == "archived" } @linkable_account_count = Current.family.accounts.where(accountable_type: "Depository").visible.count @kpi = kpi_payload(@active_goals) diff --git a/app/views/savings_goals/index.html.erb b/app/views/savings_goals/index.html.erb index 561e92f89..82c774c76 100644 --- a/app/views/savings_goals/index.html.erb +++ b/app/views/savings_goals/index.html.erb @@ -168,5 +168,23 @@
<% end %> + + <% if @archived_goals.any? %> +
+
+ + <%= icon("chevron-right", size: "sm") %> + <%= t(".archived_section.heading") %> + · + <%= @archived_goals.size %> + +
+ <% @archived_goals.each do |goal| %> + <%= render Savings::GoalCardComponent.new(goal: goal) %> + <% end %> +
+
+
+ <% end %> <% end %> diff --git a/config/locales/views/savings_goals/en.yml b/config/locales/views/savings_goals/en.yml index e6a49031f..73b349001 100644 --- a/config/locales/views/savings_goals/en.yml +++ b/config/locales/views/savings_goals/en.yml @@ -37,6 +37,8 @@ en: heading: Ongoing completed_section: heading: Completed + archived_section: + heading: Archived search: placeholder: Search goals… aria_label: Search savings goals @@ -199,6 +201,7 @@ en: pace_with_target: "%{avg}/mo · target %{target}/mo" pace_no_target: "%{avg}/mo avg" footer_paused: Paused + footer_archived: Archived footer_reached: Goal reached footer_catch_up: "Save %{amount}/mo to catch up" footer_no_deadline: No deadline set