Skip to content
Snippets Groups Projects
Commit 351b5189 authored by rhenck's avatar rhenck
Browse files

[editor] Fix duplicated section elements not getting new ID

parent a10035c6
No related branches found
No related tags found
No related merge requests found
import { Section } from './section'; import { Section } from './section';
import { moveArrayItem } from '../util/array'; import { moveArrayItem } from '../util/array';
import { UIElement } from './uI-element';
import { IdService } from '../id.service';
export class Page { export class Page {
[index: string]: string | number | boolean | Section[] | undefined | ((...args: any) => any); [index: string]: string | number | boolean | Section[] | undefined | ((...args: any) => any);
...@@ -39,8 +41,12 @@ export class Page { ...@@ -39,8 +41,12 @@ export class Page {
); );
} }
/** Create new section with old section elements are overwrite the ids. */
duplicateSection(section: Section, sectionIndex: number): void { duplicateSection(section: Section, sectionIndex: number): void {
const newSection = new Section(section); const newSection = new Section(section);
newSection.elements.forEach((element: UIElement) => {
element.id = IdService.getInstance().getNewID(element.type);
});
this.sections.splice(sectionIndex + 1, 0, newSection); this.sections.splice(sectionIndex + 1, 0, newSection);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment