From b5c31590d3712672a2943e1c08a19e6e580516b8 Mon Sep 17 00:00:00 2001 From: amentis Date: Wed, 24 Jan 2024 11:40:32 +0200 Subject: [PATCH] add description template editor validator (in progress) --- ...late-editor-composite-field.component.html | 17 ++- ...-editor-auto-complete-field.component.html | 17 ++- ...or-dataset-identifier-field.component.html | 1 + ...datasets-autocomplete-field.component.html | 1 + ...tor-dmps-autocomplete-field.component.html | 1 + ...tor-external-datasets-field.component.html | 6 +- ...e-editor-multiplicity-field.component.html | 1 + ...te-editor-placeholder-field.component.html | 1 + ...file-editor-radio-box-field.component.html | 8 +- ...archers-auto-complete-field.component.html | 4 +- ...le-editor-researchers-field.component.html | 4 +- ...t-profile-editor-tags-field.component.html | 4 +- ...emplate-editor-upload-field.component.html | 4 + ...late-editor-word-list-field.component.html | 4 + ...ption-template-editor-field.component.html | 5 +- ...dataset-profile-editor-page.component.html | 1 + ...ion-template-editor-section.component.html | 7 +- ...description-template-editor.component.html | 24 +++-- .../description-template-editor.component.ts | 102 +++++++++++------- .../description-template-editor.model.ts | 16 ++- .../notification-listing.component.html | 6 +- 21 files changed, 158 insertions(+), 76 deletions(-) diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html index 37cc9e43a..835aee3b3 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html @@ -8,6 +8,7 @@ + {{form.get('title').getError('backendError').message}} @@ -16,38 +17,43 @@
{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.DESCRIPTION' | translate}}
+ {{form.get('description').getError('backendError').message}}
{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.EXTENDED-DESCRIPTION' | translate}}
+ {{form.get('extendedDescription').getError('backendError').message}}
+ {{form.get('additionalInformation').getError('backendError').message}}
- {{'GENERAL.VALIDATION.REQUIRED' | translate}} - + {{form.get('multiplicity').get('min').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - + {{form.get('multiplicity').get('max').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}}
- + + {{form.get('multiplicity').get('multiplicity').getError('backendError').message}}
{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-TABLEVIEW' | translate}} + {{form.get('multiplicity').get('tableView').getError('backendError').message}}
@@ -268,6 +274,7 @@
  • {{'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.FIELDSET.COMMENT-FIELD' | translate}} + {{form.get('hasCommentField').getError('backendError').message}}
  • diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/auto-complete/description-template-editor-auto-complete-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/auto-complete/description-template-editor-auto-complete-field.component.html index d4e8eb685..8c4632d20 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/auto-complete/description-template-editor-auto-complete-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/auto-complete/description-template-editor-auto-complete-field.component.html @@ -3,11 +3,13 @@
    {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-TITLE' | translate}}
    {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-AUTOCOMPLETE' | translate}} + {{form.get('data').get('multiAutoComplete').getError('backendError').message}} {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-PLACEHOLDER' | translate}} + {{form.get('data').get('label').getError('backendError').message}} @@ -31,31 +33,37 @@ {{method.value}} + {{singleForm.get('method').getError('backendError').message}} {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-URL' | translate}} + {{singleForm.get('url').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-OPTIONS-ROOT' | translate}} + {{singleForm.get('optionsRoot').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-LABEL' | translate}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} + {{singleForm.get('autoCompleteOptions').get('label').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-VALUE' | translate}} + {{singleForm.get('autoCompleteOptions').get('value').getError('backendError').message}} {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-SOURCE' | translate}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} + {{singleForm.get('autoCompleteOptions').get('source').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-HAS-AUTH' | translate}}
    @@ -64,10 +72,12 @@ {{method.value}} + {{singleForm.get('auth').get('method').getError('backendError').message}} {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-URL' | translate}} + {{singleForm.get('auth').get('method').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} @@ -75,15 +85,18 @@ {{type.value}} + {{singleForm.get('auth').get('type').getError('backendError').message}} {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-OPTIONS-ROOT' | translate}} + {{singleForm.get('auth').get('path').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-AUTH-BODY' | translate}} + {{singleForm.get('auth').get('body').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}}
    diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.html index 263601838..55d56dbcb 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component.html @@ -5,5 +5,6 @@ {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-DATASET-IDENTIFIER-PLACEHOLDER' | translate}} + {{form.get('data').get('label').getError('backendError').message}} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.html index e7c6d01dc..7801ea8d0 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/datasets-auto-complete/dataset-profile-editor-datasets-autocomplete-field.component.html @@ -9,5 +9,6 @@ {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-DATASETS-PLACEHOLDER' | translate}} + {{form.get('data').get('label').getError('backendError').message}} diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.html index 2109b436b..825e863cf 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/dmps-auto-complete/dataset-profile-editor-dmps-autocomplete-field.component.html @@ -9,5 +9,6 @@ {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-DMPS-PLACEHOLDER' | translate}} + {{form.get('data').get('label').getError('backendError').message}} diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.html index d8e932f46..8149e044a 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-datasets/dataset-profile-editor-external-datasets-field.component.html @@ -7,8 +7,8 @@ {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-EXTERNAL-DATASETS-PLACEHOLDER' | translate}} - + + {{form.get('data').get('label').getError('backendError').message}} @@ -17,6 +17,6 @@ {{type.label | translate}} - + {{form.get('data').get('type').getError('backendError').message}} diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/multiplicity-field/description-template-editor-multiplicity-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/multiplicity-field/description-template-editor-multiplicity-field.component.html index d0104cab7..be9ef3417 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/multiplicity-field/description-template-editor-multiplicity-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/multiplicity-field/description-template-editor-multiplicity-field.component.html @@ -6,5 +6,6 @@ {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-LABEL' | translate}} + {{form.get('data').get('label').getError('backendError').message}} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/placeholder-field/description-template-editor-placeholder-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/placeholder-field/description-template-editor-placeholder-field.component.html index 43d7560aa..d72c65e8b 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/placeholder-field/description-template-editor-placeholder-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/placeholder-field/description-template-editor-placeholder-field.component.html @@ -5,5 +5,6 @@ {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-LABEL' | translate}} + {{form.get('data').get('label').getError('backendError').message}} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.html index 944b3e3a9..084d5c032 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/radio-box/dataset-profile-editor-radio-box-field.component.html @@ -18,13 +18,13 @@
    {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-LABEL' | translate}} - + + {{form.get('data').get('options').get(''+i).get('label').getError('backendError').message}} {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-VALUE' | translate}} - + + {{form.get('data').get('options').get(''+i).get('value').getError('backendError').message}}
    diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.html index bc1c84e39..c9891beb3 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component.html @@ -6,7 +6,7 @@
    {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RESEARCHERS-PLACEHOLDER' | translate}} - + + {{form.get('data').get('label').getError('backendError').message}} diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.html index bab2b500f..d3a9f9587 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/tags/dataset-profile-editor-tags-field.component.html @@ -3,7 +3,7 @@ | translate}} {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-TAGS-PLACEHOLDER' | translate}} - + + {{form.get('data').get('label').getError('backendError').message}} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/upload/description-template-editor-upload-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/upload/description-template-editor-upload-field.component.html index 0edfd3d46..5b73332ea 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/upload/description-template-editor-upload-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/upload/description-template-editor-upload-field.component.html @@ -8,6 +8,7 @@ {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-PLACEHOLDER' | translate}} + {{form.get('data').get('label').getError('backendError').message}} @@ -16,6 +17,7 @@ translate: { maxfilesize: getConfiguration().maxFileSizeInMB.toString() } }} + {{form.get('data').get('maxFileSizeInMB').getError('backendError').message}} @@ -36,10 +38,12 @@ {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-LABEL' | translate}} + {{form.get('data').get('types').get(''+i).get('label').getError('backendError').message}} {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-VALUE' | translate}} + {{form.get('data').get('types').get(''+i).get('value').getError('backendError').message}} + - diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts index 280839d77..4ba0e88e1 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts @@ -171,6 +171,10 @@ export class DescriptionTemplateEditorComponent extends BaseEditor -1 ){ + //create one field form fieldset + const field: DescriptionTemplateFieldEditorModel = new DescriptionTemplateFieldEditorModel(this.editorModel.validationErrorModel); + field.id = Guid.create().toString(); + field.ordinal = 0;//first filed in the fields list + // const fieldForm = field.buildForm(); + // fieldForm.setValidators(this.customFieldValidator()); + // fieldForm.get('viewStyle').get('renderStyle').setValidators(Validators.required); - try { - const maxOrdinal = fieldSetsArray.controls.map(control => control.get('ordinal').value).reduce((a, b) => Math.max(a, b)); - fieldSet.ordinal = maxOrdinal + 1; - } catch { - fieldSet.ordinal = fieldSetsArray.length; - } - const fieldsetForm = fieldSet.buildForm(); + // fieldSet.fields.push(field); + // field.ordinal = fieldSet.fields.length-1; + const fieldSetsArray = parent.form.get('fieldSets') as UntypedFormArray + const fieldForm = field.buildForm({ rootPath: 'definition.sections[' + sectionIndex + '].fieldSets[' + fieldSetsArray.length + '].fields['+ 0 + '].'}); + //give fieldset id and ordinal + const fieldSet: DescriptionTemplateFieldSetEditorModel = new DescriptionTemplateFieldSetEditorModel(this.editorModel.validationErrorModel); + const fieldSetId = Guid.create().toString(); + fieldSet.id = fieldSetId; - (fieldsetForm.get('fields') as UntypedFormArray).push(fieldForm); - fieldSetsArray.push(fieldsetForm); + try { + const maxOrdinal = fieldSetsArray.controls.map(control => control.get('ordinal').value).reduce((a, b) => Math.max(a, b)); + fieldSet.ordinal = maxOrdinal + 1; + } catch { + fieldSet.ordinal = fieldSetsArray.length; + } + const fieldsetForm = fieldSet.buildForm({ rootPath: 'definition.sections[' + sectionIndex + '].fieldSets[' + fieldSetsArray.length + '].'}); - this.refreshToCEntries(); - this.selectedTocEntry = this._findTocEntryById(fieldSetId.toString(), this.toCEntries); - // fieldForm.updateValueAndValidity(); + (fieldsetForm.get('fields') as UntypedFormArray).push(fieldForm); + fieldSetsArray.push(fieldsetForm); - break; + this.refreshToCEntries(); + this.selectedTocEntry = this._findTocEntryById(fieldSetId.toString(), this.toCEntries); + // fieldForm.updateValueAndValidity(); + + break; + } default: break; @@ -734,6 +760,8 @@ export class DescriptionTemplateEditorComponent extends BaseEditor this.users.push(new UserDescriptionTemplateEditorModel().fromModel(x))); } + if (item.users) { item.users.map(x => this.users.push(new UserDescriptionTemplateEditorModel(this.validationErrorModel).fromModel(x))); } } return this; } @@ -84,6 +84,18 @@ export class DescriptionTemplateEditorModel extends BaseEditorModel implements D return baseContext; } + createChildPage(index: number, id: string): UntypedFormGroup { + const page: DescriptionTemplatePageEditorModel = new DescriptionTemplatePageEditorModel(this.validationErrorModel); + page.id = id; + if (isNaN(index)) { page.ordinal = 0; } else { page.ordinal = index; } + return page.buildForm({ rootPath: 'definition.pages[' + index + '].' }); + } + + createChildSection(index: number): UntypedFormGroup { + const section: DescriptionTemplateSectionEditorModel = new DescriptionTemplateSectionEditorModel(this.validationErrorModel); + return section.buildForm({ rootPath: 'definition.sections[' + index + '].' }); + } + static reApplyDefinitionValidators(params: { formGroup: UntypedFormGroup, validationErrorModel: ValidationErrorModel, diff --git a/dmp-frontend/src/app/ui/admin/notification/notification-listing.component.html b/dmp-frontend/src/app/ui/admin/notification/notification-listing.component.html index 5d78108ad..a56c1ce91 100644 --- a/dmp-frontend/src/app/ui/admin/notification/notification-listing.component.html +++ b/dmp-frontend/src/app/ui/admin/notification/notification-listing.component.html @@ -1,7 +1,7 @@ -
    -
    +
    +
    -
    +

    {{'NOTIFICATION-SERVICE.NOTIFICATION-LISTING.TITLE' | translate}}