minor ui fixes

This commit is contained in:
Diamantis Tziotzios 2024-01-31 12:30:21 +02:00
parent f604eac172
commit 078ca9e0cb
6 changed files with 111 additions and 105 deletions

View File

@ -201,10 +201,7 @@ public class ReferencePersist {
.must(() -> !this.isNull(item.getSourceType()))
.failOn(ReferencePersist._sourceType).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferencePersist._sourceType}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getDefinition()))
.failOn(ReferencePersist._definition).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferencePersist._definition}, LocaleContextHolder.getLocale())),
this.refSpec()
this.refSpec()
.iff(() -> !this.isNull(item.getDefinition()))
.on(ReferencePersist._definition)
.over(item.getDefinition())

View File

@ -1,6 +1,7 @@
package eu.eudat.model.persist.dmpproperties;
import eu.eudat.commons.validation.BaseValidator;
import gr.cite.tools.validation.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
@ -53,12 +54,14 @@ public class DmpBlueprintValuePersist {
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class DmpBlueprintValuePersistValidator extends BaseValidator<DmpBlueprintValuePersist> {
private final ValidatorFactory validatorFactory;
private final MessageSource messageSource;
public static final String ValidatorName = "DmpBlueprintValuePersistValidator";
protected DmpBlueprintValuePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
protected DmpBlueprintValuePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, ValidatorFactory validatorFactory, MessageSource messageSource) {
super(conventionService, errors);
this.validatorFactory = validatorFactory;
this.messageSource = messageSource;
}
@ -70,17 +73,18 @@ public class DmpBlueprintValuePersist {
@Override
protected List<Specification> specifications(DmpBlueprintValuePersist item) {
return Arrays.asList(
this.spec()
.must(() -> !this.isValidGuid(item.getFieldId()))
.failOn(DmpBlueprintValuePersist._fieldId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpBlueprintValuePersist._fieldId}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> this.isNull(item.getReferences()) || item.getReferences().isEmpty())
.must(() -> !this.isEmpty(item.getFieldValue()))
.failOn(DmpBlueprintValuePersist._fieldValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpBlueprintValuePersist._fieldValue}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isNull(item.getReferences()) && !item.getReferences().isEmpty())
.must(() -> this.isEmpty(item.getFieldValue()))
.failOn(DmpBlueprintValuePersist._fieldValue).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{DmpBlueprintValuePersist._fieldValue}, LocaleContextHolder.getLocale()))
// this.spec()
// .must(() -> !this.isValidGuid(item.getFieldId()))
// .failOn(DmpBlueprintValuePersist._fieldId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpBlueprintValuePersist._fieldId}, LocaleContextHolder.getLocale())),
// this.spec()
// .iff(() -> this.isNull(item.getReferences()) || item.getReferences().isEmpty())
// .must(() -> !this.isEmpty(item.getFieldValue()))
// .failOn(DmpBlueprintValuePersist._fieldValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpBlueprintValuePersist._fieldValue}, LocaleContextHolder.getLocale())),
this.navSpec()
.iff(() -> !this.isListNullOrEmpty(item.getReferences()))
.on(DmpBlueprintValuePersist._references)
.over(item.getReferences())
.using((itm) -> this.validatorFactory.validator(ReferencePersist.ReferencePersistValidator.class))
);
}
}

View File

@ -79,10 +79,7 @@ public class FieldPersist {
.failOn(FieldPersist._code).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._code}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getDataType()))
.failOn(FieldPersist._dataType).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._dataType}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getValue()))
.failOn(FieldPersist._value).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._value}, LocaleContextHolder.getLocale()))
.failOn(FieldPersist._dataType).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._dataType}, LocaleContextHolder.getLocale()))
);
}
}

View File

