mirror of
https://github.com/we-promise/sure.git
synced 2026-05-25 21:44:56 +00:00
Migrates the hand-rolled "Pending" / "Review recommended" / "Potential duplicate" / "Split" badges across the transaction views to the extended DS::Pill primitive from #1902. **Visual contract for badge mode** In #1902 the badge mode (`marker: false`) used `rounded-md` (chip shape) because the marker mode does. But every existing pill / status badge in the codebase uses `rounded-full` — see `settings/providers/_status_pill.html.erb`, `settings/providers/_maturity_badge.html.erb`, and the inline transaction badges this PR is migrating. To keep the visual contract consistent, this PR shifts `DS::Pill`'s badge mode to `rounded-full` (marker mode stays `rounded-md`, unchanged from #1829). The shape distinction now reads: markers are tags, badges are pills. **Callsites migrated** (5): - `app/views/transactions/_transaction.html.erb` — Pending, Review-recommended, Possible-duplicate, Split badges - `app/views/transactions/_header.html.erb` — Pending badge - `app/views/transactions/_split_parent_row.html.erb` — Split badge **Tone mapping** | Badge | Tone | Notes | |---|---|---| | Pending | `:neutral` | unchanged copy/icon, gains subtle DS-controlled bg | | Review recommended | `:neutral` | matches existing `bg-surface-inset` look | | Possible duplicate | `:warning` | DS semantic alias for the existing `text-warning` | | Split | `:neutral` | matches existing `bg-surface-inset` look | **Deferred to follow-up PRs** - `app/views/transactions/_transfer_match.html.erb` — uses two responsive-visibility variants (`hidden lg:inline-flex` for long copy, `inline-flex lg:hidden` for short). DS::Pill currently has no `class:` arg for caller-controlled wrapper classes; deferring until that lands. - `app/views/transactions/searches/filters/_badge.html.erb` — has a close button alongside the label (`button_to clear_filter_*`) and uses `rounded-3xl p-1.5` instead of a true pill. Closer to a removable filter chip — better fit for a separate `DS::FilterChip` primitive than for `DS::Pill`. Refs #1751.
208 lines
10 KiB
Plaintext
208 lines
10 KiB
Plaintext
<%# locals: (entry:, balance_trend: nil, view_ctx: "global", in_split_group: false) %>
|
|
|
|
<% transaction = entry.entryable %>
|
|
<% transaction_security_logo_url = transaction.activity_security&.display_logo_url %>
|
|
|
|
<%= turbo_frame_tag dom_id(entry) do %>
|
|
<%= turbo_frame_tag dom_id(transaction) do %>
|
|
<div class="group flex lg:grid lg:grid-cols-12 items-center text-primary text-sm font-medium p-3 lg:p-4 <%= "pl-8 lg:pl-12" if in_split_group %>">
|
|
|
|
<div class="pr-4 lg:pr-10 flex items-center gap-3 lg:gap-4 col-span-8 min-w-0">
|
|
<%= check_box_tag dom_id(entry, "selection"),
|
|
disabled: transaction.transfer.present?,
|
|
class: "checkbox checkbox--light hidden lg:block",
|
|
data: {
|
|
id: entry.id,
|
|
entry_type: entry.entryable_type,
|
|
"bulk-select-target": "row",
|
|
action: "bulk-select#toggleRowSelection",
|
|
checkbox_toggle_target: "selectionEntry"
|
|
} %>
|
|
|
|
<div class="flex md:hidden items-center gap-1 col-span-2 relative shrink-0">
|
|
<%= render "transactions/transaction_category", transaction: transaction, variant: "mobile", in_split_group: in_split_group %>
|
|
<% if transaction_security_logo_url.present? %>
|
|
<%= image_tag Setting.transform_brand_fetch_url(transaction_security_logo_url),
|
|
class: "w-5 h-5 rounded-full absolute -bottom-1 -right-1 border border-secondary pointer-events-none",
|
|
loading: "lazy" %>
|
|
<% elsif transaction.merchant&.logo_url.present? %>
|
|
<%= image_tag Setting.transform_brand_fetch_url(transaction.merchant.logo_url),
|
|
class: "w-5 h-5 rounded-full absolute -bottom-1 -right-1 border border-secondary pointer-events-none",
|
|
loading: "lazy" %>
|
|
<% end %>
|
|
</div>
|
|
|
|
<div class="max-w-full min-w-0 <%= "opacity-50 text-secondary" if entry.excluded %>">
|
|
<%= content_tag :div, class: ["flex items-center gap-3 lg:gap-4"] do %>
|
|
<div class="hidden lg:flex">
|
|
<% if transaction.transfer? %>
|
|
<%= render DS::FilledIcon.new(
|
|
icon: "arrow-right-left",
|
|
hex_color: Category::TRANSFER_COLOR,
|
|
size: "lg",
|
|
rounded: true
|
|
) %>
|
|
<% elsif transaction_security_logo_url.present? %>
|
|
<%= image_tag Setting.transform_brand_fetch_url(transaction_security_logo_url),
|
|
class: "w-9 h-9 rounded-full border border-secondary",
|
|
loading: "lazy" %>
|
|
<% elsif transaction.merchant&.logo_url.present? %>
|
|
<%= image_tag Setting.transform_brand_fetch_url(transaction.merchant.logo_url),
|
|
class: "w-9 h-9 rounded-full border border-secondary",
|
|
loading: "lazy" %>
|
|
<% else %>
|
|
<div class="hidden lg:flex">
|
|
<%= render DS::FilledIcon.new(
|
|
variant: :text,
|
|
text: entry.name,
|
|
size: "lg",
|
|
rounded: true
|
|
) %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
|
|
<div class="truncate">
|
|
<div class="space-y-0.5">
|
|
<div class="flex items-center gap-1 min-w-0">
|
|
<div class="truncate flex-shrink">
|
|
<% if transaction.transfer? %>
|
|
<%= link_to(
|
|
entry.name,
|
|
transaction.transfer.present? ? transfer_path(transaction.transfer) : entry_path(entry),
|
|
data: {
|
|
turbo_frame: "drawer",
|
|
turbo_prefetch: false
|
|
},
|
|
class: "hover:underline"
|
|
) %>
|
|
<% else %>
|
|
<%= link_to(
|
|
entry.name,
|
|
in_split_group ? entry_path(entry, grouped: true) : entry_path(entry),
|
|
data: {
|
|
turbo_frame: "drawer",
|
|
turbo_prefetch: false
|
|
},
|
|
class: "hover:underline"
|
|
) %>
|
|
<% end %>
|
|
</div>
|
|
|
|
<div class="flex items-center gap-1 flex-shrink-0">
|
|
<% if transaction.one_time? %>
|
|
<span class="text-orange-500" title="One-time <%= entry.amount.negative? ? "income" : "expense" %> (excluded from averages)">
|
|
<%= icon "asterisk", size: "sm", color: "current" %>
|
|
</span>
|
|
<% end %>
|
|
|
|
<%# Pending indicator %>
|
|
<% if transaction.pending? %>
|
|
<%= render DS::Pill.new(
|
|
label: t("transactions.transaction.pending"),
|
|
tone: :neutral,
|
|
marker: false,
|
|
icon: "clock",
|
|
title: t("transactions.transaction.pending_tooltip")
|
|
) %>
|
|
<% end %>
|
|
|
|
<%# Potential duplicate indicator - different styling for low vs medium confidence %>
|
|
<% if transaction.has_potential_duplicate? %>
|
|
<% if transaction.low_confidence_duplicate? %>
|
|
<%= render DS::Pill.new(
|
|
label: t("transactions.transaction.review_recommended"),
|
|
tone: :neutral,
|
|
marker: false,
|
|
icon: "help-circle",
|
|
title: t("transactions.transaction.review_recommended_tooltip")
|
|
) %>
|
|
<% else %>
|
|
<%= render DS::Pill.new(
|
|
label: t("transactions.transaction.possible_duplicate"),
|
|
tone: :warning,
|
|
marker: false,
|
|
icon: "alert-triangle",
|
|
title: t("transactions.transaction.potential_duplicate_tooltip")
|
|
) %>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<%# Split indicator %>
|
|
<% if @split_parent_entry_ids ? @split_parent_entry_ids.include?(entry.id) : entry.split_parent? %>
|
|
<%= render DS::Pill.new(
|
|
label: t("transactions.transaction.split"),
|
|
tone: :neutral,
|
|
marker: false,
|
|
icon: "split",
|
|
title: t("transactions.transaction.split_tooltip")
|
|
) %>
|
|
<% end %>
|
|
<% if entry.split_child? && !in_split_group %>
|
|
<span class="text-secondary" title="<%= t("transactions.transaction.split_child_tooltip") %>">
|
|
<%= icon "corner-down-right", size: "sm", color: "current" %>
|
|
</span>
|
|
<% end %>
|
|
|
|
<% if transaction.transfer.present? %>
|
|
<%= render "transactions/transfer_match", transaction: transaction %>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="text-secondary text-xs font-normal">
|
|
<% if transaction.transfer? %>
|
|
<span class="text-secondary">
|
|
<%= transaction.loan_payment? ? t("transactions.show.loan_payment") : t("transactions.show.transfer") %> • <%= entry.account.name %>
|
|
</span>
|
|
<% else %>
|
|
<% if transaction.merchant&.present? %>
|
|
<span class="hidden lg:inline truncate"><%= transaction.merchant.name %> • </span>
|
|
<% end %>
|
|
<span class="text-secondary hidden lg:inline">
|
|
<%= link_to entry.account.name,
|
|
account_path(entry.account, tab: "transactions"),
|
|
data: { turbo_frame: "_top" },
|
|
class: "hover:underline" %>
|
|
</span>
|
|
<div class="flex min-w-0 items-center gap-1">
|
|
<%= render "categories/category_name_mobile", transaction: transaction %>
|
|
<% if transaction.merchant&.present? %>
|
|
<span class="lg:hidden min-w-0 truncate">• <%= transaction.merchant.name %></span>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="hidden md:flex min-w-0 items-center gap-1 col-span-2">
|
|
<% if entry.account.investment? && !transaction.transfer? %>
|
|
<%# For investment accounts, show activity label instead of category %>
|
|
<%= render "investment_activity/quick_edit_badge", entry: entry, entryable: transaction %>
|
|
<% else %>
|
|
<%= render "transactions/transaction_category", transaction: transaction, variant: "desktop", in_split_group: in_split_group %>
|
|
<% end %>
|
|
</div>
|
|
|
|
<div class="shrink-0 col-span-4 lg:col-span-2 ml-auto flex items-center justify-end gap-2 <%= "opacity-50" if entry.excluded %>">
|
|
<%# Protection indicator - shows on hover when entry is protected from sync %>
|
|
<% if entry.protected_from_sync? && !entry.excluded? %>
|
|
<%= link_to entry_path(entry),
|
|
data: { turbo_frame: "drawer", turbo_prefetch: false },
|
|
class: "invisible group-hover:visible transition-opacity",
|
|
title: t("entries.protection.tooltip") do %>
|
|
<%= icon "lock", size: "sm", class: "text-secondary" %>
|
|
<% end %>
|
|
<% end %>
|
|
<%= content_tag :p,
|
|
transaction.transfer? && view_ctx == "global" ? "+/- #{format_money(entry.amount_money.abs)}" : format_money(-entry.amount_money),
|
|
class: ["privacy-sensitive", "text-green-600": entry.amount.negative?] %>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
<% end %>
|