fix update form validators

This commit is contained in:
amentis 2024-01-19 16:23:34 +02:00
parent 53062a879f
commit d60ecc4f1c
6 changed files with 43 additions and 41 deletions

View File

@ -265,7 +265,7 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
else if (item.match(Reference._updatedAt)) return ReferenceEntity._updatedAt; else if (item.match(Reference._updatedAt)) return ReferenceEntity._updatedAt;
else if (item.match(Reference._hash)) return ReferenceEntity._updatedAt; else if (item.match(Reference._hash)) return ReferenceEntity._updatedAt;
else if (item.match(Reference._isActive)) return ReferenceEntity._isActive; else if (item.match(Reference._isActive)) return ReferenceEntity._isActive;
else if (item.match(Reference._definition)) return ReferenceEntity._definition; else if (item.prefix(Reference._definition)) return ReferenceEntity._definition;
else if (item.match(Reference._abbreviation)) return ReferenceEntity._abbreviation; else if (item.match(Reference._abbreviation)) return ReferenceEntity._abbreviation;
else if (item.match(Reference._reference) || item.match(PublicReference._reference)) return ReferenceEntity._reference; else if (item.match(Reference._reference) || item.match(PublicReference._reference)) return ReferenceEntity._reference;
else if (item.match(Reference._source)) return ReferenceEntity._source; else if (item.match(Reference._source)) return ReferenceEntity._source;

View File

@ -28,7 +28,7 @@ export class DmpBlueprintEditorModel extends BaseEditorModel implements DmpBluep
this.label = item.label; this.label = item.label;
this.status = item.status; this.status = item.status;
this.description = item.description; this.description = item.description;
this.definition = new DmpBlueprintDefinitionEditorModel().fromModel(item.definition); this.definition = new DmpBlueprintDefinitionEditorModel(this.validationErrorModel).fromModel(item.definition);
} }
return this; return this;
} }
@ -108,7 +108,7 @@ export class DmpBlueprintDefinitionEditorModel implements DmpBlueprintDefinition
public fromModel(item: DmpBlueprintDefinition): DmpBlueprintDefinitionEditorModel { public fromModel(item: DmpBlueprintDefinition): DmpBlueprintDefinitionEditorModel {
if (item) { if (item) {
if (item.sections) { item.sections.map(x => this.sections.push(new DmpBlueprintDefinitionSectionEditorModel().fromModel(x))); } if (item.sections) { item.sections.map(x => this.sections.push(new DmpBlueprintDefinitionSectionEditorModel(this.validationErrorModel).fromModel(x))); }
} }
return this; return this;
} }
@ -192,8 +192,8 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef
this.description = item.description; this.description = item.description;
this.ordinal = item.ordinal; this.ordinal = item.ordinal;
this.hasTemplates = item.hasTemplates; this.hasTemplates = item.hasTemplates;
if (item.fields) { item.fields.map(x => this.fields.push(new FieldInSectionEditorModel().fromModel(x))); } if (item.fields) { item.fields.map(x => this.fields.push(new FieldInSectionEditorModel(this.validationErrorModel).fromModel(x))); }
if (item.descriptionTemplates) { item.descriptionTemplates.map(x => this.descriptionTemplates.push(new DescriptionTemplatesInSectionEditorModel().fromModel(x))); } if (item.descriptionTemplates) { item.descriptionTemplates.map(x => this.descriptionTemplates.push(new DescriptionTemplatesInSectionEditorModel(this.validationErrorModel).fromModel(x))); }
} }
return this; return this;
} }
@ -222,7 +222,7 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef
(item, index) => new FieldInSectionEditorModel( (item, index) => new FieldInSectionEditorModel(
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `fields[${index}].` rootPath: `${rootPath}fields[${index}].`
}), context.getValidation('fields') }), context.getValidation('fields')
) )
), ),
@ -231,7 +231,7 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef
(item, index) => new DescriptionTemplatesInSectionEditorModel( (item, index) => new DescriptionTemplatesInSectionEditorModel(
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `fields[${index}].` rootPath: `${rootPath}descriptionTemplates[${index}].`
}), context.getValidation('descriptionTemplates') }), context.getValidation('descriptionTemplates')
) )
) )

View File

@ -25,7 +25,7 @@ export class ReferenceTypeEditorModel extends BaseEditorModel implements Referen
this.id = item.id; this.id = item.id;
this.name = item.name; this.name = item.name;
this.code = item.code; this.code = item.code;
this.definition = new ReferenceTypeDefinitionEditorModel().fromModel(item.definition); this.definition = new ReferenceTypeDefinitionEditorModel(this.validationErrorModel).fromModel(item.definition);
this.hash = item.hash; this.hash = item.hash;
if (item.createdAt) { this.createdAt = item.createdAt; } if (item.createdAt) { this.createdAt = item.createdAt; }
if (item.updatedAt) { this.updatedAt = item.updatedAt; } if (item.updatedAt) { this.updatedAt = item.updatedAt; }
@ -130,8 +130,8 @@ export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefiniti
public fromModel(item: ReferenceTypeDefinition): ReferenceTypeDefinitionEditorModel { public fromModel(item: ReferenceTypeDefinition): ReferenceTypeDefinitionEditorModel {
if (item) { if (item) {
if (item.fields) { item.fields.map(x => this.fields.push(new ReferenceTypeFieldEditorModel().fromModel(x))); } if (item.fields) { item.fields.map(x => this.fields.push(new ReferenceTypeFieldEditorModel(this.validationErrorModel).fromModel(x))); }
if (item.sources) { item.sources.map(x => this.sources.push(new ReferenceTypeSourceBaseConfigurationEditorModel().fromModel(x))); } if (item.sources) { item.sources.map(x => this.sources.push(new ReferenceTypeSourceBaseConfigurationEditorModel(this.validationErrorModel).fromModel(x))); }
} }
return this; return this;
} }
@ -155,7 +155,7 @@ export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefiniti
(item, index) => new ReferenceTypeFieldEditorModel( (item, index) => new ReferenceTypeFieldEditorModel(
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `[${index}].` rootPath: `${rootPath}fields[${index}].`
}), context.getValidation('fields') }), context.getValidation('fields')
) )
), ),
@ -164,7 +164,7 @@ export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefiniti
(item, index) => new ReferenceTypeSourceBaseConfigurationEditorModel( (item, index) => new ReferenceTypeSourceBaseConfigurationEditorModel(
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `sources[${index}].` rootPath: `${rootPath}sources[${index}].`
}), context.getValidation('sources') }), context.getValidation('sources')
) )
) )
@ -305,7 +305,7 @@ export class ReferenceTypeSourceBaseConfigurationEditorModel implements Referenc
ordinal: number; ordinal: number;
url: string; url: string;
results: ResultsConfigurationEditorModel = new ResultsConfigurationEditorModel(); results: ResultsConfigurationEditorModel = new ResultsConfigurationEditorModel(this.validationErrorModel);
paginationPath: string; paginationPath: string;
contentType: string; contentType: string;
firstPage: string; firstPage: string;
@ -333,25 +333,25 @@ export class ReferenceTypeSourceBaseConfigurationEditorModel implements Referenc
this.ordinal = item.ordinal; this.ordinal = item.ordinal;
if (item.url) this.url = item.url; if (item.url) this.url = item.url;
if (item.results) this.results = new ResultsConfigurationEditorModel().fromModel(item.results); if (item.results) this.results = new ResultsConfigurationEditorModel(this.validationErrorModel).fromModel(item.results);
if (item.paginationPath) this.paginationPath = item.paginationPath; if (item.paginationPath) this.paginationPath = item.paginationPath;
if (item.contentType) this.contentType = item.contentType; if (item.contentType) this.contentType = item.contentType;
if (item.firstPage) this.firstPage = item.firstPage; if (item.firstPage) this.firstPage = item.firstPage;
if (item.httpMethod) this.httpMethod = item.httpMethod; if (item.httpMethod) this.httpMethod = item.httpMethod;
if (item.requestBody) this.requestBody = item.requestBody; if (item.requestBody) this.requestBody = item.requestBody;
if (item.filterType) this.filterType = item.filterType; if (item.filterType) this.filterType = item.filterType;
if (item.auth) this.auth = new AuthenticationConfigurationEditorModel().fromModel(item.auth); if (item.auth) this.auth = new AuthenticationConfigurationEditorModel(this.validationErrorModel).fromModel(item.auth);
if (item.queries) { item.queries.map(x => this.queries.push(new QueryConfigEditorModel().fromModel(x))); } if (item.queries) { item.queries.map(x => this.queries.push(new QueryConfigEditorModel(this.validationErrorModel).fromModel(x))); }
if (item.options) { if (item.options) {
item.options.map(x => this.options.push(new ReferenceTypeStaticOptionEditorModel().fromModel(x))); item.options.map(x => this.options.push(new ReferenceTypeStaticOptionEditorModel(this.validationErrorModel).fromModel(x)));
} else { } else {
this.options.push(new ReferenceTypeStaticOptionEditorModel().fromModel({ code: 'reference_id', value: undefined })); this.options.push(new ReferenceTypeStaticOptionEditorModel().fromModel({ code: 'reference_id', value: undefined }));
this.options.push(new ReferenceTypeStaticOptionEditorModel().fromModel({ code: 'label', value: undefined })); this.options.push(new ReferenceTypeStaticOptionEditorModel().fromModel({ code: 'label', value: undefined }));
this.options.push(new ReferenceTypeStaticOptionEditorModel().fromModel({ code: 'description', value: undefined })); this.options.push(new ReferenceTypeStaticOptionEditorModel().fromModel({ code: 'description', value: undefined }));
} }
if (item.dependencies) { item.dependencies.map(x => this.dependencies.push(new ReferenceTypeSourceBaseDependencyEditorModel().fromModel(x))); } if (item.dependencies) { item.dependencies.map(x => this.dependencies.push(new ReferenceTypeSourceBaseDependencyEditorModel(this.validationErrorModel).fromModel(x))); }
} }
return this; return this;
} }
@ -377,8 +377,7 @@ export class ReferenceTypeSourceBaseConfigurationEditorModel implements Referenc
url: [{ value: this.url, disabled: disabled }, context.getValidation('url').validators], url: [{ value: this.url, disabled: disabled }, context.getValidation('url').validators],
results: this.results.buildForm({ results: this.results.buildForm({
rootPath: `results.`, rootPath: `${rootPath}results.`,
//context: context.getValidation('results')
}), }),
paginationPath: [{ value: this.paginationPath, disabled: disabled }, context.getValidation('paginationPath').validators], paginationPath: [{ value: this.paginationPath, disabled: disabled }, context.getValidation('paginationPath').validators],
contentType: [{ value: this.contentType, disabled: disabled }, context.getValidation('contentType').validators], contentType: [{ value: this.contentType, disabled: disabled }, context.getValidation('contentType').validators],
@ -394,7 +393,7 @@ export class ReferenceTypeSourceBaseConfigurationEditorModel implements Referenc
(item, index) => new QueryConfigEditorModel( (item, index) => new QueryConfigEditorModel(
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `queries[${index}].` rootPath: `${rootPath}queries[${index}].`
}), context.getValidation('queries') }), context.getValidation('queries')
) )
), ),
@ -403,7 +402,7 @@ export class ReferenceTypeSourceBaseConfigurationEditorModel implements Referenc
(item, index) => new ReferenceTypeStaticOptionEditorModel( (item, index) => new ReferenceTypeStaticOptionEditorModel(
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `options[${index}].` rootPath: `${rootPath}options[${index}].`
}), context.getValidation('options') }), context.getValidation('options')
) )
), ),
@ -412,7 +411,7 @@ export class ReferenceTypeSourceBaseConfigurationEditorModel implements Referenc
(item, index) => new ReferenceTypeSourceBaseDependencyEditorModel( (item, index) => new ReferenceTypeSourceBaseDependencyEditorModel(
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `dependencies[${index}].` rootPath: `${rootPath}dependencies[${index}].`
}), context.getValidation('dependencies') }), context.getValidation('dependencies')
) )
) )
@ -512,7 +511,7 @@ export class ResultsConfigurationEditorModel implements ResultsConfigurationPers
fromModel(item: ResultsConfiguration): ResultsConfigurationEditorModel { fromModel(item: ResultsConfiguration): ResultsConfigurationEditorModel {
this.resultsArrayPath = item.resultsArrayPath; this.resultsArrayPath = item.resultsArrayPath;
if (item.fieldsMapping) { item.fieldsMapping.map(x => this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel().fromModel(x))); } if (item.fieldsMapping) { item.fieldsMapping.map(x => this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel(x))); }
else { else {
this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel().fromModel({ code: 'reference_id', responsePath: undefined })); this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel().fromModel({ code: 'reference_id', responsePath: undefined }));
this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel().fromModel({ code: 'label', responsePath: undefined })); this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel().fromModel({ code: 'label', responsePath: undefined }));
@ -541,7 +540,7 @@ export class ResultsConfigurationEditorModel implements ResultsConfigurationPers
(item, index) => new ResultFieldsMappingConfigurationEditorModel( (item, index) => new ResultFieldsMappingConfigurationEditorModel(
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `fieldsMapping[${index}].` rootPath: `${rootPath}fieldsMapping[${index}].`
}), context.getValidation('fieldsMapping') }), context.getValidation('fieldsMapping')
) )
) )
@ -901,7 +900,7 @@ export class ReferenceTypeSourceBaseDependencyEditorModel implements ReferenceTy
this.referenceTypeCode = item.referenceTypeCode; this.referenceTypeCode = item.referenceTypeCode;
this.key = item.key; this.key = item.key;
this.required = item.required; this.required = item.required;
if (item.properties) { item.properties.map(x => this.properties.push(new DependencyPropertyEditorModel().fromModel(x))); } if (item.properties) { item.properties.map(x => this.properties.push(new DependencyPropertyEditorModel(this.validationErrorModel).fromModel(x))); }
return this; return this;
} }
@ -928,7 +927,7 @@ export class ReferenceTypeSourceBaseDependencyEditorModel implements ReferenceTy
(item, index) => new DependencyPropertyEditorModel( (item, index) => new DependencyPropertyEditorModel(
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `properties[${index}].` rootPath: `${rootPath}properties[${index}].`
}), context.getValidation('properties') }), context.getValidation('properties')
) )
), ),

