validator fixes
This commit is contained in:
parent
951f34e0cc
commit
c7a3b58019
|
@ -44,7 +44,7 @@ export class DescriptionTemplateTypeEditorModel extends BaseEditorModel implemen
|
||||||
const baseContext: ValidationContext = new ValidationContext();
|
const baseContext: ValidationContext = new ValidationContext();
|
||||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||||
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] });
|
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] });
|
||||||
baseValidationArray.push({ key: 'name', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'RenameourceId')] });
|
baseValidationArray.push({ key: 'name', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'name')] });
|
||||||
baseValidationArray.push({ key: 'status', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'status')] });
|
baseValidationArray.push({ key: 'status', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'status')] });
|
||||||
baseValidationArray.push({ key: 'hash', validators: [] });
|
baseValidationArray.push({ key: 'hash', validators: [] });
|
||||||
|
|
||||||
|
|
|
@ -35,10 +35,8 @@
|
||||||
<mat-form-field class="col-lg-6">
|
<mat-form-field class="col-lg-6">
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.NAME' | translate}}</mat-label>
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.NAME' | translate}}</mat-label>
|
||||||
<input matInput type="text" name="name" [formControl]="formGroup.get('name')" required>
|
<input matInput type="text" name="name" [formControl]="formGroup.get('name')" required>
|
||||||
<mat-error *ngIf="formGroup.get('name').hasError('backendError')">
|
<mat-error *ngIf="formGroup.get('name').hasError('backendError')">{{formGroup.get('name').getError('backendError').message}}</mat-error>
|
||||||
{{formGroup.get('name').getError('backendError').message}}</mat-error>
|
<mat-error *ngIf="formGroup.get('name').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
<mat-error *ngIf="formGroup.get('name').hasError('required')">
|
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="info-grid-value">
|
<div class="info-grid-value">
|
||||||
|
@ -89,24 +87,24 @@
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.LABEL' | translate}}</mat-label>
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.LABEL' | translate}}</mat-label>
|
||||||
<input matInput type="text" name="label" [formControl]="field.get('label')" required>
|
<input matInput type="text" name="label" [formControl]="field.get('label')" required>
|
||||||
<mat-error *ngIf="field.get('label').hasError('required')">
|
<mat-error *ngIf="field.get('label').hasError('backendError')">{{field.get('label').getError('backendError').message}}</mat-error>
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="field.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.DESCRIPTION' | translate}}</mat-label>
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.DESCRIPTION' | translate}}</mat-label>
|
||||||
<input matInput type="text" name="description" [formControl]="field.get('description')">
|
<input matInput type="text" name="description" [formControl]="field.get('description')">
|
||||||
<mat-error *ngIf="field.get('description').hasError('required')">
|
<mat-error *ngIf="field.get('description').hasError('backendError')">{{field.get('description').getError('backendError').message}}</mat-error>
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="field.get('description').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
||||||
<input matInput type="text" name="code" [formControl]="field.get('code')" required>
|
<input matInput type="text" name="code" [formControl]="field.get('code')" required>
|
||||||
<mat-error *ngIf="field.get('code').hasError('required')">
|
<mat-error *ngIf="field.get('code').hasError('backendError')">{{field.get('code').getError('backendError').message}}</mat-error>
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="field.get('code').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
|
|
|
@ -13,7 +13,7 @@ import { AppPermission } from '@app/core/common/enum/permission.enum';
|
||||||
import { ReferenceFieldDataType } from '@app/core/common/enum/reference-field-data-type';
|
import { ReferenceFieldDataType } from '@app/core/common/enum/reference-field-data-type';
|
||||||
import { ReferenceTypeExternalApiHTTPMethodType } from '@app/core/common/enum/reference-type-external-api-http-method-type';
|
import { ReferenceTypeExternalApiHTTPMethodType } from '@app/core/common/enum/reference-type-external-api-http-method-type';
|
||||||
import { ReferenceTypeSourceType } from '@app/core/common/enum/reference-type-source-type';
|
import { ReferenceTypeSourceType } from '@app/core/common/enum/reference-type-source-type';
|
||||||
import { ReferenceType, ReferenceTypePersist } from '@app/core/model/reference-type/reference-type';
|
import { ReferenceType, ReferenceTypeDefinition, ReferenceTypePersist } from '@app/core/model/reference-type/reference-type';
|
||||||
import { AuthService } from '@app/core/services/auth/auth.service';
|
import { AuthService } from '@app/core/services/auth/auth.service';
|
||||||
import { LoggingService } from '@app/core/services/logging/logging-service';
|
import { LoggingService } from '@app/core/services/logging/logging-service';
|
||||||
import { QueryParamsService } from '@app/core/services/utilities/query-params.service';
|
import { QueryParamsService } from '@app/core/services/utilities/query-params.service';
|
||||||
|
@ -25,7 +25,7 @@ import { FilterService } from '@common/modules/text-filter/filter-service';
|
||||||
import { Guid } from '@common/types/guid';
|
import { Guid } from '@common/types/guid';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { map, takeUntil } from 'rxjs/operators';
|
import { map, takeUntil } from 'rxjs/operators';
|
||||||
import { DependencyPropertyEditorModel, QueryConfigEditorModel, ReferenceTypeEditorModel, ReferenceTypeFieldEditorModel, ReferenceTypeSourceBaseConfigurationEditorModel, ReferenceTypeSourceBaseDependencyEditorModel, ReferenceTypeStaticOptionEditorModel, ResultFieldsMappingConfigurationEditorModel } from './reference-type-editor.model';
|
import { DependencyPropertyEditorModel, QueryConfigEditorModel, ReferenceTypeDefinitionEditorModel, ReferenceTypeEditorModel, ReferenceTypeFieldEditorModel, ReferenceTypeSourceBaseConfigurationEditorModel, ReferenceTypeSourceBaseDependencyEditorModel, ReferenceTypeStaticOptionEditorModel, ResultFieldsMappingConfigurationEditorModel } from './reference-type-editor.model';
|
||||||
import { ReferenceTypeEditorResolver } from './reference-type-editor.resolver';
|
import { ReferenceTypeEditorResolver } from './reference-type-editor.resolver';
|
||||||
import { ReferenceTypeEditorService } from './reference-type-editor.service';
|
import { ReferenceTypeEditorService } from './reference-type-editor.service';
|
||||||
|
|
||||||
|
@ -172,9 +172,9 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
||||||
|
|
||||||
formSubmit(): void {
|
formSubmit(): void {
|
||||||
this.formService.touchAllFormFields(this.formGroup);
|
this.formService.touchAllFormFields(this.formGroup);
|
||||||
if (!this.isFormValid()) {
|
// if (!this.isFormValid()) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
this.persistEntity();
|
this.persistEntity();
|
||||||
}
|
}
|
||||||
|
@ -213,8 +213,7 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
addField(): void {
|
addField(): void {
|
||||||
const field: ReferenceTypeFieldEditorModel = new ReferenceTypeFieldEditorModel();
|
(this.formGroup.get('definition').get('fields') as FormArray).push(this.editorModel.createChildField((this.formGroup.get('definition').get('fields') as FormArray).length));
|
||||||
(this.formGroup.get('definition').get('fields') as FormArray).push(field.buildForm());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
removeField(fieldIndex: number): void {
|
removeField(fieldIndex: number): void {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms
|
||||||
import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-data-type";
|
import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-data-type";
|
||||||
import { ReferenceTypeExternalApiHTTPMethodType } from "@app/core/common/enum/reference-type-external-api-http-method-type";
|
import { ReferenceTypeExternalApiHTTPMethodType } from "@app/core/common/enum/reference-type-external-api-http-method-type";
|
||||||
import { ReferenceTypeSourceType } from "@app/core/common/enum/reference-type-source-type";
|
import { ReferenceTypeSourceType } from "@app/core/common/enum/reference-type-source-type";
|
||||||
import { ReferenceType, ReferenceTypeDefinition, ReferenceTypeDefinitionPersist, ReferenceTypePersist, ReferenceTypeFieldPersist,ReferenceTypeField, AuthenticationConfiguration, AuthenticationConfigurationPersist, QueryConfigPersist, QueryConfig, ResultsConfigurationPersist, ResultFieldsMappingConfigurationPersist, ResultsConfiguration, ResultFieldsMappingConfiguration, ReferenceTypeSourceBaseConfigurationPersist, ReferenceTypeSourceBaseConfiguration, ReferenceTypeStaticOptionPersist, ReferenceTypeStaticOption, DependencyPropertyPersist, DependencyProperty, ReferenceTypeSourceBaseDependency, ReferenceTypeSourceBaseDependencyPersist } from "@app/core/model/reference-type/reference-type";
|
import { AuthenticationConfiguration, AuthenticationConfigurationPersist, DependencyProperty, DependencyPropertyPersist, QueryConfig, QueryConfigPersist, ReferenceType, ReferenceTypeDefinition, ReferenceTypeDefinitionPersist, ReferenceTypeField, ReferenceTypeFieldPersist, ReferenceTypePersist, ReferenceTypeSourceBaseConfiguration, ReferenceTypeSourceBaseConfigurationPersist, ReferenceTypeSourceBaseDependency, ReferenceTypeSourceBaseDependencyPersist, ReferenceTypeStaticOption, ReferenceTypeStaticOptionPersist, ResultFieldsMappingConfiguration, ResultFieldsMappingConfigurationPersist, ResultsConfiguration, ResultsConfigurationPersist } from "@app/core/model/reference-type/reference-type";
|
||||||
import { BaseEditorModel } from "@common/base/base-form-editor-model";
|
import { BaseEditorModel } from "@common/base/base-form-editor-model";
|
||||||
import { BackendErrorValidator } from "@common/forms/validation/custom-validator";
|
import { BackendErrorValidator } from "@common/forms/validation/custom-validator";
|
||||||
import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model";
|
import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model";
|
||||||
|
@ -58,6 +58,11 @@ export class ReferenceTypeEditorModel extends BaseEditorModel implements Referen
|
||||||
baseContext.validation = baseValidationArray;
|
baseContext.validation = baseValidationArray;
|
||||||
return baseContext;
|
return baseContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createChildField(index: number): UntypedFormGroup {
|
||||||
|
const field: ReferenceTypeFieldEditorModel = new ReferenceTypeFieldEditorModel(this.validationErrorModel);
|
||||||
|
return field.buildForm({ rootPath: 'definition.fields[' + index + '].' });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefinitionPersist {
|
export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefinitionPersist {
|
||||||
|
@ -97,7 +102,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: `fields[${index}].`
|
rootPath: `[${index}].`
|
||||||
}), context.getValidation('fields')
|
}), context.getValidation('fields')
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -182,9 +187,9 @@ export class ReferenceTypeFieldEditorModel implements ReferenceTypeFieldPersist
|
||||||
const baseContext: ValidationContext = new ValidationContext();
|
const baseContext: ValidationContext = new ValidationContext();
|
||||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||||
baseValidationArray.push({ key: 'code', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
|
baseValidationArray.push({ key: 'code', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
|
||||||
baseValidationArray.push({ key: 'label', validators: [Validators.required,BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
|
baseValidationArray.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
|
||||||
baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}description`)] });
|
baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}description`)] });
|
||||||
baseValidationArray.push({ key: 'dataType', validators: [Validators.required,BackendErrorValidator(validationErrorModel, `${rootPath}dataType`)] });
|
baseValidationArray.push({ key: 'dataType', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}dataType`)] });
|
||||||
|
|
||||||
baseContext.validation = baseValidationArray;
|
baseContext.validation = baseValidationArray;
|
||||||
return baseContext;
|
return baseContext;
|
||||||
|
@ -209,9 +214,9 @@ export class ReferenceTypeSourceBaseConfigurationEditorModel implements Referenc
|
||||||
auth: AuthenticationConfigurationEditorModel = new AuthenticationConfigurationEditorModel();
|
auth: AuthenticationConfigurationEditorModel = new AuthenticationConfigurationEditorModel();
|
||||||
queries?: QueryConfigEditorModel[] = [];
|
queries?: QueryConfigEditorModel[] = [];
|
||||||
|
|
||||||
options : ReferenceTypeStaticOptionEditorModel[] = [];
|
options: ReferenceTypeStaticOptionEditorModel[] = [];
|
||||||
|
|
||||||
dependencies : ReferenceTypeSourceBaseDependencyEditorModel[] = [];
|
dependencies: ReferenceTypeSourceBaseDependencyEditorModel[] = [];
|
||||||
|
|
||||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||||
|
|
||||||
|
@ -234,18 +239,18 @@ export class ReferenceTypeSourceBaseConfigurationEditorModel implements Referenc
|
||||||
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().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().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().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().fromModel(x))); }
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -281,7 +286,7 @@ export class ReferenceTypeSourceBaseConfigurationEditorModel implements Referenc
|
||||||
requestBody: [{ value: this.requestBody, disabled: disabled }, context.getValidation('requestBody').validators],
|
requestBody: [{ value: this.requestBody, disabled: disabled }, context.getValidation('requestBody').validators],
|
||||||
filterType: [{ value: this.filterType, disabled: disabled }, context.getValidation('filterType').validators],
|
filterType: [{ value: this.filterType, disabled: disabled }, context.getValidation('filterType').validators],
|
||||||
auth: this.auth.buildForm({
|
auth: this.auth.buildForm({
|
||||||
rootPath: `auth.`
|
rootPath: `auth.`
|
||||||
}),
|
}),
|
||||||
queries: this.formBuilder.array(
|
queries: this.formBuilder.array(
|
||||||
(this.queries ?? []).map(
|
(this.queries ?? []).map(
|
||||||
|
@ -323,9 +328,9 @@ export class ReferenceTypeSourceBaseConfigurationEditorModel implements Referenc
|
||||||
const baseContext: ValidationContext = new ValidationContext();
|
const baseContext: ValidationContext = new ValidationContext();
|
||||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||||
baseValidationArray.push({ key: 'type', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}type`)] });
|
baseValidationArray.push({ key: 'type', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}type`)] });
|
||||||
baseValidationArray.push({ key: 'key', validators: [Validators.required,BackendErrorValidator(validationErrorModel, `${rootPath}key`)] });
|
baseValidationArray.push({ key: 'key', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}key`)] });
|
||||||
baseValidationArray.push({ key: 'label', validators: [Validators.required,BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
|
baseValidationArray.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
|
||||||
baseValidationArray.push({ key: 'ordinal', validators: [Validators.required,Validators.pattern("^[0-9]*$"), BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] });
|
baseValidationArray.push({ key: 'ordinal', validators: [Validators.required, Validators.pattern("^[0-9]*$"), BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] });
|
||||||
|
|
||||||
baseValidationArray.push({ key: 'url', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}url`)] });
|
baseValidationArray.push({ key: 'url', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}url`)] });
|
||||||
baseValidationArray.push({ key: 'paginationPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}paginationPath`)] });
|
baseValidationArray.push({ key: 'paginationPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}paginationPath`)] });
|
||||||
|
@ -348,7 +353,7 @@ export class ReferenceTypeSourceBaseConfigurationEditorModel implements Referenc
|
||||||
|
|
||||||
export class ResultsConfigurationEditorModel implements ResultsConfigurationPersist {
|
export class ResultsConfigurationEditorModel implements ResultsConfigurationPersist {
|
||||||
public resultsArrayPath: string;
|
public resultsArrayPath: string;
|
||||||
public fieldsMapping: ResultFieldsMappingConfigurationEditorModel[] =[];
|
public fieldsMapping: ResultFieldsMappingConfigurationEditorModel[] = [];
|
||||||
|
|
||||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||||
|
|
||||||
|
@ -358,11 +363,11 @@ 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().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 }));
|
||||||
this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel().fromModel({code: 'description', responsePath: undefined}));
|
this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel().fromModel({ code: 'description', responsePath: undefined }));
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -391,7 +396,7 @@ export class ResultsConfigurationEditorModel implements ResultsConfigurationPers
|
||||||
}), context.getValidation('fieldsMapping')
|
}), context.getValidation('fieldsMapping')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -661,7 +666,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().fromModel(x))); }
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@ export class ValidationErrorModel implements Serializable<ValidationErrorModel>
|
||||||
let error: string;
|
let error: string;
|
||||||
if (this.message && Array.isArray(this.message)) {
|
if (this.message && Array.isArray(this.message)) {
|
||||||
for (const element of this.message) {
|
for (const element of this.message) {
|
||||||
if (element.Key === propertyName) {
|
if (element.key === propertyName) {
|
||||||
error = element.Value.join(', ');
|
error = element.value.join(', ');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,10 @@ export class ValidationErrorModel implements Serializable<ValidationErrorModel>
|
||||||
const errors = new Map<number, string>();
|
const errors = new Map<number, string>();
|
||||||
if (this.message && Array.isArray(this.message)) {
|
if (this.message && Array.isArray(this.message)) {
|
||||||
this.message.forEach(element => {
|
this.message.forEach(element => {
|
||||||
const match = element.Key.match(regExp);
|
const match = element.key.match(regExp);
|
||||||
if (match && match.length >= 2) {
|
if (match && match.length >= 2) {
|
||||||
const index = Number.parseInt(match[1]);
|
const index = Number.parseInt(match[1]);
|
||||||
errors.set(index, element.Value.join(', '));
|
errors.set(index, element.value.join(', '));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -52,15 +52,15 @@ export class ValidationErrorModel implements Serializable<ValidationErrorModel>
|
||||||
if (this.message && Array.isArray(this.message)) {
|
if (this.message && Array.isArray(this.message)) {
|
||||||
let exists = false;
|
let exists = false;
|
||||||
for (const element of this.message) {
|
for (const element of this.message) {
|
||||||
if (element.Key === propertyName) {
|
if (element.key === propertyName) {
|
||||||
if (!element.Value.includes(error)) { element.Value.push(error); }
|
if (!element.value.includes(error)) { element.value.push(error); }
|
||||||
exists = true;
|
exists = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!exists) { this.message.push({ Key: propertyName, Value: [error] }); }
|
if (!exists) { this.message.push({ key: propertyName, value: [error] }); }
|
||||||
} else {
|
} else {
|
||||||
this.message = [{ Key: propertyName, Value: [error] }];
|
this.message = [{ key: propertyName, value: [error] }];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ export class ValidationErrorModel implements Serializable<ValidationErrorModel>
|
||||||
this.error = undefined;
|
this.error = undefined;
|
||||||
if (this.message && Array.isArray(this.message)) {
|
if (this.message && Array.isArray(this.message)) {
|
||||||
this.message.forEach(element => {
|
this.message.forEach(element => {
|
||||||
element.Value.splice(0);
|
element.value.splice(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,8 +76,8 @@ export class ValidationErrorModel implements Serializable<ValidationErrorModel>
|
||||||
public clearPart(prefix: string) {
|
public clearPart(prefix: string) {
|
||||||
if (this.message && Array.isArray(this.message)) {
|
if (this.message && Array.isArray(this.message)) {
|
||||||
this.message.forEach(element => {
|
this.message.forEach(element => {
|
||||||
if (element && element.Key && element.Key.startsWith(prefix)) {
|
if (element && element.key && element.key.startsWith(prefix)) {
|
||||||
element.Value.splice(0);
|
element.value.splice(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,6 @@ export class ValidationErrorModel implements Serializable<ValidationErrorModel>
|
||||||
}
|
}
|
||||||
|
|
||||||
class ErrorMessageItem {
|
class ErrorMessageItem {
|
||||||
Key: string;
|
key: string;
|
||||||
Value: Array<string> = [];
|
value: Array<string> = [];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue