From 351b5189100630a330c8235dc21ae8e24941d5cf Mon Sep 17 00:00:00 2001 From: rhenck <richard.henck@iqb.hu-berlin.de> Date: Mon, 25 Oct 2021 15:46:42 +0200 Subject: [PATCH] [editor] Fix duplicated section elements not getting new ID --- projects/common/models/page.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/projects/common/models/page.ts b/projects/common/models/page.ts index 182e2609f..20271b878 100644 --- a/projects/common/models/page.ts +++ b/projects/common/models/page.ts @@ -1,5 +1,7 @@ import { Section } from './section'; import { moveArrayItem } from '../util/array'; +import { UIElement } from './uI-element'; +import { IdService } from '../id.service'; export class Page { [index: string]: string | number | boolean | Section[] | undefined | ((...args: any) => any); @@ -39,8 +41,12 @@ export class Page { ); } + /** Create new section with old section elements are overwrite the ids. */ duplicateSection(section: Section, sectionIndex: number): void { const newSection = new Section(section); + newSection.elements.forEach((element: UIElement) => { + element.id = IdService.getInstance().getNewID(element.type); + }); this.sections.splice(sectionIndex + 1, 0, newSection); } -- GitLab