mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-04 21:15:19 +02:00
Rework account views and addition flow (#1324)
* Move accountable partials * Split accountables into separate view partials * Fix test * Add form to permitted partials * Fix failing system tests * Update new account modal views * New sync algorithm implementation * Update account system test assertions to match new behavior * Fix off by 1 date error * Revert new balance sync algorithm * Add missing account overviews
This commit is contained in:
parent
c7c281073f
commit
e8e100e1d8
88 changed files with 763 additions and 526 deletions
7
app/views/accounts/accountables/_default_header.html.erb
Normal file
7
app/views/accounts/accountables/_default_header.html.erb
Normal file
|
@ -0,0 +1,7 @@
|
|||
<div class="flex items-center gap-3">
|
||||
<%= render "accounts/logo", account: account %>
|
||||
|
||||
<div>
|
||||
<h2 class="font-medium text-xl"><%= account.name %></h2>
|
||||
</div>
|
||||
</div>
|
7
app/views/accounts/accountables/_default_tabs.html.erb
Normal file
7
app/views/accounts/accountables/_default_tabs.html.erb
Normal file
|
@ -0,0 +1,7 @@
|
|||
<%# locals: (account:) %>
|
||||
|
||||
<% if account.transactions.any? %>
|
||||
<%= render "accounts/accountables/transactions", account: account %>
|
||||
<% else %>
|
||||
<%= render "accounts/accountables/valuations", account: account %>
|
||||
<% end %>
|
8
app/views/accounts/accountables/_tab.html.erb
Normal file
8
app/views/accounts/accountables/_tab.html.erb
Normal file
|
@ -0,0 +1,8 @@
|
|||
<%# locals: (account:, key:, is_selected:) %>
|
||||
|
||||
<%= link_to key.titleize,
|
||||
account_path(account, tab: key),
|
||||
class: [
|
||||
"px-2 py-1.5 rounded-md border border-transparent",
|
||||
"bg-white shadow-xs border-alpha-black-50": is_selected
|
||||
] %>
|
5
app/views/accounts/accountables/_transactions.html.erb
Normal file
5
app/views/accounts/accountables/_transactions.html.erb
Normal file
|
@ -0,0 +1,5 @@
|
|||
<%# locals: (account:) %>
|
||||
|
||||
<%= turbo_frame_tag dom_id(account, :transactions), src: account_transactions_path(account) do %>
|
||||
<%= render "account/entries/loading" %>
|
||||
<% end %>
|
5
app/views/accounts/accountables/_valuations.html.erb
Normal file
5
app/views/accounts/accountables/_valuations.html.erb
Normal file
|
@ -0,0 +1,5 @@
|
|||
<%# locals: (account:) %>
|
||||
|
||||
<%= turbo_frame_tag dom_id(account, :valuations), src: account_valuations_path(account) do %>
|
||||
<%= render "account/entries/loading" %>
|
||||
<% end %>
|
|
@ -0,0 +1 @@
|
|||
<%= render "accounts/accountables/default_header", account: account %>
|
|
@ -25,3 +25,7 @@
|
|||
<%= format_money(account.credit_card.annual_fee_money || Money.new(0, account.currency)) %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-center py-8">
|
||||
<%= link_to "Edit account details", edit_account_path(account), class: "btn btn--ghost", data: { turbo_frame: :modal } %>
|
||||
</div>
|
15
app/views/accounts/accountables/credit_card/_tabs.html.erb
Normal file
15
app/views/accounts/accountables/credit_card/_tabs.html.erb
Normal file
|
@ -0,0 +1,15 @@
|
|||
<%# locals: (account:, selected_tab:) %>
|
||||
|
||||
<div class="flex gap-2 text-sm text-gray-900 font-medium mb-4">
|
||||
<%= render "accounts/accountables/tab", account: account, key: "overview", is_selected: selected_tab.in?([nil, "overview"]) %>
|
||||
<%= render "accounts/accountables/tab", account: account, key: "transactions", is_selected: selected_tab == "transactions" %>
|
||||
</div>
|
||||
|
||||
<div class="min-h-[800px]">
|
||||
<% case selected_tab %>
|
||||
<% when nil, "overview" %>
|
||||
<%= render "accounts/accountables/credit_card/overview", account: account %>
|
||||
<% when "transactions" %>
|
||||
<%= render "accounts/accountables/transactions", account: account %>
|
||||
<% end %>
|
||||
</div>
|
1
app/views/accounts/accountables/crypto/_header.html.erb
Normal file
1
app/views/accounts/accountables/crypto/_header.html.erb
Normal file
|
@ -0,0 +1 @@
|
|||
<%= render "accounts/accountables/default_header", account: account %>
|
1
app/views/accounts/accountables/crypto/_tabs.html.erb
Normal file
1
app/views/accounts/accountables/crypto/_tabs.html.erb
Normal file
|
@ -0,0 +1 @@
|
|||
<%= render "accounts/accountables/default_tabs", account: account %>
|
|
@ -0,0 +1 @@
|
|||
<%= render "accounts/accountables/default_header", account: account %>
|
|
@ -0,0 +1 @@
|
|||
<%= render "accounts/accountables/default_tabs", account: account %>
|
|
@ -0,0 +1 @@
|
|||
<%= render "accounts/accountables/default_header", account: account %>
|
28
app/views/accounts/accountables/investment/_tabs.html.erb
Normal file
28
app/views/accounts/accountables/investment/_tabs.html.erb
Normal file
|
@ -0,0 +1,28 @@
|
|||
<%# locals: (account:, selected_tab:) %>
|
||||
|
||||
<% if account.entries.account_trades.any? || account.entries.account_transactions.any? %>
|
||||
<div class="flex gap-2 text-sm text-gray-900 font-medium mb-4">
|
||||
<%= render "accounts/accountables/tab", account: account, key: "holdings", is_selected: selected_tab.in?([nil, "holdings"]) %>
|
||||
<%= render "accounts/accountables/tab", account: account, key: "cash", is_selected: selected_tab == "cash" %>
|
||||
<%= render "accounts/accountables/tab", account: account, key: "transactions", is_selected: selected_tab == "transactions" %>
|
||||
</div>
|
||||
|
||||
<div class="min-h-[800px]">
|
||||
<% case selected_tab %>
|
||||
<% when nil, "holdings" %>
|
||||
<%= turbo_frame_tag dom_id(account, :holdings), src: account_holdings_path(account) do %>
|
||||
<%= render "account/entries/loading" %>
|
||||
<% end %>
|
||||
<% when "cash" %>
|
||||
<%= turbo_frame_tag dom_id(account, :cash), src: account_cashes_path(account) do %>
|
||||
<%= render "account/entries/loading" %>
|
||||
<% end %>
|
||||
<% when "transactions" %>
|
||||
<%= turbo_frame_tag dom_id(account, :trades), src: account_trades_path(account) do %>
|
||||
<%= render "account/entries/loading" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<%= render "accounts/accountables/valuations", account: account %>
|
||||
<% end %>
|
26
app/views/accounts/accountables/investment/_tooltip.html.erb
Normal file
26
app/views/accounts/accountables/investment/_tooltip.html.erb
Normal file
|
@ -0,0 +1,26 @@
|
|||
<%# locals: (account:) -%>
|
||||
|
||||
<div data-controller="tooltip" data-tooltip-placement-value="right" data-tooltip-offset-value=10 data-tooltip-cross-axis-value=50>
|
||||
<%= lucide_icon("info", class: "w-4 h-4 shrink-0 text-gray-500") %>
|
||||
<div role="tooltip" data-tooltip-target="tooltip" class="tooltip bg-gray-700 text-sm p-2 rounded w-64">
|
||||
<div class="text-white">
|
||||
<%= t(".total_value_tooltip") %>
|
||||
</div>
|
||||
<div class="flex pt-3">
|
||||
<div class="text-gray-300">
|
||||
<%= t(".holdings") %>
|
||||
</div>
|
||||
<div class="text-white ml-auto">
|
||||
<%= tag.p format_money(account.investment.holdings_value, precision: 0) %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<div class="text-gray-300">
|
||||
<%= t(".cash") %>
|
||||
</div>
|
||||
<div class="text-white ml-auto">
|
||||
<%= tag.p format_money(account.balance_money, precision: 0) %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
1
app/views/accounts/accountables/loan/_header.html.erb
Normal file
1
app/views/accounts/accountables/loan/_header.html.erb
Normal file
|
@ -0,0 +1 @@
|
|||
<%= render "accounts/accountables/default_header", account: account %>
|
|
@ -43,3 +43,7 @@
|
|||
<%= account.loan.rate_type&.titleize || t(".unknown") %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-center py-8">
|
||||
<%= link_to "Edit account details", edit_account_path(account), class: "btn btn--ghost", data: { turbo_frame: :modal } %>
|
||||
</div>
|
15
app/views/accounts/accountables/loan/_tabs.html.erb
Normal file
15
app/views/accounts/accountables/loan/_tabs.html.erb
Normal file
|
@ -0,0 +1,15 @@
|
|||
<%# locals: (account:, selected_tab:) %>
|
||||
|
||||
<div class="flex gap-2 text-sm text-gray-900 font-medium mb-4">
|
||||
<%= render "accounts/accountables/tab", account: account, key: "overview", is_selected: selected_tab.in?([nil, "overview"]) %>
|
||||
<%= render "accounts/accountables/tab", account: account, key: "value", is_selected: selected_tab == "value" %>
|
||||
</div>
|
||||
|
||||
<div class="min-h-[800px]">
|
||||
<% case selected_tab %>
|
||||
<% when nil, "overview" %>
|
||||
<%= render "accounts/accountables/loan/overview", account: account %>
|
||||
<% when "value" %>
|
||||
<%= render "accounts/accountables/valuations", account: account %>
|
||||
<% end %>
|
||||
</div>
|
|
@ -0,0 +1 @@
|
|||
<%= render "accounts/accountables/default_header", account: account %>
|
|
@ -0,0 +1 @@
|
|||
<%= render "accounts/accountables/valuations", account: account %>
|
|
@ -0,0 +1 @@
|
|||
<%= render "accounts/accountables/default_header", account: account %>
|
|
@ -0,0 +1 @@
|
|||
<%= render "accounts/accountables/valuations", account: account %>
|
11
app/views/accounts/accountables/property/_header.html.erb
Normal file
11
app/views/accounts/accountables/property/_header.html.erb
Normal file
|
@ -0,0 +1,11 @@
|
|||
<div class="flex items-center gap-3">
|
||||
<%= render "accounts/logo", account: account %>
|
||||
|
||||
<div>
|
||||
<h2 class="font-medium text-xl"><%= account.name %></h2>
|
||||
|
||||
<% if account.property.address&.line1.present? %>
|
||||
<p class="text-gray-500"><%= account.property.address %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
|
@ -27,3 +27,7 @@
|
|||
<%= account.property.area || t(".unknown") %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-center py-8">
|
||||
<%= link_to "Edit account details", edit_account_path(account), class: "btn btn--ghost", data: { turbo_frame: :modal } %>
|
||||
</div>
|
||||
|
|
15
app/views/accounts/accountables/property/_tabs.html.erb
Normal file
15
app/views/accounts/accountables/property/_tabs.html.erb
Normal file
|
@ -0,0 +1,15 @@
|
|||
<%# locals: (account:, selected_tab:) %>
|
||||
|
||||
<div class="flex gap-2 text-sm text-gray-900 font-medium mb-4">
|
||||
<%= render "accounts/accountables/tab", account: account, key: "overview", is_selected: selected_tab.in?([nil, "overview"]) %>
|
||||
<%= render "accounts/accountables/tab", account: account, key: "value", is_selected: selected_tab == "value" %>
|
||||
</div>
|
||||
|
||||
<div class="min-h-[800px]">
|
||||
<% case selected_tab %>
|
||||
<% when nil, "overview" %>
|
||||
<%= render "accounts/accountables/property/overview", account: account %>
|
||||
<% when "value" %>
|
||||
<%= render "accounts/accountables/valuations", account: account %>
|
||||
<% end %>
|
||||
</div>
|
1
app/views/accounts/accountables/vehicle/_header.html.erb
Normal file
1
app/views/accounts/accountables/vehicle/_header.html.erb
Normal file
|
@ -0,0 +1 @@
|
|||
<%= render "accounts/accountables/default_header", account: account %>
|
|
@ -31,3 +31,7 @@
|
|||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-center py-8">
|
||||
<%= link_to "Edit account details", edit_account_path(account), class: "btn btn--ghost", data: { turbo_frame: :modal } %>
|
||||
</div>
|
||||
|
|
15
app/views/accounts/accountables/vehicle/_tabs.html.erb
Normal file
15
app/views/accounts/accountables/vehicle/_tabs.html.erb
Normal file
|
@ -0,0 +1,15 @@
|
|||
<%# locals: (account:, selected_tab:) %>
|
||||
|
||||
<div class="flex gap-2 text-sm text-gray-900 font-medium mb-4">
|
||||
<%= render "accounts/accountables/tab", account: account, key: "overview", is_selected: selected_tab.in?([nil, "overview"]) %>
|
||||
<%= render "accounts/accountables/tab", account: account, key: "value", is_selected: selected_tab == "value" %>
|
||||
</div>
|
||||
|
||||
<div class="min-h-[800px]">
|
||||
<% case selected_tab %>
|
||||
<% when nil, "overview" %>
|
||||
<%= render "accounts/accountables/vehicle/overview", account: account %>
|
||||
<% when "value" %>
|
||||
<%= render "accounts/accountables/valuations", account: account %>
|
||||
<% end %>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue