refactor: rename Savings Goals feature to Goals

User-facing rename + structural rename. Feature is now called just
"Goals" everywhere — page title, sidebar nav, modal headings, flash
messages, AI assistant tool. Code identifiers follow:

- Models: SavingsGoal → Goal, SavingsContribution → GoalContribution,
  SavingsGoalAccount → GoalAccount.
- Tables: savings_goals → goals, savings_contributions → goal_contributions,
  savings_goal_accounts → goal_accounts. FK columns savings_goal_id →
  goal_id. New migration db/migrate/20260511100003_rename_savings_to_goals.rb
  uses rename_table + rename_column; PG handles index renaming and FK
  redirection automatically.
- Controllers: SavingsGoalsController → GoalsController,
  SavingsContributionsController → GoalContributionsController.
- Routes: /savings_goals → /goals, nested /goals/:id/contributions
  (resource name shifts; old route name aliases dropped).
- ViewComponent namespace: Savings::* → Goals::*. Component class
  names drop their redundant "Goal" prefix where the namespace already
  carries it: Savings::GoalCardComponent → Goals::CardComponent,
  Savings::GoalAvatarComponent → Goals::AvatarComponent. Others keep
  their names (Goals::ProgressRingComponent, Goals::StatusPillComponent,
  Goals::AccountStackComponent, Goals::FundingAccountsBreakdownComponent).
- Stimulus controllers: savings_goal_* → goal_*, savings_goals_filter
  → goals_filter. Stimulus identifiers in data-controller / data-*
  attributes follow.
- Locale keys: savings_goals: → goals: (top level), savings_contributions:
  → goal_contributions: (top level). All t() callers updated.
- AI assistant tool: Assistant::Function::CreateSavingsGoal →
  Assistant::Function::CreateGoal, tool name "create_savings_goal" →
  "create_goal", description / response text updated.
- Sidebar nav label "Savings" → "Goals". Goals/show + index page title
  "Savings" → "Goals". Empty goals_section heading/subtitle dropped
  (duplicated the page title post-rename).

Original migrations create_savings_goals / create_savings_goal_accounts /
create_savings_contributions remain untouched so historical replay
still works; the rename migration runs on top.
This commit is contained in:
Guillem Arias
2026-05-11 20:08:32 +02:00
parent 560bff87d2
commit 9b61e4a41b
56 changed files with 810 additions and 804 deletions

View File

@@ -1,15 +1,15 @@
import { Controller } from "@hotwired/stimulus";
import * as d3 from "d3";
// Projection chart for a savings goal. Renders:
// Projection chart for a goal. Renders:
// - Saved area + line from goal creation → today (solid)
// - Dashed projection line from today → target date (yellow if behind,
// green if on track)
// - Horizontal dashed target line with label
// - Today marker (vertical line + dot)
//
// Data shape passed via `data-savings-goal-projection-chart-data-value`
// matches SavingsGoal#projection_payload.
// Data shape passed via `data-goal-projection-chart-data-value`
// matches Goal#projection_payload.
export default class extends Controller {
static values = { data: Object, ariaLabel: String, ariaDescription: String };
@@ -112,7 +112,7 @@ export default class extends Controller {
const titleId = `chart-title-${this._id()}`;
const descId = `chart-desc-${this._id()}`;
svg.attr("role", "img").attr("aria-labelledby", titleId).attr("aria-describedby", descId);
svg.append("title").attr("id", titleId).text(this.ariaLabelValue || "Savings goal projection");
svg.append("title").attr("id", titleId).text(this.ariaLabelValue || "Goal projection");
svg.append("desc").attr("id", descId).text(this.ariaDescriptionValue || "");
const defs = svg.append("defs");

View File

@@ -1,6 +1,6 @@
import { Controller } from "@hotwired/stimulus";
// 2-step modal stepper for creating a savings goal.
// 2-step modal stepper for creating a goal.
//
// Single <form> with two panels. Step 1 collects identity (name, amount,
// date, color, notes, linked accounts). Step 2 reviews + optional initial
@@ -108,7 +108,7 @@ export default class extends Controller {
if (!this.hasAvatarPreviewTarget || !this.hasNameInputTarget) return;
const name = this.nameInputTarget.value.trim();
const initial = name ? name.charAt(0).toUpperCase() : "?";
const inner = this.avatarPreviewTarget.querySelector('[data-testid="savings-goal-avatar"]');
const inner = this.avatarPreviewTarget.querySelector('[data-testid="goal-avatar"]');
if (inner) inner.textContent = initial;
}
@@ -208,7 +208,7 @@ export default class extends Controller {
}
// Modal subtitle lives in the dialog header, outside this controller's
// DOM scope. Locate it by attribute and update directly.
const subtitle = document.querySelector('[data-savings-goal-stepper-modal-subtitle]');
const subtitle = document.querySelector('[data-goal-stepper-modal-subtitle]');
if (subtitle) {
subtitle.textContent =
this.currentStep === 1 ? this.step1SubtitleValue : this.step2SubtitleValue;
@@ -232,10 +232,10 @@ export default class extends Controller {
updateReview() {
if (!this.hasReviewNameTarget) return;
const name = this.element.querySelector('input[name="savings_goal[name]"]')?.value || "—";
const amountInput = this.element.querySelector('input[name="savings_goal[target_amount]"]');
const name = this.element.querySelector('input[name="goal[name]"]')?.value || "—";
const amountInput = this.element.querySelector('input[name="goal[target_amount]"]');
const amount = amountInput?.value ? Number.parseFloat(amountInput.value) : 0;
const dateInput = this.element.querySelector('input[type="date"][name="savings_goal[target_date]"]');
const dateInput = this.element.querySelector('input[type="date"][name="goal[target_date]"]');
const dateValue = dateInput?.value;
this.reviewNameTarget.textContent = name;

View File

@@ -1,6 +1,6 @@
import { Controller } from "@hotwired/stimulus";
// Free-text + status-chip filter for the savings-goals index grid.
// Free-text + status-chip filter for the goals index grid.
// Mirrors the providers-filter pattern. Each card has data-goal-name
// and data-goal-status; the controller toggles `.hidden` on cards
// based on the active query/chip.