From 3b2d630d992a22c10afd9edc2d626fc82bd8e212 Mon Sep 17 00:00:00 2001 From: Alessio Cappa <104093777+alessiocappa@users.noreply.github.com> Date: Fri, 6 Mar 2026 10:11:21 +0100 Subject: [PATCH] Fix holdings table on mobile (#1114) * fix: extend width for holdings table in reports * fix: use right cols for header * fix: reduce padding on sections * fix: update holdings table display on dashboard * feat: set max width for holding name * fix: remove fixed width on last column * Update app/views/pages/dashboard/_investment_summary.html.erb Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Alessio Cappa <104093777+alessiocappa@users.noreply.github.com> * fix: add check on holding.ticker to ensure it's present --------- Signed-off-by: Alessio Cappa <104093777+alessiocappa@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../dashboard/_investment_summary.html.erb | 82 ++++++++++--------- .../reports/_investment_performance.html.erb | 75 ++++++++--------- app/views/reports/index.html.erb | 2 +- 3 files changed, 81 insertions(+), 78 deletions(-) diff --git a/app/views/pages/dashboard/_investment_summary.html.erb b/app/views/pages/dashboard/_investment_summary.html.erb index f10f0d776..c6396e1dd 100644 --- a/app/views/pages/dashboard/_investment_summary.html.erb +++ b/app/views/pages/dashboard/_investment_summary.html.erb @@ -27,50 +27,52 @@ <% holdings = investment_statement.top_holdings(limit: 5) %> <% if holdings.any? %> -
-
-
<%= t(".holding") %>
-
<%= t(".weight") %>
-
<%= t(".value") %>
-
<%= t(".return") %>
-
+
+
+
+
<%= t(".holding") %>
+
<%= t(".weight") %>
+
<%= t(".value") %>
+
<%= t(".return") %>
+
-
- <% holdings.each_with_index do |holding, idx| %> -
"> -
- <% if holding.security.logo_url.present? %> - <%= holding.ticker %> - <% else %> -
- <%= holding.ticker[0..1] %> +
+ <% holdings.each_with_index do |holding, idx| %> +
"> +
+ <% if holding.security.logo_url.present? %> + <%= holding.ticker %> + <% else %> +
+ <%= holding.ticker.to_s.first(2).presence || "—" %> +
+ <% end %> +
+

<%= holding.ticker %>

+

<%= truncate(holding.name, length: 20) %>

- <% end %> -
-

<%= holding.ticker %>

-

<%= truncate(holding.name, length: 20) %>

+
+ +
+ <%= number_to_percentage(holding.weight || 0, precision: 1) %> +
+ +
+ <%= format_money(holding.amount_money) %> +
+ +
+ <% if holding.trend %> + + <%= holding.trend.percent_formatted %> + + <% else %> + - + <% end %>
- -
- <%= number_to_percentage(holding.weight || 0, precision: 1) %> -
- -
- <%= format_money(holding.amount_money) %> -
- -
- <% if holding.trend %> - - <%= holding.trend.percent_formatted %> - - <% else %> - - - <% end %> -
-
- <% end %> + <% end %> +
<% end %> diff --git a/app/views/reports/_investment_performance.html.erb b/app/views/reports/_investment_performance.html.erb index aa63cbf4d..88fa6f979 100644 --- a/app/views/reports/_investment_performance.html.erb +++ b/app/views/reports/_investment_performance.html.erb @@ -58,48 +58,49 @@ <% if investment_metrics[:top_holdings].any? %>

<%= t("reports.investment_performance.top_holdings") %>

-
-
-
<%= t("reports.investment_performance.holding") %>
-
<%= t("reports.investment_performance.weight") %>
-
<%= t("reports.investment_performance.value") %>
-
<%= t("reports.investment_performance.return") %>
-
-
- <% investment_metrics[:top_holdings].each_with_index do |holding, idx| %> -
-
- <% if holding.security.brandfetch_icon_url.present? %> - <%= holding.ticker %> - <% elsif holding.security.logo_url.present? %> - <%= holding.ticker %> - <% else %> -
- <%= holding.ticker[0..1] %> +
+
+
<%= t("reports.investment_performance.holding") %>
+
<%= t("reports.investment_performance.weight") %>
+
<%= t("reports.investment_performance.value") %>
+
<%= t("reports.investment_performance.return") %>
+
+
+ <% investment_metrics[:top_holdings].each_with_index do |holding, idx| %> +
+
+ <% if holding.security.brandfetch_icon_url.present? %> + <%= holding.ticker %> + <% elsif holding.security.logo_url.present? %> + <%= holding.ticker %> + <% else %> +
+ <%= holding.ticker[0..1] %> +
+ <% end %> +
+

<%= holding.ticker %>

+

<%= truncate(holding.name, length: 25) %>

- <% end %> -
-

<%= holding.ticker %>

-

<%= truncate(holding.name, length: 25) %>

+
+
<%= number_to_percentage(holding.weight || 0, precision: 1) %>
+
<%= format_money(holding.amount_money) %>
+
+ <% if holding.trend %> + + <%= holding.trend.percent_formatted %> + + <% else %> + <%= t("reports.investment_performance.no_data") %> + <% end %>
-
<%= number_to_percentage(holding.weight || 0, precision: 1) %>
-
<%= format_money(holding.amount_money) %>
-
- <% if holding.trend %> - - <%= holding.trend.percent_formatted %> - - <% else %> - <%= t("reports.investment_performance.no_data") %> - <% end %> -
-
- <% if idx < investment_metrics[:top_holdings].size - 1 %> - <%= render "shared/ruler", classes: "mx-3 lg:mx-4" %> + <% if idx < investment_metrics[:top_holdings].size - 1 %> + <%= render "shared/ruler", classes: "mx-3 lg:mx-4" %> + <% end %> <% end %> - <% end %> +
diff --git a/app/views/reports/index.html.erb b/app/views/reports/index.html.erb index 888271567..d3bd12b37 100644 --- a/app/views/reports/index.html.erb +++ b/app/views/reports/index.html.erb @@ -153,7 +153,7 @@ <%= icon("grip-vertical", size: "sm") %>
-
+
<%= render partial: section[:partial], locals: section[:locals] %>