From 80eecab5d272f42135cbab2eccbcab3a515f906c Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 24 May 2019 09:12:04 +0200 Subject: [PATCH] fix: EDITOR-363 now using disabled prop of FormControl --- .../default-input.component.html | 108 +++++++++++++----- packages/ui/src/lib/form/form.service.ts | 10 +- 2 files changed, 86 insertions(+), 32 deletions(-) diff --git a/packages/ui/src/lib/form/default-input/default-input.component.html b/packages/ui/src/lib/form/default-input/default-input.component.html index 15c4c3c82..23cb83902 100644 --- a/packages/ui/src/lib/form/default-input/default-input.component.html +++ b/packages/ui/src/lib/form/default-input/default-input.component.html @@ -1,33 +1,64 @@
- + - + - +
- + - + @@ -35,22 +66,39 @@
- + + - +
-
- {{item?.display(field.property)}} +
+ {{ item?.display(field.property) }}
@@ -58,4 +106,4 @@
-
\ No newline at end of file + diff --git a/packages/ui/src/lib/form/form.service.ts b/packages/ui/src/lib/form/form.service.ts index 4893636fc..1fd57aa13 100644 --- a/packages/ui/src/lib/form/form.service.ts +++ b/packages/ui/src/lib/form/form.service.ts @@ -28,7 +28,13 @@ export class FormService { .filter((field) => this.shouldBePartOfForm(field, form)) .forEach((field) => { const validators = this.getValidators(field); - controls[field.property] = new FormControl(form.getValue(field.property), validators); + controls[field.property] = new FormControl( + { + value: form.getValue(field.property), + disabled: this.isReadOnly(field, form), + }, + validators, + ); // TODO use { updateOn: blur } when updating to angular 5.0.0 // see https://github.com/angular/angular/commit/333a708bb632d4258ecb5fd4a0e86229fe9d26e4 }); @@ -39,7 +45,7 @@ export class FormService { public addField(field: Field, form: Form, group: FormGroup) { console.warn('addField is experimental!'); const validators = this.getValidators(field); - const control = new FormControl(form.getValue(field.property), validators); + const control = new FormControl({ value: form.getValue(field.property) }, validators); group.addControl(field.property, control); }