View File

@ -31,7 +31,7 @@ export class ReferenceEditorModel extends BaseEditorModel implements ReferencePe
this.label = item.label; this.label = item.label;
this.type = item.type; this.type = item.type;
this.description = item.description; this.description = item.description;
if (item.definition) this.definition = new DefinitionEditorModel().fromModel(item.definition); if (item.definition) this.definition = new DefinitionEditorModel(this.validationErrorModel).fromModel(item.definition);
this.reference = item.reference; this.reference = item.reference;
this.abbreviation = item.abbreviation; this.abbreviation = item.abbreviation;
this.source = item.source; this.source = item.source;
@ -108,7 +108,7 @@ export class DefinitionEditorModel implements DefinitionPersist {
public fromModel(item: Definition): DefinitionEditorModel { public fromModel(item: Definition): DefinitionEditorModel {
if (item) { if (item) {
if (item.fields) { item.fields.map(x => this.fields.push(new FieldEditorModel().fromModel(x))); } if (item.fields) { item.fields.map(x => this.fields.push(new FieldEditorModel(this.validationErrorModel).fromModel(x))); }
} }
return this; return this;
} }
@ -132,7 +132,7 @@ export class DefinitionEditorModel implements DefinitionPersist {
(item, index) => new FieldEditorModel( (item, index) => new FieldEditorModel(
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `fields[${index}].` rootPath: `${rootPath}fields[${index}].`
}), context.getValidation('fields') }), context.getValidation('fields')
) )
), ),

