From 79005d70c42c316c0e2dcd4669c5d6f7f5e7edb4 Mon Sep 17 00:00:00 2001 From: Sofia Papacharalampous Date: Mon, 20 May 2024 11:00:57 +0300 Subject: [PATCH] bug fix on chapter reordering of description-template-editor toc --- .../description-template-table-of-contents.ts | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/table-of-contents/description-template-table-of-contents.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/table-of-contents/description-template-table-of-contents.ts index 81128906e..2e89caf35 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/table-of-contents/description-template-table-of-contents.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/table-of-contents/description-template-table-of-contents.ts @@ -66,8 +66,6 @@ export class DescriptionTemplateTableOfContents extends BaseComponent implements if (this._dragStartedAt) { const timeNow = new Date().getTime(); if (timeNow - this._dragStartedAt > this.VALID_DROP_TIME) { - // console.log('timenow: ', timeNow); - // console.log('timestarted', this._dragStartedAt); this._dragStartedAt = null; } else { @@ -113,9 +111,7 @@ export class DescriptionTemplateTableOfContents extends BaseComponent implements switch (element.type) { case ToCEntryType.FieldSet: { if (targetContainer.type != this.tocEntryType.Section) { - // const message = 'Fieldset can only be child of Subsections'; const message = this.language.instant('DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.TABLE-OF-CONTENTS.ERROR-MESSAGES.FIELDSET-MUST-HAVE-PARENT-SECTION'); - // console.error(message); this.notifyUser(message) this.dataNeedsRefresh.emit(); return; @@ -123,10 +119,8 @@ export class DescriptionTemplateTableOfContents extends BaseComponent implements //check if target container has no sections if ((targetContainer.form.get('sections') as UntypedFormArray).length) { - // const message = 'Cannot have inputs and sections on the same level'; const message = this.language.instant('DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.TABLE-OF-CONTENTS.ERROR-MESSAGES.INPUT-SECTION-SAME-LEVEL'); this.notifyUser(message); - // console.error(message); this.dataNeedsRefresh.emit(); return; } @@ -201,10 +195,8 @@ export class DescriptionTemplateTableOfContents extends BaseComponent implements if (targetContainer.type == ToCEntryType.Section) { if ((targetContainer.form.get('fieldSets') as UntypedFormArray).length) { - // const message = 'Cannot have inputs and sections on the same level'; const message = this.language.instant('DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.TABLE-OF-CONTENTS.ERROR-MESSAGES.INPUT-SECTION-SAME-LEVEL');; this.notifyUser(message); - // console.info(message); this.dataNeedsRefresh.emit(); return; } @@ -267,7 +259,6 @@ export class DescriptionTemplateTableOfContents extends BaseComponent implements } else if (targetContainer.type === ToCEntryType.Page) { const rootform = targetContainer.form; - // const rootform = targetContainer.form.root; const sectionForm = element.form; const parentSections = sectionForm.parent as UntypedFormArray; @@ -333,10 +324,8 @@ export class DescriptionTemplateTableOfContents extends BaseComponent implements targetSectionsArray.push(sectionForm); } else { - // const message = 'Drag not support to specific container'; const message = this.language.instant('DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.TABLE-OF-CONTENTS.ERROR-MESSAGES.DRAG-NOT-SUPPORTED'); this.notifyUser(message); - // console.info(message); this.dataNeedsRefresh.emit(); return; } @@ -348,10 +337,8 @@ export class DescriptionTemplateTableOfContents extends BaseComponent implements } case ToCEntryType.Page: { if (targetId != this.ROOT_ID) { - // const message = 'A page element can only be at top level'; const message = this.language.instant('DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.TABLE-OF-CONTENTS.ERROR-MESSAGES.PAGE-ELEMENT-ONLY-TOP-LEVEL'); this.notifyUser(message); - // console.info(message); this.dataNeedsRefresh.emit(); return; } @@ -364,7 +351,7 @@ export class DescriptionTemplateTableOfContents extends BaseComponent implements } - const pages = rootForm.get('pages') as UntypedFormArray; + const pages = rootForm.get('definition')?.get('pages') as UntypedFormArray; const pageForm = element.form; let index = -1;