prefilling sources ui changes

This commit is contained in:
amentis 2024-02-28 13:29:53 +02:00
parent dad32207e3
commit 9989f5ca69
6 changed files with 30 additions and 19 deletions

View File

@ -160,9 +160,6 @@ public class ExternalFetcherApiSourceConfigurationPersist extends ExternalFetche
this.spec() this.spec()
.must(() -> !this.isEmpty(item.getContentType())) .must(() -> !this.isEmpty(item.getContentType()))
.failOn(ExternalFetcherApiSourceConfigurationPersist._contentType).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._contentType}, LocaleContextHolder.getLocale())), .failOn(ExternalFetcherApiSourceConfigurationPersist._contentType).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._contentType}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getFirstPage()))
.failOn(ExternalFetcherApiSourceConfigurationPersist._firstPage).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._firstPage}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.must(() -> !this.isNull(item.getHttpMethod())) .must(() -> !this.isNull(item.getHttpMethod()))
.failOn(ExternalFetcherApiSourceConfigurationPersist._httpMethod).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._httpMethod}, LocaleContextHolder.getLocale())), .failOn(ExternalFetcherApiSourceConfigurationPersist._httpMethod).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._httpMethod}, LocaleContextHolder.getLocale())),

View File

@ -38,6 +38,7 @@ import { ValidationType } from '../../common/enum/validation-type';
import { DescriptionTemplateExternalSelectAuthType } from '@app/core/common/enum/description-template-external-select-auth-type'; import { DescriptionTemplateExternalSelectAuthType } from '@app/core/common/enum/description-template-external-select-auth-type';
import { DmpBlueprintFieldCategory } from '@app/core/common/enum/dmp-blueprint-field-category'; import { DmpBlueprintFieldCategory } from '@app/core/common/enum/dmp-blueprint-field-category';
import { DmpUserType } from '@app/core/common/enum/dmp-user-type'; import { DmpUserType } from '@app/core/common/enum/dmp-user-type';
import { PrefillingSourceSystemTargetType } from '@app/core/common/enum/prefilling-source-system-target-type';
@Injectable() @Injectable()
export class EnumUtils { export class EnumUtils {
@ -398,5 +399,13 @@ export class EnumUtils {
} }
} }
public toPrefillingSourceSystemTargetTypeString(value: PrefillingSourceSystemTargetType): string {
switch (value) {
case PrefillingSourceSystemTargetType.Label: return this.language.instant('TYPES.PREFILLING-SOURCE-SYSTEM-TARGET-TYPE.LABEL');
case PrefillingSourceSystemTargetType.Description: return this.language.instant('TYPES.PREFILLING-SOURCE-SYSTEM-TARGET-TYPE.DESCRIPTION');
case PrefillingSourceSystemTargetType.Tags: return this.language.instant('TYPES.PREFILLING-SOURCE-SYSTEM-TARGET-TYPE.TAGS');
}
}
} }

View File

@ -40,9 +40,6 @@
</div> </div>
<!-- Fields --> <!-- Fields -->
<div class="col-12"> <div class="col-12">
<h3>
<button mat-button class="action-btn" type="button" (click)="addField()" [disabled]="formGroup.disabled">{{'PREFILLING-SOURCE-EDITOR.ACTIONS.ADD-FIELD' | translate}}</button>
</h3>
<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('fields').controls; let fieldIndex=index;" class="row mb-3">
<div class="col-12"> <div class="col-12">
<div class="row mb-3 d-flex align-items-center"> <div class="row mb-3 d-flex align-items-center">
@ -67,12 +64,13 @@
<div class="col"> <div class="col">
<mat-form-field class="w-100"> <mat-form-field class="w-100">
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.SYSTEM-TARGET' | translate}}</mat-label> <mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.SYSTEM-TARGET' | translate}}</mat-label>
<input matInput type="text" name="systemFieldTarget" [formControl]="field.get('systemFieldTarget')"> <mat-select [formControl]="field.get('systemFieldTarget')">
<mat-error *ngIf="field.get('systemFieldTarget').hasError('backendError')">{{field.get('systemFieldTarget').getError('backendError').message}}</mat-error> <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-error *ngIf="field.get('systemFieldTarget').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
<div class="col"> <div class="col-12">
<mat-form-field class="w-100"> <mat-form-field class="w-100">
<mat-label>{{'PREFILLING-SOURCE-EDITOR.FIELDS.SEMANTIC-TARGET' | translate}}</mat-label> <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> <app-single-auto-complete placeholder="{{'PREFILLING-SOURCE-EDITOR.FIELDS.SEMANTIC-TARGET' | translate}}" [formControl]="field.get('semanticTarget')" [configuration]="semanticsService.singleAutocompleteConfiguration"> </app-single-auto-complete>
@ -99,6 +97,7 @@
</div> </div>
</div> </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 != ''" <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> type="button" (click)="submitFields()" [disabled]="!formGroup.get('definition').get('fields').valid">{{'PREFILLING-SOURCE-EDITOR.ACTIONS.SUBMIT-FIELDS' | translate}}</button>
</div> </div>

