The personal finance app for everyone (by everyone)
Ruby
Polish All bills and put the bills tabs' loose text on surfaces (#4129)
Guillem Arias Faustec4a7585efd75
diff --git a/app/components/DS/table.html.erb b/app/components/DS/table.html.erbindex 51d9b75d15..d411633ecf 100644--- a/app/components/DS/table.html.erb+++ b/app/components/DS/table.html.erb@@ -13,7 +13,7 @@</thead><tbody><% rows.each_with_index do |row, index| %>- <%= tag.tr class: row_classes(row) do %>+ <%= tag.tr class: row_classes(row), **row_attributes(row) do %><% columns.each do |column| %><%= column.cell(row, index) %><% end %>diff --git a/app/components/DS/table.rb b/app/components/DS/table.rbindex 4a378c4427..49f84c5e9c 100644--- a/app/components/DS/table.rb+++ b/app/components/DS/table.rb@@ -18,7 +18,7 @@ class DS::Table < DesignSystemComponentDS::Table::Column.new(header, cell: cell, sticky: sticky_header, **options)end- attr_reader :rows, :inset, :sticky_header, :label, :row_class, :opts+ attr_reader :rows, :inset, :sticky_header, :label, :row_class, :row_opts, :opts# @param rows [Enumerable] the records, one table row each# @param inset [Boolean] frame the table in container-inset, for a table that@@ -32,13 +32,17 @@ class DS::Table < DesignSystemComponent# screen.# @param row_class [Proc, nil] called with each row, returns extra classes for# its <tr>, e.g. the tint on a loan's past payments+ # @param row_opts [Proc, nil] called with each row, returns extra attributes for+ # its <tr>, e.g. a `clickable-row` controller so a click anywhere on the row+ # opens the link in its name cell# @param opts [Hash] forwarded to the outer element; :class merges with the base classes- def initialize(rows:, inset: false, sticky_header: false, label: nil, row_class: nil, **opts)+ def initialize(rows:, inset: false, sticky_header: false, label: nil, row_class: nil, row_opts: nil, **opts)@rows = rows@inset = inset@sticky_header = sticky_header@label = label@row_class = row_class+ @row_opts = row_opts@opts = optsend@@ -73,4 +77,8 @@ class DS::Table < DesignSystemComponentdef row_classes(row)row_class&.call(row)end++ def row_attributes(row)+ row_opts&.call(row) || {}+ endenddiff --git a/app/controllers/bills_controller.rb b/app/controllers/bills_controller.rbindex 31163fe634..a8b998c9c4 100644--- a/app/controllers/bills_controller.rb+++ b/app/controllers/bills_controller.rb@@ -416,6 +416,7 @@ class BillsController < ApplicationController@by_day = occurrences.group_by(&:due_on)month_occurrences = occurrences.select { |occurrence| occurrence.due_on.between?(@month, @month.end_of_month) }+ @month_bill_count = month_occurrences.size@month_expected, @month_unconvertible = total_of(month_occurrences) { |occurrence| occurrence.resolved_expected_amount_money }@month_paid, _ = total_of(month_occurrences) { |occurrence| occurrence.confirmed_allocated_money }enddiff --git a/app/helpers/bills_helper.rb b/app/helpers/bills_helper.rbindex bc360d6ca0..e91960111a 100644--- a/app/helpers/bills_helper.rb+++ b/app/helpers/bills_helper.rb@@ -7,6 +7,26 @@ module BillsHelperl(date, format: date.year == Date.current.year ? :short : :short_with_year)end+ # What an All bills row says under the name: its schedule, led by its kind+ # when the kind is not the plain "bill" that most rows are, so a subscription+ # or an income still reads as one now that the list has no Type column.+ def bills_series_subline(series)+ kind = t("bills.all.types.#{series.bill_type}") unless series.typed_bill?+ [ kind, frequency_label(series) ].compact.join(" · ")+ end++ # Only a live series is owed or expected, so only a live one carries full+ # weight. A paused or dismissed one recedes through the text, as an autopaying+ # bill does on the overview: opacity on the row would sink the secondary text+ # below 3:1.+ def bills_series_tone(series)+ series.active? ? "text-primary" : "text-secondary"+ end++ def bills_series_amount_tone(series)+ series.active? && series.typed_income? ? "text-success" : bills_series_tone(series)+ end+# The date a bill row is about. The subline leads with it below @lg, and the# rail prints it from there up (bills_rail_date). Snooze-aware, like# derived_state and Next up.diff --git a/app/views/bills/_occurrence.html.erb b/app/views/bills/_occurrence.html.erbindex 0448d1c177..a09587c642 100644--- a/app/views/bills/_occurrence.html.erb+++ b/app/views/bills/_occurrence.html.erb@@ -39,18 +39,7 @@<%= bills_rail_date(occurrence) %></div>- <% if series.merchant&.logo_url.present? %>- <%= image_tag Setting.transform_brand_fetch_url(series.merchant.logo_url),- class: "w-9 h-9 rounded-full shrink-0 border border-secondary",- loading: "lazy" %>- <% else %>- <%= render DS::FilledIcon.new(- variant: :text,- text: series.display_name,- size: "lg",- rounded: true- ) %>- <% end %>+ <%= render "bills/series_avatar", series: series %><div class="min-w-0 flex-1"><p class="<%= lead_tone %> text-sm font-medium truncate hover:underline">diff --git a/app/views/bills/_paycheck_bridge.html.erb b/app/views/bills/_paycheck_bridge.html.erbindex 4ef49bd755..3440186db3 100755--- a/app/views/bills/_paycheck_bridge.html.erb+++ b/app/views/bills/_paycheck_bridge.html.erb@@ -9,7 +9,7 @@Deliberately quiet. Nothing is wrong here, and the window still has to bevisible. %>-<div class="rounded-lg bg-surface-inset px-4 py-3 space-y-1">+<div class="rounded-xl bg-surface-inset px-4 py-3 space-y-1"><div class="flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1"><p class="text-sm text-primary tabular-nums privacy-sensitive"><span class="font-medium"><%= t("bills.paycheck.bridge_label") %></span>diff --git a/app/views/bills/_paycheck_income.html.erb b/app/views/bills/_paycheck_income.html.erbindex f9e2d5894b..aa713be65b 100644--- a/app/views/bills/_paycheck_income.html.erb+++ b/app/views/bills/_paycheck_income.html.erb@@ -2,7 +2,10 @@controls behind Manage. Dates come from occurrences, never from the storednext_expected_date column, so this and the plan always agree. %>-<%= render DS::Disclosure.new(variant: :bare) do |disclosure| %>+<%# A card, like the pulse and the review banner on the overview: this was a+ bare disclosure, so the eyebrow, the headline and Manage sat straight on the+ page background. %>+<%= render DS::Disclosure.new(variant: :card, body_class: "mt-3 border-t border-subdued divide-y divide-subdued") do |disclosure| %><% disclosure.with_summary_content do %><div class="flex items-baseline justify-between gap-3"><div class="min-w-0">@@ -24,34 +27,32 @@</div><% end %>- <div class="bg-container rounded-xl shadow-border-xs mt-3 px-4 py-2">- <% @income_series.each do |series| %>- <% occurrence = @next_income_by_series[series.id] %>- <div class="flex items-center justify-between gap-3 py-2">- <div class="min-w-0">- <p class="text-sm text-primary truncate">- <%= link_to series.display_name, bill_path(series), data: { turbo_frame: "drawer", turbo_prefetch: false }, class: "hover:underline" %>- </p>- <p class="text-xs text-secondary truncate">- <%= frequency_label(series) %>- <% if occurrence %>- · <%= t("bills.paycheck.income_next_payday", date: l(occurrence.due_on, format: :short)) %>- <% end %>- <% unless paycheck_income_plans?(series) %>- · <%= paycheck_income_excluded_reason(series) %>- <% end %>- </p>- </div>- <div class="flex items-center gap-1 shrink-0">- <p class="text-sm text-primary tabular-nums privacy-sensitive"><%= format_money(occurrence&.resolved_expected_amount_money || Money.new(series.amount.abs, series.currency)) %></p>- <%= render DS::Link.new(- icon: "pencil",- variant: "icon",- href: edit_recurring_transaction_path(series),- frame: :modal- ) %>- </div>+ <% @income_series.each do |series| %>+ <% occurrence = @next_income_by_series[series.id] %>+ <div class="flex items-center justify-between gap-3 py-2">+ <div class="min-w-0">+ <p class="text-sm text-primary truncate">+ <%= link_to series.display_name, bill_path(series), data: { turbo_frame: "drawer", turbo_prefetch: false }, class: "hover:underline" %>+ </p>+ <p class="text-xs text-secondary truncate">+ <%= frequency_label(series) %>+ <% if occurrence %>+ · <%= t("bills.paycheck.income_next_payday", date: l(occurrence.due_on, format: :short)) %>+ <% end %>+ <% unless paycheck_income_plans?(series) %>+ · <%= paycheck_income_excluded_reason(series) %>+ <% end %>+ </p>+ </div>+ <div class="flex items-center gap-1 shrink-0">+ <p class="text-sm text-primary tabular-nums privacy-sensitive"><%= format_money(occurrence&.resolved_expected_amount_money || Money.new(series.amount.abs, series.currency)) %></p>+ <%= render DS::Link.new(+ icon: "pencil",+ variant: "icon",+ href: edit_recurring_transaction_path(series),+ frame: :modal+ ) %></div>- <% end %>- </div>+ </div>+ <% end %><% end %>diff --git a/app/views/bills/_paycheck_shortfall.html.erb b/app/views/bills/_paycheck_shortfall.html.erbindex df77fed081..6606ce4513 100644--- a/app/views/bills/_paycheck_shortfall.html.erb+++ b/app/views/bills/_paycheck_shortfall.html.erb@@ -8,7 +8,7 @@<% largest = period.largest_obligation %>-<div class="rounded-lg bg-destructive/5 px-4 py-3 space-y-1" role="status">+<div class="rounded-xl bg-destructive/5 px-4 py-3 space-y-1" role="status"><div class="flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1"><p class="text-sm text-primary tabular-nums privacy-sensitive"><span class="font-medium text-destructive"><%= t("bills.paycheck.shortfall_label") %></span>diff --git a/app/views/bills/_series_avatar.html.erb b/app/views/bills/_series_avatar.html.erbnew file mode 100644index 0000000000..27561d5e55--- /dev/null+++ b/app/views/bills/_series_avatar.html.erb@@ -0,0 +1,16 @@+<%# locals: (series:) %>+<%# The face of a bill: its merchant's logo, else initials. One recipe for the+ overview rows and the All bills list, and the transaction row's: round, 36px,+ a hairline around a logo so a white one still has an edge. %>+<% if series.merchant&.logo_url.present? %>+ <%= image_tag Setting.transform_brand_fetch_url(series.merchant.logo_url),+ class: "w-9 h-9 rounded-full shrink-0 border border-secondary",+ loading: "lazy" %>+<% else %>+ <%= render DS::FilledIcon.new(+ variant: :text,+ text: series.display_name,+ size: "lg",+ rounded: true+ ) %>+<% end %>diff --git a/app/views/bills/_series_menu.html.erb b/app/views/bills/_series_menu.html.erbnew file mode 100644index 0000000000..f8e5188e78--- /dev/null+++ b/app/views/bills/_series_menu.html.erb@@ -0,0 +1,23 @@+<%# locals: (series:) %>+<%= render DS::Menu.new do |menu| %>+ <% menu.with_item(+ variant: "link",+ text: t("recurring_transactions.edit.trigger_label"),+ icon: "pencil",+ href: edit_recurring_transaction_path(series),+ data: { turbo_frame: :modal }) %>+ <% menu.with_item(+ variant: "button",+ text: series.active? ? t("recurring_transactions.actions.pause") : t("recurring_transactions.actions.resume"),+ icon: series.active? ? "pause" : "play",+ href: toggle_status_recurring_transaction_path(series),+ method: :post) %>+ <% menu.with_item(+ variant: "button",+ text: t("recurring_transactions.actions.delete"),+ icon: "trash-2",+ href: recurring_transaction_path(series),+ method: :delete,+ destructive: true,+ confirm: t(series.typed_income? ? "recurring_transactions.confirm_delete_income" : "recurring_transactions.confirm_delete", name: series.display_name)) %>+<% end %>diff --git a/app/views/bills/all.html.erb b/app/views/bills/all.html.erbindex 82bed112b8..9e4b3cf3e1 100644--- a/app/views/bills/all.html.erb+++ b/app/views/bills/all.html.erb@@ -1,42 +1,6 @@<div class="space-y-4 pb-6 lg:pb-12"><%= render "bills/view_switcher", active: "all" %>- <%# Built with the styled form builder, so each filter sits in the boxed field- every form uses, one height with the search box. As bare selects they read- as loose words with a chevron, and had no focus ring at all. %>- <%= styled_form_with url: bills_path, method: :get, scope: :q,- data: { controller: "auto-submit-form" },- class: "flex flex-wrap items-center gap-2" do |form| %>- <%= hidden_field_tag :view, "all" %>- <%= render DS::SearchInput.new(- name: "q[search]",- value: params.dig(:q, :search),- placeholder: t(".search_placeholder"),- class: "grow max-w-xs",- data: { "auto-submit-form-target": "auto" }) %>- <%= form.select :status,- options_for_select(- [ [ t(".any_status"), "" ] ] + BillsController::STATUS_FILTERS.map { |status| [ t(".status_filters.#{status}"), status ] },- params.dig(:q, :status)- ),- { container_class: "w-auto py-2.5" },- { class: "form-field__input w-auto", "data-auto-submit-form-target": "auto" } %>- <%= form.select :bill_type,- options_for_select(- [ [ t(".any_type"), "" ] ] + RecurringTransaction.bill_types.keys.map { |type| [ t(".types.#{type}"), type ] },- params.dig(:q, :bill_type)- ),- { container_class: "w-auto py-2.5" },- { class: "form-field__input w-auto", "data-auto-submit-form-target": "auto" } %>- <%= form.select :sort,- options_for_select(- [ [ t(".sort_due"), "" ], [ t(".sort_name"), "name" ], [ t(".sort_amount"), "amount" ] ],- params.dig(:q, :sort)- ),- { container_class: "w-auto py-2.5" },- { class: "form-field__input w-auto", "data-auto-submit-form-target": "auto" } %>- <% end %>-<%# What the Subscriptions tab existed to answer. It was a whole destinationfor a filter All bills already had, so the rollup now appears when thatfilter is on rather than living behind its own tab. %>@@ -66,123 +30,152 @@</div><% end %>- <% if @all_series.empty? %>- <div class="bg-container rounded-xl shadow-border-xs p-4">+ <%# One card, the way Transactions does it: the filters live with the list+ they filter, and the table sits in an inset tray inside it. Nothing is+ left on the page background but the header and the switcher. %>+ <div class="bg-container rounded-xl shadow-border-xs px-3 py-4 lg:p-4 space-y-4">+ <%# Built with the styled form builder, so each filter sits in the boxed field+ every form uses, one height with the search box. As bare selects they read+ as loose words with a chevron, and had no focus ring at all. %>+ <%= styled_form_with url: bills_path, method: :get, scope: :q,+ data: { controller: "auto-submit-form" },+ class: "flex flex-wrap items-center gap-2" do |form| %>+ <%= hidden_field_tag :view, "all" %>+ <%= render DS::SearchInput.new(+ name: "q[search]",+ value: params.dig(:q, :search),+ placeholder: t(".search_placeholder"),+ class: "grow max-w-xs",+ data: { "auto-submit-form-target": "auto" }) %>+ <%= form.select :status,+ options_for_select(+ [ [ t(".any_status"), "" ] ] + BillsController::STATUS_FILTERS.map { |status| [ t(".status_filters.#{status}"), status ] },+ params.dig(:q, :status)+ ),+ { container_class: "w-auto py-2.5" },+ { class: "form-field__input w-auto", "data-auto-submit-form-target": "auto" } %>+ <%= form.select :bill_type,+ options_for_select(+ [ [ t(".any_type"), "" ] ] + RecurringTransaction.bill_types.keys.map { |type| [ t(".types.#{type}"), type ] },+ params.dig(:q, :bill_type)+ ),+ { container_class: "w-auto py-2.5" },+ { class: "form-field__input w-auto", "data-auto-submit-form-target": "auto" } %>+ <%= form.select :sort,+ options_for_select(+ [ [ t(".sort_due"), "" ], [ t(".sort_name"), "name" ], [ t(".sort_amount"), "amount" ] ],+ params.dig(:q, :sort)+ ),+ { container_class: "w-auto py-2.5" },+ { class: "form-field__input w-auto", "data-auto-submit-form-target": "auto" } %>+ <% end %>++ <% if @all_series.empty? %><%= render DS::EmptyState.new(icon: "receipt",title: t(".no_matches_title"),description: t(".no_matches_description")) %>- </div>- <% else %>- <%# A seven-column table on a phone is a table you scroll sideways to read.- The same rows, the same filters, laid out the way the Calendar already- does it: a purpose-built small-screen list rather than a squeezed- desktop one. Switched on the container, not the viewport: the app- shell's sidebars can squeeze a desktop window to phone-list widths,- and a viewport breakpoint cannot see that. %>- <div class="@container">- <div class="@3xl:hidden bg-container rounded-xl shadow-border-xs divide-y divide-subdued">- <% @all_series.each do |series| %>- <div class="flex items-center gap-3 p-3">- <%= link_to bill_path(series), data: { turbo_frame: "drawer", turbo_prefetch: false }, class: "flex items-center gap-3 min-w-0 flex-1 group" do %>- <div class="min-w-0 flex-1">- <p class="text-sm font-medium text-primary truncate group-hover:underline"><%= series.display_name %></p>- <p class="text-xs text-secondary truncate">- <%= frequency_label(series) %>- <% if series.next_expected_date %>- · <%= t(".next_short", date: bills_upcoming_date(series.next_expected_date)) %>- <% end %>- </p>- </div>- <div class="shrink-0 text-right">- <p class="text-sm font-medium text-primary privacy-sensitive">- <%= format_money(Money.new(series.amount.abs, series.currency)) %>- </p>- <p class="text-xs">- <%= render DS::Pill.new(label: t("recurring_transactions.status.#{series.status}"), tone: recurring_status_pill_tone(series.status), marker: false) %>- </p>+ <% else %>+ <%# A table on a phone is a table you scroll sideways to read. The same+ rows, laid out the way the Calendar already does it: a purpose-built+ small-screen list rather than a squeezed desktop one. Switched on the+ container, not the viewport: the app shell's sidebars can squeeze a+ desktop window to phone-list widths, and a viewport breakpoint cannot+ see that. Four columns now, so the table fits from @2xl rather than+ from the width the seven it had needed. %>+ <div class="@container">+ <%# Same recipe as the overview rows and a transaction row: the face,+ the name over what it is, the figure at the end, and a click+ anywhere on the row opens the drawer. A live row says nothing about+ its status; a paused or dismissed one says it where a date would be,+ because it has no next due, and recedes. %>+ <%# Rows straight on the card, no tray inside it: on a phone the tray+ and a second card cost 20px a row, which is the name. %>+ <div class="@2xl:hidden">+ <% @all_series.each do |series| %>+ <div class="flex items-center gap-3 py-3"+ data-controller="clickable-row"+ data-action="click->clickable-row#open">+ <%= link_to bill_path(series), data: { turbo_frame: "drawer", turbo_prefetch: false, clickable_row_target: "link" }, class: "flex items-center gap-3 min-w-0 flex-1 rounded-lg focus-ring outline-offset-4" do %>+ <%= render "bills/series_avatar", series: series %>+ <div class="min-w-0 flex-1">+ <p class="text-sm font-medium <%= bills_series_tone(series) %> truncate hover:underline"><%= series.display_name %></p>+ <p class="text-xs text-secondary truncate"><%= bills_series_subline(series) %></p>+ </div>+ <div class="shrink-0 text-right">+ <p class="text-sm font-medium <%= bills_series_amount_tone(series) %> privacy-sensitive">+ <%= format_money(Money.new(series.amount.abs, series.currency)) %>+ </p>+ <%# Under the figure, where the table puts it in its own+ column: the subline already spends its width on the+ schedule. %>+ <% if series.active? %>+ <% if series.next_expected_date %>+ <p class="text-xs text-secondary"><%= bills_upcoming_date(series.next_expected_date) %></p>+ <% end %>+ <% else %>+ <p class="text-xs">+ <%= render DS::Pill.new(label: t("recurring_transactions.status.#{series.status}"), tone: recurring_status_pill_tone(series.status), marker: false) %>+ </p>+ <% end %>+ </div>+ <% end %>++ <div class="shrink-0">+ <%= render "bills/series_menu", series: series %>+ </div></div><% end %>-- <div class="shrink-0">- <%= render DS::Menu.new do |menu| %>- <% menu.with_item(- variant: "link",- text: t("recurring_transactions.edit.trigger_label"),- icon: "pencil",- href: edit_recurring_transaction_path(series),- data: { turbo_frame: :modal }) %>- <% menu.with_item(- variant: "button",- text: series.active? ? t("recurring_transactions.actions.pause") : t("recurring_transactions.actions.resume"),- icon: series.active? ? "pause" : "play",- href: toggle_status_recurring_transaction_path(series),- method: :post) %>- <% menu.with_item(- variant: "button",- text: t("recurring_transactions.actions.delete"),- icon: "trash-2",- href: recurring_transaction_path(series),- method: :delete,- destructive: true,- confirm: t(series.typed_income? ? "recurring_transactions.confirm_delete_income" : "recurring_transactions.confirm_delete", name: series.display_name)) %>- <% end %></div>- </div>- <% end %>- </div>- <%= render DS::Table.new(rows: @all_series, label: t("bills.views.all"), class: "hidden @3xl:block") do |table| %>- <% table.with_column(t(".col_name")) do |series| %>- <%= link_to series.display_name, bill_path(series), data: { turbo_frame: "drawer", turbo_prefetch: false }, class: "font-medium hover:underline" %>- <% end %>- <% table.with_column(t(".col_type"), class: "text-secondary") { |series| t(".types.#{series.bill_type}") } %>- <% table.with_column(t(".col_frequency"), class: "text-secondary") { |series| frequency_label(series) } %>- <% table.with_column(t(".col_amount"), numeric: true, class: "privacy-sensitive") do |series| %>- <% amount = Money.new(series.amount.abs, series.currency) %>- <% monthly = series.monthly_equivalent_amount.abs %>- <%= format_money(amount) %>- <%# A monthly bill's monthly equivalent is its own amount, so the- second line said "$5.99" under "$5.99". It only carries- information for the other cadences. %>- <% if monthly != amount %>- <p class="text-xs text-secondary"><%= t(".monthly_equivalent", amount: format_money(monthly)) %></p>- <% end %>- <% end %>- <% table.with_column(t(".col_next"), class: "text-secondary") do |series| %>- <%= series.next_expected_date ? bills_upcoming_date(series.next_expected_date) : "–" %>- <% end %>- <% table.with_column(t(".col_status")) do |series| %>- <%= render DS::Pill.new(label: t("recurring_transactions.status.#{series.status}"), tone: recurring_status_pill_tone(series.status), marker: false) %>- <% end %>- <% table.with_column(t(".col_actions"), align: :right) do |series| %>- <%= render DS::Menu.new do |menu| %>- <% menu.with_item(- variant: "link",- text: t("recurring_transactions.edit.trigger_label"),- icon: "pencil",- href: edit_recurring_transaction_path(series),- data: { turbo_frame: :modal }) %>- <% menu.with_item(- variant: "button",- text: series.active? ? t("recurring_transactions.actions.pause") : t("recurring_transactions.actions.resume"),- icon: series.active? ? "pause" : "play",- href: toggle_status_recurring_transaction_path(series),- method: :post) %>- <% menu.with_item(- variant: "button",- text: t("recurring_transactions.actions.delete"),- icon: "trash-2",- href: recurring_transaction_path(series),- method: :delete,- destructive: true,- confirm: t(series.typed_income? ? "recurring_transactions.confirm_delete_income" : "recurring_transactions.confirm_delete", name: series.display_name)) %>+ <%# inset: the table sits in the card above, so it takes the tray frame+ the transaction list's date groups have, not a card of its own. %>+ <%= render DS::Table.new(+ rows: @all_series,+ inset: true,+ label: t("bills.views.all"),+ class: "hidden @2xl:block",+ row_opts: ->(_series) { { data: { controller: "clickable-row", action: "click->clickable-row#open" } } }+ ) do |table| %>+ <%# w-full max-w-0 is the table idiom for "take what the other columns+ leave, and truncate inside it": a bank-style name is one long+ unbreakable run, and without it the column grows past the card and+ pushes the actions menu out of reach. %>+ <% table.with_column(t(".col_name"), class: "w-full max-w-0") do |series| %>+ <div class="flex items-center gap-3 @lg:gap-4">+ <%= render "bills/series_avatar", series: series %>+ <div class="min-w-0">+ <%= link_to series.display_name, bill_path(series), data: { turbo_frame: "drawer", turbo_prefetch: false, clickable_row_target: "link" }, class: "block truncate font-medium #{bills_series_tone(series)} hover:underline" %>+ <p class="text-xs text-secondary truncate"><%= bills_series_subline(series) %></p>+ </div>+ </div>+ <% end %>+ <% table.with_column(t(".col_next"), class: "text-secondary") do |series| %>+ <% if series.active? %>+ <%= series.next_expected_date ? bills_upcoming_date(series.next_expected_date) : "–" %>+ <% else %>+ <%= render DS::Pill.new(label: t("recurring_transactions.status.#{series.status}"), tone: recurring_status_pill_tone(series.status), marker: false) %>+ <% end %>+ <% end %>+ <% table.with_column(t(".col_amount"), numeric: true, class: "privacy-sensitive") do |series| %>+ <% amount = Money.new(series.amount.abs, series.currency) %>+ <% monthly = series.monthly_equivalent_amount.abs %>+ <span class="font-medium <%= bills_series_amount_tone(series) %>"><%= format_money(amount) %></span>+ <%# A monthly bill's monthly equivalent is its own amount, so the+ second line said "$5.99" under "$5.99". It only carries+ information for the other cadences. %>+ <% if monthly != amount %>+ <p class="text-xs text-secondary"><%= t(".monthly_equivalent", amount: format_money(monthly)) %></p>+ <% end %>+ <% end %>+ <% table.with_column(t(".col_actions"), align: :right) do |series| %>+ <%= render "bills/series_menu", series: series %>+ <% end %><% end %>- <% end %>+ </div><% end %>- </div>- <% end %>+ </div><%# Across every bill, not just the one you have open. Per-bill history livesin the bill's own detail. %>diff --git a/app/views/bills/calendar.html.erb b/app/views/bills/calendar.html.erbindex c2dea3482c..d8e3ae914e 100644--- a/app/views/bills/calendar.html.erb+++ b/app/views/bills/calendar.html.erb@@ -1,31 +1,37 @@<div class="space-y-4 pb-6 lg:pb-12"><%= render "bills/view_switcher", active: "calendar" %>- <%# The nav group and a totals line carrying two money values do not share- 375px, and neither had anywhere to wrap. %>- <div class="flex flex-wrap items-center justify-between gap-2">- <div class="flex items-center gap-1 min-w-0">+ <%# The month's navigation is controls, which may sit on the page background+ the way Budgets and Reports keep their period pickers. The figures and the+ feed links are content, so they live on the grid's own surface below. %>+ <div class="flex items-center gap-1 min-w-0">+ <%= render DS::Link.new(+ icon: "chevron-left",+ variant: "ghost",+ href: bills_path(view: "calendar", month: (@month - 1.month).strftime("%Y-%m")),+ "aria-label": t(".previous_month")+ ) %>+ <% unless @at_forward_limit %><%= render DS::Link.new(- icon: "chevron-left",+ icon: "chevron-right",variant: "ghost",- href: bills_path(view: "calendar", month: (@month - 1.month).strftime("%Y-%m")),- "aria-label": t(".previous_month")+ href: bills_path(view: "calendar", month: (@month + 1.month).strftime("%Y-%m")),+ "aria-label": t(".next_month")) %>- <% unless @at_forward_limit %>- <%= render DS::Link.new(- icon: "chevron-right",- variant: "ghost",- href: bills_path(view: "calendar", month: (@month + 1.month).strftime("%Y-%m")),- "aria-label": t(".next_month")- ) %>- <% end %>- <h2 class="text-lg font-medium text-primary ml-2 truncate"><%= l(@month, format: "%B %Y") %></h2>- <% unless @month == Date.current.beginning_of_month %>- <%= render DS::Link.new(text: t(".today"), variant: "ghost", href: bills_path(view: "calendar")) %>- <% end %>- </div>- <div class="text-right text-sm">- <p class="text-secondary">+ <% end %>+ <h2 class="text-lg font-medium text-primary ml-2 truncate"><%= l(@month, format: "%B %Y") %></h2>+ <% unless @month == Date.current.beginning_of_month %>+ <%= render DS::Link.new(text: t(".today"), variant: "ghost", href: bills_path(view: "calendar")) %>+ <% end %>+ </div>++ <%# A section like the overview's: the tray, a heading with the month's count,+ and one card holding the totals, the grid (an agenda below md) and the+ feed. The totals and the feed links used to sit loose on the page+ background either side of it. %>+ <%= render DS::Section.new(title: t("bills.index.title"), count: @month_bill_count, divided: false) do %>+ <div class="px-4 py-3 border-b border-subdued space-y-0.5">+ <p class="text-sm text-secondary privacy-sensitive"><%= t(".month_totals",expected: @month_expected ? format_money(@month_expected) : format_money(Money.new(0, Current.family.currency)),paid: @month_paid ? format_money(@month_paid) : format_money(Money.new(0, Current.family.currency))) %>@@ -34,61 +40,59 @@<p class="text-xs text-warning"><%= t("bills.index.unconvertible", count: @month_unconvertible) %></p><% end %></div>- </div>- <%# Month grid: desktop and tablet. %>- <div class="hidden md:block bg-container rounded-xl shadow-border-xs p-2">- <div class="grid grid-cols-7 text-xs font-medium text-secondary uppercase">- <% (0..6).each do |offset| %>- <div class="px-2 py-1"><%= t("date.abbr_day_names")[offset] %></div>- <% end %>+ <%# Month grid: desktop and tablet. %>+ <div class="hidden md:block p-2">+ <div class="grid grid-cols-7 text-xs font-medium text-secondary uppercase">+ <% (0..6).each do |offset| %>+ <div class="px-2 py-1"><%= t("date.abbr_day_names")[offset] %></div>+ <% end %>+ </div>+ <div class="grid grid-cols-7 gap-px bg-alpha-black-100 theme-dark:bg-alpha-white-200 rounded-lg overflow-hidden">+ <% (@grid_start..@grid_end).each do |day| %>+ <% in_month = day.between?(@month, @month.end_of_month) %>+ <div class="bg-container min-h-24 p-1.5 space-y-1 <%= "opacity-40" unless in_month %>">+ <p class="text-xs <%= day == Date.current ? "font-bold text-link" : "text-secondary" %>">+ <%= day.day %>+ </p>+ <% (@by_day[day] || []).sort_by { |occurrence| -occurrence.resolved_expected_amount }.each do |occurrence| %>+ <%= render "bills/calendar_chip", occurrence: occurrence %>+ <% end %>+ </div>+ <% end %>+ </div></div>- <div class="grid grid-cols-7 gap-px bg-alpha-black-100 theme-dark:bg-alpha-white-200 rounded-lg overflow-hidden">- <% (@grid_start..@grid_end).each do |day| %>- <% in_month = day.between?(@month, @month.end_of_month) %>- <div class="bg-container min-h-24 p-1.5 space-y-1 <%= "opacity-40" unless in_month %>">- <p class="text-xs <%= day == Date.current ? "font-bold text-link" : "text-secondary" %>">- <%= day.day %>- </p>- <% (@by_day[day] || []).sort_by { |occurrence| -occurrence.resolved_expected_amount }.each do |occurrence| %>- <%= render "bills/calendar_chip", occurrence: occurrence %>- <% end %>- </div>++ <%# Mobile: an agenda list of the month's days that actually have bills,+ not a shrunken grid. %>+ <div class="md:hidden divide-y divide-subdued">+ <% month_days = (@[email protected]_of_month).select { |day| @by_day[day].present? } %>+ <% if month_days.empty? %>+ <p class="p-4 text-sm text-secondary"><%= t(".empty_month") %></p>+ <% else %>+ <% month_days.each do |day| %>+ <div class="p-3 space-y-1.5">+ <p class="text-xs font-medium <%= day == Date.current ? "text-link" : "text-secondary" %> uppercase">+ <%= l(day, format: :long) %>+ </p>+ <% @by_day[day].sort_by { |occurrence| -occurrence.resolved_expected_amount }.each do |occurrence| %>+ <%= render "bills/calendar_chip", occurrence: occurrence %>+ <% end %>+ </div>+ <% end %><% end %></div>- </div>- <div class="flex items-center justify-end gap-3"><%# Minted for THIS member: the feed applies per-account sharing, so eachmember's URL serves only the bills they can reach in the app. %>- <%= link_to t(".subscribe_ical"),- bills_feed_path(token: Current.family.bills_feed_token_for(Current.user)),- class: "text-xs text-link hover:underline" %>- <%= button_to t(".reset_feed"),- reset_feed_token_bills_path,- class: "text-xs text-secondary hover:underline",- data: { turbo_confirm: t("bills.reset_feed_token.confirm") } %>- </div>-- <%# Mobile: an agenda list of the month's days that actually have bills,- not a shrunken grid. %>- <div class="md:hidden space-y-1 rounded-xl bg-surface-inset p-1">- <% month_days = (@[email protected]_of_month).select { |day| @by_day[day].present? } %>- <% if month_days.empty? %>- <div class="bg-container rounded-lg p-4">- <p class="text-sm text-secondary"><%= t(".empty_month") %></p>- </div>- <% else %>- <% month_days.each do |day| %>- <div class="bg-container rounded-lg p-3 space-y-1.5">- <p class="text-xs font-medium <%= day == Date.current ? "text-link" : "text-secondary" %> uppercase">- <%= l(day, format: :long) %>- </p>- <% @by_day[day].sort_by { |occurrence| -occurrence.resolved_expected_amount }.each do |occurrence| %>- <%= render "bills/calendar_chip", occurrence: occurrence %>- <% end %>- </div>- <% end %>- <% end %>- </div>+ <div class="flex items-center justify-end gap-3 px-4 py-2 border-t border-subdued">+ <%= link_to t(".subscribe_ical"),+ bills_feed_path(token: Current.family.bills_feed_token_for(Current.user)),+ class: "text-xs text-link hover:underline" %>+ <%= button_to t(".reset_feed"),+ reset_feed_token_bills_path,+ class: "text-xs text-secondary hover:underline",+ data: { turbo_confirm: t("bills.reset_feed_token.confirm") } %>+ </div>+ <% end %></div>diff --git a/config/locales/views/bills/ca.yml b/config/locales/views/bills/ca.ymlindex 2f64fb0f4b..c592d75278 100644--- a/config/locales/views/bills/ca.yml+++ b/config/locales/views/bills/ca.yml@@ -230,12 +230,8 @@ ca:no_matches_title: Cap resultatno_matches_description: Prova de treure un filtre o la cerca.col_name: Nom- col_type: Tipus- col_frequency: Freqüènciacol_amount: Importcol_next: Proper venciment- next_short: 'proper: %{date}'- col_status: Estatcol_actions: Accionsmonthly_equivalent: '%{amount}/mes'types:diff --git a/config/locales/views/bills/en.yml b/config/locales/views/bills/en.ymlindex 592582ca86..93ea9b9e56 100644--- a/config/locales/views/bills/en.yml+++ b/config/locales/views/bills/en.yml@@ -245,12 +245,8 @@ en:no_matches_title: Nothing matchesno_matches_description: Try clearing a filter or the search.col_name: Name- col_type: Type- col_frequency: Frequencycol_amount: Amountcol_next: Next due- next_short: "next %{date}"- col_status: Statuscol_actions: Actionsmonthly_equivalent: "%{amount}/mo"types:diff --git a/config/locales/views/bills/fr.yml b/config/locales/views/bills/fr.ymlindex 54b70fb4cc..737e856c45 100644--- a/config/locales/views/bills/fr.yml+++ b/config/locales/views/bills/fr.yml@@ -13,13 +13,9 @@ fr:any_type: Tous les typescol_actions: Actionscol_amount: Montant- col_frequency: Fréquencecol_name: Nomcol_next: Prochaine échéance- col_status: Statut- col_type: Typemonthly_equivalent: "%{amount}/mois"- next_short: prochaine le %{date}no_matches_description: Essayez de retirer un filtre ou de modifier la recherche.no_matches_title: Aucun résultatsearch_placeholder: Rechercher une facturediff --git a/config/locales/views/bills/pl.yml b/config/locales/views/bills/pl.ymlindex 2ef1d7977e..e133388600 100644--- a/config/locales/views/bills/pl.yml+++ b/config/locales/views/bills/pl.yml@@ -13,13 +13,9 @@ pl:any_type: Dowolny typcol_actions: Akcjecol_amount: Kwota- col_frequency: Częstotliwośćcol_name: Nazwacol_next: Następny termin- col_status: Status- col_type: Typmonthly_equivalent: "%{amount}/mies."- next_short: następny %{date}no_matches_description: Spróbuj wyczyścić filtr lub wyszukiwanie.no_matches_title: Brak wynikówsearch_placeholder: Szukaj rachunkówdiff --git a/config/locales/views/bills/ru.yml b/config/locales/views/bills/ru.ymlindex 7d68bae5df..09dd6585ec 100644--- a/config/locales/views/bills/ru.yml+++ b/config/locales/views/bills/ru.yml@@ -258,12 +258,8 @@ ru:no_matches_title: Ничего не найденоno_matches_description: Попробуйте сбросить фильтр или поиск.col_name: Название- col_type: Тип- col_frequency: Периодичностьcol_amount: Суммаcol_next: Следующая оплата- next_short: след. %{date}- col_status: Статусcol_actions: Действияmonthly_equivalent: '%{amount}/мес'types:diff --git a/config/locales/views/bills/tr.yml b/config/locales/views/bills/tr.ymlindex c4cb59638f..1a5f3ee23b 100644--- a/config/locales/views/bills/tr.yml+++ b/config/locales/views/bills/tr.yml@@ -230,12 +230,8 @@ tr:no_matches_title: Sonuç yokno_matches_description: Bir filtreyi veya aramayı temizlemeyi deneyin.col_name: Ad- col_type: Tür- col_frequency: Sıklıkcol_amount: Tutarcol_next: Sonraki son ödeme- next_short: sonraki %{date}- col_status: Durumcol_actions: Eylemlermonthly_equivalent: '%{amount}/ay'types:diff --git a/config/locales/views/bills/uk.yml b/config/locales/views/bills/uk.ymlindex 1e1c57e193..ce2a1dfa48 100644--- a/config/locales/views/bills/uk.yml+++ b/config/locales/views/bills/uk.yml@@ -258,12 +258,8 @@ uk:no_matches_title: Нічого не знайденоno_matches_description: Спробуйте скинути фільтр або пошук.col_name: Назва- col_type: Тип- col_frequency: Частотаcol_amount: Сумаcol_next: Наступний строк- next_short: наступний %{date}- col_status: Статусcol_actions: Діїmonthly_equivalent: '%{amount}/міс.'types:diff --git a/test/components/DS/table_test.rb b/test/components/DS/table_test.rbindex 3366443d1d..415134ea2b 100644--- a/test/components/DS/table_test.rb+++ b/test/components/DS/table_test.rb@@ -67,6 +67,16 @@ class DS::TableTest < ViewComponent::TestCaseassert_selector "tbody tr.bg-container-inset", count: 1, text: "Rent"end+ test "adds row attributes from the row_opts proc" do+ opts = ->(row) { { data: { controller: "clickable-row", name: row[:name] } } }+ render_inline(DS::Table.new(rows: ROWS, row_opts: opts)) do |table|+ table.with_column("Name") { |row| row[:name] }+ end++ assert_selector "tbody tr[data-controller='clickable-row'][data-name='Rent']"+ assert_selector "tbody tr[data-controller='clickable-row'][data-name='Internet']"+ end+test "stands alone as a card by default and sits in an inset frame on request" dorender_tableassert_selector "div.table-scroll.rounded-xl.shadow-border-xs"diff --git a/test/controllers/bills_controller_test.rb b/test/controllers/bills_controller_test.rbindex 9f74031415..83b3f3aad4 100644--- a/test/controllers/bills_controller_test.rb+++ b/test/controllers/bills_controller_test.rb@@ -943,9 +943,15 @@ class BillsControllerTest < ActionDispatch::IntegrationTestassert_match "Gamma income", response.body# DS::Table renders the desktop table's cells from blocks written in this# view, so their relative keys still have to resolve against bills/all.- assert_select "table td", text: I18n.t("bills.all.types.bill")+ assert_select "table td", text: /Alpha bill/+ # The name column takes what the others leave and truncates inside it, so a+ # long bank-style name cannot widen the table past its card.+ assert_select "table td.w-full.max-w-0 a.truncate", text: /Alpha bill/+ assert_select "table tr[data-controller~=clickable-row] a[data-clickable-row-target=link][data-turbo-frame=drawer]", minimum: 3+ # Only a live row skips its status; the paused one says it where the date goes.+ assert_select "table td .rounded-full", text: I18n.t("recurring_transactions.status.paused")assert_select ".translation_missing", false- # Seven columns can overflow just above @3xl, where the table replaces the+ # The columns can overflow just above @3xl, where the table replaces the# cards: the scroll area is named, so a keyboard can reach the columns.assert_select "[role=region][aria-label=?]", I18n.t("bills.views.all")@@ -958,6 +964,19 @@ class BillsControllerTest < ActionDispatch::IntegrationTestassert_no_match "Beta paused", response.bodyend+ # Content sits on a surface everywhere else in the app. The filters belong to+ # the list they filter, and the table takes the inset tray a table inside a+ # card gets, as the transaction list does.+ test "the all view keeps its filters and its table on one card" do+ create_bill(name: "Alpha bill", amount: 10)++ get bills_url(view: "all")++ assert_response :success+ assert_select "div.bg-container.rounded-xl.shadow-border-xs form[method=get] input[name='q[search]']"+ assert_select "div.bg-container.rounded-xl.shadow-border-xs div.bg-container-inset table"+ end+test "the calendar renders the month grid with paid and overdue states" dopaid_bill = create_bill(name: "Paid on time", amount: 40, expected_day_of_month: 5)paid_occurrence = paid_bill.recurring_occurrences.find_by!(due_on: Date.current.beginning_of_month + 4)@@ -977,6 +996,20 @@ class BillsControllerTest < ActionDispatch::IntegrationTestassert_match Date.current.strftime("%B %Y"), response.bodyend+ # The totals and the feed links used to sit loose on the page background,+ # either side of the grid's card.+ test "the calendar holds its totals and its feed links on the grid's surface" do+ create_bill(name: "Rent", amount: 100, expected_day_of_month: 5)++ get bills_url(view: "calendar")++ assert_response :success+ assert_select "section.bg-surface-inset h2", text: /#{Regexp.escape(I18n.t("bills.index.title"))}/+ assert_select "section.bg-surface-inset div.bg-container p", text: /#{Regexp.escape(Money.new(100, "USD").format.to_s)}/+ assert_select "section.bg-surface-inset div.bg-container a", text: I18n.t("bills.calendar.subscribe_ical")+ assert_select "section.bg-surface-inset div.bg-container button", text: I18n.t("bills.calendar.reset_feed")+ end+# The calendar loads paused bills too, and painted a paused bill's leftover# as a red overdue chip.test "the calendar paints a paused bill's leftover neutral" do@@ -1383,6 +1416,18 @@ class BillsControllerTest < ActionDispatch::IntegrationTest"the stale column date must not appear anywhere on the page")end+ # The schedule was a bare disclosure: its eyebrow, headline and Manage sat on+ # the page background. It is a card now, like the pulse on the overview.+ test "the income schedule sits on a card" do+ declare_income(name: "Frito Lay", amount: -1200, payday: Date.current + 6)++ get bills_url(view: "paycheck")++ assert_response :success+ assert_select "details.bg-container.rounded-xl.shadow-border-xs > summary",+ text: /#{Regexp.escape(I18n.t("bills.paycheck.income_section_title"))}/+ end+# An auto-detected inflow sat in the list looking exactly like a real payday# source while moving no number on the page.test "income the planner cannot use says so" dodiff --git a/test/helpers/bills_helper_test.rb b/test/helpers/bills_helper_test.rbindex 7a0edc57cc..08d1623b7c 100644--- a/test/helpers/bills_helper_test.rb+++ b/test/helpers/bills_helper_test.rb@@ -15,6 +15,20 @@ class BillsHelperTest < ActionView::TestCaseendend+ test "an All bills row names its kind unless it is a plain bill, and recedes unless it is live" do+ bill = RecurringTransaction.new(bill_type: "bill", status: "active", name: "Rent", amount: 10, currency: "USD", expected_day_of_month: 1)+ income = RecurringTransaction.new(bill_type: "income", status: "active", name: "Salary", amount: -10, currency: "USD", expected_day_of_month: 1)+ ended = RecurringTransaction.new(bill_type: "income", status: "ended", name: "Old job", amount: -10, currency: "USD", expected_day_of_month: 1)++ assert_equal frequency_label(bill), bills_series_subline(bill)+ assert_equal "#{I18n.t("bills.all.types.income")} · #{frequency_label(income)}", bills_series_subline(income)++ assert_equal "text-primary", bills_series_tone(bill)+ assert_equal "text-success", bills_series_amount_tone(income)+ assert_equal "text-secondary", bills_series_tone(ended)+ assert_equal "text-secondary", bills_series_amount_tone(ended)+ end+# The matcher has always stored WHY it matched something, in match_signals.# Nothing rendered it, so the app showed a bare percentage instead of the# facts the percentage is made of.