UI separate prefilling sources fixed Value fields

This commit is contained in:
amentis 2024-02-29 15:18:55 +02:00
parent 656afc2045
commit 96696f1a14
12 changed files with 272 additions and 65 deletions

View File

@ -87,7 +87,10 @@ public class PrefillingSourceDefinitionFieldPersist {
.failOn(PrefillingSourceDefinitionFieldPersist._code).failWith(messageSource.getMessage("Validation_Required", new Object[]{PrefillingSourceDefinitionFieldPersist._code}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getSemanticTarget()) || !this.isEmpty(item.getSystemFieldTarget()))
.failOn(PrefillingSourceDefinitionFieldPersist._semanticTarget).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{PrefillingSourceDefinitionFieldPersist._semanticTarget}, LocaleContextHolder.getLocale()))
.failOn(PrefillingSourceDefinitionFieldPersist._semanticTarget).failWith(messageSource.getMessage("Validation_Required", new Object[]{PrefillingSourceDefinitionFieldPersist._semanticTarget}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getSemanticTarget()) || !this.isEmpty(item.getSystemFieldTarget()))
.failOn(PrefillingSourceDefinitionFieldPersist._systemFieldTarget).failWith(messageSource.getMessage("Validation_Required", new Object[]{PrefillingSourceDefinitionFieldPersist._systemFieldTarget}, LocaleContextHolder.getLocale()))
);
}

View File

@ -86,14 +86,11 @@ public class PrefillingSourceDefinitionFixedValueFieldPersist {
.must(() -> !this.isEmpty(item.getFixedValue()))
.failOn(PrefillingSourceDefinitionFixedValueFieldPersist._fixedValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{PrefillingSourceDefinitionFixedValueFieldPersist._fixedValue}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getFixedValue()))
.must(() -> this.isEmpty(item.getSemanticTarget()))
.failOn(PrefillingSourceDefinitionFixedValueFieldPersist._semanticTarget).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{PrefillingSourceDefinitionFixedValueFieldPersist._semanticTarget}, LocaleContextHolder.getLocale())),
.must(() -> !this.isEmpty(item.getSemanticTarget()) || !this.isEmpty(item.getSystemFieldTarget()))
.failOn(PrefillingSourceDefinitionFixedValueFieldPersist._semanticTarget).failWith(messageSource.getMessage("Validation_Required", new Object[]{PrefillingSourceDefinitionFixedValueFieldPersist._semanticTarget}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getSemanticTarget()))
.must(() -> this.isEmpty(item.getFixedValue()))
.failOn(PrefillingSourceDefinitionFixedValueFieldPersist._fixedValue).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{PrefillingSourceDefinitionFixedValueFieldPersist._fixedValue}, LocaleContextHolder.getLocale()))
.must(() -> !this.isEmpty(item.getSemanticTarget()) || !this.isEmpty(item.getSystemFieldTarget()))
.failOn(PrefillingSourceDefinitionFixedValueFieldPersist._systemFieldTarget).failWith(messageSource.getMessage("Validation_Required", new Object[]{PrefillingSourceDefinitionFixedValueFieldPersist._systemFieldTarget}, LocaleContextHolder.getLocale()))
);
}
}

View File

