Add minDate and maxDate parameters in Operation query.

This commit is contained in:
Alexis Lahouze 2017-07-29 17:57:50 +02:00
parent 595fe60fc4
commit 4c921bfaaa
1 changed files with 26 additions and 2 deletions

View File

@ -1,5 +1,7 @@
// vim: set tw=80 ts=2 sw=2 sts=2 :
import * as moment from 'moment';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx';
@ -21,8 +23,30 @@ export class OperationService {
return this.restangular.one('operation', id);
}
query(): Observable<Operation[]> {
return this.all().getList();
formatDate(date: Date|string) {
if(date instanceof Date) {
return moment(date).format('YYYY-MM-DD');
}
return date;
}
query(
accountId: number,
minDate: Date|string = null,
maxDate: Date|string = null
): Observable<Operation[]> {
var dateRange: any = {};
if(minDate) {
dateRange.begin = this.formatDate(minDate);
}
if(maxDate) {
dateRange.end = this.formatDate(maxDate);
}
return this.all().getList([], dateRange);
}
get(id: number): Observable<Operation> {