Skip to content
Snippets Groups Projects
Commit 304af773 authored by jojohoch's avatar jojohoch
Browse files

[editor] Add ids of drop values to IdService in DropListElement

and DropListSimpleElement
parent 693572a0
No related branches found
No related tags found
No related merge requests found
import {
DragNDropValueObject,
FontElement,
FontProperties,
InputElement,
......@@ -7,6 +8,7 @@ import {
UIElement
} from '../../models/uI-element';
import { initFontElement, initSurfaceElement } from '../../util/unit-interface-initializer';
import { IdService } from '../../../editor/src/app/services/id.service';
export class DropListSimpleElement extends InputElement implements FontElement, SurfaceElement {
connectedTo: string[] = [];
......@@ -25,10 +27,16 @@ export class DropListSimpleElement extends InputElement implements FontElement,
delete this.label;
this.value = serializedElement.value as string[] || [];
this.value = serializedElement.value as DragNDropValueObject[] || [];
this.height = serializedElement.height || 100;
this.surfaceProps.backgroundColor =
serializedElement.surfaceProps?.backgroundColor as string ||
'#eeeeec';
this.value?.forEach((valueElement: DragNDropValueObject) => {
if (IdService.getInstance() && IdService.getInstance().isIdAvailable(valueElement.id)) {
IdService.getInstance().addID(valueElement.id);
}
});
}
}
......@@ -9,6 +9,7 @@ import {
UIElement
} from '../../models/uI-element';
import { initFontElement, initPositionedElement, initSurfaceElement } from '../../util/unit-interface-initializer';
import { IdService } from '../../../editor/src/app/services/id.service';
export class DropListElement extends InputElement implements PositionedElement, FontElement, SurfaceElement {
onlyOneItem: boolean = false;
......@@ -43,6 +44,12 @@ export class DropListElement extends InputElement implements PositionedElement,
'#f4f4f2';
this.handleBackwardsCompatibility(serializedElement);
this.value?.forEach((valueElement: DragNDropValueObject) => {
if (IdService.getInstance() && IdService.getInstance().isIdAvailable(valueElement.id)) {
IdService.getInstance().addID(valueElement.id);
}
});
}
handleBackwardsCompatibility(serializedElement: Partial<UIElement>): void {
......
......@@ -50,25 +50,9 @@ export class UnitService {
loadUnitDefinition(unitDefinition: string): void {
if (unitDefinition) {
this.unit = new Unit(JSON.parse(unitDefinition));
this.readExistingIDs();
}
}
private readExistingIDs(): void {
this.unit.pages.forEach((page: Page) => {
page.sections.forEach((section: Section) => {
section.elements.forEach((element: UIElement) => {
this.idService.addID(element.id);
if (element.type === 'drop-list') {
element.value?.forEach((valueElement: DragNDropValueObject) => {
this.idService.addID(valueElement.id);
});
}
});
});
});
}
addPage(): void {
this.unit.addPage();
this.veronaApiService.sendVoeDefinitionChangedNotification();
......
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