From 61bbc7277501692d1520a421dff5af5d38ba6cf4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 31 Jan 2018 10:41:44 +0100 Subject: Fix human dates in result lists --- client/src/app/shared/rest/rest-extractor.service.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'client/src/app/shared/rest') 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 @@ +import { HttpErrorResponse } from '@angular/common/http' import { Injectable } from '@angular/core' +import { dateToHuman } from '@app/shared/misc/utils' import { Observable } from 'rxjs/Observable' -import { HttpErrorResponse } from '@angular/common/http' - -import { Utils } from '../utils' import { ResultList } from '../../../../../shared' @Injectable() @@ -16,7 +15,7 @@ export class RestExtractor { const data: T[] = result.data const newData: T[] = [] - data.forEach(d => newData.push(fun.call(this, d, additionalArgs))) + data.forEach(d => newData.push(fun.apply(this, [ d ].concat(additionalArgs)))) return { total: result.total, @@ -29,12 +28,9 @@ export class RestExtractor { } convertDateToHuman (target: object, fieldsToConvert: string[]) { - const source = {} - fieldsToConvert.forEach(field => { - source[field] = Utils.dateToHuman(target[field]) - }) + fieldsToConvert.forEach(field => target[field] = dateToHuman(target[field])) - return Object.assign(target, source) + return target } handleError (err: HttpErrorResponse) { -- cgit v1.2.3