View File

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { Reference } from '@app/core/model/reference/reference'; import { Definition, Field, Reference } from '@app/core/model/reference/reference';
import { ReferenceService } from '@app/core/services/reference/reference.service'; import { ReferenceService } from '@app/core/services/reference/reference.service';
import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service'; import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
import { BaseEditorResolver } from '@common/base/base-editor.resolver'; import { BaseEditorResolver } from '@common/base/base-editor.resolver';
@ -28,6 +28,9 @@ export class ReferenceEditorResolver extends BaseEditorResolver {
nameof<Reference>(x => x.sourceType), nameof<Reference>(x => x.sourceType),
nameof<Reference>(x => x.createdAt), nameof<Reference>(x => x.createdAt),
nameof<Reference>(x => x.updatedAt), nameof<Reference>(x => x.updatedAt),
[nameof<Reference>(x => x.definition), nameof<Definition>(x => x.fields), nameof<Field>(x => x.code)].join('.'),
[nameof<Reference>(x => x.definition), nameof<Definition>(x => x.fields), nameof<Field>(x => x.dataType)].join('.'),
[nameof<Reference>(x => x.definition), nameof<Definition>(x => x.fields), nameof<Field>(x => x.value)].join('.'),
nameof<Reference>(x => x.hash), nameof<Reference>(x => x.hash),
nameof<Reference>(x => x.isActive) nameof<Reference>(x => x.isActive)
] ]

View File

