From 67ac64efad36d98582cefcd59db2ab1370a71022 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 17 Sep 2020 11:10:51 +0200 Subject: [PATCH] Revert the updateOn strategy. --- frontend/app/shared/state/contents.forms.ts | 12 ++-- .../shared/state/contents.forms.visitors.ts | 62 ------------------- 2 files changed, 5 insertions(+), 69 deletions(-) diff --git a/frontend/app/shared/state/contents.forms.ts b/frontend/app/shared/state/contents.forms.ts index 68d4102f3..4f7d14a83 100644 --- a/frontend/app/shared/state/contents.forms.ts +++ b/frontend/app/shared/state/contents.forms.ts @@ -15,7 +15,7 @@ import { LanguageDto } from './../services/languages.service'; import { FieldDto, NestedFieldDto, RootFieldDto, SchemaDetailsDto, TableField } from './../services/schemas.service'; import { fieldInvariant } from './../services/schemas.types'; import { CompiledRule, FieldSection, Hidden, PartitionConfig } from './contents.forms-helpers'; -import { FieldDefaultValue, FieldsValidators, FieldUpdateOn } from './contents.forms.visitors'; +import { FieldDefaultValue, FieldsValidators } from './contents.forms.visitors'; export { FieldSection } from './contents.forms-helpers'; @@ -48,7 +48,7 @@ export class PatchContentForm extends Form { for (const field of this.editableFields) { const validators = FieldsValidators.create(field, this.language.isOptional); - this.form.setControl(field.name, new FormControl(undefined, { updateOn: FieldUpdateOn.get(field), validators })); + this.form.setControl(field.name, new FormControl(undefined, { validators })); } } @@ -86,9 +86,7 @@ export class EditContentForm extends Form { constructor(languages: ReadonlyArray, schema: SchemaDetailsDto, private readonly user: any = {} ) { - super(new FormGroup({}, { - updateOn: 'blur' - })); + super(new FormGroup({})); const compiledPartitions = new PartitionConfig(languages); const compiledConditions = schema.fieldRules.map(x => new CompiledRule(x)); @@ -339,7 +337,7 @@ export class FieldValueForm extends AbstractContentForm { return null; } - public visitUI(_: UIFieldPropertiesDto): any { - return null; - } -} - -type UpdateOn = 'change' | 'blur'; - -export class FieldUpdateOn implements FieldPropertiesVisitor { - private static INSTANCE = new FieldUpdateOn(); - - private constructor( - ) { - } - - public static get(field: FieldDto): UpdateOn { - if (field.properties.editorUrl) { - return 'change'; - } - - return field.properties.accept(FieldUpdateOn.INSTANCE); - } - - public visitDateTime(_: DateTimeFieldPropertiesDto): any { - return 'blur'; - } - - public visitArray(_: ArrayFieldPropertiesDto): any { - return 'blur'; - } - - public visitAssets(_: AssetsFieldPropertiesDto): any { - return 'blur'; - } - - public visitBoolean(_: BooleanFieldPropertiesDto): any { - return 'change'; - } - - public visitGeolocation(_: GeolocationFieldPropertiesDto): any { - return 'blur'; - } - - public visitJson(_: JsonFieldPropertiesDto): any { - return 'blur'; - } - - public visitNumber(properties: NumberFieldPropertiesDto): any { - return properties.editor === 'Radio' || properties.editor === 'Dropdown' ? 'change' : 'blur'; - } - - public visitReferences(properties: ReferencesFieldPropertiesDto): any { - return properties.editor === 'Dropdown' || properties.editor === 'Checkboxes' ? 'change' : 'blur'; - } - - public visitString(properties: StringFieldPropertiesDto): any { - return properties.editor === 'Radio' || properties.editor === 'Dropdown' ? 'change' : 'blur'; - } - - public visitTags(properties: TagsFieldPropertiesDto): any { - return properties.editor === 'Checkboxes' || properties.editor === 'Dropdown' ? 'change' : 'blur'; - } - public visitUI(_: UIFieldPropertiesDto): any { return null; }