Huge refactoring of state and initial UI setup

This commit is contained in:
Pieter Vander Vennet 2021-10-15 05:20:02 +02:00
parent 4e43673de5
commit eff6b5bfad
37 changed files with 5232 additions and 4907 deletions

View file

@ -176,7 +176,8 @@ export default class LocationInput extends InputElement<Loc> implements MinimapO
enablePopups: false,
zoomToFeatures: false,
leafletMap: this.map.leafletMap,
layers: State.state.filteredLayers
layers: State.state.filteredLayers,
allElements: State.state.allElements
}
)
// Show the central point
@ -191,7 +192,9 @@ export default class LocationInput extends InputElement<Loc> implements MinimapO
enablePopups: false,
zoomToFeatures: false,
leafletMap: this.map.leafletMap,
layerToShow: this._matching_layer
layerToShow: this._matching_layer,
allElements: State.state.allElements,
selectedElement: State.state.selectedElement
})
}

View file

@ -1,6 +1,7 @@
import {UIEventSource} from "../../Logic/UIEventSource";
import BaseUIElement from "../BaseUIElement";
import {VariableUiElement} from "../Base/VariableUIElement";
import Lazy from "../Base/Lazy";
/**
* The 'Toggle' is a UIElement showing either one of two elements, depending on the state.
@ -24,4 +25,16 @@ export default class Toggle extends VariableUiElement {
})
return this;
}
public static If(condition: UIEventSource<boolean>, constructor: () => BaseUIElement): BaseUIElement {
if(constructor === undefined){
return undefined
}
return new Toggle(
new Lazy(constructor),
undefined,
condition
)
}
}