mirror of
https://github.com/we-promise/sure.git
synced 2026-05-30 07:49:01 +00:00
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.
45 lines
1.2 KiB
Ruby
45 lines
1.2 KiB
Ruby
class Goals::AvatarComponent < ApplicationComponent
|
|
SIZES = {
|
|
"sm" => { box: "w-6 h-6", text: "text-[10px]", radius: "rounded-md" },
|
|
"md" => { box: "w-9 h-9", text: "text-sm", radius: "rounded-lg" },
|
|
"lg" => { box: "w-11 h-11", text: "text-base", radius: "rounded-xl" },
|
|
"xl" => { box: "w-16 h-16", text: "text-2xl", radius: "rounded-2xl" }
|
|
}.freeze
|
|
|
|
PALETTE = Goal::COLORS
|
|
|
|
# Deterministic color pick from the palette so the same string maps to
|
|
# the same color across processes (Ruby's String#hash is randomized per
|
|
# boot for DoS protection — not stable enough for visual identity).
|
|
def self.color_for(name)
|
|
return PALETTE.first if name.blank?
|
|
PALETTE[Digest::MD5.hexdigest(name).to_i(16) % PALETTE.size]
|
|
end
|
|
|
|
def initialize(goal: nil, name: nil, color: nil, size: "md")
|
|
@goal = goal
|
|
@name = name || goal&.name
|
|
@color = color || goal&.color || Goal::COLORS.first
|
|
@size = SIZES.key?(size) ? size : "md"
|
|
end
|
|
|
|
attr_reader :color
|
|
|
|
def initial
|
|
return "?" if @name.blank?
|
|
@name.strip.first&.upcase || "?"
|
|
end
|
|
|
|
def box_classes
|
|
SIZES[@size][:box]
|
|
end
|
|
|
|
def text_classes
|
|
SIZES[@size][:text]
|
|
end
|
|
|
|
def radius_classes
|
|
SIZES[@size][:radius]
|
|
end
|
|
end
|