diff options
Diffstat (limited to 'client/src/app/shared/rest')
-rw-r--r-- | client/src/app/shared/rest/rest-extractor.service.ts | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/client/src/app/shared/rest/rest-extractor.service.ts b/client/src/app/shared/rest/rest-extractor.service.ts index 1b475da89..ad08a32f8 100644 --- a/client/src/app/shared/rest/rest-extractor.service.ts +++ b/client/src/app/shared/rest/rest-extractor.service.ts | |||
@@ -1,8 +1,7 @@ | |||
1 | import { HttpErrorResponse } from '@angular/common/http' | ||
1 | import { Injectable } from '@angular/core' | 2 | import { Injectable } from '@angular/core' |
3 | import { dateToHuman } from '@app/shared/misc/utils' | ||
2 | import { Observable } from 'rxjs/Observable' | 4 | import { Observable } from 'rxjs/Observable' |
3 | import { HttpErrorResponse } from '@angular/common/http' | ||
4 | |||
5 | import { Utils } from '../utils' | ||
6 | import { ResultList } from '../../../../../shared' | 5 | import { ResultList } from '../../../../../shared' |
7 | 6 | ||
8 | @Injectable() | 7 | @Injectable() |
@@ -16,7 +15,7 @@ export class RestExtractor { | |||
16 | const data: T[] = result.data | 15 | const data: T[] = result.data |
17 | const newData: T[] = [] | 16 | const newData: T[] = [] |
18 | 17 | ||
19 | data.forEach(d => newData.push(fun.call(this, d, additionalArgs))) | 18 | data.forEach(d => newData.push(fun.apply(this, [ d ].concat(additionalArgs)))) |
20 | 19 | ||
21 | return { | 20 | return { |
22 | total: result.total, | 21 | total: result.total, |
@@ -29,12 +28,9 @@ export class RestExtractor { | |||
29 | } | 28 | } |
30 | 29 | ||
31 | convertDateToHuman (target: object, fieldsToConvert: string[]) { | 30 | convertDateToHuman (target: object, fieldsToConvert: string[]) { |
32 | const source = {} | 31 | fieldsToConvert.forEach(field => target[field] = dateToHuman(target[field])) |
33 | fieldsToConvert.forEach(field => { | ||
34 | source[field] = Utils.dateToHuman(target[field]) | ||
35 | }) | ||
36 | 32 | ||
37 | return Object.assign(target, source) | 33 | return target |
38 | } | 34 | } |
39 | 35 | ||
40 | handleError (err: HttpErrorResponse) { | 36 | handleError (err: HttpErrorResponse) { |