dmp blueprint editor changes
This commit is contained in:
parent
b6a85e151d
commit
ae543324a4
|
@ -114,4 +114,14 @@ public class ErrorThesaurusProperties {
|
|||
public void setDescriptionIsFinalized(ErrorDescription descriptionIsFinalized) {
|
||||
this.descriptionIsFinalized = descriptionIsFinalized;
|
||||
}
|
||||
|
||||
private ErrorDescription dmpBlueprintHasNoDescriptionTemplates;
|
||||
|
||||
public ErrorDescription getDmpBlueprintHasNoDescriptionTemplates() {
|
||||
return dmpBlueprintHasNoDescriptionTemplates;
|
||||
}
|
||||
|
||||
public void setDmpBlueprintHasNoDescriptionTemplates(ErrorDescription dmpBlueprintHasNoDescriptionTemplates) {
|
||||
this.dmpBlueprintHasNoDescriptionTemplates = dmpBlueprintHasNoDescriptionTemplates;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,9 @@ public class DefinitionPersist {
|
|||
this.sections = sections;
|
||||
}
|
||||
|
||||
public static final String _hasAnyDescriptionTemplatesError = "hasAnyDescriptionTemplates";
|
||||
|
||||
|
||||
@Component(DefinitionPersistValidator.ValidatorName)
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public static class DefinitionPersistValidator extends BaseValidator<DefinitionPersist> {
|
||||
|
@ -60,8 +63,14 @@ public class DefinitionPersist {
|
|||
.on(DefinitionPersist._sections)
|
||||
.over(item.getSections())
|
||||
.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())),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -102,16 +102,7 @@ public class DescriptionTemplatePersist {
|
|||
.failOn(DescriptionTemplatePersist._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._id}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.must(() -> this.isValidGuid(item.getDescriptionTemplateId()))
|
||||
.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()))
|
||||
.failOn(DescriptionTemplatePersist._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._descriptionTemplateId}, LocaleContextHolder.getLocale()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.springframework.context.annotation.Scope;
|
|||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ExtraFieldPersist extends FieldPersist {
|
||||
|
@ -44,11 +45,14 @@ public class ExtraFieldPersist extends FieldPersist {
|
|||
@Override
|
||||
protected List<Specification> specifications(ExtraFieldPersist 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()
|
||||
.must(() -> !this.isNull(item.getDataType()))
|
||||
.failOn(ExtraFieldPersist._dataType).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExtraFieldPersist._dataType}, LocaleContextHolder.getLocale()))
|
||||
);
|
||||
));
|
||||
return specifications;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,12 +126,6 @@ public abstract class FieldPersist {
|
|||
this.spec()
|
||||
.must(() -> !this.isNull(item.getCategory()))
|
||||
.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()
|
||||
.must(() -> !this.isNull(item.getOrdinal()))
|
||||
.failOn(FieldPersist._ordinal).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._ordinal}, LocaleContextHolder.getLocale())),
|
||||
|
|
|
@ -136,24 +136,14 @@ public class SectionPersist {
|
|||
this.spec()
|
||||
.must(() -> !this.isNull(item.getHasTemplates()))
|
||||
.failOn(SectionPersist._hasTemplates).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._hasTemplates}, LocaleContextHolder.getLocale())),
|
||||
|
||||
this.spec()
|
||||
.must(() -> !this.isListNullOrEmpty(item.getFields()))
|
||||
.failOn(SectionPersist._fields).failWith(messageSource.getMessage("Validation_Required", new Object[]{eu.eudat.model.persist.descriptiontemplatedefinition.SectionPersist._fieldSets}, LocaleContextHolder.getLocale())),
|
||||
this.navSpec()
|
||||
.iff(() -> !this.isListNullOrEmpty(item.getFields()))
|
||||
.on(SectionPersist._fields)
|
||||
.over(item.getFields().stream().filter(x -> x.getCategory() == DmpBlueprintFieldCategory.System).toList())
|
||||
.using((itm) -> 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())),
|
||||
.over(item.getFields())
|
||||
.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.getDescriptionTemplates()))
|
||||
.on(SectionPersist._descriptionTemplates)
|
||||
|
|
|
@ -134,6 +134,10 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
|||
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.setStatus(model.getStatus());
|
||||
data.setUpdatedAt(Instant.now());
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
import org.springframework.web.context.request.WebRequest;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestControllerAdvice
|
||||
|
@ -111,19 +112,11 @@ public class GlobalExceptionHandler {
|
|||
logLevel = System.Logger.Level.DEBUG;
|
||||
statusCode = HttpStatus.BAD_REQUEST;
|
||||
int code = myValidationException.getCode();
|
||||
if (code > 0) {
|
||||
result = Map.ofEntries(
|
||||
Map.entry("code", code),
|
||||
Map.entry("error", myValidationException.getMessage()),
|
||||
Map.entry("message", myValidationException.getErrors())
|
||||
);
|
||||
}
|
||||
else {
|
||||
result = Map.ofEntries(
|
||||
Map.entry("error", myValidationException.getMessage()),
|
||||
Map.entry("message", myValidationException.getErrors())
|
||||
);
|
||||
}
|
||||
|
||||
result = new HashMap<>();
|
||||
if (code > 0) result.put("code", code);
|
||||
if (myValidationException.getMessage() != null) result.put("error", myValidationException.getMessage());
|
||||
if (myValidationException.getErrors() != null) result.put("message", myValidationException.getErrors());
|
||||
}
|
||||
case MyApplicationException myApplicationException -> {
|
||||
logLevel = System.Logger.Level.ERROR;
|
||||
|
|
|
@ -47,3 +47,6 @@ error-thesaurus:
|
|||
description-is-finalized:
|
||||
code: 119
|
||||
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.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
export enum DmpBlueprintExtraFieldDataType {
|
||||
Date = 0,
|
||||
Number = 1,
|
||||
Text = 2,
|
||||
ExternalAutocomplete = 3
|
||||
Text = 0,
|
||||
RichTex = 1,
|
||||
Date = 2,
|
||||
Number = 3
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
switch (type) {
|
||||
case DmpBlueprintType.Input: return this.language.instant('TYPES.DMP-PROFILE-FIELD.TYPE.INPUT');
|
||||
|
@ -154,10 +145,10 @@ export class EnumUtils {
|
|||
|
||||
toDmpBlueprintExtraFieldDataTypeString(status: DmpBlueprintExtraFieldDataType): string {
|
||||
switch (status) {
|
||||
case DmpBlueprintExtraFieldDataType.Date: return this.language.instant('TYPES.DMP-BLUEPRINT-EXTRA-FIELD-DATA-TYPE.DATE');
|
||||
case DmpBlueprintExtraFieldDataType.Number: return this.language.instant('TYPES.DMP-BLUEPRINT-EXTRA-FIELD-DATA-TYPE.NUMBER');
|
||||
case DmpBlueprintExtraFieldDataType.Text: return this.language.instant('TYPES.DMP-BLUEPRINT-EXTRA-FIELD-DATA-TYPE.TEXT');
|
||||
case DmpBlueprintExtraFieldDataType.ExternalAutocomplete: return this.language.instant('TYPES.DMP-BLUEPRINT-EXTRA-FIELD-DATA-TYPE.EXTERNAL-AUTOCOMPLETE');
|
||||
case DmpBlueprintExtraFieldDataType.Text: return this.language.instant('TYPES.DMP-PROFILE-FIELD.DATA-TYPE.TEXT');
|
||||
case DmpBlueprintExtraFieldDataType.RichTex: return this.language.instant('TYPES.DMP-PROFILE-FIELD.DATA-TYPE.RICH-TEXT');
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
<div class="col-auto d-flex">
|
||||
<mat-card-title>{{'DMP-BLUEPRINT-EDITOR.FIELDS.SECTION-PREFIX' | translate}} {{sectionIndex + 1}}</mat-card-title>
|
||||
</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">
|
||||
<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">
|
||||
<mat-form-field class="w-100">
|
||||
<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-select>
|
||||
<!-- <mat-error *ngIf="fieldsArray(sectionIndex).hasError('required')">
|
||||
|
@ -103,7 +103,7 @@
|
|||
<span style="font-size: 15px;">{{fieldIndex + 1}}</span>
|
||||
</div>
|
||||
<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 class="col-auto" *ngIf="field.get('category').value === dmpBlueprintSectionFieldCategory.SYSTEM">
|
||||
<mat-form-field class="w-100">
|
||||
|
@ -115,7 +115,7 @@
|
|||
<div class="col-auto" *ngIf="field.get('category').value === dmpBlueprintSectionFieldCategory.EXTRA">
|
||||
<mat-form-field class="w-100">
|
||||
<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">
|
||||
{{enumUtils.toDmpBlueprintExtraFieldDataTypeString(extraFieldDataType)}}
|
||||
</mat-option>
|
||||
|
@ -127,7 +127,7 @@
|
|||
<div class="col">
|
||||
<mat-form-field class="w-100">
|
||||
<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('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
|
@ -182,8 +182,7 @@
|
|||
<div class="col-12">
|
||||
<mat-form-field class="w-100">
|
||||
<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>
|
||||
</mat-form-field>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -219,6 +218,8 @@
|
|||
</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>
|
||||
|
||||
|
||||
|
|
|
@ -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 {
|
||||
background-color: var(--primary-color-3);
|
||||
// background-color: #0070c0;
|
||||
|
|
|
@ -748,7 +748,7 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
|
|||
|
||||
// getDmpBlueprintFieldDataTypeWithLanguage(fieldType: DmpBlueprintFieldDataType): string {
|
||||
// let result = '';
|
||||
// this.language.get(this.enumUtils.toDmpBlueprintFieldDataTypeString(fieldType))
|
||||
// this.language.get(this.enumUtils.toDmpBlueprintExtraFieldDataTypeString(fieldType))
|
||||
// .pipe(takeUntil(this._destroyed))
|
||||
// .subscribe((value: string) => {
|
||||
// result = value;
|
||||
|
|
|
@ -67,14 +67,14 @@ export class DmpBlueprintEditorModel extends BaseEditorModel implements DmpBluep
|
|||
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);
|
||||
field.id = Guid.create();
|
||||
field.ordinal = index + 1;
|
||||
field.category = DmpBlueprintSectionFieldCategory.SYSTEM;
|
||||
field.systemFieldType = systemFieldType;
|
||||
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 {
|
||||
|
@ -82,7 +82,7 @@ export class DmpBlueprintEditorModel extends BaseEditorModel implements DmpBluep
|
|||
field.id = Guid.create();
|
||||
field.ordinal = index + 1;
|
||||
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 {
|
||||
|
@ -90,7 +90,7 @@ export class DmpBlueprintEditorModel extends BaseEditorModel implements DmpBluep
|
|||
descriptionTemplate.id = Guid.create();
|
||||
descriptionTemplate.descriptionTemplateId = item.id;
|
||||
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: {
|
||||
|
@ -143,8 +143,8 @@ export class DmpBlueprintDefinitionEditorModel implements DmpBlueprintDefinition
|
|||
this.validationErrorModel
|
||||
).fromModel(item).buildForm({
|
||||
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 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;
|
||||
return baseContext;
|
||||
|
@ -233,8 +233,8 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef
|
|||
this.validationErrorModel
|
||||
).fromModel(item).buildForm({
|
||||
rootPath: `${rootPath}fields[${index}].`
|
||||
}), context.getValidation('fields')
|
||||
)
|
||||
})
|
||||
), context.getValidation('fields')
|
||||
),
|
||||
descriptionTemplates: this.formBuilder.array(
|
||||
(this.descriptionTemplates ?? []).map(
|
||||
|
@ -242,8 +242,8 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef
|
|||
this.validationErrorModel
|
||||
).fromModel(item).buildForm({
|
||||
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 baseValidationArray: Validation[] = new Array<Validation>();
|
||||
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: 'description', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}description`)] });
|
||||
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: 'hash', validators: [] });
|
||||
|
||||
|
@ -280,7 +280,7 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef
|
|||
validationErrorModel
|
||||
});
|
||||
|
||||
['id','label', 'ordinal', 'description', 'hasTemplates', 'hash'].forEach(keyField => {
|
||||
['id', 'label', 'ordinal', 'description', 'hasTemplates', 'hash'].forEach(keyField => {
|
||||
const control = formGroup?.get(keyField);
|
||||
control?.clearValidators();
|
||||
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],
|
||||
dataType: [{ value: this.dataType, disabled: disabled }, context.getValidation('dataType').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],
|
||||
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').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: 'dataType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}dataType`)] });
|
||||
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: 'description', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}description`)] });
|
||||
baseValidationArray.push({ key: 'required', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}required`)] });
|
||||
|
@ -401,10 +402,14 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
|
|||
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);
|
||||
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);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -450,7 +455,6 @@ export class DescriptionTemplatesInSectionEditorModel implements DescriptionTemp
|
|||
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
|
||||
minMultiplicity: [{ value: this.minMultiplicity, disabled: disabled }, context.getValidation('minMultiplicity').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>();
|
||||
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}id`)] });
|
||||
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: 'maxMultiplicity', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}maxMultiplicity`)] });
|
||||
|
||||
|
|
|
@ -2299,7 +2299,7 @@
|
|||
"DATE": "Date",
|
||||
"NUMBER": "Number",
|
||||
"TEXT": "Text",
|
||||
"EXTERNAL-AUTOCOMPLETE": "External AutoComplete"
|
||||
"RICH-TEXT": "Rich Text"
|
||||
},
|
||||
"REFERENCE-FIELD-DATA-TYPE": {
|
||||
"TEXT": "Text",
|
||||
|
|
|
@ -11,6 +11,15 @@ export class ValidationContext {
|
|||
}
|
||||
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 {
|
||||
|
|
Loading…
Reference in New Issue