From 38e8169067030284f1de1ac14d1632170e8dcf8e Mon Sep 17 00:00:00 2001 From: Guillem Arias Date: Mon, 11 May 2026 20:37:31 +0200 Subject: [PATCH] feat(goals/show): status-aware chart variants for empty + no-target-date Empty state (goal with zero contributions) was rendering a flat-at-$0 saved series and a flat-at-$0 projection that looked broken to anyone opening a freshly created goal. Now show.html.erb branches on @goal.goal_contributions.empty? and renders a piggy-bank + "Add a contribution" CTA card before the chart card. Brand-new goals get a clean inline call-to-action instead of a misleading line at zero. No-target-date goals (target_amount set, target_date null) used to render a standalone "Set a target date" prompt card and hide history entirely. Now they render the chart with the saved history + the target horizontal line (no projection segment, no projection legend item), plus a secondary "Set target date" callout below the chart linking into the edit modal. History is informative even without a deadline. Locale: new goals.show.empty.{heading,body,cta}. --- app/views/goals/show.html.erb | 39 ++++++++++++++++++++----------- config/locales/views/goals/en.yml | 4 ++++ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/app/views/goals/show.html.erb b/app/views/goals/show.html.erb index 95b353c2b..ecc343cad 100644 --- a/app/views/goals/show.html.erb +++ b/app/views/goals/show.html.erb @@ -204,21 +204,22 @@ <% end %> - <% elsif @goal.target_date.nil? %> - <%# No-target-date prompt %> + <% elsif @goal.goal_contributions.empty? %> + <%# No contributions yet: render an inline "add your first" CTA card + instead of a flat-at-$0 chart that looks broken. %>
- <%= icon("calendar-plus", size: "2xl") %> + <%= icon("piggy-bank", size: "2xl") %>
-

<%= t(".no_target_date.heading") %>

-

<%= t(".no_target_date.body") %>

+

<%= t(".empty.heading") %>

+

<%= t(".empty.body") %>

<%= render DS::Link.new( - text: t(".no_target_date.cta"), - variant: "outline", + text: t(".empty.cta"), + variant: "primary", size: "sm", - href: edit_goal_path(@goal), - icon: "calendar-plus", + href: new_goal_contribution_path(@goal), + icon: "plus", frame: :modal ) %>
@@ -236,10 +237,12 @@ <%= t(".projection.legend_saved") %> - - - <%= t(".projection.legend_projection") %> - + <% unless @goal.target_date.nil? %> + + + <%= t(".projection.legend_projection") %> + + <% end %>
" data-goal-projection-chart-aria-description-value="<%= strip_tags(@stats[:projection_summary]) %>">
+ <% if @goal.target_date.nil? %> +
+ <%= icon("calendar-plus", size: "sm") %> + <%= t(".no_target_date.body") %> + <%= link_to t(".no_target_date.cta"), + edit_goal_path(@goal), + data: { turbo_frame: :modal }, + class: "font-medium text-primary underline-offset-2 hover:underline" %> +
+ <% end %> <% end %> diff --git a/config/locales/views/goals/en.yml b/config/locales/views/goals/en.yml index 529d56d51..c40ecde16 100644 --- a/config/locales/views/goals/en.yml +++ b/config/locales/views/goals/en.yml @@ -153,6 +153,10 @@ en: heading: Add a target date body: Set a deadline to project a finish line and track required pace. cta: Set target date + empty: + heading: No contributions yet + body: Track your progress by adding your first contribution. + cta: Add a contribution source: initial: Initial manual: Manual