View File

@ -29,6 +29,7 @@ import { PrefillingSourceDefinitionEditorModel, PrefillingSourceEditorModel } fr
import { ResultFieldsMappingConfigurationEditorModel } from '@app/ui/external-fetcher/external-fetcher-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 { SemanticsService } from '@app/core/services/semantic/semantics.service';
import { MatCheckboxChange } from '@angular/material/checkbox'; import { MatCheckboxChange } from '@angular/material/checkbox';
import { PrefillingSourceSystemTargetType } from '@app/core/common/enum/prefilling-source-system-target-type';
@Component({ @Component({
selector: 'app-prefilling-source-editor-component', selector: 'app-prefilling-source-editor-component',
@ -42,6 +43,7 @@ export class PrefillingSourceEditorComponent extends BaseEditor<PrefillingSource
isDeleted = false; isDeleted = false;
formGroup: UntypedFormGroup = null; formGroup: UntypedFormGroup = null;
showInactiveDetails = false; showInactiveDetails = false;
prefillingSourceSystemTargetTypeEnumValues = this.enumUtils.getEnumValues<PrefillingSourceSystemTargetType>(PrefillingSourceSystemTargetType);
protected get canDelete(): boolean { protected get canDelete(): boolean {
return !this.isDeleted && !this.isNew && this.hasPermission(this.authService.permissionEnum.DeletePrefillingSource); return !this.isDeleted && !this.isNew && this.hasPermission(this.authService.permissionEnum.DeletePrefillingSource);
@ -190,9 +192,6 @@ export class PrefillingSourceEditorComponent extends BaseEditor<PrefillingSource
const definition = new PrefillingSourceDefinitionEditorModel(this.editorModel.validationErrorModel); const definition = new PrefillingSourceDefinitionEditorModel(this.editorModel.validationErrorModel);
definition.buildGetConfiguration(this.formGroup.get('definition') as UntypedFormGroup, "definition."); definition.buildGetConfiguration(this.formGroup.get('definition') as UntypedFormGroup, "definition.");
this.addFieldMapping("prefilling_id", "getConfiguration");
this.addFieldMapping("label", "getConfiguration");
this.addFieldMapping("description", "getConfiguration");
this.submitFields(); this.submitFields();
} }
} }
@ -221,7 +220,7 @@ export class PrefillingSourceEditorComponent extends BaseEditor<PrefillingSource
) )
fieldForm.markAsDirty(); fieldForm.markAsDirty();
this.removeFieldMapping((this.formGroup.get('definition').get('searchConfiguration') as FormGroup), fieldCode); // this.removeFieldMapping((this.formGroup.get('definition').get('searchConfiguration') as FormGroup), fieldCode);
if(this.formGroup.get('definition').get('getEnabled').value == true) this.removeFieldMapping((this.formGroup.get('definition').get('getConfiguration') as FormGroup), fieldCode); if(this.formGroup.get('definition').get('getEnabled').value == true) this.removeFieldMapping((this.formGroup.get('definition').get('getConfiguration') as FormGroup), fieldCode);
} }
@ -231,7 +230,7 @@ export class PrefillingSourceEditorComponent extends BaseEditor<PrefillingSource
if (fieldsFormArray.valid) { if (fieldsFormArray.valid) {
for (let i = 0; i < fieldsFormArray.length; i++) { for (let i = 0; i < fieldsFormArray.length; i++) {
const code = fieldsFormArray.at(i).get('code').value; const code = fieldsFormArray.at(i).get('code').value;
this.addFieldMapping(code, "searchConfiguration"); // this.addFieldMapping(code, "searchConfiguration");
if(this.formGroup.get('definition').get('getEnabled').value == true) this.addFieldMapping(code, "getConfiguration"); if(this.formGroup.get('definition').get('getEnabled').value == true) this.addFieldMapping(code, "getConfiguration");
} }
} }