@ -148,6 +148,7 @@ export class ReferenceService {
lookup.project = {
fields: [
nameof<Reference>(x => x.id),
nameof<Reference>(x => x.hash),
nameof<Reference>(x => x.label),
nameof<Reference>(x => x.type),
nameof<Reference>(x => x.description),

View File

@ -179,13 +179,6 @@
</mat-form-field>
</div>
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.CONTACT">
<div class="row">
<div class="col">
<button mat-icon-button (click)="addContact()" [disabled]="formGroup.disabled">
<mat-icon>add</mat-icon>
</button>
</div>
</div>
<div cdkDropList class="col-12" (cdkDropListDropped)="dropContacts($event)">
<div *ngFor="let contact of formGroup.get('properties').get('contacts').controls; let contactIndex=index;" cdkDrag class="row align-items-center" [cdkDragDisabled]="formGroup.disabled">
<div class="col-auto">
@ -193,53 +186,66 @@
</div>
<div class="col-auto d-flex"><mat-icon [ngClass]="{'drag-handle-disabled': formGroup.disabled}" cdkDragHandle class="drag-handle">drag_indicator</mat-icon></div>
<div class="col-auto">
<mat-button-toggle-group name="fontStyle" aria-label="Font Style" [formControl]= "contact.get('contactType')">
<mat-button-toggle-group name="fontStyle" aria-label="Font Style" [formControl]="contact.get('contactType')">
<div *ngFor="let contactType of dmpContactTypeEnumValues">
<mat-button-toggle class="lang-button" [value]="contactType">{{enumUtils.toDmpContactTypeString(contactType)}}</mat-button-toggle>
</div>
</mat-button-toggle-group>
</div>
<div class="col-auto d-flex" *ngIf="contact.get('contactType').value == dmpContactTypeEnum.Internal">
<mat-form-field class="w-100">
<mat-label>{{'DMP-EDITOR.FIELDS1.USER' | translate}}</mat-label>
<app-single-auto-complete [formControl]="contact.get('userId')" [hidePlaceholder]="true" [configuration]= "userService.singleAutocompleteConfiguration"></app-single-auto-complete>
<mat-error *ngIf="contact.get('userId').hasError('backendError')">{{contact.get('userId').getError('backendError').message}}</mat-error>
<mat-error *ngIf="contact.get('userId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-auto d-flex" *ngIf="contact.get('contactType').value == dmpContactTypeEnum.External">
<div class="col">
<mat-form-field class="w-100">
<mat-label>{{'DMP-EDITOR.FIELDS1.FIRST-NAME' | translate}}</mat-label>
<input matInput type="text" name="firstName" [formControl]="contact.get('firstName')">
<mat-error *ngIf="contact.get('firstName').hasError('backendError')">{{contact.get('firstName').getError('backendError').message}}</mat-error>
<mat-error *ngIf="contact.get('firstName').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col">
<mat-form-field class="w-100">
<mat-label>{{'DMP-EDITOR.FIELDS1.LAST-NAME' | translate}}</mat-label>
<input matInput type="text" name="lastName" [formControl]="contact.get('lastName')">
<mat-error *ngIf="contact.get('lastName').hasError('backendError')">{{contact.get('lastName').getError('backendError').message}}</mat-error>
<mat-error *ngIf="contact.get('lastName').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col">
<mat-form-field class="w-100">
<mat-label>{{'DMP-EDITOR.FIELDS1.EMAIL' | translate}}</mat-label>
<input matInput type="text" name="email" [formControl]="contact.get('email')">
<mat-error *ngIf="contact.get('email').hasError('backendError')">{{contact.get('email').getError('backendError').message}}</mat-error>
<mat-error *ngIf="contact.get('email').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<div class="col pt-4">
<div class="row">
<div class="col d-flex" *ngIf="contact.get('contactType').value == dmpContactTypeEnum.Internal">
<mat-form-field class="w-100">
<mat-label>{{'DMP-EDITOR.FIELDS1.USER' | translate}}</mat-label>
<app-single-auto-complete [formControl]="contact.get('userId')" [hidePlaceholder]="true" [configuration]="userService.singleAutocompleteConfiguration"></app-single-auto-complete>
<mat-error *ngIf="contact.get('userId').hasError('backendError')">{{contact.get('userId').getError('backendError').message}}</mat-error>
<mat-error *ngIf="contact.get('userId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<ng-container *ngIf="contact.get('contactType').value == dmpContactTypeEnum.External">
<div class="col">
<mat-form-field class="w-100">
<mat-label>{{'DMP-EDITOR.FIELDS1.FIRST-NAME' | translate}}</mat-label>
<input matInput type="text" name="firstName" [formControl]="contact.get('firstName')">
<mat-error *ngIf="contact.get('firstName').hasError('backendError')">{{contact.get('firstName').getError('backendError').message}}</mat-error>
<mat-error *ngIf="contact.get('firstName').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col">
<mat-form-field class="w-100">
<mat-label>{{'DMP-EDITOR.FIELDS1.LAST-NAME' | translate}}</mat-label>
<input matInput type="text" name="lastName" [formControl]="contact.get('lastName')">
<mat-error *ngIf="contact.get('lastName').hasError('backendError')">{{contact.get('lastName').getError('backendError').message}}</mat-error>
<mat-error *ngIf="contact.get('lastName').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col">
<mat-form-field class="w-100">
<mat-label>{{'DMP-EDITOR.FIELDS1.EMAIL' | translate}}</mat-label>
<input matInput type="text" name="email" [formControl]="contact.get('email')">
<mat-error *ngIf="contact.get('email').hasError('backendError')">{{contact.get('email').getError('backendError').message}}</mat-error>
<mat-error *ngIf="contact.get('email').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
</ng-container>
</div>
</div>
<button mat-icon-button class="action-list-icon" matTooltip="{{'DMP-EDITOR.FIELDS.REMOVE-CONTACT' | translate}}" (click)="removeContact(contactIndex)" [disabled]="formGroup.disabled">
<mat-icon>delete</mat-icon>
</button>
<div class="col-auto">
<button mat-icon-button class="action-list-icon" matTooltip="{{'DMP-EDITOR.FIELDS.REMOVE-CONTACT' | translate}}" (click)="removeContact(contactIndex)" [disabled]="formGroup.disabled">
<mat-icon>delete</mat-icon>
</button>
</div>
</div>
<mat-error *ngIf="formGroup.get('properties').get('contacts').hasError('backendError')">{{formGroup.get('properties').get('contacts').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('properties').get('contacts').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</div>
<div class="row">
<div class="col">
<button mat-icon-button (click)="addContact()" [disabled]="formGroup.disabled">
<mat-icon>add</mat-icon>
</button>
</div>
</div>
</div>
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.ACCESS_RIGHTS">
<mat-form-field class="w-100">
@ -252,55 +258,56 @@
<mat-error *ngIf="formGroup.get('accessType').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div *ngIf="field.category === dmpBlueprintSectionFieldCategoryEnum.EXTRA">
<div *ngIf="field.dataType === dmpBlueprintExtraFieldDataTypeEnum.TEXT">
<mat-form-field class="w-100">
<input matInput placeholder="{{field.placeholder}}" type="text" name="value" [formControl]="formGroup.get('extraFields').get(getExtraFieldIndex(field.id)).get('value')" [required]="field.required">
</mat-form-field>
</div>
<div *ngIf="field.dataType === dmpBlueprintExtraFieldDataTypeEnum.RICH_TEXT">
<ng-container formArrayName="extraFields">
<ng-container *ngFor="let control of extraFieldsArray().controls; let extraFieldIndex = index;">
<ng-container [formGroupName]="extraFieldIndex">
<ng-container *ngIf="control.get('id').value === field.id">
<rich-text-editor-component [form]="control.get('value')" [placeholder]="field.placeholder" [required]="field.required">
</rich-text-editor-component>
<div *ngIf="field.category === dmpBlueprintSectionFieldCategoryEnum.EXTRA">
<div *ngIf="field.dataType === dmpBlueprintExtraFieldDataTypeEnum.TEXT">
<mat-form-field class="w-100">
<input matInput placeholder="{{field.placeholder}}" type="text" name="value" [formControl]="formGroup.get('extraFields').get(getExtraFieldIndex(field.id)).get('value')" [required]="field.required">
</mat-form-field>
</div>
<div *ngIf="field.dataType === dmpBlueprintExtraFieldDataTypeEnum.RICH_TEXT">
<ng-container formArrayName="extraFields">
<ng-container *ngFor="let control of extraFieldsArray().controls; let extraFieldIndex = index;">
<ng-container [formGroupName]="extraFieldIndex">
<ng-container *ngIf="control.get('id').value === field.id">
<rich-text-editor-component [form]="control.get('value')" [placeholder]="field.placeholder" [required]="field.required">
</rich-text-editor-component>
</ng-container>
</ng-container>
</ng-container>
</ng-container>
</ng-container>
</div>
<div *ngIf="field.dataType === dmpBlueprintExtraFieldDataTypeEnum.DATE">
<mat-form-field class="w-100">
<input matInput placeholder="{{field.placeholder}}" type="date" name="value" [formControl]="formGroup.get('extraFields').get(getExtraFieldIndex(field.id)).get('value')" [required]="field.required">
</mat-form-field>
</div>
<div *ngIf="field.dataType === dmpBlueprintExtraFieldDataTypeEnum.NUMBER">
<mat-form-field class="w-100">
<input matInput placeholder="{{field.placeholder}}" type="number" name="value" [formControl]="formGroup.get('extraFields').get(getExtraFieldIndex(field.id)).get('value')" [required]="field.required">
</mat-form-field>
</div>
<div *ngIf="field.dataType === dmpBlueprintExtraFieldDataTypeEnum.DATE">
<mat-form-field class="w-100">
<input matInput placeholder="{{field.placeholder}}" type="date" name="value" [formControl]="formGroup.get('extraFields').get(getExtraFieldIndex(field.id)).get('value')" [required]="field.required">
</mat-form-field>
</div>
<div *ngIf="field.dataType === dmpBlueprintExtraFieldDataTypeEnum.NUMBER">
<mat-form-field class="w-100">
<input matInput placeholder="{{field.placeholder}}" type="number" name="value" [formControl]="formGroup.get('extraFields').get(getExtraFieldIndex(field.id)).get('value')" [required]="field.required">
</mat-form-field>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-12 card" *ngIf="section.hasTemplates">
{{formGroup.get('descriptionTemplates').get(section.id).value | json}}
<div class="row">
<div class="col-12">
<div class="input-form">
<div class="heading">{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES' | translate}}</div>
<mat-form-field class="w-100">
<mat-label>{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}</mat-label>
<app-multiple-auto-complete placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}" [hidePlaceholder]="true" required='true' [formControl]="formGroup.get('descriptionTemplates').get(section.id)" [configuration]="descriptionTemplateService.descriptionTempalteGroupMultipleAutocompleteConfiguration" (optionRemoved)="onRemoveDescriptionTemplate($event, i)" (optionActionClicked)="onPreviewDescriptionTemplate($event, i)" (optionSelected)="onDescriptionTemplateSelected($event, i)">
</app-multiple-auto-complete>
<mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).hasError('backendError')">{{formGroup.get('descriptionTemplates').get(section.id).getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<div class="col pl-0 pt-0 pb-0 d-flex">
<span class="not-found-template">{{'DMP-EDITOR.NO-TEMPLATE-MESSAGE' | translate}}</span>
<div class="col-12 card" *ngIf="section.hasTemplates">
{{formGroup.get('descriptionTemplates').get(section.id).value | json}}
<div class="row">
<div class="col-12">
<div class="input-form">
<div class="heading">{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES' | translate}}</div>
<mat-form-field class="w-100">
<mat-label>{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}</mat-label>
<app-multiple-auto-complete placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}" [hidePlaceholder]="true" required='true' [formControl]="formGroup.get('descriptionTemplates').get(section.id)" [configuration]="descriptionTemplateService.descriptionTempalteGroupMultipleAutocompleteConfiguration" (optionRemoved)="onRemoveDescriptionTemplate($event, i)" (optionActionClicked)="onPreviewDescriptionTemplate($event, i)" (optionSelected)="onDescriptionTemplateSelected($event, i)">
</app-multiple-auto-complete>
<mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).hasError('backendError')">{{formGroup.get('descriptionTemplates').get(section.id).getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<div class="col pl-0 pt-0 pb-0 d-flex">
<span class="not-found-template">{{'DMP-EDITOR.NO-TEMPLATE-MESSAGE' | translate}}</span>
</div>
</div>
</div>
</div>
@ -312,5 +319,4 @@
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -5,6 +5,7 @@
<mat-error *ngIf="form.hasError('backendError')">{{form.getError('backendError').message}}</mat-error>
<mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
{{form.errors | json}}
<div class="mb-4">
<span *ngIf="!form.disabled" class="not-found">{{'REFERENCE-FIELD.COULD-NOT-FIND-MESSAGE' | translate}}</span>
<span *ngIf="!form.disabled" class="insert-manually" (click)="addReference($event)">{{'REFERENCE-FIELD.ACTIONS.INSERT-MANUALLY' | translate}}</span>