Skip to content
Snippets Groups Projects
page.ts 1.4 KiB
Newer Older
  • Learn to ignore specific revisions
  • import { Section } from 'common/models/section';
    
    import { AnswerScheme, UIElement } from 'common/models/elements/element';
    
    
    export class Page {
    
    rhenck's avatar
    rhenck committed
      [index: string]: unknown;
    
      sections: Section[] = [];
      hasMaxWidth: boolean = false;
      maxWidth: number = 900;
      margin: number = 30;
      backgroundColor: string = '#ffffff';
      alwaysVisible: boolean = false;
      alwaysVisiblePagePosition: 'left' | 'right' | 'top' | 'bottom' = 'left';
      alwaysVisibleAspectRatio: number = 50;
    
    
    rhenck's avatar
    rhenck committed
      constructor(page?: Partial<Page>) {
    
    rhenck's avatar
    rhenck committed
        if (page?.hasMaxWidth) this.hasMaxWidth = page.hasMaxWidth;
        if (page?.maxWidth) this.maxWidth = page.maxWidth;
    
        if (page?.margin !== undefined) this.margin = page.margin;
    
    rhenck's avatar
    rhenck committed
        if (page?.backgroundColor) this.backgroundColor = page.backgroundColor;
        if (page?.alwaysVisible) this.alwaysVisible = page.alwaysVisible;
        if (page?.alwaysVisiblePagePosition) this.alwaysVisiblePagePosition = page.alwaysVisiblePagePosition;
        if (page?.alwaysVisibleAspectRatio) this.alwaysVisibleAspectRatio = page.alwaysVisibleAspectRatio;
    
    rhenck's avatar
    rhenck committed
        this.sections = page?.sections?.map(section => new Section(section)) || [new Section()];
    
    
      getAllElements(elementType?: string): UIElement[] {
        return this.sections.map(section => section.getAllElements(elementType)).flat();
      }
    
      getAnswerScheme(dropLists: UIElement[]): AnswerScheme[] {
        return this.sections.map(section => section.getAnswerScheme(dropLists)).flat();