mirror of
https://github.com/we-promise/sure.git
synced 2026-07-12 12:55:20 +00:00
fix(cashflow): use Turbo.visit for donut chart deep-link navigation (#2166)
Replaces window.location.href with Turbo.visit for SPA-consistent navigation, matching the pattern used across internal navigation in the codebase (selectable_link_controller, trade_form_controller, etc.).
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Controller } from "@hotwired/stimulus";
|
||||
import * as d3 from "d3";
|
||||
import { buildCategoryTransactionsUrl } from "utils/transactions_filter_url";
|
||||
|
||||
// Connects to data-controller="donut-chart"
|
||||
export default class extends Controller {
|
||||
@@ -250,14 +251,15 @@ export default class extends Controller {
|
||||
|
||||
// Handles click on segment (optional, controlled by enableClick value)
|
||||
#handleClick(segment) {
|
||||
if (!segment.name || !this.startDateValue || !this.endDateValue) return;
|
||||
if (!segment.name) return;
|
||||
|
||||
const segmentName = encodeURIComponent(segment.name);
|
||||
const startDate = this.startDateValue;
|
||||
const endDate = this.endDateValue;
|
||||
|
||||
const url = `/transactions?q[categories][]=${segmentName}&q[start_date]=${startDate}&q[end_date]=${endDate}`;
|
||||
window.location.href = url;
|
||||
Turbo.visit(
|
||||
buildCategoryTransactionsUrl({
|
||||
name: segment.name,
|
||||
startDate: this.startDateValue,
|
||||
endDate: this.endDateValue,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
// Public methods for external highlighting (e.g., from category list hover)
|
||||
|
||||
Reference in New Issue
Block a user