@ -8,6 +8,7 @@ export interface PrefillingSource extends BaseEntity{
export interface PrefillingSourceDefinition{
fields: PrefillingSourceDefinitionField[];
fixedValueFields: PrefillingSourceDefinitionFixedValueField[];
searchConfiguration: ExternalFetcherBaseSourceConfiguration;
getConfiguration: ExternalFetcherBaseSourceConfiguration;
}
@ -17,6 +18,12 @@ export interface PrefillingSourceDefinitionField {
systemFieldTarget: string;
semanticTarget: string;
trimRegex: string;
}
export interface PrefillingSourceDefinitionFixedValueField {
systemFieldTarget: string;
semanticTarget: string;
trimRegex: string;
fixedValue: string;
}
@ -29,6 +36,7 @@ export interface PrefillingSourcePersist extends BaseEntityPersist{
export interface PrefillingSourceDefinitionPersist{
fields: PrefillingSourceDefinitionFieldPersist[];
fixedValueFields: PrefillingSourceDefinitionFixedValueFieldPersist[];
searchConfiguration: ExternalFetcherBaseSourceConfigurationPersist;
getConfiguration: ExternalFetcherBaseSourceConfigurationPersist;
}
@ -38,6 +46,11 @@ export interface PrefillingSourceDefinitionFieldPersist {
systemFieldTarget: string;
semanticTarget: string;
trimRegex: string;
fixedValue: string;
}
export interface PrefillingSourceDefinitionFixedValueFieldPersist {
systemFieldTarget: string;
semanticTarget: string;
trimRegex: string;
fixedValue: string;
}

View File

@ -0,0 +1,25 @@
<div class="col">
<mat-form-field class="w-100">
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.SYSTEM-TARGET' | translate}}</mat-label>
<mat-select [formControl]="form.get('systemFieldTarget')">
<mat-option *ngFor="let systemFieldTarget of prefillingSourceSystemTargetTypeEnumValues" [value]="systemFieldTarget">{{enumUtils.toPrefillingSourceSystemTargetTypeString(systemFieldTarget)}}</mat-option>
</mat-select>
<mat-error *ngIf="form.get('systemFieldTarget').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col">
<mat-form-field class="w-100">
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.SEMANTIC-TARGET' | translate}}</mat-label>
<app-single-auto-complete placeholder="{{'PREFILLING-SOURCE-EDITOR.FIELDS.SEMANTIC-TARGET' | translate}}" [formControl]="form.get('semanticTarget')" [configuration]="semanticsService.singleAutocompleteConfiguration"> </app-single-auto-complete>
<mat-error *ngIf="form.get('semanticTarget').hasError('backendError')">{{formGroup.get('semanticTarget').getError('backendError').message}}</mat-error>
<mat-error *ngIf="form.get('semanticTarget').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col">
<mat-form-field class="w-100">
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.TRIM-REGEX' | translate}}</mat-label>
<input matInput type="text" name="trimRegex" [formControl]="form.get('trimRegex')">
<mat-error *ngIf="form.get('trimRegex').hasError('backendError')">{{formGroup.get('trimRegex').getError('backendError').message}}</mat-error>
<mat-error *ngIf="form.get('trimRegex').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>

View File

@ -0,0 +1,28 @@
import { Component, Input, OnInit } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms';
import { PrefillingSourceSystemTargetType } from '@app/core/common/enum/prefilling-source-system-target-type';
import { SemanticsService } from '@app/core/services/semantic/semantics.service';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
import { BaseComponent } from '@common/base/base.component';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
@Component({
selector: 'app-prefilling-source-field-component',
templateUrl: 'prefilling-source-field.component.html',
styleUrls: ['./prefilling-source-field.component.scss']
})
export class PrefillingSourceComponent extends BaseComponent implements OnInit {
@Input() form: UntypedFormGroup = null;
prefillingSourceSystemTargetTypeEnumValues = this.enumUtils.getEnumValues<PrefillingSourceSystemTargetType>(PrefillingSourceSystemTargetType);
constructor(
public enumUtils: EnumUtils,
public semanticsService: SemanticsService,
) { super(); }
ngOnInit() {
}
}

View File

@ -38,54 +38,31 @@
<mat-error *ngIf="formGroup.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<!-- Fields -->
</div>
</mat-card-content>
</mat-card>
<mat-card appearance="outlined">
<mat-card-header>
<mat-card-title>{{'PREFILLING-SOURCE-EDITOR.FIELDS.FIXED-VALUE-FIELDS' | translate}}</mat-card-title>
</mat-card-header>
<mat-card-content>
<div class="row">
<!-- Fixed Value Fields -->
<div class="col-12">
<div *ngFor="let field of formGroup.get('definition').get('fields').controls; let fieldIndex=index;" class="row mb-3">
<div *ngFor="let field of formGroup.get('definition').get('fixedValueFields').controls; let fieldIndex=index;" class="row mb-3">
<div class="col-12">
<div class="row mb-3 d-flex align-items-center">
<div class="col-auto d-flex">
<mat-card-title>{{'PREFILLING-SOURCE-EDITOR.FIELDS.FIELD' | translate}} {{fieldIndex + 1}}</mat-card-title>
</div>
<div class="col-auto d-flex">
<button mat-icon-button class="action-list-icon" matTooltip="{{'PREFILLING-SOURCE-EDITOR.ACTIONS.REMOVE-FIELD' | translate}}" (click)="removeField(fieldIndex)" [disabled]="formGroup.disabled">
<button mat-icon-button class="action-list-icon" matTooltip="{{'PREFILLING-SOURCE-EDITOR.ACTIONS.REMOVE-FIELD' | translate}}" (click)="removeFixedValueField(fieldIndex)" [disabled]="formGroup.disabled">
<mat-icon>delete</mat-icon>
</button>
</div>
</div>
<div class="row" >
<div class="col">
<mat-form-field class="w-100">
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
<input matInput type="text" name="code" [formControl]="field.get('code')">
<mat-error *ngIf="field.get('code').hasError('backendError')">{{field.get('code').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('code').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col">
<mat-form-field class="w-100">
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.SYSTEM-TARGET' | translate}}</mat-label>
<mat-select [formControl]="field.get('systemFieldTarget')">
<mat-option *ngFor="let systemFieldTarget of prefillingSourceSystemTargetTypeEnumValues" [value]="systemFieldTarget">{{enumUtils.toPrefillingSourceSystemTargetTypeString(systemFieldTarget)}}</mat-option>
</mat-select>
<mat-error *ngIf="field.get('systemFieldTarget').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-12">
<mat-form-field class="w-100">
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.SEMANTIC-TARGET' | translate}}</mat-label>
<app-single-auto-complete placeholder="{{'PREFILLING-SOURCE-EDITOR.FIELDS.SEMANTIC-TARGET' | translate}}" [formControl]="field.get('semanticTarget')" [configuration]="semanticsService.singleAutocompleteConfiguration"> </app-single-auto-complete>
<mat-error *ngIf="field.get('semanticTarget').hasError('backendError')">{{field.get('semanticTarget').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('semanticTarget').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col">
<mat-form-field class="w-100">
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.TRIM-REGEX' | translate}}</mat-label>
<input matInput type="text" name="trimRegex" [formControl]="field.get('trimRegex')">
<mat-error *ngIf="field.get('trimRegex').hasError('backendError')">{{field.get('trimRegex').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('trimRegex').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-auto" >
<app-prefilling-source-field-component [form]="field"></app-prefilling-source-field-component>
<div class="col">
<mat-form-field class="w-100">
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.FIXED-VALUE' | translate}}</mat-label>
@ -97,13 +74,49 @@
</div>
</div>
</div>
<button mat-button class="action-btn" type="button" (click)="addField()" [disabled]="formGroup.disabled">{{'PREFILLING-SOURCE-EDITOR.ACTIONS.ADD-FIELD' | translate}}</button>
<button mat-button class="action-btn" *ngIf="formGroup.get('definition').get('fields').value != ''"
type="button" (click)="submitFields()" [disabled]="!formGroup.get('definition').get('fields').valid">{{'PREFILLING-SOURCE-EDITOR.ACTIONS.SUBMIT-FIELDS' | translate}}</button>
<button mat-button class="action-btn" type="button" (click)="addFixedValiueField()" [disabled]="formGroup.disabled">{{'PREFILLING-SOURCE-EDITOR.ACTIONS.ADD-FIELD' | translate}}</button>
</div>
</div>
</mat-card-content>
</mat-card>
<mat-card appearance="outlined">
<mat-card-header>
<mat-card-title>{{'PREFILLING-SOURCE-EDITOR.FIELDS.FIELDS' | translate}}</mat-card-title>
</mat-card-header>
<mat-card-content>
<!-- Fields -->
<div class="col-12">
<div *ngFor="let field of formGroup.get('definition').get('fields').controls; let fieldIndex=index;" class="row mb-3">
<div class="col-12">
<div class="row mb-3 d-flex align-items-center">
<div class="col-auto d-flex">
<mat-card-title>{{'PREFILLING-SOURCE-EDITOR.FIELDS.FIELD' | translate}} {{fieldIndex + 1}}</mat-card-title>
</div>
<div class="col-auto d-flex">
<button mat-icon-button class="action-list-icon" matTooltip="{{'PREFILLING-SOURCE-EDITOR.ACTIONS.REMOVE-FIELD' | translate}}" (click)="removeField(fieldIndex)" [disabled]="formGroup.disabled">
<mat-icon>delete</mat-icon>
</button>
</div>
</div>
<div class="col-auto" >
<div class="col">
<mat-form-field class="w-100">
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
<input matInput type="text" name="code" [formControl]="field.get('code')">
<mat-error *ngIf="field.get('code').hasError('backendError')">{{field.get('code').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('code').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<app-prefilling-source-field-component [form]="field"></app-prefilling-source-field-component>
</div>
</div>
</div>
<button mat-button class="action-btn" type="button" (click)="addField()" [disabled]="formGroup.disabled">{{'PREFILLING-SOURCE-EDITOR.ACTIONS.ADD-FIELD' | translate}}</button>
<button mat-button class="action-btn" *ngIf="formGroup.get('definition').get('fields').value != ''"
type="button" (click)="submitFields()" [disabled]="!formGroup.get('definition').get('fields').valid">{{'PREFILLING-SOURCE-EDITOR.ACTIONS.SUBMIT-FIELDS' | translate}}</button>
</div>
</mat-card-content>
</mat-card>
<mat-card appearance="outlined">
<mat-card-header>

View File

@ -27,9 +27,7 @@ import { PrefillingSourceEditorResolver } from './prefilling-source-editor.resol
import { PrefillingSourceEditorService } from './prefilling-source-editor.service';
import { PrefillingSourceDefinitionEditorModel, PrefillingSourceEditorModel } from './prefilling-source-editor.model';
import { ResultFieldsMappingConfigurationEditorModel } from '@app/ui/external-fetcher/external-fetcher-source-editor.model';
import { SemanticsService } from '@app/core/services/semantic/semantics.service';
import { MatCheckboxChange } from '@angular/material/checkbox';
import { PrefillingSourceSystemTargetType } from '@app/core/common/enum/prefilling-source-system-target-type';
@Component({
selector: 'app-prefilling-source-editor-component',
@ -43,7 +41,6 @@ export class PrefillingSourceEditorComponent extends BaseEditor<PrefillingSource
isDeleted = false;
formGroup: UntypedFormGroup = null;
showInactiveDetails = false;
prefillingSourceSystemTargetTypeEnumValues = this.enumUtils.getEnumValues<PrefillingSourceSystemTargetType>(PrefillingSourceSystemTargetType);
protected get canDelete(): boolean {
return !this.isDeleted && !this.isNew && this.hasPermission(this.authService.permissionEnum.DeletePrefillingSource);
@ -75,7 +72,6 @@ export class PrefillingSourceEditorComponent extends BaseEditor<PrefillingSource
private prefillingSourceService: PrefillingSourceService,
private logger: LoggingService,
private prefillingSourceEditorService: PrefillingSourceEditorService,
public semanticsService: SemanticsService,
private matomoService: MatomoService
) {
super(dialog, language, formService, router, uiNotificationService, httpErrorHandlingService, filterService, datePipe, route, queryParamsService);
@ -196,6 +192,30 @@ export class PrefillingSourceEditorComponent extends BaseEditor<PrefillingSource
}
}
//
//
// fixed value fields
//
//
addFixedValiueField(): void {
(this.formGroup.get('definition').get('fixedValueFields') as FormArray).push(this.editorModel.createChildFixedValueField((this.formGroup.get('definition').get('fixedValueFields') as FormArray).length));
}
removeFixedValueField(fieldIndex: number): void {
const fieldForm = this.formGroup.get('definition').get('fixedValueFields') as FormArray;
fieldForm.removeAt(fieldIndex);
//Reapply validators
PrefillingSourceEditorModel.reApplyDefinitionValidators(
{
formGroup: this.formGroup,
validationErrorModel: this.editorModel.validationErrorModel
}
)
fieldForm.markAsDirty();
}
//
//
// fields
@ -256,6 +276,7 @@ export class PrefillingSourceEditorComponent extends BaseEditor<PrefillingSource
const fieldsMapping = new ResultFieldsMappingConfigurationEditorModel(this.editorModel.validationErrorModel);
fieldsMapping.code = code;
formArray.push(fieldsMapping.buildForm({rootPath: "definition." + controlName + ".results.fieldsMapping[" + fieldMappingSize + "]."}));
// formArray.at(fieldMappingSize).get('code').patchValue(code);
}
removeFieldMapping(baseFormGroup: any, fieldCode: string){

View File

@ -1,5 +1,5 @@
import { UntypedFormArray, UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
import { PrefillingSource, PrefillingSourceDefinition, PrefillingSourceDefinitionField, PrefillingSourceDefinitionFieldPersist, PrefillingSourceDefinitionPersist, PrefillingSourcePersist } from "@app/core/model/prefilling-source/prefilling-source";
import { PrefillingSource, PrefillingSourceDefinition, PrefillingSourceDefinitionField, PrefillingSourceDefinitionFieldPersist, PrefillingSourceDefinitionFixedValueField, PrefillingSourceDefinitionFixedValueFieldPersist, PrefillingSourceDefinitionPersist, PrefillingSourcePersist } from "@app/core/model/prefilling-source/prefilling-source";
import { ExternalFetcherBaseSourceConfigurationEditorModel, QueryCaseConfigEditorModel, QueryConfigEditorModel } from "@app/ui/external-fetcher/external-fetcher-source-editor.model";
import { BaseEditorModel } from "@common/base/base-form-editor-model";
@ -69,10 +69,16 @@ export class PrefillingSourceEditorModel extends BaseEditorModel implements Pref
const field: PrefillingSourceDefinitionFieldEditorModel = new PrefillingSourceDefinitionFieldEditorModel(this.validationErrorModel);
return field.buildForm({ rootPath: 'definition.fields[' + index + '].' });
}
createChildFixedValueField(index: number): UntypedFormGroup {
const field: PrefillingSourceDefinitionFixedValueFieldEditorModel = new PrefillingSourceDefinitionFixedValueFieldEditorModel(this.validationErrorModel);
return field.buildForm({ rootPath: 'definition.fixedValueFields[' + index + '].' });
}
}
export class PrefillingSourceDefinitionEditorModel implements PrefillingSourceDefinitionPersist {
fields: PrefillingSourceDefinitionFieldEditorModel[] = [];
fixedValueFields: PrefillingSourceDefinitionFixedValueFieldEditorModel[] = [];
searchConfiguration: ExternalFetcherBaseSourceConfigurationEditorModel = new ExternalFetcherBaseSourceConfigurationEditorModel(this.validationErrorModel);
getConfiguration: ExternalFetcherBaseSourceConfigurationEditorModel;
getEnabled = false;
@ -86,6 +92,7 @@ export class PrefillingSourceDefinitionEditorModel implements PrefillingSourceDe
public fromModel(item: PrefillingSourceDefinition): PrefillingSourceDefinitionEditorModel {
if (item) {
if (item.fields) { item.fields.map(x => this.fields.push(new PrefillingSourceDefinitionFieldEditorModel(this.validationErrorModel).fromModel(x))); }
if (item.fixedValueFields) { item.fixedValueFields.map(x => this.fixedValueFields.push(new PrefillingSourceDefinitionFixedValueFieldEditorModel(this.validationErrorModel).fromModel(x))); }
if (item.searchConfiguration) this.searchConfiguration = new ExternalFetcherBaseSourceConfigurationEditorModel(this.validationErrorModel).fromModel(item.searchConfiguration);
if (item.getConfiguration) {
this.getConfiguration = new ExternalFetcherBaseSourceConfigurationEditorModel(this.validationErrorModel).fromModel(item.getConfiguration);
@ -113,8 +120,15 @@ export class PrefillingSourceDefinitionEditorModel implements PrefillingSourceDe
(this.fields ?? []).map(
(item, index) => item.buildForm({
rootPath: `${rootPath}fields[${index}].`
}), context.getValidation('fields')
)
})
), context.getValidation('fields')
),
fixedValueFields: this.formBuilder.array(
(this.fixedValueFields ?? []).map(
(item, index) => item.buildForm({
rootPath: `${rootPath}fixedValueFields[${index}].`
})
), context.getValidation('fixedValueFields')
),
searchConfiguration: this.searchConfiguration.buildForm({
rootPath: `${rootPath}searchConfiguration.`
@ -149,7 +163,8 @@ export class PrefillingSourceDefinitionEditorModel implements PrefillingSourceDe
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'fields', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}fields`)] });
baseValidationArray.push({ key: 'fields', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fields`)] });
baseValidationArray.push({ key: 'fixedValueFields', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fixedValueFields`)] });
baseValidationArray.push({ key: 'searchConfiguration', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}searchConfiguration`)] });
baseValidationArray.push({ key: 'getConfiguration', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}getConfiguration`)] });
baseValidationArray.push({ key: 'getEnabled', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}getConfiguration`)] });
@ -172,6 +187,14 @@ export class PrefillingSourceDefinitionEditorModel implements PrefillingSourceDe
})
);
(formGroup.get('fixedValueFields') as UntypedFormArray).controls?.forEach(
(control, index) => PrefillingSourceDefinitionFixedValueFieldEditorModel.reapplyValidators({
formGroup: control as UntypedFormGroup,
rootPath: `${rootPath}fixedValueFields[${index}].`,
validationErrorModel: validationErrorModel
})
);
ExternalFetcherBaseSourceConfigurationEditorModel.reapplyValidators({
formGroup: formGroup.get('searchConfiguration') as UntypedFormGroup,
rootPath: `${rootPath}searchConfiguration.`,
@ -193,7 +216,6 @@ export class PrefillingSourceDefinitionFieldEditorModel implements PrefillingSou
systemFieldTarget: string;
semanticTarget: string;
trimRegex: string;
fixedValue: string;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
@ -207,7 +229,6 @@ export class PrefillingSourceDefinitionFieldEditorModel implements PrefillingSou
this.systemFieldTarget = item.systemFieldTarget;
this.semanticTarget = item.semanticTarget;
this.trimRegex = item.trimRegex;
this.fixedValue = item.fixedValue;
}
return this;
}
@ -230,7 +251,6 @@ export class PrefillingSourceDefinitionFieldEditorModel implements PrefillingSou
systemFieldTarget: [{ value: this.systemFieldTarget, disabled: disabled }, context.getValidation('systemFieldTarget').validators],
semanticTarget: [{ value: this.semanticTarget, disabled: disabled }, context.getValidation('semanticTarget').validators],
trimRegex: [{ value: this.trimRegex, disabled: disabled }, context.getValidation('trimRegex').validators],
fixedValue: [{ value: this.fixedValue, disabled: disabled }, context.getValidation('fixedValue').validators],
});
}
@ -246,7 +266,6 @@ export class PrefillingSourceDefinitionFieldEditorModel implements PrefillingSou
baseValidationArray.push({ key: 'systemFieldTarget', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}systemFieldTarget`)] });
baseValidationArray.push({ key: 'semanticTarget', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}semanticTarget`)] });
baseValidationArray.push({ key: 'trimRegex', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}trimRegex`)] });
baseValidationArray.push({ key: 'fixedValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}clientSecret`)] });
baseContext.validation = baseValidationArray;
return baseContext;
@ -264,7 +283,87 @@ export class PrefillingSourceDefinitionFieldEditorModel implements PrefillingSou
validationErrorModel
});
['code', 'systemFieldTarget', 'semanticTarget', 'trimRegex', 'fixedValue'].forEach(keyField => {
['code', 'systemFieldTarget', 'semanticTarget', 'trimRegex'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);
})
}
}
export class PrefillingSourceDefinitionFixedValueFieldEditorModel implements PrefillingSourceDefinitionFixedValueFieldPersist {
systemFieldTarget: string;
semanticTarget: string;
trimRegex: string;
fixedValue: string;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
public fromModel(item: PrefillingSourceDefinitionFixedValueField): PrefillingSourceDefinitionFixedValueFieldEditorModel {
if (item) {
this.systemFieldTarget = item.systemFieldTarget;
this.semanticTarget = item.semanticTarget;
this.trimRegex = item.trimRegex;
this.fixedValue = item.fixedValue;
}
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = PrefillingSourceDefinitionFixedValueFieldEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
return this.formBuilder.group({
systemFieldTarget: [{ value: this.systemFieldTarget, disabled: disabled }, context.getValidation('systemFieldTarget').validators],
semanticTarget: [{ value: this.semanticTarget, disabled: disabled }, context.getValidation('semanticTarget').validators],
trimRegex: [{ value: this.trimRegex, disabled: disabled }, context.getValidation('trimRegex').validators],
fixedValue: [{ value: this.fixedValue, disabled: disabled }, context.getValidation('fixedValue').validators],
});
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'systemFieldTarget', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}systemFieldTarget`)] });
baseValidationArray.push({ key: 'semanticTarget', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}semanticTarget`)] });
baseValidationArray.push({ key: 'trimRegex', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}trimRegex`)] });
baseValidationArray.push({ key: 'fixedValue', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}fixedValue`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
static reapplyValidators(params: {
formGroup: UntypedFormGroup,
validationErrorModel: ValidationErrorModel,
rootPath: string
}): void {
const { formGroup, rootPath, validationErrorModel } = params;
const context = PrefillingSourceDefinitionFixedValueFieldEditorModel.createValidationContext({
rootPath,
validationErrorModel
});
['systemFieldTarget', 'semanticTarget', 'trimRegex', 'fixedValue'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);

View File

@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { AuthenticationConfiguration, ExternalFetcherBaseSourceConfiguration, QueryCaseConfig, QueryConfig, ResultFieldsMappingConfiguration, ResultsConfiguration } from '@app/core/model/external-fetcher/external-fetcher';
import { PrefillingSource, PrefillingSourceDefinition, PrefillingSourceDefinitionField } from '@app/core/model/prefilling-source/prefilling-source';
import { PrefillingSource, PrefillingSourceDefinition, PrefillingSourceDefinitionField, PrefillingSourceDefinitionFixedValueField } from '@app/core/model/prefilling-source/prefilling-source';
import { PrefillingSourceService } from '@app/core/services/prefilling-source/prefilling-source.service';
import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
import { BaseEditorResolver } from '@common/base/base-editor.resolver';
@ -26,7 +26,11 @@ export class PrefillingSourceEditorResolver extends BaseEditorResolver {
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.fields), nameof<PrefillingSourceDefinitionField>(x => x.systemFieldTarget)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.fields), nameof<PrefillingSourceDefinitionField>(x => x.semanticTarget)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.fields), nameof<PrefillingSourceDefinitionField>(x => x.trimRegex)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.fields), nameof<PrefillingSourceDefinitionField>(x => x.fixedValue)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.fixedValueFields), nameof<PrefillingSourceDefinitionFixedValueField>(x => x.systemFieldTarget)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.fixedValueFields), nameof<PrefillingSourceDefinitionFixedValueField>(x => x.semanticTarget)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.fixedValueFields), nameof<PrefillingSourceDefinitionFixedValueField>(x => x.trimRegex)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.fixedValueFields), nameof<PrefillingSourceDefinitionFixedValueField>(x => x.fixedValue)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.type)].join('.'),
[nameof<PrefillingSource>(x => x.definition), nameof<PrefillingSourceDefinition>(x => x.searchConfiguration), nameof<ExternalFetcherBaseSourceConfiguration>(x => x.key)].join('.'),

