dmp blueprint editor changes

This commit is contained in:
Diamantis Tziotzios 2024-01-25 18:08:47 +02:00
parent b6a85e151d
commit ae543324a4
17 changed files with 104 additions and 92 deletions

View File

@ -114,4 +114,14 @@ public class ErrorThesaurusProperties {
public void setDescriptionIsFinalized(ErrorDescription descriptionIsFinalized) { public void setDescriptionIsFinalized(ErrorDescription descriptionIsFinalized) {
this.descriptionIsFinalized = descriptionIsFinalized; this.descriptionIsFinalized = descriptionIsFinalized;
} }
private ErrorDescription dmpBlueprintHasNoDescriptionTemplates;
public ErrorDescription getDmpBlueprintHasNoDescriptionTemplates() {
return dmpBlueprintHasNoDescriptionTemplates;
}
public void setDmpBlueprintHasNoDescriptionTemplates(ErrorDescription dmpBlueprintHasNoDescriptionTemplates) {
this.dmpBlueprintHasNoDescriptionTemplates = dmpBlueprintHasNoDescriptionTemplates;
}
} }

View File

@ -28,6 +28,9 @@ public class DefinitionPersist {
this.sections = sections; this.sections = sections;
} }
public static final String _hasAnyDescriptionTemplatesError = "hasAnyDescriptionTemplates";
@Component(DefinitionPersistValidator.ValidatorName) @Component(DefinitionPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class DefinitionPersistValidator extends BaseValidator<DefinitionPersist> { public static class DefinitionPersistValidator extends BaseValidator<DefinitionPersist> {
@ -60,8 +63,14 @@ public class DefinitionPersist {
.on(DefinitionPersist._sections) .on(DefinitionPersist._sections)
.over(item.getSections()) .over(item.getSections())
.using((itm) -> this.validatorFactory.validator(SectionPersist.SectionPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(SectionPersist.SectionPersistValidator.class))
//TODO: We need to add a validation that check if hasTemplates boolean is true in at least one section.
// this.spec()
// .must(() -> !this.isListNullOrEmpty(item.getSections()) && item.sections.stream().anyMatch(x -> x.getHasTemplates()))
// .failOn(DefinitionPersist._hasAnyDescriptionTemplatesError).failWith(messageSource.getMessage("Validation_Required", null, LocaleContextHolder.getLocale())),
); );
} }
} }
} }

View File

@ -102,16 +102,7 @@ public class DescriptionTemplatePersist {
.failOn(DescriptionTemplatePersist._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._id}, LocaleContextHolder.getLocale())), .failOn(DescriptionTemplatePersist._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._id}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.must(() -> this.isValidGuid(item.getDescriptionTemplateId())) .must(() -> this.isValidGuid(item.getDescriptionTemplateId()))
.failOn(DescriptionTemplatePersist._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._descriptionTemplateId}, LocaleContextHolder.getLocale())), .failOn(DescriptionTemplatePersist._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._descriptionTemplateId}, LocaleContextHolder.getLocale()))
this.spec()
.must(() -> !this.isEmpty(item.getLabel()))
.failOn(DescriptionTemplatePersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._label}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getMinMultiplicity()))
.failOn(DescriptionTemplatePersist._minMultiplicity).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._minMultiplicity}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getMaxMultiplicity()))
.failOn(DescriptionTemplatePersist._maxMultiplicity).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._maxMultiplicity}, LocaleContextHolder.getLocale()))
); );
} }
} }

View File

@ -10,6 +10,7 @@ import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class ExtraFieldPersist extends FieldPersist { public class ExtraFieldPersist extends FieldPersist {
@ -44,11 +45,14 @@ public class ExtraFieldPersist extends FieldPersist {
@Override @Override
protected List<Specification> specifications(ExtraFieldPersist item) { protected List<Specification> specifications(ExtraFieldPersist item) {
List<Specification> specifications = getBaseSpecifications(item); List<Specification> specifications = getBaseSpecifications(item);
specifications.add( specifications.addAll(Arrays.asList(
this.spec()
.must(() -> !this.isEmpty(item.getLabel()))
.failOn(FieldPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._label}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.must(() -> !this.isNull(item.getDataType())) .must(() -> !this.isNull(item.getDataType()))
.failOn(ExtraFieldPersist._dataType).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExtraFieldPersist._dataType}, LocaleContextHolder.getLocale())) .failOn(ExtraFieldPersist._dataType).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExtraFieldPersist._dataType}, LocaleContextHolder.getLocale()))
); ));
return specifications; return specifications;
} }
} }

View File

@ -126,12 +126,6 @@ public abstract class FieldPersist {
this.spec() this.spec()
.must(() -> !this.isNull(item.getCategory())) .must(() -> !this.isNull(item.getCategory()))
.failOn(FieldPersist._category).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._category}, LocaleContextHolder.getLocale())), .failOn(FieldPersist._category).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._category}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getLabel()))
.failOn(FieldPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._label}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getPlaceholder()))
.failOn(FieldPersist._placeholder).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._placeholder}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.must(() -> !this.isNull(item.getOrdinal())) .must(() -> !this.isNull(item.getOrdinal()))
.failOn(FieldPersist._ordinal).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._ordinal}, LocaleContextHolder.getLocale())), .failOn(FieldPersist._ordinal).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._ordinal}, LocaleContextHolder.getLocale())),

View File

@ -136,24 +136,14 @@ public class SectionPersist {
this.spec() this.spec()
.must(() -> !this.isNull(item.getHasTemplates())) .must(() -> !this.isNull(item.getHasTemplates()))
.failOn(SectionPersist._hasTemplates).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._hasTemplates}, LocaleContextHolder.getLocale())), .failOn(SectionPersist._hasTemplates).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._hasTemplates}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.must(() -> !this.isListNullOrEmpty(item.getFields())) .must(() -> !this.isListNullOrEmpty(item.getFields()))
.failOn(SectionPersist._fields).failWith(messageSource.getMessage("Validation_Required", new Object[]{eu.eudat.model.persist.descriptiontemplatedefinition.SectionPersist._fieldSets}, LocaleContextHolder.getLocale())), .failOn(SectionPersist._fields).failWith(messageSource.getMessage("Validation_Required", new Object[]{eu.eudat.model.persist.descriptiontemplatedefinition.SectionPersist._fieldSets}, LocaleContextHolder.getLocale())),
this.navSpec() this.navSpec()
.iff(() -> !this.isListNullOrEmpty(item.getFields())) .iff(() -> !this.isListNullOrEmpty(item.getFields()))
.on(SectionPersist._fields) .on(SectionPersist._fields)
.over(item.getFields().stream().filter(x -> x.getCategory() == DmpBlueprintFieldCategory.System).toList()) .over(item.getFields())
.using((itm) -> this.validatorFactory.validator(SystemFieldPersist.SystemFieldPersistValidator.class)), .using((itm) -> ((FieldPersist) itm).getCategory() == DmpBlueprintFieldCategory.Extra ? this.validatorFactory.validator(ExtraFieldPersist.ExtraFieldPersistValidator.class) : this.validatorFactory.validator(SystemFieldPersist.SystemFieldPersistValidator.class)),
this.navSpec()
.iff(() -> !this.isListNullOrEmpty(item.getFields()))
.on(SectionPersist._fields)
.over(item.getFields().stream().filter(x -> x.getCategory() == DmpBlueprintFieldCategory.Extra).toList())
.using((itm) -> this.validatorFactory.validator(ExtraFieldPersist.ExtraFieldPersistValidator.class)),
this.spec()
.iff(() -> (item.getHasTemplates()))
.must(() -> !this.isListNullOrEmpty(item.getDescriptionTemplates()))
.failOn(SectionPersist._descriptionTemplates).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._descriptionTemplates}, LocaleContextHolder.getLocale())),
this.navSpec() this.navSpec()
.iff(() -> !this.isListNullOrEmpty(item.getDescriptionTemplates())) .iff(() -> !this.isListNullOrEmpty(item.getDescriptionTemplates()))
.on(SectionPersist._descriptionTemplates) .on(SectionPersist._descriptionTemplates)

View File

@ -134,6 +134,10 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
data.setCreatedAt(Instant.now()); data.setCreatedAt(Instant.now());
} }
if (model.getDefinition() != null && !model.getDefinition().getSections().stream().anyMatch(x -> x.getHasTemplates())) {
throw new MyValidationException(this.errors.getDmpBlueprintHasNoDescriptionTemplates().getCode(), this.errors.getDmpBlueprintHasNoDescriptionTemplates().getMessage());
}
data.setLabel(model.getLabel()); data.setLabel(model.getLabel());
data.setStatus(model.getStatus()); data.setStatus(model.getStatus());
data.setUpdatedAt(Instant.now()); data.setUpdatedAt(Instant.now());

