From f9d26ed88858e4f9cee212bec144eca3076638d1 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Sun, 10 Jun 2018 17:37:20 +0200 Subject: [PATCH] Update query parameter when changing selection range in graph. --- src/operations/balanceChart.component.ts | 15 +++++++++++++++ src/operations/operation.states.ts | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/operations/balanceChart.component.ts b/src/operations/balanceChart.component.ts index 05a48fe..b49f578 100644 --- a/src/operations/balanceChart.component.ts +++ b/src/operations/balanceChart.component.ts @@ -7,6 +7,9 @@ import { Inject, Input, Output, EventEmitter, OnChanges } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; + +import { Logger } from '@nsalaun/ng-logger'; import { Account } from '../accounts/account'; import { DailyBalance } from './dailyBalance'; @@ -122,6 +125,9 @@ export class BalanceChartComponent implements OnChanges { }]; constructor( + private router: Router, + private activatedRoute: ActivatedRoute, + private logger: Logger, private dailyBalanceService: DailyBalanceService, ) { this.data = []; @@ -177,5 +183,14 @@ export class BalanceChartComponent implements OnChanges { this.updateXBands(args.minValue, args.maxValue); this.onUpdate.emit({minDate: args.minValue, maxDate: args.maxValue}); + + let accountId = this.activatedRoute.snapshot.paramMap.get('accountId'); + + this.router.navigate(['account', accountId, 'operations'], { + queryParams: { + from: moment(args.minValue).format('YYYY-MM-DD'), + to: moment(args.maxValue).format('YYYY-MM-DD') + } + }); } } diff --git a/src/operations/operation.states.ts b/src/operations/operation.states.ts index 7c0de6a..bc98d35 100644 --- a/src/operations/operation.states.ts +++ b/src/operations/operation.states.ts @@ -4,5 +4,6 @@ import { OperationListComponent } from './operationList.component'; export const OperationListState = { path: 'account/:accountId/operations', - component: OperationListComponent + component: OperationListComponent, + onSameUrlNavigation: 'reload' }