From 53b61853e193b86ff1caeec9f536b0acdf441633 Mon Sep 17 00:00:00 2001 From: Aldo Mihasi Date: Mon, 2 Oct 2023 09:34:58 +0300 Subject: [PATCH] bug fixes --- .../editor/dmp-profile-editor.component.html | 2 +- .../editor/dmp-profile-editor.component.ts | 21 ++++++++++++------- .../dmp-editor-blueprint.component.ts | 4 ++-- .../dmp-upload-dialogue.component.html | 6 +++--- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.html b/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.html index f30781fdc..b3a196742 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.html @@ -82,7 +82,7 @@ System fields - {{f.label}} + {{f.label}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} diff --git a/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.ts b/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.ts index 94b6e5e70..b1c623a11 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.ts @@ -74,7 +74,6 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie {label: 'License', type: SystemFieldType.LICENSE}, {label: 'Access Rights', type: SystemFieldType.ACCESS_RIGHTS} ]; - selectedSystemFields: string[] = []; systemFieldListPerSection: Array> = new Array(); descriptionTemplatesPerSection: Array> = new Array>(); @@ -195,9 +194,11 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie section.ordinal = this.sectionsArray().length + 1; section.hasTemplates = false; this.sectionsArray().push(section.buildForm()); + this.systemFieldListPerSection.push(new Array()); } removeSection(sectionIndex: number): void { + this.systemFieldListPerSection.splice(sectionIndex, 1); this.sectionsArray().removeAt(sectionIndex); } @@ -245,14 +246,14 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie return this.fieldList.find(f => f.type == type).label; } - selectedFieldType(systemField: string, type: SystemFieldType, sectionIndex: number): void { - let index = this.selectedSystemFields.indexOf(systemField); + selectedFieldType(type: SystemFieldType, sectionIndex: number): void { + let index = this.systemFieldListPerSection[sectionIndex].indexOf(type); if (index == -1) { - this.selectedSystemFields.push(systemField); + this.systemFieldListPerSection[sectionIndex].push(type); this.addSystemField(sectionIndex, type); } else { - this.selectedSystemFields.splice(index, 1); + this.systemFieldListPerSection[sectionIndex].splice(index, 1); this.removeSystemField(sectionIndex, type); } } @@ -273,6 +274,9 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie } removeSystemFieldWithIndex(sectionIndex: number, fieldIndex: number): void { + let type: SystemFieldType = this.fieldsArray(sectionIndex).at(fieldIndex).get('type').value; + let index = this.systemFieldListPerSection[sectionIndex].indexOf(type); + this.systemFieldListPerSection[sectionIndex] = this.systemFieldListPerSection[sectionIndex].filter(types => types != type); this.fieldsArray(sectionIndex).removeAt(fieldIndex); } @@ -337,6 +341,9 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie dropSections(event: CdkDragDrop) { moveItemInArray(this.sectionsArray().controls, event.previousIndex, event.currentIndex); moveItemInArray(this.sectionsArray().value, event.previousIndex, event.currentIndex); + this.sectionsArray().controls.forEach((section, index) => { + section.get('ordinal').setValue(index + 1); + }); } moveItemInFormArray(formArray: FormArray, fromIndex: number, toIndex: number): void { @@ -430,12 +437,12 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie hasTitle(): boolean { const dmpBlueprint: DmpBlueprint = this.formGroup.value; - return dmpBlueprint.definition.sections.some(section => section.fields.some(field => field.category as unknown === 'SYSTEM' && field.type === SystemFieldType.TEXT)); + return dmpBlueprint.definition.sections.some(section => section.fields.some(field => (field.category === FieldCategory.SYSTEM || field.category as unknown === 'SYSTEM') && field.type === SystemFieldType.TEXT)); } hasDescription(): boolean { const dmpBlueprint: DmpBlueprint = this.formGroup.value; - return dmpBlueprint.definition.sections.some(section => section.fields.some(field => field.category as unknown === 'SYSTEM' && field.type === SystemFieldType.HTML_TEXT)); + return dmpBlueprint.definition.sections.some(section => section.fields.some(field => (field.category === FieldCategory.SYSTEM || field.category as unknown === 'SYSTEM') && field.type === SystemFieldType.HTML_TEXT)); } hasDescriptionTemplates(): boolean { diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts index f55a7a9e2..6ae617058 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts @@ -473,7 +473,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im } hasProfile(sectionIndex: number): boolean { - return this.formGroup.get('profiles') && this.formGroup.get('profiles').value && this.formGroup.get('profiles').value.filter(x => x.data.dmpSectionIndex.includes(sectionIndex)).length > 0; + return this.formGroup.get('profiles') && this.formGroup.get('profiles').value && this.formGroup.get('profiles').value.some(x => x.data.dmpSectionIndex.includes(sectionIndex)); } addDataset(dmpSectionIndex: number) { @@ -893,7 +893,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im else { section.descriptionTemplates.forEach(template => { this.sectionTemplates[section.ordinal - 1].push({id: template.descriptionTemplateId, label: template.label, description: ""}) - let found: DmpDatasetProfile = templates.find(dmpDatasetProfile => dmpDatasetProfile.id == template.descriptionTemplateId); + let found: DmpDatasetProfile = templates.find(dmpDatasetProfile => dmpDatasetProfile.descriptionTemplateId == template.descriptionTemplateId); if (found === undefined) { let data: DmpDatasetProfileSectionsFormModel= new DmpDatasetProfileSectionsFormModel(); data.dmpSectionIndex.push(section.ordinal - 1); diff --git a/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html b/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html index 941a735a4..66874939c 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html +++ b/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html @@ -30,14 +30,14 @@ -
+ + -
+ -->