View File

@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.WebRequest; import org.springframework.web.context.request.WebRequest;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
@RestControllerAdvice @RestControllerAdvice
@ -111,19 +112,11 @@ public class GlobalExceptionHandler {
logLevel = System.Logger.Level.DEBUG; logLevel = System.Logger.Level.DEBUG;
statusCode = HttpStatus.BAD_REQUEST; statusCode = HttpStatus.BAD_REQUEST;
int code = myValidationException.getCode(); int code = myValidationException.getCode();
if (code > 0) {
result = Map.ofEntries( result = new HashMap<>();
Map.entry("code", code), if (code > 0) result.put("code", code);
Map.entry("error", myValidationException.getMessage()), if (myValidationException.getMessage() != null) result.put("error", myValidationException.getMessage());
Map.entry("message", myValidationException.getErrors()) if (myValidationException.getErrors() != null) result.put("message", myValidationException.getErrors());
);
}
else {
result = Map.ofEntries(
Map.entry("error", myValidationException.getMessage()),
Map.entry("message", myValidationException.getErrors())
);
}
} }
case MyApplicationException myApplicationException -> { case MyApplicationException myApplicationException -> {
logLevel = System.Logger.Level.ERROR; logLevel = System.Logger.Level.ERROR;

View File

@ -47,3 +47,6 @@ error-thesaurus:
description-is-finalized: description-is-finalized:
code: 119 code: 119
message: To perform this action you will need to revert description finalisation message: To perform this action you will need to revert description finalisation
dmp-blueprint-has-no-description-templates:
code: 120
message: You need to select Has Description Templates field to at least one Section.

View File

@ -1,6 +1,6 @@
export enum DmpBlueprintExtraFieldDataType { export enum DmpBlueprintExtraFieldDataType {
Date = 0, Text = 0,
Number = 1, RichTex = 1,
Text = 2, Date = 2,
ExternalAutocomplete = 3 Number = 3
} }

View File

@ -67,15 +67,6 @@ export class EnumUtils {
} }
} }
toDmpBlueprintFieldDataTypeString(type: DmpBlueprintExtraFieldDataType): string {
switch (type) {
case DmpBlueprintExtraFieldDataType.Date: return this.language.instant('TYPES.DMP-PROFILE-FIELD.DATA-TYPE.DATE');
case DmpBlueprintExtraFieldDataType.Number: return this.language.instant('TYPES.DMP-PROFILE-FIELD.DATA-TYPE.NUMBER');
case DmpBlueprintExtraFieldDataType.Text: return this.language.instant('TYPES.DMP-PROFILE-FIELD.DATA-TYPE.TEXT');
case DmpBlueprintExtraFieldDataType.ExternalAutocomplete: return this.language.instant('TYPES.DMP-PROFILE-FIELD.DATA-TYPE.EXTERNAL-AUTOCOMPLETE');
}
}
toDmpBlueprintTypeString(type: DmpBlueprintType): string { toDmpBlueprintTypeString(type: DmpBlueprintType): string {
switch (type) { switch (type) {
case DmpBlueprintType.Input: return this.language.instant('TYPES.DMP-PROFILE-FIELD.TYPE.INPUT'); case DmpBlueprintType.Input: return this.language.instant('TYPES.DMP-PROFILE-FIELD.TYPE.INPUT');
@ -154,10 +145,10 @@ export class EnumUtils {
toDmpBlueprintExtraFieldDataTypeString(status: DmpBlueprintExtraFieldDataType): string { toDmpBlueprintExtraFieldDataTypeString(status: DmpBlueprintExtraFieldDataType): string {
switch (status) { switch (status) {
case DmpBlueprintExtraFieldDataType.Date: return this.language.instant('TYPES.DMP-BLUEPRINT-EXTRA-FIELD-DATA-TYPE.DATE'); case DmpBlueprintExtraFieldDataType.Text: return this.language.instant('TYPES.DMP-PROFILE-FIELD.DATA-TYPE.TEXT');
case DmpBlueprintExtraFieldDataType.Number: return this.language.instant('TYPES.DMP-BLUEPRINT-EXTRA-FIELD-DATA-TYPE.NUMBER'); case DmpBlueprintExtraFieldDataType.RichTex: return this.language.instant('TYPES.DMP-PROFILE-FIELD.DATA-TYPE.RICH-TEXT');
case DmpBlueprintExtraFieldDataType.Text: return this.language.instant('TYPES.DMP-BLUEPRINT-EXTRA-FIELD-DATA-TYPE.TEXT'); case DmpBlueprintExtraFieldDataType.Date: return this.language.instant('TYPES.DMP-PROFILE-FIELD.DATA-TYPE.DATE');
case DmpBlueprintExtraFieldDataType.ExternalAutocomplete: return this.language.instant('TYPES.DMP-BLUEPRINT-EXTRA-FIELD-DATA-TYPE.EXTERNAL-AUTOCOMPLETE'); case DmpBlueprintExtraFieldDataType.Number: return this.language.instant('TYPES.DMP-PROFILE-FIELD.DATA-TYPE.NUMBER');
} }
} }

View File

@ -54,7 +54,7 @@
<div class="col-auto d-flex"> <div class="col-auto d-flex">
<mat-card-title>{{'DMP-BLUEPRINT-EDITOR.FIELDS.SECTION-PREFIX' | translate}} {{sectionIndex + 1}}</mat-card-title> <mat-card-title>{{'DMP-BLUEPRINT-EDITOR.FIELDS.SECTION-PREFIX' | translate}} {{sectionIndex + 1}}</mat-card-title>
</div> </div>
<div class="col-auto d-flex"><mat-icon cdkDragHandle style="cursor: move; color: #129d99;">drag_indicator</mat-icon></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 d-flex"> <div class="col-auto d-flex">
<button mat-icon-button class="action-list-icon" matTooltip="{{'DMP-BLUEPRINT-EDITOR.ACTIONS.REMOVE-SECTION' | translate}}" (click)="removeSection(sectionIndex)" [disabled]="formGroup.disabled"> <button mat-icon-button class="action-list-icon" matTooltip="{{'DMP-BLUEPRINT-EDITOR.ACTIONS.REMOVE-SECTION' | translate}}" (click)="removeSection(sectionIndex)" [disabled]="formGroup.disabled">
@ -84,7 +84,7 @@
<div class="col-6"> <div class="col-6">
<mat-form-field class="w-100"> <mat-form-field class="w-100">
<mat-label>{{'DMP-BLUEPRINT-EDITOR.FIELDS.SYSTEM-FIELDS' | translate}}</mat-label> <mat-label>{{'DMP-BLUEPRINT-EDITOR.FIELDS.SYSTEM-FIELDS' | translate}}</mat-label>
<mat-select multiple [(ngModel)]="selectedSystemFields" [ngModelOptions]="{standalone: true}" (selectionChange)= "addSystemField(sectionIndex, $event)"> <mat-select multiple [(ngModel)]="selectedSystemFields" [disabled]="formGroup.disabled" [ngModelOptions]="{standalone: true}" (selectionChange)= "addSystemField(sectionIndex, $event)">
<mat-option *ngFor="let systemFieldType of dmpBlueprintSystemFieldTypeEnum" [disabled]="systemFieldDisabled(systemFieldType)" [value]="systemFieldType">{{enumUtils.toDmpBlueprintSystemFieldTypeString(systemFieldType)}}</mat-option> <mat-option *ngFor="let systemFieldType of dmpBlueprintSystemFieldTypeEnum" [disabled]="systemFieldDisabled(systemFieldType)" [value]="systemFieldType">{{enumUtils.toDmpBlueprintSystemFieldTypeString(systemFieldType)}}</mat-option>
</mat-select> </mat-select>
<!-- <mat-error *ngIf="fieldsArray(sectionIndex).hasError('required')"> <!-- <mat-error *ngIf="fieldsArray(sectionIndex).hasError('required')">
@ -103,7 +103,7 @@
<span style="font-size: 15px;">{{fieldIndex + 1}}</span> <span style="font-size: 15px;">{{fieldIndex + 1}}</span>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<mat-icon cdkDragHandle style="cursor: move; color: #129d99;">drag_indicator</mat-icon> <mat-icon cdkDragHandle [ngClass]="{'drag-handle-disabled': formGroup.disabled}">drag_indicator</mat-icon>
</div> </div>
<div class="col-auto" *ngIf="field.get('category').value === dmpBlueprintSectionFieldCategory.SYSTEM"> <div class="col-auto" *ngIf="field.get('category').value === dmpBlueprintSectionFieldCategory.SYSTEM">
<mat-form-field class="w-100"> <mat-form-field class="w-100">
@ -115,7 +115,7 @@
<div class="col-auto" *ngIf="field.get('category').value === dmpBlueprintSectionFieldCategory.EXTRA"> <div class="col-auto" *ngIf="field.get('category').value === dmpBlueprintSectionFieldCategory.EXTRA">
<mat-form-field class="w-100"> <mat-form-field class="w-100">
<mat-label>{{'DMP-BLUEPRINT-EDITOR.FIELDS.FIELD-DATA-TYPE' | translate}}</mat-label> <mat-label>{{'DMP-BLUEPRINT-EDITOR.FIELDS.FIELD-DATA-TYPE' | translate}}</mat-label>
<mat-select [formControl]="field.get('dataType')" required> <mat-select [formControl]="field.get('dataType')">
<mat-option *ngFor="let extraFieldDataType of dmpBlueprintExtraFieldDataTypeEnum" [value]="extraFieldDataType"> <mat-option *ngFor="let extraFieldDataType of dmpBlueprintExtraFieldDataTypeEnum" [value]="extraFieldDataType">
{{enumUtils.toDmpBlueprintExtraFieldDataTypeString(extraFieldDataType)}} {{enumUtils.toDmpBlueprintExtraFieldDataTypeString(extraFieldDataType)}}
</mat-option> </mat-option>
@ -127,7 +127,7 @@
<div class="col"> <div class="col">
<mat-form-field class="w-100"> <mat-form-field class="w-100">
<mat-label>{{'DMP-BLUEPRINT-EDITOR.FIELDS.FIELD-LABEL' | translate}}</mat-label> <mat-label>{{'DMP-BLUEPRINT-EDITOR.FIELDS.FIELD-LABEL' | translate}}</mat-label>
<input matInput type="text" name="label" [formControl]="field.get('label')" required> <input matInput type="text" name="label" [formControl]="field.get('label')">
<mat-error *ngIf="field.get('label').hasError('backendError')">{{field.get('label').getError('backendError').message}}</mat-error> <mat-error *ngIf="field.get('label').hasError('backendError')">{{field.get('label').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="field.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
@ -182,8 +182,7 @@
<div class="col-12"> <div class="col-12">
<mat-form-field class="w-100"> <mat-form-field class="w-100">
<mat-label>{{'DMP-BLUEPRINT-EDITOR.FIELDS.DESCRIPTION-TEMPLATES' | translate}}</mat-label> <mat-label>{{'DMP-BLUEPRINT-EDITOR.FIELDS.DESCRIPTION-TEMPLATES' | translate}}</mat-label>
<app-multiple-auto-complete [formControl]="section.get('descriptionTemplates')" [disabled]="formGroup.disabled" [hidePlaceholder]="true" required='false' [configuration]="templatesAutoCompleteConfiguration" (optionRemoved)="onRemoveDescritionTemplate($event, sectionIndex)" (optionSelected)="onSelectDescritionTemplate($event, sectionIndex)"></app-multiple-auto-complete> <app-multiple-auto-complete [disabled]="formGroup.disabled" [hidePlaceholder]="true" required='false' [configuration]="templatesAutoCompleteConfiguration" (optionRemoved)="onRemoveDescritionTemplate($event, sectionIndex)" (optionSelected)="onSelectDescritionTemplate($event, sectionIndex)"></app-multiple-auto-complete> </mat-form-field>
</mat-form-field>
</div> </div>
</div> </div>
</div> </div>
@ -219,6 +218,8 @@
</div> </div>
</div> </div>
<mat-error *ngIf="formGroup.get('definition').get('sections').dirty && formGroup.get('definition').get('sections').hasError('required')">{{'DMP-BLUEPRINT-EDITOR.SECTIONS-REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="formGroup.get('definition').get('sections').hasError('backendError')">{{formGroup.get('definition').get('sections').getError('backendError').message}}</mat-error>
</div> </div>

View File

@ -14,6 +14,15 @@
} }
} }
.drag-handle {
cursor: move;
color: var(--primary-color);
}
.drag-handle-disabled {
cursor: auto;
color: rgba(0, 0, 0, 0.38);;
}
::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-background, .mat-checkbox-indeterminate.mat-accent .mat-checkbox-background { ::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-background, .mat-checkbox-indeterminate.mat-accent .mat-checkbox-background {
background-color: var(--primary-color-3); background-color: var(--primary-color-3);
// background-color: #0070c0; // background-color: #0070c0;

View File

@ -748,7 +748,7 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
// getDmpBlueprintFieldDataTypeWithLanguage(fieldType: DmpBlueprintFieldDataType): string { // getDmpBlueprintFieldDataTypeWithLanguage(fieldType: DmpBlueprintFieldDataType): string {
// let result = ''; // let result = '';
// this.language.get(this.enumUtils.toDmpBlueprintFieldDataTypeString(fieldType)) // this.language.get(this.enumUtils.toDmpBlueprintExtraFieldDataTypeString(fieldType))
// .pipe(takeUntil(this._destroyed)) // .pipe(takeUntil(this._destroyed))
// .subscribe((value: string) => { // .subscribe((value: string) => {
// result = value; // result = value;

View File

@ -67,14 +67,14 @@ export class DmpBlueprintEditorModel extends BaseEditorModel implements DmpBluep
return section.buildForm({ rootPath: 'definition.sections[' + index + '].' }); return section.buildForm({ rootPath: 'definition.sections[' + index + '].' });
} }
createChildSystemField(sectionIndex: number, index: number, systemFieldType: DmpBlueprintSystemFieldType): UntypedFormGroup{ createChildSystemField(sectionIndex: number, index: number, systemFieldType: DmpBlueprintSystemFieldType): UntypedFormGroup {
const field: FieldInSectionEditorModel = new FieldInSectionEditorModel(this.validationErrorModel); const field: FieldInSectionEditorModel = new FieldInSectionEditorModel(this.validationErrorModel);
field.id = Guid.create(); field.id = Guid.create();
field.ordinal = index + 1; field.ordinal = index + 1;
field.category = DmpBlueprintSectionFieldCategory.SYSTEM; field.category = DmpBlueprintSectionFieldCategory.SYSTEM;
field.systemFieldType = systemFieldType; field.systemFieldType = systemFieldType;
field.required = (systemFieldType == DmpBlueprintSystemFieldType.TEXT || systemFieldType == DmpBlueprintSystemFieldType.HTML_TEXT) ? true : false; field.required = (systemFieldType == DmpBlueprintSystemFieldType.TEXT || systemFieldType == DmpBlueprintSystemFieldType.HTML_TEXT) ? true : false;
return field.buildForm({ rootPath: 'definition.sections[' + sectionIndex + '].fields[' + index + '].'}); return field.buildForm({ rootPath: 'definition.sections[' + sectionIndex + '].fields[' + index + '].' });
} }
createChildExtraField(sectionIndex: number, index: number): UntypedFormGroup { createChildExtraField(sectionIndex: number, index: number): UntypedFormGroup {
@ -82,7 +82,7 @@ export class DmpBlueprintEditorModel extends BaseEditorModel implements DmpBluep
field.id = Guid.create(); field.id = Guid.create();
field.ordinal = index + 1; field.ordinal = index + 1;
field.category = DmpBlueprintSectionFieldCategory.EXTRA; field.category = DmpBlueprintSectionFieldCategory.EXTRA;
return field.buildForm({ rootPath: 'definition.sections[' + sectionIndex + '].fields[' + index + '].'}); return field.buildForm({ rootPath: 'definition.sections[' + sectionIndex + '].fields[' + index + '].' });
} }
createChildDescriptionTemplate(item: any, sectionIndex: number, index: number): UntypedFormGroup { createChildDescriptionTemplate(item: any, sectionIndex: number, index: number): UntypedFormGroup {
@ -90,7 +90,7 @@ export class DmpBlueprintEditorModel extends BaseEditorModel implements DmpBluep
descriptionTemplate.id = Guid.create(); descriptionTemplate.id = Guid.create();
descriptionTemplate.descriptionTemplateId = item.id; descriptionTemplate.descriptionTemplateId = item.id;
descriptionTemplate.label = item.label; descriptionTemplate.label = item.label;
return descriptionTemplate.buildForm({ rootPath: 'definition.sections[' + sectionIndex + '].descriptionTemplates[' + index + '].'}); return descriptionTemplate.buildForm({ rootPath: 'definition.sections[' + sectionIndex + '].descriptionTemplates[' + index + '].' });
} }
static reApplySectionValidators(params: { static reApplySectionValidators(params: {
@ -143,8 +143,8 @@ export class DmpBlueprintDefinitionEditorModel implements DmpBlueprintDefinition
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `${rootPath}sections[${index}].` rootPath: `${rootPath}sections[${index}].`
}), context.getValidation('sections') })
) ), context.getValidation('sections').validators
), ),
}); });
} }
@ -157,7 +157,7 @@ export class DmpBlueprintDefinitionEditorModel implements DmpBlueprintDefinition
const baseContext: ValidationContext = new ValidationContext(); const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>(); const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'sections', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}sections`)] }); baseValidationArray.push({ key: 'sections', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}sections`)] });
baseContext.validation = baseValidationArray; baseContext.validation = baseValidationArray;
return baseContext; return baseContext;
@ -233,8 +233,8 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `${rootPath}fields[${index}].` rootPath: `${rootPath}fields[${index}].`
}), context.getValidation('fields') })
) ), context.getValidation('fields')
), ),
descriptionTemplates: this.formBuilder.array( descriptionTemplates: this.formBuilder.array(
(this.descriptionTemplates ?? []).map( (this.descriptionTemplates ?? []).map(
@ -242,8 +242,8 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `${rootPath}descriptionTemplates[${index}].` rootPath: `${rootPath}descriptionTemplates[${index}].`
}), context.getValidation('descriptionTemplates') })
) ), context.getValidation('descriptionTemplates')
) )
}); });
} }
@ -257,11 +257,11 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef
const baseContext: ValidationContext = new ValidationContext(); const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>(); const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}id`)] }); baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}id`)] });
baseValidationArray.push({ key: 'label', validators: [Validators.required,BackendErrorValidator(validationErrorModel, `${rootPath}label`)] }); baseValidationArray.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
baseValidationArray.push({ key: 'ordinal', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] }); baseValidationArray.push({ key: 'ordinal', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] });
baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}description`)] }); baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}description`)] });
baseValidationArray.push({ key: 'hasTemplates', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}hasTemplates`)] }); baseValidationArray.push({ key: 'hasTemplates', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}hasTemplates`)] });
baseValidationArray.push({ key: 'fields', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fields`)] }); baseValidationArray.push({ key: 'fields', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}fields`)] });
baseValidationArray.push({ key: 'descriptionTemplates', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}descriptionTemplates`)] }); baseValidationArray.push({ key: 'descriptionTemplates', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}descriptionTemplates`)] });
baseValidationArray.push({ key: 'hash', validators: [] }); baseValidationArray.push({ key: 'hash', validators: [] });
@ -280,7 +280,7 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef
validationErrorModel validationErrorModel
}); });
['id','label', 'ordinal', 'description', 'hasTemplates', 'hash'].forEach(keyField => { ['id', 'label', 'ordinal', 'description', 'hasTemplates', 'hash'].forEach(keyField => {
const control = formGroup?.get(keyField); const control = formGroup?.get(keyField);
control?.clearValidators(); control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators); control?.addValidators(context.getValidation(keyField).validators);
@ -357,7 +357,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
category: [{ value: this.category, disabled: disabled }, context.getValidation('category').validators], category: [{ value: this.category, disabled: disabled }, context.getValidation('category').validators],
dataType: [{ value: this.dataType, disabled: disabled }, context.getValidation('dataType').validators], dataType: [{ value: this.dataType, disabled: disabled }, context.getValidation('dataType').validators],
systemFieldType: [{ value: this.systemFieldType, disabled: disabled }, context.getValidation('systemFieldType').validators], systemFieldType: [{ value: this.systemFieldType, disabled: disabled }, context.getValidation('systemFieldType').validators],
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators], label: [{ value: this.label, disabled: disabled }, this.category === DmpBlueprintSectionFieldCategory.SYSTEM ? context.getValidation('label-system').validators : context.getValidation('label-extra').validators],
placeholder: [{ value: this.placeholder, disabled: disabled }, context.getValidation('placeholder').validators], placeholder: [{ value: this.placeholder, disabled: disabled }, context.getValidation('placeholder').validators],
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators], description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators],
required: [{ value: this.required, disabled: disabled }, context.getValidation('required').validators], required: [{ value: this.required, disabled: disabled }, context.getValidation('required').validators],
@ -379,7 +379,8 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
baseValidationArray.push({ key: 'category', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}category`)] }); baseValidationArray.push({ key: 'category', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}category`)] });
baseValidationArray.push({ key: 'dataType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}dataType`)] }); baseValidationArray.push({ key: 'dataType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}dataType`)] });
baseValidationArray.push({ key: 'systemFieldType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}systemFieldType`)] }); baseValidationArray.push({ key: 'systemFieldType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}systemFieldType`)] });
baseValidationArray.push({ key: 'label', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}label`)] }); baseValidationArray.push({ key: 'label-system', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
baseValidationArray.push({ key: 'label-extra', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
baseValidationArray.push({ key: 'placeholder', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}placeholder`)] }); baseValidationArray.push({ key: 'placeholder', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}placeholder`)] });
baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}description`)] }); baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}description`)] });
baseValidationArray.push({ key: 'required', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}required`)] }); baseValidationArray.push({ key: 'required', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}required`)] });
@ -401,10 +402,14 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
validationErrorModel validationErrorModel
}); });
['id', 'category', 'dataType', 'systemFieldType', 'label', 'placeholder', 'description', 'required', 'ordinal'].forEach(keyField => { ['id', 'category', 'dataType', 'systemFieldType', , 'label', 'placeholder', 'description', 'required', 'ordinal'].forEach(keyField => {
const control = formGroup?.get(keyField); const control = formGroup?.get(keyField);
control?.clearValidators(); control?.clearValidators();
if (keyField == 'label') {
control?.addValidators(context.has('label-system') ? context.getValidation('label-system').validators : context.getValidation('label-extra').validators);
} else {
control?.addValidators(context.getValidation(keyField).validators); control?.addValidators(context.getValidation(keyField).validators);
}
}) })
} }
} }
@ -450,7 +455,6 @@ export class DescriptionTemplatesInSectionEditorModel implements DescriptionTemp
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators], label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
minMultiplicity: [{ value: this.minMultiplicity, disabled: disabled }, context.getValidation('minMultiplicity').validators], minMultiplicity: [{ value: this.minMultiplicity, disabled: disabled }, context.getValidation('minMultiplicity').validators],
maxMultiplicity: [{ value: this.maxMultiplicity, disabled: disabled }, context.getValidation('maxMultiplicity').validators], maxMultiplicity: [{ value: this.maxMultiplicity, disabled: disabled }, context.getValidation('maxMultiplicity').validators],
}); });
} }
@ -464,7 +468,7 @@ export class DescriptionTemplatesInSectionEditorModel implements DescriptionTemp
const baseValidationArray: Validation[] = new Array<Validation>(); const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}id`)] }); baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}id`)] });
baseValidationArray.push({ key: 'descriptionTemplateId', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}descriptionTemplateId`)] }); baseValidationArray.push({ key: 'descriptionTemplateId', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}descriptionTemplateId`)] });
baseValidationArray.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}label`)] }); baseValidationArray.push({ key: 'label', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
baseValidationArray.push({ key: 'minMultiplicity', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}minMultiplicity`)] }); baseValidationArray.push({ key: 'minMultiplicity', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}minMultiplicity`)] });
baseValidationArray.push({ key: 'maxMultiplicity', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}maxMultiplicity`)] }); baseValidationArray.push({ key: 'maxMultiplicity', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}maxMultiplicity`)] });

View File

@ -2299,7 +2299,7 @@
"DATE": "Date", "DATE": "Date",
"NUMBER": "Number", "NUMBER": "Number",
"TEXT": "Text", "TEXT": "Text",
"EXTERNAL-AUTOCOMPLETE": "External AutoComplete" "RICH-TEXT": "Rich Text"
}, },
"REFERENCE-FIELD-DATA-TYPE": { "REFERENCE-FIELD-DATA-TYPE": {
"TEXT": "Text", "TEXT": "Text",

View File

@ -11,6 +11,15 @@ export class ValidationContext {
} }
throw new Error('Key ' + key + ' Was Not Found In The Validation Context'); throw new Error('Key ' + key + ' Was Not Found In The Validation Context');
} }
has(key: string): boolean {
for (let i = 0; i < this.validation.length; i++) {
if (this.validation[i].key === key) {
return true;
}
}
return false;
}
} }
export class Validation { export class Validation {