@ -23,7 +23,7 @@ export class TenantEditorModel extends BaseEditorModel implements TenantPersist
this.name = item.name; this.name = item.name;
this.code = item.code; this.code = item.code;
this.description = item.description; this.description = item.description;
if (item.config) this.config = new TenantConfigEditorModel().fromModel(item.config); if (item.config) this.config = new TenantConfigEditorModel(this.validationErrorModel).fromModel(item.config);
} }
return this; return this;
} }
@ -37,7 +37,7 @@ export class TenantEditorModel extends BaseEditorModel implements TenantPersist
code: [{ value: this.code, disabled: disabled }, context.getValidation('code').validators], code: [{ value: this.code, disabled: disabled }, context.getValidation('code').validators],
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators], description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators],
config: this.config.buildForm({ config: this.config.buildForm({
rootPath: `config.` rootPath: `config.`,
}), }),
hash: [{ value: this.hash, disabled: disabled }, context.getValidation('hash').validators] hash: [{ value: this.hash, disabled: disabled }, context.getValidation('hash').validators]
}); });
@ -107,8 +107,8 @@ export class TenantConfigEditorModel implements TenantConfigPersist {
public fromModel(item: TenantConfig): TenantConfigEditorModel { public fromModel(item: TenantConfig): TenantConfigEditorModel {
if (item) { if (item) {
if (item.deposit) this.deposit = new TenantDepositConfigEditorModel().fromModel(item.deposit); if (item.deposit) this.deposit = new TenantDepositConfigEditorModel(this.validationErrorModel).fromModel(item.deposit);
if (item.fileTransformers) this.fileTransformers = new TenantFileTransformersConfigEditorModel().fromModel(item.fileTransformers); if (item.fileTransformers) this.fileTransformers = new TenantFileTransformersConfigEditorModel(this.validationErrorModel).fromModel(item.fileTransformers);
} }
return this; return this;
} }
@ -128,10 +128,10 @@ export class TenantConfigEditorModel implements TenantConfigPersist {
return this.formBuilder.group({ return this.formBuilder.group({
deposit: this.deposit.buildForm({ deposit: this.deposit.buildForm({
rootPath: `deposit.` rootPath: `${rootPath}deposit.`
}), }),
fileTransformers: this.fileTransformers.buildForm({ fileTransformers: this.fileTransformers.buildForm({
rootPath: `fileTransformers.` rootPath: `${rootPath}fileTransformers.`
}), }),
}); });
} }
@ -161,7 +161,7 @@ export class TenantDepositConfigEditorModel implements TenantDepositConfigPersis
public fromModel(item: TenantDepositConfig): TenantDepositConfigEditorModel { public fromModel(item: TenantDepositConfig): TenantDepositConfigEditorModel {
if (item) { if (item) {
if (item.sources) { item.sources.map(x => this.sources.push(new TenantSourceEditorModel().fromModel(x))); } if (item.sources) { item.sources.map(x => this.sources.push(new TenantSourceEditorModel(this.validationErrorModel).fromModel(x))); }
} }
return this; return this;
} }
@ -185,7 +185,7 @@ export class TenantDepositConfigEditorModel implements TenantDepositConfigPersis
(item, index) => new TenantSourceEditorModel( (item, index) => new TenantSourceEditorModel(
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `sources[${index}].` rootPath: `${rootPath}sources[${index}].`
}), context.getValidation('sources') }), context.getValidation('sources')
) )
), ),
@ -233,7 +233,7 @@ export class TenantFileTransformersConfigEditorModel implements TenantFileTransf
public fromModel(item: TenantFileTransformersConfig): TenantFileTransformersConfigEditorModel { public fromModel(item: TenantFileTransformersConfig): TenantFileTransformersConfigEditorModel {
if (item) { if (item) {
if (item.sources) { item.sources.map(x => this.sources.push(new TenantSourceEditorModel().fromModel(x))); } if (item.sources) { item.sources.map(x => this.sources.push(new TenantSourceEditorModel(this.validationErrorModel).fromModel(x))); }
} }
return this; return this;
} }
@ -257,7 +257,7 @@ export class TenantFileTransformersConfigEditorModel implements TenantFileTransf
(item, index) => new TenantSourceEditorModel( (item, index) => new TenantSourceEditorModel(
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `sources[${index}].` rootPath: `${rootPath}sources[${index}].`
}), context.getValidation('sources') }), context.getValidation('sources')
) )
), ),