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

[editor] Fix initialization of GeoGebra elements when loading a 2nd unit

parent ca3c4df5
No related branches found
No related tags found
No related merge requests found
......@@ -12,11 +12,10 @@ import { CompoundChildOverlayComponent } from
import { DragNDropValueObject, UIElement } from 'common/models/elements/element';
import { GeometryComponent } from 'common/components/geometry/geometry.component';
import { GeometryElement } from 'common/models/elements/geometry/geometry';
import { UnitService } from '../../../services/unit.service';
import { SelectionService } from '../../../services/selection.service';
import { DropListComponent } from 'common/components/input-elements/drop-list.component';
import { DropListElement } from 'common/models/elements/input-elements/drop-list';
import { FormElementComponent } from 'common/directives/form-element-component.directive';
import { UnitService } from '../../../services/unit.service';
import { SelectionService } from '../../../services/selection.service';
@Directive()
export abstract class CanvasElementOverlay implements OnInit, OnDestroy {
......@@ -36,6 +35,9 @@ export abstract class CanvasElementOverlay implements OnInit, OnDestroy {
ngOnInit(): void {
this.childComponent = this.elementContainer.createComponent(this.element.getElementComponent());
this.childComponent.instance.elementModel = this.element;
if (this.childComponent.instance instanceof GeometryComponent) {
this.childComponent.instance.appDefinition = (this.element as GeometryElement).appDefinition;
}
this.childComponent.changeDetectorRef.detectChanges(); // this fires onInit, which initializes the FormControl
if (this.childComponent.instance instanceof FormElementComponent) {
(this.childComponent.instance as FormElementComponent).elementFormControl.setValue(this.element.value);
......@@ -48,9 +50,6 @@ export abstract class CanvasElementOverlay implements OnInit, OnDestroy {
// Make children not clickable. This way the only relevant events are managed by the overlay.
this.childComponent.location.nativeElement.style.pointerEvents = 'none';
if (this.childComponent.instance instanceof GeometryComponent) {
this.childComponent.instance.appDefinition = (this.element as GeometryElement).appDefinition;
}
if (this.childComponent.instance instanceof ClozeComponent) {
// make cloze element children clickable to access child elements
this.childComponent.instance.editorMode = true;
......
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