reference type changes
This commit is contained in:
parent
20498001b3
commit
aabcdd8c65
|
@ -113,18 +113,23 @@ public class AuthenticationConfigurationPersist {
|
|||
.must(() -> !this.isNull(item.getEnabled()))
|
||||
.failOn(AuthenticationConfigurationPersist._enabled).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthenticationConfigurationPersist._enabled}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(() -> !this.isNull(item.getEnabled()))
|
||||
.must(() -> !this.isEmpty(item.getAuthUrl()))
|
||||
.failOn(AuthenticationConfigurationPersist._authUrl).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthenticationConfigurationPersist._authUrl}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(() -> !this.isNull(item.getEnabled()))
|
||||
.must(() -> !this.isNull(item.getAuthMethod()))
|
||||
.failOn(AuthenticationConfigurationPersist._authMethod).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthenticationConfigurationPersist._authMethod}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(() -> !this.isNull(item.getEnabled()))
|
||||
.must(() -> !this.isEmpty(item.getAuthTokenPath()))
|
||||
.failOn(AuthenticationConfigurationPersist._authTokenPath).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthenticationConfigurationPersist._authTokenPath}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(() -> !this.isNull(item.getEnabled()))
|
||||
.must(() -> !this.isEmpty(item.getAuthRequestBody()))
|
||||
.failOn(AuthenticationConfigurationPersist._authRequestBody).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthenticationConfigurationPersist._authRequestBody}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(() -> !this.isNull(item.getEnabled()))
|
||||
.must(() -> !this.isEmpty(item.getType()))
|
||||
.failOn(AuthenticationConfigurationPersist._type).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthenticationConfigurationPersist._type}, LocaleContextHolder.getLocale()))
|
||||
);
|
||||
|
|
|
@ -98,7 +98,11 @@ public class QueryCaseConfigPersist {
|
|||
return Arrays.asList(
|
||||
this.spec()
|
||||
.must(() -> !this.isEmpty(item.getValue()))
|
||||
.failOn(QueryCaseConfigPersist._value).failWith(messageSource.getMessage("Validation_Required", new Object[]{QueryCaseConfigPersist._value}, LocaleContextHolder.getLocale()))
|
||||
.failOn(QueryCaseConfigPersist._value).failWith(messageSource.getMessage("Validation_Required", new Object[]{QueryCaseConfigPersist._value}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(() -> this.isValidGuid(item.getReferenceTypeId()))
|
||||
.must(() -> !this.isEmpty(item.getReferenceTypeSourceKey()))
|
||||
.failOn(QueryCaseConfigPersist._referenceTypeSourceKey).failWith(messageSource.getMessage("Validation_Required", new Object[]{QueryCaseConfigPersist._referenceTypeSourceKey}, LocaleContextHolder.getLocale()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-da
|
|||
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 { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model";
|
||||
import { Guid } from "@common/types/guid";
|
||||
|
||||
export interface ReferenceType extends BaseEntity{
|
||||
name: string;
|
||||
|
@ -26,7 +27,7 @@ export interface ReferenceTypeSourceBaseConfiguration extends ReferenceTypeSourc
|
|||
key: string;
|
||||
label: string;
|
||||
ordinal: number;
|
||||
dependencies: ReferenceTypeSourceBaseDependency[];
|
||||
referenceTypeDependencies?: ReferenceType[];
|
||||
}
|
||||
|
||||
export interface ReferenceTypeSourceExternalApiConfiguration{
|
||||
|
@ -34,7 +35,6 @@ export interface ReferenceTypeSourceExternalApiConfiguration{
|
|||
results: ResultsConfiguration;
|
||||
paginationPath: string;
|
||||
contentType: string;
|
||||
//funderQuery?: string;
|
||||
firstPage: string;
|
||||
httpMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||
requestBody?: string;
|
||||
|
@ -64,10 +64,17 @@ export interface AuthenticationConfiguration{
|
|||
}
|
||||
|
||||
export interface QueryConfig{
|
||||
condition: string;
|
||||
name: string;
|
||||
defaultValue: string;
|
||||
cases: QueryCaseConfig[];
|
||||
}
|
||||
|
||||
export interface QueryCaseConfig{
|
||||
likePattern: string,
|
||||
separator: string;
|
||||
value: string;
|
||||
ordinal: number;
|
||||
referenceType?: ReferenceType;
|
||||
referenceTypeSourceKey: string
|
||||
}
|
||||
|
||||
export interface ReferenceTypeSourceStaticOptionConfiguration{
|
||||
|
@ -79,20 +86,6 @@ export interface ReferenceTypeStaticOption{
|
|||
value: string;
|
||||
}
|
||||
|
||||
export interface ReferenceTypeSourceBaseDependency{
|
||||
referenceTypeCode: string;
|
||||
key: string;
|
||||
required: boolean;
|
||||
properties: DependencyProperty[];
|
||||
}
|
||||
|
||||
export interface DependencyProperty{
|
||||
code: string;
|
||||
target: string;
|
||||
required: boolean;
|
||||
}
|
||||
|
||||
|
||||
// Persist
|
||||
|
||||
export interface ReferenceTypePersist extends BaseEntityPersist{
|
||||
|
@ -118,7 +111,7 @@ export interface ReferenceTypeSourceBaseConfigurationPersist extends ReferenceTy
|
|||
key: string;
|
||||
label: string;
|
||||
ordinal: number;
|
||||
dependencies?: ReferenceTypeSourceBaseDependencyPersist[];
|
||||
referenceTypeDependencyIds?: Guid[];
|
||||
}
|
||||
|
||||
export interface ReferenceTypeSourceExternalApiConfigurationPersist{
|
||||
|
@ -126,8 +119,6 @@ export interface ReferenceTypeSourceExternalApiConfigurationPersist{
|
|||
results: ResultsConfigurationPersist;
|
||||
paginationPath: string;
|
||||
contentType: string;
|
||||
// toDo move to a general query
|
||||
//funderQuery?: string;
|
||||
firstPage: string;
|
||||
httpMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||
requestBody?: string;
|
||||
|
@ -158,10 +149,17 @@ export interface AuthenticationConfigurationPersist{
|
|||
}
|
||||
|
||||
export interface QueryConfigPersist{
|
||||
condition: string;
|
||||
name: string;
|
||||
defaultValue: string;
|
||||
cases: QueryCaseConfigPersist[];
|
||||
}
|
||||
|
||||
export interface QueryCaseConfigPersist{
|
||||
likePattern: string,
|
||||
separator: string;
|
||||
value: string;
|
||||
ordinal: number;
|
||||
referenceTypeId: Guid;
|
||||
referenceTypeSourceKey: string
|
||||
}
|
||||
|
||||
export interface ReferenceTypeSourceStaticOptionConfigurationPersist {
|
||||
|
@ -172,16 +170,3 @@ export interface ReferenceTypeStaticOptionPersist{
|
|||
code: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface ReferenceTypeSourceBaseDependencyPersist{
|
||||
referenceTypeCode: string;
|
||||
key: string;
|
||||
required: boolean;
|
||||
properties: DependencyPropertyPersist[];
|
||||
}
|
||||
|
||||
export interface DependencyPropertyPersist{
|
||||
code: string;
|
||||
target: string;
|
||||
required: boolean;
|
||||
}
|
||||
|
|
|
@ -173,11 +173,19 @@
|
|||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.ORDINAL' | translate}}</mat-label>
|
||||
<input matInput type="text" name="ordinal" [formControl]="source.get('ordinal')" required>
|
||||
<input matInput type="number" name="ordinal" [formControl]="source.get('ordinal')" required>
|
||||
<mat-error *ngIf="source.get('ordinal').hasError('backendError')">{{source.get('ordinal').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="source.get('ordinal').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.DEPENDENCIES' | translate}}</mat-label>
|
||||
<app-multiple-auto-complete [formControl]="source.get('referenceTypeDependencyIds')" [configuration]="referenceTypeService.multipleAutocompleteConfiguration"></app-multiple-auto-complete>
|
||||
<mat-error *ngIf="source.get('referenceTypeDependencyIds').hasError('backendError')">{{source.get('referenceTypeDependencyIds').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="source.get('referenceTypeDependencyIds').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.SOURCE-TYPE' | translate}}</mat-label>
|
||||
|
@ -348,7 +356,7 @@
|
|||
</div>
|
||||
<!-- Queries info -->
|
||||
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.QUERIES' | translate}}
|
||||
<button mat-button type="button" (click)="addQuery(sourceIndex)" [disabled]="formGroup.disabled">{{'REFERENCE-TYPE-EDITOR.ACTIONS.ADD-QUERY' | translate}}</button>
|
||||
<button mat-button type="button" class="action-btn" (click)="addQuery(sourceIndex)" [disabled]="formGroup.disabled">{{'REFERENCE-TYPE-EDITOR.ACTIONS.ADD-QUERY' | translate}}</button>
|
||||
</h3>
|
||||
<div class="col-12">
|
||||
<div *ngFor="let query of source.get('queries').controls; let queryIndex=index;" class="row mb-3">
|
||||
|
@ -363,45 +371,101 @@
|
|||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button mat-button class="action-btn" type="button" (click)="addCase(sourceIndex, queryIndex)" [disabled]="formGroup.disabled">{{'REFERENCE-TYPE-EDITOR.ACTIONS.ADD-CASE' | translate}}</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CONDITION' | translate}}</mat-label>
|
||||
<input matInput type="text" name="condition" [formControl]="query.get('condition')" required>
|
||||
<mat-error *ngIf="query.get('condition').hasError('backendError')">{{query.get('condition').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="query.get('condition').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.NAME' | translate}}</mat-label>
|
||||
<input matInput type="text" name="name" [formControl]="query.get('name')" required>
|
||||
<mat-error *ngIf="query.get('name').hasError('backendError')">{{query.get('name').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="query.get('name').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.SEPARATOR' | translate}}</mat-label>
|
||||
<input matInput type="text" name="separator" [formControl]="query.get('separator')" required>
|
||||
<mat-error *ngIf="query.get('separator').hasError('backendError')">{{query.get('separator').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="query.get('separator').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.VALUE' | translate}}</mat-label>
|
||||
<input matInput type="text" name="value" [formControl]="query.get('value')" required>
|
||||
<mat-error *ngIf="query.get('value').hasError('backendError')">{{query.get('value').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="query.get('value').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.ORDINAL' | translate}}</mat-label>
|
||||
<input matInput type="text" name="value" [formControl]="query.get('ordinal')" required>
|
||||
<mat-error *ngIf="query.get('ordinal').hasError('backendError')">{{query.get('ordinal').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="query.get('ordinal').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.DEFAULT-VALUE' | translate}}</mat-label>
|
||||
<input matInput type="text" name="defaultValue" [formControl]="query.get('defaultValue')">
|
||||
<mat-error *ngIf="query.get('defaultValue').hasError('backendError')">{{query.get('defaultValue').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="query.get('defaultValue').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</div>
|
||||
<!-- Query Cases -->
|
||||
<div *ngFor="let case of query.get('cases').controls; let caseIndex=index;" class="row mb-3">
|
||||
<div class="col-12">
|
||||
<mat-card-header>
|
||||
<div class="row mb-3 d-flex align-items-center">
|
||||
<div class="col-auto d-flex">
|
||||
<h4 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.CASE' | translate}} {{caseIndex + 1}}</h4>
|
||||
</div>
|
||||
<div class="col-auto d-flex">
|
||||
<button mat-icon-button class="action-list-icon" matTooltip="{{'REFERENCE-TYPE-EDITOR.ACTIONS.REMOVE-CASE' | translate}}" (click)="removeCase(sourceIndex, queryIndex, caseIndex)" [disabled]="formGroup.disabled">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.LIKE-PATTERN' | translate}}</mat-label>
|
||||
<input matInput type="text" name="likePattern" [formControl]="case.get('likePattern')">
|
||||
<mat-error *ngIf="case.get('likePattern').hasError('backendError')">{{case.get('likePattern').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="case.get('likePattern').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.SEPARATOR' | translate}}</mat-label>
|
||||
<input matInput type="text" name="separator" [formControl]="case.get('separator')">
|
||||
<mat-error *ngIf="case.get('separator').hasError('backendError')">{{case.get('separator').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="case.get('separator').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.VALUE' | translate}}</mat-label>
|
||||
<input matInput type="text" name="value" [formControl]="case.get('value')">
|
||||
<mat-error *ngIf="case.get('value').hasError('backendError')">{{case.get('value').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="case.get('value').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.REFERENCE-TYPE' | translate}}</mat-label>
|
||||
<mat-select (selectionChange)="selectedReferenceTypeChanged($event.value)" name="referenceTypeId" [formControl]="case.get('referenceTypeId')">
|
||||
<mat-option *ngFor="let referenceType of referenceTypes" [value]="referenceType.id">
|
||||
{{referenceType.code}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="case.get('referenceTypeId').hasError('backendError')">{{case.get('referenceTypeId').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="case.get('referenceTypeId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6" *ngIf="case.get('referenceTypeId').value">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.SOURCE-KEY' | translate}}</mat-label>
|
||||
<mat-select name = 'referenceTypeSourceKey' [formControl]="case.get('referenceTypeSourceKey')">
|
||||
<mat-option *ngFor="let sourceKey of sourceKeysMap.get(case.get('referenceTypeId').value)" [value]="sourceKey">
|
||||
{{sourceKey}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="case.get('referenceTypeSourceKey').hasError('backendError')">{{case.get('referenceTypeSourceKey').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="case.get('referenceTypeSourceKey').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -442,123 +506,6 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Dependencies -->
|
||||
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.DEPENDENCIES' | translate}}
|
||||
<button mat-button type="button" (click)="addDependency(sourceIndex)" [disabled]="formGroup.disabled">{{'REFERENCE-TYPE-EDITOR.ACTIONS.ADD-DEPENDENCY' | translate}}</button>
|
||||
</h3>
|
||||
<div class="col-12">
|
||||
<div *ngFor="let dependency of source.get('dependencies').controls; let dependencyIndex= index;" class="row mb-3">
|
||||
<div class="col-12">
|
||||
<mat-card-header>
|
||||
<div class="row mb-3 d-flex align-items-center">
|
||||
<div class="col-auto d-flex">
|
||||
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.DEPENDENCY' | translate}} {{dependencyIndex + 1}}</h3>
|
||||
</div>
|
||||
<div class="col-auto d-flex">
|
||||
<button mat-icon-button class="action-list-icon" matTooltip="{{'REFERENCE-TYPE-EDITOR.ACTIONS.REMOVE-DEPENDENCY' | translate}}" (click)="removeDependency(sourceIndex, dependencyIndex)" [disabled]="formGroup.disabled">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
||||
<mat-select (selectionChange)="selectedReferenceTypeChanged($event.value)" name="referenceTypeCode" [formControl]="dependency.get('referenceTypeCode')" required>
|
||||
<mat-option *ngFor="let referenceType of referenceTypes" [value]="referenceType.code">
|
||||
{{referenceType.code}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="dependency.get('referenceTypeCode').hasError('backendError')">{{dependency.get('referenceTypeCode').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="dependency.get('referenceTypeCode').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6" *ngIf="dependency.get('referenceTypeCode').value">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.KEY' | translate}}</mat-label>
|
||||
<mat-select name = 'key' [formControl]="dependency.get('key')" required>
|
||||
<mat-option *ngFor="let key of sourceKeysMap.get(dependency.get('referenceTypeCode').value)" [value]="key">
|
||||
{{key}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="dependency.get('key').hasError('backendError')">{{dependency.get('key').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="dependency.get('key').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.REQUIRED' | translate}}</mat-label>
|
||||
<input matInput type="text" name="required" [formControl]="dependency.get('required')" required>
|
||||
<mat-error *ngIf="dependency.get('required').hasError('backendError')">{{dependency.get('required').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="dependency.get('required').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Properties -->
|
||||
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.PROPERTIES' | translate}}
|
||||
<button mat-button type="button" (click)="addProperty(sourceIndex, dependencyIndex)" [disabled]="formGroup.disabled">{{'REFERENCE-TYPE-EDITOR.ACTIONS.ADD-PROPERTY' | translate}}</button>
|
||||
</h3>
|
||||
<div class="col-12">
|
||||
<div *ngFor="let property of dependency.get('properties').controls; let propertyIndex= 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">
|
||||
<h4>{{'REFERENCE-TYPE-EDITOR.FIELDS.PROPERTY' | translate}} {{propertyIndex + 1}}</h4>
|
||||
</div>
|
||||
<div class="col-auto d-flex">
|
||||
<button mat-icon-button class="action-list-icon" matTooltip="{{'REFERENCE-TYPE-EDITOR.ACTIONS.REMOVE-PROPERTY' | translate}}" (click)="removeProperty(sourceIndex, dependencyIndex, propertyIndex)" [disabled]="formGroup.disabled">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
||||
<mat-select name="code" [formControl]="property.get('code')" required>
|
||||
<mat-option *ngFor="let code of propertyCodes" [value]="code">
|
||||
{{code}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="property.get('code').hasError('backendError')">{{property.get('code').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="property.get('code').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.TARGET' | translate}}</mat-label>
|
||||
<mat-select name = 'target' [formControl]="property.get('target')" required>
|
||||
<mat-option *ngFor="let targetCode of targetPropertyCodesMap.get(dependency.get('referenceTypeCode').value)" [value]="targetCode">
|
||||
{{targetCode}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="property.get('target').hasError('backendError')">{{property.get('target').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="property.get('target').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.REQUIRED' | translate}}</mat-label>
|
||||
<input matInput type="text" name="required" [formControl]="property.get('required')" required>
|
||||
<mat-error *ngIf="property.get('required').hasError('backendError')">{{property.get('required').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="property.get('required').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<mat-error *ngIf="dependency.get('properties').dirty && dependency.get('properties').hasError('required')">{{'REFERENCE-TYPE-EDITOR.SOURCES-REQUIRED' | translate}}</mat-error>
|
||||
<mat-error *ngIf="dependency.get('properties').hasError('backendError')">{{dependency.get('properties').getError('backendError').message}}</mat-error>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</div>
|
||||
|
@ -567,6 +514,7 @@
|
|||
<mat-error *ngIf="formGroup.get('definition').get('sources').hasError('backendError')">{{formGroup.get('definition').get('sources').getError('backendError').message}}</mat-error>
|
||||
</div>
|
||||
</form>
|
||||
{{formGroup.value | json}}
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import { FilterService } from '@common/modules/text-filter/filter-service';
|
|||
import { Guid } from '@common/types/guid';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { map, takeUntil } from 'rxjs/operators';
|
||||
import { DependencyPropertyEditorModel, QueryConfigEditorModel, ReferenceTypeDefinitionEditorModel, ReferenceTypeEditorModel, ReferenceTypeFieldEditorModel, ReferenceTypeSourceBaseConfigurationEditorModel, ReferenceTypeSourceBaseDependencyEditorModel, ReferenceTypeStaticOptionEditorModel, ResultFieldsMappingConfigurationEditorModel } from './reference-type-editor.model';
|
||||
import { ReferenceTypeEditorModel} from './reference-type-editor.model';
|
||||
import { ReferenceTypeEditorResolver } from './reference-type-editor.resolver';
|
||||
import { ReferenceTypeEditorService } from './reference-type-editor.service';
|
||||
|
||||
|
@ -48,11 +48,7 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
public referenceFieldDataTypeEnum = this.enumUtils.getEnumValues<ReferenceFieldDataType>(ReferenceFieldDataType);
|
||||
public referenceTypeExternalApiHTTPMethodTypeEnum = this.enumUtils.getEnumValues<ReferenceTypeExternalApiHTTPMethodType>(ReferenceTypeExternalApiHTTPMethodType);
|
||||
referenceTypes: ReferenceType[] = null;
|
||||
sourceKeys: string[] = [];
|
||||
sourceKeysMap: Map<string, string[]> = new Map<string, string[]>();
|
||||
propertyCodes: string[] = [];
|
||||
targetPropertyCodes: string[] = [];
|
||||
targetPropertyCodesMap: Map<string, string[]> = new Map<string, string[]>();
|
||||
sourceKeysMap: Map<Guid, string[]> = new Map<Guid, string[]>();
|
||||
|
||||
protected get canDelete(): boolean {
|
||||
return !this.isDeleted && !this.isNew && this.hasPermission(this.authService.permissionEnum.DeleteReferenceType);
|
||||
|
@ -86,7 +82,7 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
// Rest dependencies. Inject any other needed deps here:
|
||||
public authService: AuthService,
|
||||
public enumUtils: EnumUtils,
|
||||
private referenceTypeService: ReferenceTypeService,
|
||||
public referenceTypeService: ReferenceTypeService,
|
||||
private logger: LoggingService,
|
||||
private referenceTypeEditorService: ReferenceTypeEditorService
|
||||
) {
|
||||
|
@ -114,18 +110,13 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
this.editorModel = data ? new ReferenceTypeEditorModel().fromModel(data) : new ReferenceTypeEditorModel();
|
||||
|
||||
this.getReferenceTypes(this.editorModel.id);
|
||||
this.propertyCodes = this.referenceTypeService.getSystemFields([]);
|
||||
|
||||
if (data) {
|
||||
this.editorModel.definition.sources.forEach(source => source.dependencies.forEach(dependency => {
|
||||
this.selectedReferenceTypeChanged(dependency.referenceTypeCode);
|
||||
data.definition.sources?.forEach(source => source.queries?.forEach(query => {
|
||||
query?.cases?.forEach(queryCase => {
|
||||
this.selectedReferenceTypeChanged(queryCase.referenceType.id);
|
||||
})
|
||||
}));
|
||||
|
||||
this.editorModel.definition.fields.forEach(field => {
|
||||
if (!this.propertyCodes.includes(field.code)) {
|
||||
this.propertyCodes.push(field.code);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
|
||||
|
@ -217,15 +208,10 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
}
|
||||
|
||||
removeField(fieldIndex: number): void {
|
||||
const fieldCode = (this.formGroup.get('definition').get('fields') as FormArray).at(fieldIndex).get('code').value
|
||||
const fieldForm = this.formGroup.get('definition').get('fields') as FormArray;
|
||||
const fieldCode = fieldForm.at(fieldIndex).get('code').value;
|
||||
|
||||
if (this.propertyCodes.length > 0) {
|
||||
if (this.propertyCodes.includes(fieldCode)) {
|
||||
this.propertyCodes.splice(this.propertyCodes.indexOf(fieldCode), 1);
|
||||
}
|
||||
}
|
||||
|
||||
(this.formGroup.get('definition').get('fields') as FormArray).removeAt(fieldIndex);
|
||||
fieldForm.removeAt(fieldIndex);
|
||||
|
||||
//Reapply validators
|
||||
ReferenceTypeEditorModel.reApplyDefinitionFieldsValidators(
|
||||
|
@ -234,22 +220,24 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
validationErrorModel: this.editorModel.validationErrorModel
|
||||
}
|
||||
)
|
||||
this.formGroup.get('definition').get('fields').markAsDirty();
|
||||
fieldForm.markAsDirty();
|
||||
|
||||
const sourceFormArray = ((this.formGroup.get('definition').get('sources') as FormArray));
|
||||
for (let i = 0; i < sourceFormArray.length; i++) {
|
||||
const sourceFormArray = (this.formGroup.get('definition').get('sources') as FormArray);
|
||||
if(sourceFormArray){
|
||||
for (let i = 0; i < sourceFormArray.length; i++) {
|
||||
|
||||
const optionsFormArray = ((this.formGroup.get('definition').get('sources') as FormArray).at(i).get('options') as FormArray);
|
||||
for (let j = 0; j < optionsFormArray.length; j++) {
|
||||
if (fieldCode == ((this.formGroup.get('definition').get('sources') as FormArray).at(i).get('options') as FormArray).at(j).get('code').getRawValue()) {
|
||||
this.removeOption(i, j);
|
||||
const optionsFormArray = (sourceFormArray.at(i).get('options') as FormArray);
|
||||
for (let j = 0; j < optionsFormArray.length; j++) {
|
||||
if (fieldCode == optionsFormArray.at(j).get('code').getRawValue()) {
|
||||
this.removeOption(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const fieldMappingFormArray = ((this.formGroup.get('definition').get('sources') as FormArray).at(i).get('results').get('fieldsMapping') as FormArray);
|
||||
for (let j = 0; j < fieldMappingFormArray.length; j++) {
|
||||
if (fieldCode == ((this.formGroup.get('definition').get('sources') as FormArray).at(i).get('results').get('fieldsMapping') as FormArray).at(j).get('code').getRawValue()) {
|
||||
this.removeFieldMapping(i, j);
|
||||
const fieldMappingFormArray = (sourceFormArray.at(i).get('results').get('fieldsMapping') as FormArray);
|
||||
for (let j = 0; j < fieldMappingFormArray.length; j++) {
|
||||
if (fieldCode == fieldMappingFormArray.at(j).get('code').getRawValue()) {
|
||||
this.removeFieldMapping(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -266,10 +254,6 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
for (let i = 0; i < fieldsFormArray.length; i++) {
|
||||
this.addFieldMapping(j, fieldsFormArray.at(i).get('code').value);
|
||||
this.addOption(j, fieldsFormArray.at(i).get('code').value);
|
||||
|
||||
if (!this.propertyCodes.includes(fieldsFormArray.at(i).get('code').value)) {
|
||||
this.propertyCodes.push(fieldsFormArray.at(i).get('code').value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -299,7 +283,8 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
}
|
||||
|
||||
removeSource(sourceIndex: number): void {
|
||||
(this.formGroup.get('definition').get('sources') as FormArray).removeAt(sourceIndex);
|
||||
const formArray = (this.formGroup.get('definition').get('sources') as FormArray);
|
||||
formArray.removeAt(sourceIndex);
|
||||
|
||||
ReferenceTypeEditorModel.reApplyDefinitionSourcesValidators(
|
||||
{
|
||||
|
@ -307,7 +292,7 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
validationErrorModel: this.editorModel.validationErrorModel
|
||||
}
|
||||
)
|
||||
this.formGroup.get('definition').get('sources').markAsDirty();
|
||||
formArray.markAsDirty();
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -316,7 +301,6 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
//
|
||||
//
|
||||
addFieldMapping(sourceIndex: number, code: string): void {
|
||||
const fieldMapping: ResultFieldsMappingConfigurationEditorModel = new ResultFieldsMappingConfigurationEditorModel();
|
||||
const fieldMappingSize = ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('results').get('fieldsMapping') as FormArray).length;
|
||||
|
||||
if (fieldMappingSize > 0) {
|
||||
|
@ -366,13 +350,32 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
validationErrorModel: this.editorModel.validationErrorModel
|
||||
}
|
||||
);
|
||||
(this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('queries').markAsDirty();
|
||||
formArray.markAsDirty();
|
||||
}
|
||||
|
||||
// cases
|
||||
|
||||
addCase(sourceIndex: number, queryIndex: number): void {
|
||||
const formArray = ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('queries') as FormArray).at(queryIndex).get('cases') as FormArray;
|
||||
formArray.push(this.editorModel.createCase(sourceIndex, queryIndex, formArray.length));
|
||||
}
|
||||
|
||||
removeCase(sourceIndex: number, queryIndex: number, index: number): void {
|
||||
const formArray = ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('queries') as FormArray).at(queryIndex).get('cases') as FormArray;
|
||||
formArray.removeAt(index);
|
||||
|
||||
ReferenceTypeEditorModel.reApplyDefinitionSourcesValidators(
|
||||
{
|
||||
formGroup: this.formGroup,
|
||||
validationErrorModel: this.editorModel.validationErrorModel
|
||||
}
|
||||
);
|
||||
formArray.markAsDirty();
|
||||
}
|
||||
|
||||
// Options
|
||||
|
||||
addOption(sourceIndex: number, code: string): void {
|
||||
const options: ReferenceTypeStaticOptionEditorModel = new ReferenceTypeStaticOptionEditorModel();
|
||||
const optionsSize = ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('options') as FormArray).length;
|
||||
|
||||
if (optionsSize > 0) {
|
||||
|
@ -400,30 +403,6 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
(this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('options').markAsDirty();
|
||||
}
|
||||
|
||||
|
||||
// Dependencies
|
||||
|
||||
addDependency(sourceIndex: number): void {
|
||||
|
||||
const depedencySize = ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('dependencies') as FormArray).length;
|
||||
((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('dependencies') as FormArray)
|
||||
.push(this.editorModel.createDepedency(sourceIndex, depedencySize));
|
||||
//this.addProperty(sourceIndex, (depedencySize));
|
||||
}
|
||||
|
||||
removeDependency(sourceIndex: number, dependencyIndex: number): void {
|
||||
const formArray = ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('dependencies') as FormArray);
|
||||
formArray.removeAt(dependencyIndex);
|
||||
|
||||
ReferenceTypeEditorModel.reApplyDefinitionSourcesValidators(
|
||||
{
|
||||
formGroup: this.formGroup,
|
||||
validationErrorModel: this.editorModel.validationErrorModel
|
||||
}
|
||||
);
|
||||
(this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('dependencies').markAsDirty();
|
||||
}
|
||||
|
||||
private getReferenceTypes(excludedId?: Guid): void {
|
||||
|
||||
const lookup = ReferenceTypeService.DefaultReferenceTypeLookup();
|
||||
|
@ -434,73 +413,29 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
.subscribe(response => {
|
||||
this.referenceTypes = response.items as ReferenceType[];
|
||||
this.referenceTypes.forEach(referenceType => {
|
||||
this.sourceKeysMap.set(referenceType.code, []);
|
||||
this.targetPropertyCodesMap.set(referenceType.code, []);
|
||||
this.sourceKeysMap.set(referenceType.id, []);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
selectedReferenceTypeChanged(code: string): void {
|
||||
this.sourceKeys = [];
|
||||
this.targetPropertyCodes = [];
|
||||
selectedReferenceTypeChanged(id: Guid): void {
|
||||
let sourceKeys: string[] = [];
|
||||
|
||||
this.referenceTypeService.getSingleWithCode(code, ReferenceTypeEditorResolver.lookupFields())
|
||||
this.referenceTypeService.getSingle(id, ReferenceTypeEditorResolver.lookupFields())
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(data => {
|
||||
const referenceType = data as ReferenceType;
|
||||
|
||||
// source keys
|
||||
referenceType.definition.sources.forEach(source => {
|
||||
if (!this.sourceKeys.includes(source.key)) this.sourceKeys.push(source.key)
|
||||
if (!sourceKeys.includes(source.key)) sourceKeys.push(source.key)
|
||||
});
|
||||
|
||||
if (this.sourceKeysMap.has(code) && this.sourceKeysMap.get(code).length == 0) {
|
||||
this.sourceKeysMap.set(code, this.sourceKeys);
|
||||
if (this.sourceKeysMap.has(referenceType.id) && this.sourceKeysMap.get(referenceType.id).length == 0) {
|
||||
this.sourceKeysMap.set(referenceType.id, sourceKeys);
|
||||
}
|
||||
|
||||
// targetPropertyCodes
|
||||
|
||||
let fields = [];
|
||||
if (referenceType.definition.fields) {
|
||||
fields = this.referenceTypeService.getSystemFields(referenceType.definition.fields.map(x => x.code));
|
||||
} else {
|
||||
fields = this.referenceTypeService.getSystemFields(fields);
|
||||
}
|
||||
|
||||
fields.forEach(field => {
|
||||
if (!this.targetPropertyCodes.includes(field)) this.targetPropertyCodes.push(field)
|
||||
})
|
||||
|
||||
if (this.targetPropertyCodesMap.has(code) && this.targetPropertyCodesMap.get(code).length == 0) {
|
||||
this.targetPropertyCodesMap.set(code, this.targetPropertyCodes);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Properties
|
||||
addProperty(sourceIndex: number, dependencyIndex: number): void {
|
||||
|
||||
if (((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('dependencies') as FormArray).at(dependencyIndex).get('referenceTypeCode').value == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const formArray = ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('dependencies') as FormArray).at(dependencyIndex).get("properties") as FormArray
|
||||
formArray.push(this.editorModel.createProperty(sourceIndex, dependencyIndex, formArray.length));
|
||||
}
|
||||
|
||||
removeProperty(sourceIndex: number, dependencyIndex: number, propertyIndex: number): void {
|
||||
const formArray = (((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('dependencies') as FormArray).at(dependencyIndex).get("properties") as FormArray);
|
||||
formArray.removeAt(propertyIndex);
|
||||
|
||||
ReferenceTypeEditorModel.reApplyDefinitionSourcesValidators(
|
||||
{
|
||||
formGroup: this.formGroup,
|
||||
validationErrorModel: this.editorModel.validationErrorModel
|
||||
}
|
||||
);
|
||||
((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('dependencies') as FormArray).at(dependencyIndex).get("properties").markAsDirty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,11 +2,12 @@ import { FormArray, UntypedFormArray, UntypedFormBuilder, UntypedFormGroup, Vali
|
|||
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 { ReferenceTypeSourceType } from "@app/core/common/enum/reference-type-source-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 { AuthenticationConfiguration, AuthenticationConfigurationPersist, QueryCaseConfig, QueryCaseConfigPersist, QueryConfig, QueryConfigPersist, ReferenceType, ReferenceTypeDefinition, ReferenceTypeDefinitionPersist, ReferenceTypeField, ReferenceTypeFieldPersist, ReferenceTypePersist, ReferenceTypeSourceBaseConfiguration, ReferenceTypeSourceBaseConfigurationPersist, ReferenceTypeStaticOption, ReferenceTypeStaticOptionPersist, ResultFieldsMappingConfiguration, ResultFieldsMappingConfigurationPersist, ResultsConfiguration, ResultsConfigurationPersist } from "@app/core/model/reference-type/reference-type";
|
||||
import { BaseEditorModel } from "@common/base/base-form-editor-model";
|
||||
import { BackendErrorValidator } from "@common/forms/validation/custom-validator";
|
||||
import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model";
|
||||
import { Validation, ValidationContext } from "@common/forms/validation/validation-context";
|
||||
import { Guid } from "@common/types/guid";
|
||||
|
||||
export class ReferenceTypeEditorModel extends BaseEditorModel implements ReferenceTypePersist {
|
||||
name: string;
|
||||
|
@ -84,14 +85,9 @@ export class ReferenceTypeEditorModel extends BaseEditorModel implements Referen
|
|||
return query.buildForm({ rootPath: 'definition.sources[' + sourceIndex + '].queries[' + index + '].'});
|
||||
}
|
||||
|
||||
createDepedency(sourceIndex: number, index: number): UntypedFormGroup {
|
||||
const dependency: ReferenceTypeSourceBaseDependencyEditorModel = new ReferenceTypeSourceBaseDependencyEditorModel(this.validationErrorModel);
|
||||
return dependency.buildForm({ rootPath: 'definition.sources[' + sourceIndex + '].dependencies[' + index + '].'});
|
||||
}
|
||||
|
||||
createProperty(sourceIndex: number, dependencyIndex: number, index: number): UntypedFormGroup {
|
||||
const property: DependencyPropertyEditorModel = new DependencyPropertyEditorModel(this.validationErrorModel);
|
||||
return property.buildForm({ rootPath: 'definition.sources[' + sourceIndex + '].dependencies[' + dependencyIndex + '].properties[' + index + '].'});
|
||||
createCase(sourceIndex: number, queryIndex: number, index: number): UntypedFormGroup {
|
||||
const queryCase: QueryCaseConfigEditorModel = new QueryCaseConfigEditorModel(this.validationErrorModel);
|
||||
return queryCase.buildForm({ rootPath: 'definition.sources[' + sourceIndex + '].queries[' + queryIndex + '].cases[' + index + '].'});
|
||||
}
|
||||
|
||||
static reApplyDefinitionFieldsValidators(params: {
|
||||
|
@ -166,9 +162,7 @@ export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefiniti
|
|||
),
|
||||
sources: this.formBuilder.array(
|
||||
(this.sources ?? []).map(
|
||||
(item, index) => new ReferenceTypeSourceBaseConfigurationEditorModel(
|
||||
this.validationErrorModel
|
||||
).fromModel(item).buildForm({
|
||||
(item, index) =>item.buildForm({
|
||||
rootPath: `${rootPath}sources[${index}].`
|
||||
})
|
||||
), context.getValidation('sources').validators
|
||||
|
@ -322,7 +316,7 @@ export class ReferenceTypeSourceBaseConfigurationEditorModel implements Referenc
|
|||
|
||||
options: ReferenceTypeStaticOptionEditorModel[] = [];
|
||||
|
||||
dependencies: ReferenceTypeSourceBaseDependencyEditorModel[] = [];
|
||||
referenceTypeDependencyIds: Guid[] = [];
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
|
@ -356,7 +350,7 @@ export class ReferenceTypeSourceBaseConfigurationEditorModel implements Referenc
|
|||
this.options.push(new ReferenceTypeStaticOptionEditorModel().fromModel({ code: 'description', value: undefined }));
|
||||
}
|
||||
|
||||
if (item.dependencies) { item.dependencies.map(x => this.dependencies.push(new ReferenceTypeSourceBaseDependencyEditorModel(this.validationErrorModel).fromModel(x))); }
|
||||
if (item.referenceTypeDependencies) { item.referenceTypeDependencies.forEach(referenceType => this.referenceTypeDependencyIds.push(referenceType.id))}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -395,9 +389,7 @@ export class ReferenceTypeSourceBaseConfigurationEditorModel implements Referenc
|
|||
}),
|
||||
queries: this.formBuilder.array(
|
||||
(this.queries ?? []).map(
|
||||
(item, index) => new QueryConfigEditorModel(
|
||||
this.validationErrorModel
|
||||
).fromModel(item).buildForm({
|
||||
(item, index) => item.buildForm({
|
||||
rootPath: `${rootPath}queries[${index}].`
|
||||
})
|
||||
), context.getValidation('queries').validators
|
||||
|
@ -411,15 +403,7 @@ export class ReferenceTypeSourceBaseConfigurationEditorModel implements Referenc
|
|||
})
|
||||
), context.getValidation('options').validators
|
||||
),
|
||||
dependencies: this.formBuilder.array(
|
||||
(this.dependencies ?? []).map(
|
||||
(item, index) => new ReferenceTypeSourceBaseDependencyEditorModel(
|
||||
this.validationErrorModel
|
||||
).fromModel(item).buildForm({
|
||||
rootPath: `${rootPath}dependencies[${index}].`
|
||||
})
|
||||
), context.getValidation('dependencies').validators
|
||||
)
|
||||
referenceTypeDependencyIds: [{ value: this.referenceTypeDependencyIds, disabled: disabled }, context.getValidation('referenceTypeDependencyIds').validators],
|
||||
|
||||
});
|
||||
}
|
||||
|
@ -449,7 +433,7 @@ export class ReferenceTypeSourceBaseConfigurationEditorModel implements Referenc
|
|||
|
||||
baseValidationArray.push({ key: 'options', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}options`)] });
|
||||
|
||||
baseValidationArray.push({ key: 'dependencies', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}dependencies`)] });
|
||||
baseValidationArray.push({ key: 'referenceTypeDependencyIds', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeDependencyIds`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
|
@ -467,7 +451,7 @@ export class ReferenceTypeSourceBaseConfigurationEditorModel implements Referenc
|
|||
validationErrorModel
|
||||
});
|
||||
|
||||
['type', 'key', 'label', 'ordinal', 'url', 'paginationPath', 'contentType', 'firstPage', 'httpMethod', 'requestBody','filterType'].forEach(keyField => {
|
||||
['type', 'key', 'label', 'ordinal', 'url', 'paginationPath', 'contentType', 'firstPage', 'httpMethod', 'requestBody','filterType', 'referenceTypeDependencyIds'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
|
@ -502,13 +486,6 @@ export class ReferenceTypeSourceBaseConfigurationEditorModel implements Referenc
|
|||
})
|
||||
);
|
||||
|
||||
(formGroup.get('dependencies') as FormArray).controls?.forEach(
|
||||
(control, index) => ReferenceTypeSourceBaseDependencyEditorModel.reapplyDepedencyValidators({
|
||||
formGroup: control as UntypedFormGroup,
|
||||
rootPath: `${rootPath}dependencies[${index}].`,
|
||||
validationErrorModel: validationErrorModel
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -526,9 +503,9 @@ export class ResultsConfigurationEditorModel implements ResultsConfigurationPers
|
|||
this.resultsArrayPath = item.resultsArrayPath;
|
||||
if (item.fieldsMapping) { item.fieldsMapping.map(x => this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel(x))); }
|
||||
else {
|
||||
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: 'description', responsePath: undefined }));
|
||||
this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel({ code: 'reference_id', responsePath: undefined }));
|
||||
this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel({ code: 'label', responsePath: undefined }));
|
||||
this.fieldsMapping.push(new ResultFieldsMappingConfigurationEditorModel(this.validationErrorModel).fromModel({ code: 'description', responsePath: undefined }));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -764,10 +741,9 @@ export class AuthenticationConfigurationEditorModel implements AuthenticationCon
|
|||
}
|
||||
|
||||
export class QueryConfigEditorModel implements QueryConfigPersist {
|
||||
public condition: string;
|
||||
public separator: string;
|
||||
public value: string;
|
||||
public ordinal: number;
|
||||
public name: string;
|
||||
public defaultValue: string;
|
||||
public cases: QueryCaseConfigEditorModel[] = [];
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
|
@ -776,10 +752,9 @@ export class QueryConfigEditorModel implements QueryConfigPersist {
|
|||
) { }
|
||||
|
||||
fromModel(item: QueryConfig): QueryConfigEditorModel {
|
||||
this.condition = item.condition;
|
||||
this.separator = item.separator;
|
||||
this.value = item.value;
|
||||
this.ordinal = item.ordinal;
|
||||
this.name = item.name;
|
||||
this.defaultValue = item.defaultValue;
|
||||
if (item.cases) { item.cases.map(x => this.cases.push(new QueryCaseConfigEditorModel(this.validationErrorModel).fromModel(x))); }
|
||||
|
||||
return this;
|
||||
}
|
||||
|
@ -798,10 +773,15 @@ export class QueryConfigEditorModel implements QueryConfigPersist {
|
|||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
condition: [{ value: this.condition, disabled: disabled }, context.getValidation('condition').validators],
|
||||
separator: [{ value: this.separator, disabled: disabled }, context.getValidation('separator').validators],
|
||||
value: [{ value: this.value, disabled: disabled }, context.getValidation('value').validators],
|
||||
ordinal: [{ value: this.ordinal, disabled: disabled }, context.getValidation('ordinal').validators],
|
||||
name: [{ value: this.name, disabled: disabled }, context.getValidation('name').validators],
|
||||
defaultValue: [{ value: this.defaultValue, disabled: disabled }, context.getValidation('defaultValue').validators],
|
||||
cases: this.formBuilder.array(
|
||||
(this.cases ?? []).map(
|
||||
(item, index) => item.buildForm({
|
||||
rootPath: `${rootPath}cases[${index}].`
|
||||
})
|
||||
), context.getValidation('cases').validators
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -813,10 +793,9 @@ export class QueryConfigEditorModel implements QueryConfigPersist {
|
|||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'condition', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}condition`)] });
|
||||
baseValidationArray.push({ key: 'separator', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}separator`)] });
|
||||
baseValidationArray.push({ key: 'value', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}value`)] });
|
||||
baseValidationArray.push({ key: 'ordinal', validators: [Validators.required, Validators.pattern("^[0-9]*$"), BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] });
|
||||
baseValidationArray.push({ key: 'name', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}name`)] });
|
||||
baseValidationArray.push({ key: 'defaultValue', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}defaultValue`)] });
|
||||
baseValidationArray.push({ key: 'cases', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}cases`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
|
@ -834,7 +813,99 @@ export class QueryConfigEditorModel implements QueryConfigPersist {
|
|||
validationErrorModel
|
||||
});
|
||||
|
||||
['condition', 'separator', 'value', 'ordinal'].forEach(keyField => {
|
||||
['name', 'defaultValue'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
});
|
||||
|
||||
(formGroup.get('cases') as FormArray).controls?.forEach(
|
||||
(control, index) => QueryCaseConfigEditorModel.reapplyValidators({
|
||||
formGroup: control as UntypedFormGroup,
|
||||
rootPath: `${rootPath}cases[${index}].`,
|
||||
validationErrorModel: validationErrorModel
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class QueryCaseConfigEditorModel implements QueryCaseConfigPersist {
|
||||
public likePattern: string;
|
||||
public separator: string;
|
||||
public value: string;
|
||||
public referenceTypeId: Guid;
|
||||
public referenceTypeSourceKey: string;
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
fromModel(item: QueryCaseConfig): QueryCaseConfigEditorModel {
|
||||
this.likePattern = item.likePattern;
|
||||
this.separator = item.separator;
|
||||
this.value = item.value;
|
||||
if(item?.referenceType?.id) this.referenceTypeId = item.referenceType.id;
|
||||
this.referenceTypeSourceKey = item.referenceTypeSourceKey;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(params?: {
|
||||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = QueryCaseConfigEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
likePattern: [{ value: this.likePattern, disabled: disabled }, context.getValidation('likePattern').validators],
|
||||
separator: [{ value: this.separator, disabled: disabled }, context.getValidation('separator').validators],
|
||||
value: [{ value: this.value, disabled: disabled }, context.getValidation('value').validators],
|
||||
referenceTypeId: [{ value: this.referenceTypeId, disabled: disabled }, context.getValidation('referenceTypeId').validators],
|
||||
referenceTypeSourceKey: [{ value: this.referenceTypeSourceKey, disabled: disabled }, context.getValidation('referenceTypeSourceKey').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: 'likePattern', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}likePattern`)] });
|
||||
baseValidationArray.push({ key: 'separator', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}separator`)] });
|
||||
baseValidationArray.push({ key: 'value', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}value`)] });
|
||||
baseValidationArray.push({ key: 'referenceTypeId', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeId`)] });
|
||||
baseValidationArray.push({ key: 'referenceTypeSourceKey', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeSourceKey`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
static reapplyValidators(params: {
|
||||
formGroup: UntypedFormGroup,
|
||||
validationErrorModel: ValidationErrorModel,
|
||||
rootPath: string
|
||||
}): void {
|
||||
|
||||
const { formGroup, rootPath, validationErrorModel } = params;
|
||||
const context = QueryCaseConfigEditorModel.createValidationContext({
|
||||
rootPath,
|
||||
validationErrorModel
|
||||
});
|
||||
|
||||
['likePattern', 'separator', 'value', 'referenceTypeId', 'referenceTypeSourceKey'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
|
@ -915,174 +986,3 @@ export class ReferenceTypeStaticOptionEditorModel implements ReferenceTypeStatic
|
|||
}
|
||||
}
|
||||
|
||||
export class ReferenceTypeSourceBaseDependencyEditorModel implements ReferenceTypeSourceBaseDependencyPersist {
|
||||
public referenceTypeCode: string;
|
||||
public key: string;
|
||||
public required = true;
|
||||
public properties: DependencyPropertyEditorModel[] = [];
|
||||
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
fromModel(item: ReferenceTypeSourceBaseDependency): ReferenceTypeSourceBaseDependencyEditorModel {
|
||||
this.referenceTypeCode = item.referenceTypeCode;
|
||||
this.key = item.key;
|
||||
this.required = item.required;
|
||||
if (item.properties) { item.properties.map(x => this.properties.push(new DependencyPropertyEditorModel(this.validationErrorModel).fromModel(x))); }
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(params?: {
|
||||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = ReferenceTypeSourceBaseDependencyEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
referenceTypeCode: [{ value: this.referenceTypeCode, disabled: disabled }, context.getValidation('referenceTypeCode').validators],
|
||||
key: [{ value: this.key, disabled: disabled }, context.getValidation('key').validators],
|
||||
required: [{ value: this.required, disabled: true }, context.getValidation('required').validators],
|
||||
properties: this.formBuilder.array(
|
||||
(this.properties ?? []).map(
|
||||
(item, index) => new DependencyPropertyEditorModel(
|
||||
this.validationErrorModel
|
||||
).fromModel(item).buildForm({
|
||||
rootPath: `${rootPath}properties[${index}].`
|
||||
})
|
||||
), context.getValidation('properties').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: 'referenceTypeCode', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}referenceTypeCode`)] });
|
||||
baseValidationArray.push({ key: 'key', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}key`)] });
|
||||
baseValidationArray.push({ key: 'required', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}required`)] });
|
||||
baseValidationArray.push({ key: 'properties', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}properties`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
static reapplyDepedencyValidators(params: {
|
||||
formGroup: UntypedFormGroup,
|
||||
validationErrorModel: ValidationErrorModel,
|
||||
rootPath: string
|
||||
}): void {
|
||||
|
||||
const { formGroup, rootPath, validationErrorModel } = params;
|
||||
const context = ReferenceTypeSourceBaseDependencyEditorModel.createValidationContext({
|
||||
rootPath,
|
||||
validationErrorModel
|
||||
});
|
||||
|
||||
['referenceTypeCode', 'key', 'required'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
});
|
||||
|
||||
(formGroup.get('properties') as FormArray).controls?.forEach(
|
||||
(control, index) => DependencyPropertyEditorModel.reapplyPropertyValidators({
|
||||
formGroup: control as UntypedFormGroup,
|
||||
rootPath: `${rootPath}properties[${index}].`,
|
||||
validationErrorModel: validationErrorModel
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class DependencyPropertyEditorModel implements DependencyPropertyPersist {
|
||||
public code: string;
|
||||
public target: string;
|
||||
public required = true;
|
||||
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
fromModel(item: DependencyProperty): DependencyPropertyEditorModel {
|
||||
this.code = item.code;
|
||||
this.target = item.target;
|
||||
this.required = item.required;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(params?: {
|
||||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = DependencyPropertyEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
code: [{ value: this.code, disabled: disabled }, context.getValidation('code').validators],
|
||||
target: [{ value: this.target, disabled: disabled }, context.getValidation('target').validators],
|
||||
required: [{ value: this.required, disabled: true }, context.getValidation('required').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: 'code', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
|
||||
baseValidationArray.push({ key: 'target', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}target`)] });
|
||||
baseValidationArray.push({ key: 'required', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}required`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
static reapplyPropertyValidators(params: {
|
||||
formGroup: UntypedFormGroup,
|
||||
validationErrorModel: ValidationErrorModel,
|
||||
rootPath: string
|
||||
}): void {
|
||||
|
||||
const { formGroup, rootPath, validationErrorModel } = params;
|
||||
const context = DependencyPropertyEditorModel.createValidationContext({
|
||||
rootPath,
|
||||
validationErrorModel
|
||||
});
|
||||
|
||||
['code', 'target', 'required'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
})
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
||||
import { AuthenticationConfiguration, QueryConfig, ReferenceType, ReferenceTypeDefinition, ReferenceTypeField, ReferenceTypeSourceBaseConfiguration, ResultsConfiguration, ResultFieldsMappingConfiguration, ReferenceTypeStaticOption, ReferenceTypeSourceBaseDependency, DependencyProperty } from '@app/core/model/reference-type/reference-type';
|
||||
import { AuthenticationConfiguration, QueryConfig, ReferenceType, ReferenceTypeDefinition, ReferenceTypeField, ReferenceTypeSourceBaseConfiguration, ResultsConfiguration, ResultFieldsMappingConfiguration, ReferenceTypeStaticOption, QueryCaseConfig } from '@app/core/model/reference-type/reference-type';
|
||||
import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service';
|
||||
import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
|
||||
import { BaseEditorResolver } from '@common/base/base-editor.resolver';
|
||||
|
@ -31,6 +31,8 @@ export class ReferenceTypeEditorResolver extends BaseEditorResolver {
|
|||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.key)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.label)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.ordinal)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.referenceTypeDependencies),nameof<ReferenceType>(x => x.id)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.referenceTypeDependencies),nameof<ReferenceType>(x => x.name)].join('.'),
|
||||
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.url)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.resultsArrayPath)].join('.'),
|
||||
|
@ -52,22 +54,19 @@ export class ReferenceTypeEditorResolver extends BaseEditorResolver {
|
|||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authRequestBody)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.type)].join('.'),
|
||||
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.condition)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.separator)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.value)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.ordinal)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.name)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.defaultValue)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.likePattern)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.separator)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.value)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.referenceType)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.referenceType),nameof<ReferenceType>(x => x.id)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.referenceType),nameof<ReferenceType>(x => x.name)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.cases),nameof<QueryCaseConfig>(x => x.referenceTypeSourceKey)].join('.'),
|
||||
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.options),nameof<ReferenceTypeStaticOption>(x => x.code)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.options),nameof<ReferenceTypeStaticOption>(x => x.value)].join('.'),
|
||||
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.dependencies),nameof<ReferenceTypeSourceBaseDependency>(x => x.referenceTypeCode)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.dependencies),nameof<ReferenceTypeSourceBaseDependency>(x => x.key)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.dependencies),nameof<ReferenceTypeSourceBaseDependency>(x => x.required)].join('.'),
|
||||
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.dependencies),nameof<ReferenceTypeSourceBaseDependency>(x => x.properties), nameof<DependencyProperty>(x => x.code)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.dependencies),nameof<ReferenceTypeSourceBaseDependency>(x => x.properties), nameof<DependencyProperty>(x => x.target)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.dependencies),nameof<ReferenceTypeSourceBaseDependency>(x => x.properties), nameof<DependencyProperty>(x => x.required)].join('.'),
|
||||
|
||||
nameof<ReferenceType>(x => x.createdAt),
|
||||
nameof<ReferenceType>(x => x.updatedAt),
|
||||
nameof<ReferenceType>(x => x.isActive)
|
||||
|
|
|
@ -1496,14 +1496,13 @@
|
|||
"RESULTS-PATH": "Results Path",
|
||||
"TOKEN-PATH": "Token Path",
|
||||
"TYPE": "Type",
|
||||
"CONDITION": "Condition",
|
||||
"SEPARATOR": "Separator",
|
||||
"DEPENDENCIES": "Dependencies",
|
||||
"DEPENDENCY": "Dependency",
|
||||
"REQUIRED": "Required",
|
||||
"PROPERTIES": "Properties",
|
||||
"PROPERTY": "Property",
|
||||
"TARGET": "Target"
|
||||
"DEFAULT-VALUE": "Default Value",
|
||||
"CASE": "Case",
|
||||
"LIKE-PATTERN": "Condition",
|
||||
"SOURCE-KEY": "Source Key"
|
||||
},
|
||||
"ACTIONS": {
|
||||
"SAVE": "Save",
|
||||
|
@ -1515,10 +1514,8 @@
|
|||
"REMOVE-SOURCE": "Remove Source",
|
||||
"ADD-QUERY": "Add Query",
|
||||
"REMOVE-QUERY": "Remove Query",
|
||||
"ADD-DEPENDENCY": "Add Dependency",
|
||||
"REMOVE-DEPENDENCY": "Remove Dependency",
|
||||
"ADD-PROPERTY": "Add property",
|
||||
"REMOVE-PROPERTY": "Remove property"
|
||||
"ADD-CASE": "Add Case",
|
||||
"REMOVE-CASE": "Remove Case"
|
||||
},
|
||||
"CONFIRM-DELETE-DIALOG": {
|
||||
"MESSAGE": "Would you like to delete this Reference type?",
|
||||
|
|
Loading…
Reference in New Issue