mirror of
https://github.com/we-promise/sure.git
synced 2026-05-30 15:59:02 +00:00
Previously sat next to the name input via `flex items-start gap-3` so the picker avatar competed with the input for horizontal space. Move to its own row, centered (`flex justify-center`), positioned just before the name field. Mirrors the categories form layout where the avatar is the focal element above the name input. Same change applied to the edit form: picker comes first, then name. Stepper step 1 order is now: heading · picker · name · amount/date · funding accounts · notes.
65 lines
3.0 KiB
Plaintext
65 lines
3.0 KiB
Plaintext
<%# locals: (goal:, linkable_accounts:, currently_linked_account_ids:) %>
|
|
|
|
<% if goal.errors.any? %>
|
|
<%= render "shared/form_errors", model: goal %>
|
|
<% end %>
|
|
|
|
<%= styled_form_with model: goal,
|
|
url: goal_path(goal),
|
|
method: :patch,
|
|
class: "space-y-3" do |f| %>
|
|
<div class="flex justify-center">
|
|
<%= render "color_picker", form: f, colors: Goal::COLORS, icons: Goal::ICONS %>
|
|
</div>
|
|
|
|
<%= f.text_field :name,
|
|
label: t("goals.form_stepper.step1.fields.name"),
|
|
required: true,
|
|
autofocus: true %>
|
|
|
|
<%= f.money_field :target_amount,
|
|
label: t("goals.form_stepper.step1.fields.target_amount"),
|
|
required: true %>
|
|
|
|
<%= f.date_field :target_date,
|
|
label: t("goals.form_stepper.step1.fields.target_date") %>
|
|
|
|
<div>
|
|
<div class="mb-2">
|
|
<span class="block text-sm font-medium text-primary"><%= t("goals.form_stepper.step1.fields.funding_accounts") %></span>
|
|
<p class="text-xs text-secondary mt-0.5"><%= t("goals.form_stepper.step1.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_stepper.step1.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 <%= "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" %>
|
|
<%= 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"><%= Money.new(account.balance, account.currency).format %></span>
|
|
</label>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
|
|
<%= f.text_area :notes,
|
|
label: t("goals.form_stepper.step1.fields.notes"),
|
|
rows: 2 %>
|
|
|
|
<div class="flex justify-end pt-2">
|
|
<%= f.submit t("goals.edit.save") %>
|
|
</div>
|
|
<% end %>
|