mirror of
https://github.com/we-promise/sure.git
synced 2026-06-08 20:29:05 +00:00
* fix(ds): disabled buttons use not-allowed cursor
Tailwind v4 preflight sets cursor:pointer on every <button>, including
disabled ones. Add disabled:cursor-not-allowed to the DS button base so
disabled buttons read as non-interactive.
* fix(goals): disable new-goal submit until required fields valid
The submit button was always enabled, and the funding-accounts checkbox
group has no native 'required', so a goal with no linked account could be
submitted and only fail server-side (422). Disable the submit until name,
a positive target amount, and >=1 account are present, and add a
submit-time guard that surfaces inline errors and focuses the first
offending field as a backstop.
* fix(goals): keep color/icon picker from shifting the form
DS::Disclosure wraps its body in an mt-2 div that sits in normal flow, so
opening the absolutely-positioned picker popover nudged the form down ~8px.
Use a raw <details> for the picker so the popover overlays without
reflowing the content beneath it.
* fix(goals): container-responsive cards, meta-line status, scrollable tabs
- Card grids + KPI strip switch from viewport breakpoints to container
queries (@container), so columns track the actual content width when the
account/AI sidebars are open instead of crushing three columns into a
narrow center.
- Move the status pill from the title row to the meta line; the title now
gets the full header width (no more 'Hou...' truncation at 3-up). Drop
the secondary line when the pill already states it (completed / open).
- Card internals harden for narrow widths (ring shrink-0, footer wrap,
shorter 'N days left' secondary).
- Filter tabs scroll horizontally instead of wrapping 'On track' mid-label
or forcing the row wider than the viewport.
* fix(goals): only require a funding account on the create form
GoalsController#edit renders account checkboxes from visible accounts only,
so a goal backed solely by a now-hidden (disabled / pending_deletion)
account renders none checked. The submit-validation then wedged the edit
form — a name/notes change couldn't be saved even though #update preserves
existing links when account_ids is omitted. Gate the account requirement on
a require-account Stimulus value that is true only for the create form.
* fix(goals): give the color/icon picker trigger an accessible name
The hand-rolled <summary> is icon-only (pen), so screen readers announced an
unlabeled control. Add a localized aria-label.
* fix(goals): render form validation errors inline on server re-render
The client-side controller already surfaces name / amount / account errors
inline and disables submit, but a server 422 (JS disabled, or a race that
lets an invalid submit through) fell back to the top run-on banner
("X must be filled and Y and Z."). Make the existing inline error hints
server-aware so a failed submit shows the same per-field red text the
client path does, and drop the base-error banner — base only ever carries
the account requirement, which now renders beside the funding-accounts
list.
* fix(goals): blur projection chart under privacy mode
The projection chart's SVG axis labels and annotations (target, "$X short",
$200K/$400K ticks) rendered in cleartext while privacy mode blurred every
other number on the page. Tag the chart container `privacy-sensitive`, the
same wrapper-level treatment the net-worth and cashflow-sankey charts
already use, so it blurs with the rest.
* fix(goals): stop target-date input stretching when amount error shows
The target-amount / target-date row is a two-column grid. The amount
column carries its inline error <p> underneath, so when that error
appears the column grows and the default `items-stretch` makes the
sibling date input stretch to match — the date box visibly grew taller
than the amount box. Anchor the row with `items-start` so each input
keeps its natural height and the error just extends below its own column.
* fix(goals): make invalid submit announce errors instead of dead-ending
Review follow-ups:
- Swap the submit gate from the disabled attribute to aria-disabled: a
truly disabled default submit also blocks Enter-key implicit
submission, so an invalid form was a dead button with every inline
error still hidden. The button now stays clickable and lets
validateOnSubmit surface the errors; DS buttonish styles the
aria-disabled state (cursor-not-allowed + opacity-50). Side effect:
loading_button_controller submits also dim while busy, which reads as
an upgrade.
- Focus the first funding-account checkbox when accounts are the only
missing field (focus previously went nowhere).
- Drop the now-orphaned goals.goal_card.days_left_by locale key.
89 lines
5.1 KiB
Plaintext
89 lines
5.1 KiB
Plaintext
<%# locals: (goal:, linkable_accounts:, currently_linked_account_ids: []) %>
|
|
|
|
<div data-controller="goal-form"
|
|
data-goal-form-currency-value="<%= Current.family.primary_currency_code %>"
|
|
data-goal-form-require-account-value="<%= !goal.persisted? %>"
|
|
data-goal-form-suggested-with-date-value="<%= t("goals.form.suggested_with_date") %>"
|
|
data-goal-form-suggested-no-date-value="<%= t("goals.form.suggested_no_date") %>">
|
|
<%= styled_form_with model: goal,
|
|
url: goal.persisted? ? goal_path(goal) : goals_path,
|
|
method: goal.persisted? ? :patch : :post,
|
|
class: "space-y-5",
|
|
data: { action: "submit->goal-form#validateOnSubmit" } do |f| %>
|
|
<div class="flex justify-center">
|
|
<%= render "color_picker", form: f, colors: Goal::COLORS, icons: Goal::ICONS %>
|
|
</div>
|
|
|
|
<div>
|
|
<%= f.text_field :name,
|
|
placeholder: t("goals.form.fields.name_placeholder"),
|
|
autofocus: true,
|
|
required: true,
|
|
label: t("goals.form.fields.name"),
|
|
data: { goal_form_target: "nameInput", action: "input->goal-form#nameChanged" } %>
|
|
<p class="<%= "hidden" unless goal.errors[:name].any? %> mt-1.5 text-xs text-destructive" data-goal-form-target="nameError"><%= t("goals.form.errors.name_required") %></p>
|
|
</div>
|
|
|
|
<div class="grid grid-cols-2 gap-3 items-start">
|
|
<div>
|
|
<%= f.money_field :target_amount,
|
|
label: t("goals.form.fields.target_amount"),
|
|
hide_currency: true,
|
|
required: true,
|
|
amount_data: { goal_form_target: "amountInput", action: "input->goal-form#suggestedChanged" } %>
|
|
<p class="<%= "hidden" unless goal.errors[:target_amount].any? %> mt-1.5 text-xs text-destructive" data-goal-form-target="amountError"><%= t("goals.form.errors.amount_required") %></p>
|
|
</div>
|
|
<%= f.date_field :target_date,
|
|
label: t("goals.form.fields.target_date"),
|
|
data: { goal_form_target: "dateInput", action: "input->goal-form#suggestedChanged" } %>
|
|
</div>
|
|
|
|
<p class="text-xs text-secondary italic tabular-nums privacy-sensitive hidden" data-goal-form-target="suggested"></p>
|
|
|
|
<div>
|
|
<div class="mb-2">
|
|
<span class="block text-sm font-medium text-primary"><%= t("goals.form.fields.funding_accounts") %></span>
|
|
<p class="text-xs text-secondary mt-0.5"><%= t("goals.form.fields.funding_accounts_hint") %></p>
|
|
</div>
|
|
<div class="bg-container-inset rounded-lg p-1">
|
|
<% grouped = linkable_accounts.group_by { |a| a.subtype.to_s.presence || "other" } %>
|
|
<% grouped.each_with_index do |(subtype, accts), group_idx| %>
|
|
<div class="px-3 py-2 text-[11px] font-medium uppercase tracking-wide text-secondary"><%= t("goals.form.subtypes.#{subtype}", default: subtype.titleize) %></div>
|
|
<div class="bg-container rounded-md <%= "mb-1" if group_idx < grouped.size - 1 %>">
|
|
<% accts.each_with_index do |account, idx| %>
|
|
<label class="flex items-center gap-3 px-3 py-2.5 cursor-pointer hover:bg-surface-hover <%= "border-t border-subdued" if idx > 0 %>">
|
|
<%= check_box_tag "goal[account_ids][]",
|
|
account.id,
|
|
currently_linked_account_ids.include?(account.id.to_s),
|
|
id: "goal_account_ids_#{account.id}",
|
|
class: "checkbox checkbox--light shrink-0",
|
|
data: {
|
|
goal_form_target: "linkedAccountCheckbox",
|
|
action: "change->goal-form#linkedAccountChanged"
|
|
} %>
|
|
<%= render Goals::AvatarComponent.new(name: account.name, color: Goals::AvatarComponent.color_for(account.name), size: "md") %>
|
|
<div class="flex-1 min-w-0">
|
|
<p class="text-sm font-medium text-primary truncate"><%= account.name %></p>
|
|
<p class="text-xs text-secondary"><%= (account.subtype || subtype).titleize %></p>
|
|
</div>
|
|
<span class="text-sm text-primary tabular-nums privacy-sensitive"><%= Money.new(account.balance, account.currency).format %></span>
|
|
</label>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
<p class="<%= "hidden" unless goal.errors[:base].any? %> mt-1.5 text-xs text-destructive" data-goal-form-target="accountsError"><%= t("goals.form.errors.accounts_required") %></p>
|
|
</div>
|
|
|
|
<%= f.text_area :notes,
|
|
label: t("goals.form.fields.notes"),
|
|
rows: 2,
|
|
placeholder: t("goals.form.fields.notes_placeholder") %>
|
|
|
|
<div class="flex justify-end pt-2">
|
|
<%= f.submit goal.persisted? ? t("goals.form.save") : t("goals.form.create"),
|
|
data: { goal_form_target: "submitButton" } %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|