2024-03-21 13:39:10 -04:00
|
|
|
<%# locals: (group:) -%>
|
|
|
|
<% type = Accountable.from_type(group.name) %>
|
2024-09-10 17:17:10 -04:00
|
|
|
<% if group && group.children.any? %>
|
2024-03-18 11:21:00 -04:00
|
|
|
<details class="mb-1 text-sm group" data-controller="account-collapse" data-account-collapse-type-value="<%= type %>">
|
2024-06-24 12:49:08 +02:00
|
|
|
<summary class="flex gap-4 px-3 py-2 items-center w-full rounded-[10px] font-medium hover:bg-gray-100 cursor-pointer">
|
2024-03-18 11:21:00 -04:00
|
|
|
<%= lucide_icon("chevron-down", class: "hidden group-open:block text-gray-500 w-5 h-5") %>
|
|
|
|
<%= lucide_icon("chevron-right", class: "group-open:hidden text-gray-500 w-5 h-5") %>
|
|
|
|
<div class="text-left"><%= type.model_name.human %></div>
|
2024-03-21 13:39:10 -04:00
|
|
|
<div class="ml-auto flex flex-col items-end">
|
|
|
|
<p class="text-right"><%= format_money group.sum %></p>
|
2024-09-10 17:17:10 -04:00
|
|
|
<div class="flex items-center gap-1">
|
|
|
|
<%=
|
2024-04-29 14:56:38 +01:00
|
|
|
tag.div(
|
|
|
|
id: "#{group.name}_sparkline",
|
|
|
|
class: "h-3 w-8 ml-auto",
|
|
|
|
data: {
|
|
|
|
controller: "time-series-chart",
|
|
|
|
"time-series-chart-data-value": group.series.to_json,
|
|
|
|
"time-series-chart-stroke-width-value": 1,
|
|
|
|
"time-series-chart-use-labels-value": false,
|
|
|
|
"time-series-chart-use-tooltip-value": false
|
|
|
|
}
|
|
|
|
)
|
2024-09-10 17:17:10 -04:00
|
|
|
%>
|
|
|
|
<% styles = trend_styles(group.series.trend) %>
|
|
|
|
<span class="text-xs <%= styles[:text_class] %>"><%= sprintf("%+.2f", group.series.trend.percent) %>%</span>
|
|
|
|
</div>
|
2024-03-21 13:39:10 -04:00
|
|
|
</div>
|
2024-03-18 11:21:00 -04:00
|
|
|
</summary>
|
2024-05-28 19:22:04 +02:00
|
|
|
<% group.children.sort_by(&:name).each do |account_value_node| %>
|
2024-04-29 14:56:38 +01:00
|
|
|
<% account = account_value_node.original %>
|
|
|
|
<%= link_to account_path(account), class: "flex items-center w-full gap-3 px-3 py-2 mb-1 hover:bg-gray-100 rounded-[10px]" do %>
|
2024-10-18 14:37:42 -04:00
|
|
|
<%= render "accounts/logo", account: account, size: "sm" %>
|
2024-03-18 11:21:00 -04:00
|
|
|
<div>
|
2024-03-21 13:39:10 -04:00
|
|
|
<p class="font-medium"><%= account_value_node.name %></p>
|
2024-04-29 14:56:38 +01:00
|
|
|
<% if account.subtype %>
|
|
|
|
<p class="text-xs text-gray-500"><%= account.subtype&.humanize %></p>
|
2024-03-18 11:21:00 -04:00
|
|
|
<% end %>
|
|
|
|
</div>
|
2024-04-29 14:56:38 +01:00
|
|
|
<div class="flex flex-col ml-auto font-medium text-right">
|
|
|
|
<p><%= format_money account.balance_money %></p>
|
2024-09-13 11:28:47 -04:00
|
|
|
<% unless account_value_node.series.trend.direction.flat? %>
|
|
|
|
<div class="flex items-center gap-1">
|
|
|
|
<%=
|
2024-04-29 14:56:38 +01:00
|
|
|
tag.div(
|
|
|
|
id: dom_id(account, :list_sparkline),
|
|
|
|
class: "h-3 w-8 ml-auto",
|
|
|
|
data: {
|
|
|
|
controller: "time-series-chart",
|
|
|
|
"time-series-chart-data-value": account_value_node.series.to_json,
|
|
|
|
"time-series-chart-stroke-width-value": 1,
|
|
|
|
"time-series-chart-use-labels-value": false,
|
|
|
|
"time-series-chart-use-tooltip-value": false
|
|
|
|
}
|
|
|
|
)
|
2024-09-13 11:28:47 -04:00
|
|
|
%>
|
|
|
|
<% styles = trend_styles(account_value_node.series.trend) %>
|
|
|
|
<span class="text-xs <%= styles[:text_class] %>"><%= sprintf("%+.2f", account_value_node.series.trend.percent) %>%</span>
|
|
|
|
</div>
|
|
|
|
<% end %>
|
2024-04-29 14:56:38 +01:00
|
|
|
</div>
|
2024-03-18 11:21:00 -04:00
|
|
|
<% end %>
|
2024-02-10 19:39:18 -06:00
|
|
|
<% end %>
|
2024-04-29 14:56:38 +01:00
|
|
|
<%= link_to new_account_path(step: "method", type: type.name.demodulize), class: "flex items-center min-h-10 gap-4 px-3 py-2 mb-1 text-gray-500 text-sm font-medium rounded-[10px] hover:bg-gray-100", data: { turbo_frame: "modal" } do %>
|
2024-03-18 11:21:00 -04:00
|
|
|
<%= lucide_icon("plus", class: "w-5 h-5") %>
|
2024-10-18 14:37:42 -04:00
|
|
|
<%= t(".new_account", type: type.model_name.human.downcase) %>
|
2024-03-18 11:21:00 -04:00
|
|
|
<% end %>
|
|
|
|
</details>
|
2024-02-08 15:52:33 -06:00
|
|
|
<% end %>
|