View File

@ -15,6 +15,7 @@ import { PrefillingSourceListingComponent } from './listing/prefilling-source-li
import { PrefillingSourceListingFiltersComponent } from './listing/filters/prefilling-source-listing-filters.component';
import { PrefillingSourceEditorComponent } from './editor/prefilling-source-editor.component';
import { ExternalFetcherSourceModule } from '@app/ui/external-fetcher/external-fetcher-source.module';
import { PrefillingSourceComponent } from './editor/field/prefilling-source-field.component';
@NgModule({
imports: [
@ -35,6 +36,7 @@ import { ExternalFetcherSourceModule } from '@app/ui/external-fetcher/external-f
declarations: [
PrefillingSourceEditorComponent,
PrefillingSourceListingComponent,
PrefillingSourceListingFiltersComponent ]
PrefillingSourceListingFiltersComponent,
PrefillingSourceComponent ]
})
export class PrefillingSourceModule { }

View File

@ -1605,6 +1605,8 @@
"PREFILLING-SOURCE-EDITOR": {
"NEW": "New Prefilling Source",
"FIELDS": {
"FIXED-VALUE-FIELDS": "Fixed Value Fields",
"FIELDS": "API Fields",
"SOURCE-CONFIGURATION":"Search Source Configuration",
"GET-SOURCE-CONFIGURATION": "Get Source Configuration",
"LABEL": "Label",