Skip to content
Snippets Groups Projects
Commit 9c309b39 authored by jojohoch's avatar jojohoch
Browse files

[editor] Implement getSchemerData in Unit, Page and Section

parent 5b5a67ca
No related branches found
No related tags found
No related merge requests found
import { Section } from 'common/models/section';
import { IDManager } from 'common/util/id-manager';
import { UIElement } from 'common/models/elements/element';
import { SchemerData, UIElement } from 'common/models/elements/element';
export class Page {
[index: string]: unknown;
......@@ -27,4 +27,8 @@ export class Page {
getAllElements(elementType?: string): UIElement[] {
return this.sections.map(section => section.getAllElements(elementType)).flat();
}
getSchemerData(dropLists: UIElement[]): SchemerData[] {
return this.sections.map(section => section.getSchemerData(dropLists)).flat();
}
}
import { Type } from '@angular/core';
import { IDManager } from 'common/util/id-manager';
import { PositionedUIElement, UIElement, UIElementValue } from 'common/models/elements/element';
import {
InputElement,
PositionedUIElement,
SchemerData,
UIElement,
UIElementValue
} from 'common/models/elements/element';
import { ButtonElement } from 'common/models/elements/button/button';
import { TextElement } from 'common/models/elements/text/text';
import { TextFieldElement } from 'common/models/elements/input-elements/text-field';
......@@ -97,4 +103,13 @@ export class Section {
}
return allElements;
}
getSchemerData(dropLists: UIElement[]): SchemerData[] {
return this.getAllElements()
.filter(element => element.hasSchemerData())
.map(element =>
(element.type === 'drop-list' || element.type === 'drop-list-simple') ?
(element as InputElement).getSchemerData(dropLists) :
(element as InputElement | TextElement).getSchemerData());
}
}
import packageJSON from '../../../package.json';
import { Page } from 'common/models/page';
import { IDManager } from 'common/util/id-manager';
import { UIElement } from 'common/models/elements/element';
import { SchemerData, UIElement } from 'common/models/elements/element';
export class Unit {
type = 'aspect-unit-definition';
......@@ -16,4 +16,12 @@ export class Unit {
getAllElements(elementType?: string): UIElement[] {
return this.pages.map(page => page.getAllElements(elementType)).flat();
}
getSchemerData(): SchemerData[] {
const dropLists = [
...this.getAllElements('drop-list'),
...this.getAllElements('drop-list-simple')
];
return this.pages.map(page => page.getSchemerData(dropLists)).flat();
}
}
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