Browse Source
Merge pull request #3029 from vvlladd28/improvement/entity/trim-fields
[3.0] Added form fields trim to add/edit entity
pull/3089/head
Igor Kulikov
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
15 additions and
1 deletions
-
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<T extends BaseData<HasId>, |
|
|
|
} |
|
|
|
|
|
|
|
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) { |
|
|
|
|