Cashflow should use default period (and related) (#328)

* Fix cashflow and outflows widgets to respect user's default period preference

Resolves issue #118 where the Cashflow and Outflows widgets on the dashboard
were hardcoded to use a 30-day period instead of respecting the user's default
period preference setting.

Changes:
- Updated @cashflow_period to use Current.user&.default_period as fallback
- Updated @outflows_period to use Current.user&.default_period as fallback
- Both now follow the same pattern as the Periodable concern's set_period method

This ensures consistency across all dashboard widgets - Net Worth, Cashflow,
and Outflows now all respect the user's preference.

* Synchronize period selection across all dashboard widgets

All three dashboard widgets (Net Worth, Cashflow, and Outflows) now use
a single shared period parameter, ensuring consistent data magnitudes
across the dashboard.

Changes:
- Simplified controller to use single @period for all three widgets
- Removed widget-specific period parameters (cashflow_period, outflows_period)
- All widgets now use the shared 'period' parameter
- All period dropdowns use turbo_frame: "_top" to reload entire page
- Removed turbo_frame_tags from dashboard view for cleaner implementation

User experience improvement:
- Changing the period in any widget now updates all three widgets
- Ensures data consistency and easier comparison across widgets
- Maintains respect for user's default period preference

* Make Net Worth widget title styling consistent with Cashflow and Outflows

Changed Net Worth title from <p> with text-sm/text-secondary to <h2> with
text-lg to match the consistent styling used by Cashflow and Outflows widgets.

This provides a more unified visual appearance across all dashboard widgets.

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Juan José Mata
2025-11-14 19:15:30 +01:00
committed by GitHub
parent 54656c943a
commit 3c8ba643a0
5 changed files with 23 additions and 53 deletions

View File

@@ -29,24 +29,20 @@
<div class="w-full space-y-6 pb-24">
<% if Current.family.accounts.any? %>
<%= turbo_frame_tag "cashflow_sankey_section" do %>
<section class="bg-container py-4 rounded-xl shadow-border-xs mb-6">
<%= render partial: "pages/dashboard/cashflow_sankey", locals: {
sankey_data: @cashflow_sankey_data,
period: @cashflow_period
} %>
</section>
<% end %>
<section class="bg-container py-4 rounded-xl shadow-border-xs mb-6">
<%= render partial: "pages/dashboard/cashflow_sankey", locals: {
sankey_data: @cashflow_sankey_data,
period: @period
} %>
</section>
<% if @outflows_data[:categories].present? %>
<%= turbo_frame_tag "outflows_donut_section" do %>
<section class="bg-container py-4 rounded-xl shadow-border-xs mb-6">
<%= render partial: "pages/dashboard/outflows_donut", locals: {
outflows_data: @outflows_data,
period: @outflows_period
} %>
</section>
<% end %>
<section class="bg-container py-4 rounded-xl shadow-border-xs mb-6">
<%= render partial: "pages/dashboard/outflows_donut", locals: {
outflows_data: @outflows_data,
period: @period
} %>
</section>
<% end %>
<section class="bg-container py-4 rounded-xl shadow-border-xs">