diff --git a/projects/common/models/page.ts b/projects/common/models/page.ts index 96b6f0e9b58c69e007d7b9db36a79222568543d7..06752164466eba1805cfd3a25b1df420225d5fa0 100644 --- a/projects/common/models/page.ts +++ b/projects/common/models/page.ts @@ -2,7 +2,6 @@ import { Section } from 'common/models/section'; export class Page { [index: string]: any; - sections: Section[] = []; hasMaxWidth: boolean = false; maxWidth: number = 900; @@ -13,7 +12,7 @@ export class Page { alwaysVisibleAspectRatio: number = 50; constructor(page?: Page) { - this.sections = page?.sections.map(section => new Section(section)) || [new Section()]; Object.assign(this, page); + this.sections = page?.sections.map(section => new Section(section)) || [new Section()]; } } diff --git a/projects/common/models/section.ts b/projects/common/models/section.ts index b8344f3f68decf42806643a76062e7a14f31c0a9..19bd845115f2c71f0af2c725dda7cc35b800e688 100644 --- a/projects/common/models/section.ts +++ b/projects/common/models/section.ts @@ -1,4 +1,4 @@ -import { PositionedUIElement } from 'common/models/elements/element'; +import { PositionedUIElement, UIElement } from 'common/models/elements/element'; import { ElementFactory } from 'common/util/element.factory'; export class Section { @@ -15,13 +15,17 @@ export class Section { activeAfterID: string | null = null; constructor(section?: Partial<Section>) { + Object.assign(this, section); this.elements = section?.elements?.map(element => ElementFactory.createElement(element.type, element) as PositionedUIElement) || []; - Object.assign(this, section); } setProperty(property: string, value: any): void { this[property] = value; } + + getElements(): UIElement[] { + return this.elements; + } }