View File

@ -34,7 +34,7 @@
<mat-error *ngIf="formGroup.get('referenceTypeDependencyIds').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="formGroup.get('referenceTypeDependencyIds').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
<div class="col-6"> <div class="col-6" *ngIf="referenceTypeSourceIndex != null">
<mat-form-field class="w-100"> <mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.SOURCE-TYPE' | translate}}</mat-label> <mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.SOURCE-TYPE' | translate}}</mat-label>
<mat-select name="type" [formControl]="formGroup.get('type')" required> <mat-select name="type" [formControl]="formGroup.get('type')" required>
@ -288,7 +288,7 @@
</div> </div>
<div class="col-6" *ngIf="formGroup.get('referenceTypeDependencyIds').value"> <div class="col-6" *ngIf="formGroup.get('referenceTypeDependencyIds').value">
<mat-form-field class="w-100"> <mat-form-field class="w-100">
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.REFERENCE-TYPE' | translate}}</mat-label> <mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.DEPENDENCY' | translate}}</mat-label>
<mat-select name="referenceTypeId" [formControl]="case.get('referenceTypeId')"> <mat-select name="referenceTypeId" [formControl]="case.get('referenceTypeId')">
<mat-option *ngFor="let referenceType of referenceTypeDependenciesMap.get(referenceTypeSourceIndex)" [value]="referenceType.id"> <mat-option *ngFor="let referenceType of referenceTypeDependenciesMap.get(referenceTypeSourceIndex)" [value]="referenceType.id">
{{referenceType.code}} {{referenceType.code}}
@ -355,5 +355,4 @@
</div> </div>
</div> </div>
</div> </div>
{{formGroup.value | json}}
</div> </div>

View File

@ -1529,6 +1529,7 @@
"TYPE": "Type", "TYPE": "Type",
"SEPARATOR": "Separator", "SEPARATOR": "Separator",
"DEPENDENCIES": "Dependencies", "DEPENDENCIES": "Dependencies",
"DEPENDENCY": "Dependency",
"REQUIRED": "Required", "REQUIRED": "Required",
"DEFAULT-VALUE": "Default Value", "DEFAULT-VALUE": "Default Value",
"CASE": "Case", "CASE": "Case",
@ -1591,6 +1592,8 @@
"PREFILLING-SOURCE-EDITOR": { "PREFILLING-SOURCE-EDITOR": {
"NEW": "New Prefilling Source", "NEW": "New Prefilling Source",
"FIELDS": { "FIELDS": {
"SOURCE-CONFIGURATION":"Search Source Configuration",
"GET-SOURCE-CONFIGURATION": "Get Source Configuration",
"LABEL": "Label", "LABEL": "Label",
"FIELD": "Field", "FIELD": "Field",
"CODE": "Code", "CODE": "Code",
@ -1606,7 +1609,7 @@
"DELETE": "Delete", "DELETE": "Delete",
"ADD-FIELD": "Add Field", "ADD-FIELD": "Add Field",
"REMOVE-FIELD": "Remove Field", "REMOVE-FIELD": "Remove Field",
"SUBMIT-FIELDS": "Submit" "SUBMIT-FIELDS": "Submit Fields"
}, },
"CONFIRM-DELETE-DIALOG": { "CONFIRM-DELETE-DIALOG": {
"MESSAGE": "Would you like to delete this Prefilling Source?", "MESSAGE": "Would you like to delete this Prefilling Source?",
@ -2489,6 +2492,11 @@
"SYSTEM": "System", "SYSTEM": "System",
"EXTRA": "Custom", "EXTRA": "Custom",
"REFERENCE-TYPE": "External Reference" "REFERENCE-TYPE": "External Reference"
},
"PREFILLING-SOURCE-SYSTEM-TARGET-TYPE": {
"LABEL": "Label",
"DESCRIPTION": "Description",
"TAGS": "Tags"
} }
}, },
"ADDRESEARCHERS-EDITOR": { "ADDRESEARCHERS-EDITOR": {