Fix routing.
This commit is contained in:
parent
ffbae85e11
commit
c92b1bed11
@ -1,6 +1,9 @@
|
|||||||
// vim: set tw=80 ts=2 sw=2 sts=2 :
|
// vim: set tw=80 ts=2 sw=2 sts=2 :
|
||||||
|
|
||||||
|
import * as moment from 'moment';
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
|
||||||
import { Observable } from 'rxjs/Rx';
|
import { Observable } from 'rxjs/Rx';
|
||||||
|
|
||||||
@ -72,21 +75,36 @@ export class OperationListComponent implements OnInit {
|
|||||||
private accountService: AccountService,
|
private accountService: AccountService,
|
||||||
private logger: Logger,
|
private logger: Logger,
|
||||||
private ngbModal: NgbModal,
|
private ngbModal: NgbModal,
|
||||||
private route: ActivatedRoute
|
private route: ActivatedRoute,
|
||||||
|
private router: Router
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.accountService.get(
|
|
||||||
+this.route.snapshot.paramMap.get('accountId')
|
|
||||||
).subscribe(account => {
|
|
||||||
this.account = account;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.route.queryParamMap.subscribe(() => {
|
this.route.queryParamMap.subscribe(() => {
|
||||||
this.loadData();
|
this.loadData();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.loadData();
|
let accountId = this.route.snapshot.paramMap.get('accountId');
|
||||||
|
let fromDay = this.route.snapshot.queryParamMap.get('from');
|
||||||
|
let toDay = this.route.snapshot.queryParamMap.get('to');
|
||||||
|
|
||||||
|
if(! fromDay && ! toDay) {
|
||||||
|
this.router.navigate(['account', accountId, 'operations'], {
|
||||||
|
queryParams: {
|
||||||
|
from: moment().startOf('month').format('YYYY-MM-DD'),
|
||||||
|
to: moment().endOf('month').format('YYYY-MM-DD')
|
||||||
|
}
|
||||||
|
}).then(() => {
|
||||||
|
this.loadData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.accountService.get(
|
||||||
|
+accountId
|
||||||
|
).subscribe(account => {
|
||||||
|
this.account = account;
|
||||||
|
});
|
||||||
|
//this.loadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -137,7 +155,9 @@ export class OperationListComponent implements OnInit {
|
|||||||
(operation) => {
|
(operation) => {
|
||||||
this.toastrService.success('Operation #' + operation.id + ' saved.');
|
this.toastrService.success('Operation #' + operation.id + ' saved.');
|
||||||
|
|
||||||
this.loadData();
|
//this.loadData();
|
||||||
|
this.logger.info('Reload route', this.router.url);
|
||||||
|
this.router.navigateByUrl(this.router.url);
|
||||||
}, (result) => {
|
}, (result) => {
|
||||||
this.toastrService.error(
|
this.toastrService.error(
|
||||||
'Error while saving operation: ' + result.message
|
'Error while saving operation: ' + result.message
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
// vim: set tw=80 ts=2 sw=2 sts=2 :
|
// vim: set tw=80 ts=2 sw=2 sts=2 :
|
||||||
import { CurrencyPipe } from '@angular/common';
|
import { CurrencyPipe } from '@angular/common';
|
||||||
import { Component, Inject, Input, Output, EventEmitter } from '@angular/core';
|
import { Component, Inject, Input, Output, EventEmitter } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
|
import { Logger } from '@nsalaun/ng-logger';
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { ToastrService } from 'ngx-toastr';
|
import { ToastrService } from 'ngx-toastr';
|
||||||
|
|
||||||
@ -80,7 +82,9 @@ export class OperationRowComponent {
|
|||||||
constructor(
|
constructor(
|
||||||
private operationService: OperationService,
|
private operationService: OperationService,
|
||||||
private toastrService: ToastrService,
|
private toastrService: ToastrService,
|
||||||
|
private logger: Logger,
|
||||||
private ngbModal: NgbModal,
|
private ngbModal: NgbModal,
|
||||||
|
private router: Router
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
togglePointed(operation, rowform) {
|
togglePointed(operation, rowform) {
|
||||||
@ -102,6 +106,9 @@ export class OperationRowComponent {
|
|||||||
this.toastrService.success('Operation #' + operation.id + ' saved.');
|
this.toastrService.success('Operation #' + operation.id + ' saved.');
|
||||||
|
|
||||||
this.needsReload.emit();
|
this.needsReload.emit();
|
||||||
|
|
||||||
|
this.logger.info('Reload route', this.router.url);
|
||||||
|
this.router.navigateByUrl(this.router.url);
|
||||||
}, (result) => {
|
}, (result) => {
|
||||||
this.toastrService.error(
|
this.toastrService.error(
|
||||||
'Error while saving operation: ' + result.message
|
'Error while saving operation: ' + result.message
|
||||||
@ -129,6 +136,9 @@ export class OperationRowComponent {
|
|||||||
this.toastrService.success('Operation #' + id + ' deleted.');
|
this.toastrService.success('Operation #' + id + ' deleted.');
|
||||||
|
|
||||||
this.needsReload.emit();
|
this.needsReload.emit();
|
||||||
|
|
||||||
|
this.logger.info('Reload route', this.router.url);
|
||||||
|
this.router.navigateByUrl(this.router.url);
|
||||||
}, (result) => {
|
}, (result) => {
|
||||||
this.toastrService.error(
|
this.toastrService.error(
|
||||||
'An error occurred while trying to delete operation #' +
|
'An error occurred while trying to delete operation #' +
|
||||||
|
Loading…
Reference in New Issue
Block a user