Update query parameter when changing selection range in graph.

This commit is contained in:
Alexis Lahouze 2018-06-10 17:37:20 +02:00
parent d69ace6292
commit f9d26ed888
2 changed files with 17 additions and 1 deletions

View File

@ -7,6 +7,9 @@ import {
Inject, Input, Output, EventEmitter, Inject, Input, Output, EventEmitter,
OnChanges OnChanges
} from '@angular/core'; } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Logger } from '@nsalaun/ng-logger';
import { Account } from '../accounts/account'; import { Account } from '../accounts/account';
import { DailyBalance } from './dailyBalance'; import { DailyBalance } from './dailyBalance';
@ -122,6 +125,9 @@ export class BalanceChartComponent implements OnChanges {
}]; }];
constructor( constructor(
private router: Router,
private activatedRoute: ActivatedRoute,
private logger: Logger,
private dailyBalanceService: DailyBalanceService, private dailyBalanceService: DailyBalanceService,
) { ) {
this.data = []; this.data = [];
@ -177,5 +183,14 @@ export class BalanceChartComponent implements OnChanges {
this.updateXBands(args.minValue, args.maxValue); this.updateXBands(args.minValue, args.maxValue);
this.onUpdate.emit({minDate: args.minValue, maxDate: 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')
}
});
} }
} }

View File

@ -4,5 +4,6 @@ import { OperationListComponent } from './operationList.component';
export const OperationListState = { export const OperationListState = {
path: 'account/:accountId/operations', path: 'account/:accountId/operations',
component: OperationListComponent component: OperationListComponent,
onSameUrlNavigation: 'reload'
} }