diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb
index 07a7d10f0..eaeb0a8b6 100644
--- a/app/controllers/pages_controller.rb
+++ b/app/controllers/pages_controller.rb
@@ -7,40 +7,14 @@ class PagesController < ApplicationController
@balance_sheet = Current.family.balance_sheet
@accounts = Current.family.accounts.visible.with_attached_logo
- # Handle cashflow period
- cashflow_period_param = params[:cashflow_period]
- @cashflow_period = if cashflow_period_param.present?
- begin
- Period.from_key(cashflow_period_param)
- rescue Period::InvalidKeyError
- Period.last_30_days
- end
- else
- Period.last_30_days
- end
-
- # Handle outflows period
- outflows_period_param = params[:outflows_period]
- @outflows_period = if outflows_period_param.present?
- begin
- Period.from_key(outflows_period_param)
- rescue Period::InvalidKeyError
- Period.last_30_days
- end
- else
- Period.last_30_days
- end
-
family_currency = Current.family.currency
- # Get data for cashflow section
- income_totals = Current.family.income_statement.income_totals(period: @cashflow_period)
- cashflow_expense_totals = Current.family.income_statement.expense_totals(period: @cashflow_period)
- @cashflow_sankey_data = build_cashflow_sankey_data(income_totals, cashflow_expense_totals, family_currency)
+ # Use the same period for all widgets (set by Periodable concern)
+ income_totals = Current.family.income_statement.income_totals(period: @period)
+ expense_totals = Current.family.income_statement.expense_totals(period: @period)
- # Get data for outflows section (using its own period)
- outflows_expense_totals = Current.family.income_statement.expense_totals(period: @outflows_period)
- @outflows_data = build_outflows_donut_data(outflows_expense_totals)
+ @cashflow_sankey_data = build_cashflow_sankey_data(income_totals, expense_totals, family_currency)
+ @outflows_data = build_outflows_donut_data(expense_totals)
@breadcrumbs = [ [ "Home", root_path ], [ "Dashboard", nil ] ]
end
diff --git a/app/views/pages/dashboard.html.erb b/app/views/pages/dashboard.html.erb
index f67237d48..34f3796cd 100644
--- a/app/views/pages/dashboard.html.erb
+++ b/app/views/pages/dashboard.html.erb
@@ -29,24 +29,20 @@
<% if Current.family.accounts.any? %>
- <%= turbo_frame_tag "cashflow_sankey_section" do %>
-
- <%= render partial: "pages/dashboard/cashflow_sankey", locals: {
- sankey_data: @cashflow_sankey_data,
- period: @cashflow_period
- } %>
-
- <% end %>
+
+ <%= render partial: "pages/dashboard/cashflow_sankey", locals: {
+ sankey_data: @cashflow_sankey_data,
+ period: @period
+ } %>
+
<% if @outflows_data[:categories].present? %>
- <%= turbo_frame_tag "outflows_donut_section" do %>
-
- <%= render partial: "pages/dashboard/outflows_donut", locals: {
- outflows_data: @outflows_data,
- period: @outflows_period
- } %>
-
- <% end %>
+
+ <%= render partial: "pages/dashboard/outflows_donut", locals: {
+ outflows_data: @outflows_data,
+ period: @period
+ } %>
+
<% end %>
diff --git a/app/views/pages/dashboard/_cashflow_sankey.html.erb b/app/views/pages/dashboard/_cashflow_sankey.html.erb
index 1f9b30053..bb49fa50f 100644
--- a/app/views/pages/dashboard/_cashflow_sankey.html.erb
+++ b/app/views/pages/dashboard/_cashflow_sankey.html.erb
@@ -5,8 +5,8 @@
<%= t("pages.dashboard.cashflow_sankey.title") %>
- <%= form_with url: root_path, method: :get, data: { controller: "auto-submit-form", turbo_frame: "cashflow_sankey_section" } do |form| %>
- <%= form.select :cashflow_period,
+ <%= form_with url: root_path, method: :get, data: { controller: "auto-submit-form", turbo_frame: "_top" } do |form| %>
+ <%= form.select :period,
Period.as_options,
{ selected: period.key },
data: { "auto-submit-form-target": "auto" },
diff --git a/app/views/pages/dashboard/_net_worth_chart.html.erb b/app/views/pages/dashboard/_net_worth_chart.html.erb
index 56a31f249..2376d79c6 100644
--- a/app/views/pages/dashboard/_net_worth_chart.html.erb
+++ b/app/views/pages/dashboard/_net_worth_chart.html.erb
@@ -6,7 +6,7 @@
-
<%= t(".title") %>
+
<%= t(".title") %>
">
@@ -21,7 +21,7 @@
- <%= form_with url: root_path, method: :get, data: { controller: "auto-submit-form" } do |form| %>
+ <%= form_with url: root_path, method: :get, data: { controller: "auto-submit-form", turbo_frame: "_top" } do |form| %>
<%= form.select :period,
Period.as_options,
{ selected: period.key },
diff --git a/app/views/pages/dashboard/_outflows_donut.html.erb b/app/views/pages/dashboard/_outflows_donut.html.erb
index 01c52f34c..dd1aab80f 100644
--- a/app/views/pages/dashboard/_outflows_donut.html.erb
+++ b/app/views/pages/dashboard/_outflows_donut.html.erb
@@ -5,8 +5,8 @@
<%= t("pages.dashboard.outflows_donut.title") %>
- <%= form_with url: root_path, method: :get, data: { controller: "auto-submit-form", turbo_frame: "outflows_donut_section" } do |form| %>
- <%= form.select :outflows_period,
+ <%= form_with url: root_path, method: :get, data: { controller: "auto-submit-form", turbo_frame: "_top" } do |form| %>
+ <%= form.select :period,
Period.as_options,
{ selected: period.key },
data: { "auto-submit-form-target": "auto" },