From e15fa45232e39e18f7bb7fcd209402ea5f0819e6 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Tue, 30 Jun 2020 23:53:36 +0300 Subject: [PATCH] Added form fields trim to add/edit entity --- .../home/components/entity/entity.component.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ui-ngx/src/app/modules/home/components/entity/entity.component.ts b/ui-ngx/src/app/modules/home/components/entity/entity.component.ts index 8dbd80279e..5ccda220c8 100644 --- a/ui-ngx/src/app/modules/home/components/entity/entity.component.ts +++ b/ui-ngx/src/app/modules/home/components/entity/entity.component.ts @@ -23,6 +23,7 @@ import { AppState } from '@core/core.state'; import { EntityAction } from '@home/models/entity/entity-component.models'; import { EntityTableConfig } from '@home/models/entity/entities-table-config.models'; import { PageLink } from '@shared/models/page/page-link'; +import { isObject, isString } from '@core/utils'; // @dynamic @Directive() @@ -115,7 +116,20 @@ export abstract class EntityComponent, } prepareFormValue(formValue: any): any { - return formValue; + return this.deepTrim(formValue); + } + + private deepTrim(obj: object): object { + return Object.keys(obj).reduce((acc, curr) => { + if (isString(obj[curr])) { + acc[curr] = obj[curr].trim(); + } else if (isObject(obj[curr])) { + acc[curr] = this.deepTrim(obj[curr]) + } else { + acc[curr] = obj[curr]; + } + return acc; + }, {}); } protected setEntitiesTableConfig(entitiesTableConfig: C) {