Browse Source

Revert the updateOn strategy.

pull/579/head
Sebastian 5 years ago
parent
commit
67ac64efad
  1. 12
      frontend/app/shared/state/contents.forms.ts
  2. 62
      frontend/app/shared/state/contents.forms.visitors.ts

12
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<FormGroup, any> {
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<FormGroup, any> {
constructor(languages: ReadonlyArray<AppLanguageDto>, 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<RootFieldDto, FormContro
const validators = FieldsValidators.create(field, isOptional);
return new FormControl(value, { updateOn: FieldUpdateOn.get(field), validators });
return new FormControl(value, { validators });
}
}
@ -517,7 +515,7 @@ export class FieldArrayItemValueForm extends AbstractContentForm<NestedFieldDto,
const validators = FieldsValidators.create(field, isOptional);
return new FormControl(value, { updateOn: FieldUpdateOn.get(field), validators });
return new FormControl(value, { validators });
}
}

62
frontend/app/shared/state/contents.forms.visitors.ts

@ -400,68 +400,6 @@ export class FieldDefaultValue implements FieldPropertiesVisitor<any> {
return null;
}
public visitUI(_: UIFieldPropertiesDto): any {
return null;
}
}
type UpdateOn = 'change' | 'blur';
export class FieldUpdateOn implements FieldPropertiesVisitor<UpdateOn> {
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;
}

Loading…
Cancel
Save