2020-09-13 03:29:44 +02:00
|
|
|
import {UIElement} from "./UIElement";
|
2020-10-02 19:00:24 +02:00
|
|
|
import CheckBox from "./Input/CheckBox";
|
2020-07-22 11:56:40 +02:00
|
|
|
import Combine from "./Base/Combine";
|
2020-10-02 19:00:24 +02:00
|
|
|
import State from "../State";
|
2020-09-13 03:29:44 +02:00
|
|
|
import Translations from "./i18n/Translations";
|
2020-09-17 19:11:16 +02:00
|
|
|
import {FixedUiElement} from "./Base/FixedUiElement";
|
|
|
|
import {VariableUiElement} from "./Base/VariableUIElement";
|
2020-11-27 03:05:29 +01:00
|
|
|
import {UIEventSource} from "../Logic/UIEventSource";
|
2020-07-22 11:49:01 +02:00
|
|
|
|
2020-07-31 16:17:16 +02:00
|
|
|
export class LayerSelection extends UIElement {
|
2020-07-22 11:49:01 +02:00
|
|
|
|
|
|
|
private readonly _checkboxes: UIElement[];
|
|
|
|
|
2020-07-31 16:17:16 +02:00
|
|
|
constructor() {
|
|
|
|
super(undefined);
|
|
|
|
this._checkboxes = [];
|
|
|
|
|
|
|
|
for (const layer of State.state.filteredLayers.data) {
|
2020-11-27 03:05:29 +01:00
|
|
|
const leafletStyle = layer.layerDef.GenerateLeafletStyle(new UIEventSource<any>({id: "node/-1"}), true)
|
|
|
|
const leafletHtml = leafletStyle.icon.html;
|
|
|
|
const icon =
|
|
|
|
new FixedUiElement(leafletHtml)
|
|
|
|
.SetClass("single-layer-selection-toggle")
|
|
|
|
let iconUnselected: UIElement = new FixedUiElement(leafletHtml)
|
|
|
|
.SetClass("single-layer-selection-toggle")
|
|
|
|
.SetStyle("opacity:0.2;");
|
2020-09-17 19:11:16 +02:00
|
|
|
|
2020-09-13 03:29:44 +02:00
|
|
|
const name = Translations.WT(layer.layerDef.name).Clone()
|
2020-09-17 19:11:16 +02:00
|
|
|
.SetStyle("font-size:large;margin-left: 0.5em;");
|
2020-07-23 16:28:19 +02:00
|
|
|
|
2020-09-17 20:59:05 +02:00
|
|
|
|
2020-09-17 19:11:16 +02:00
|
|
|
const zoomStatus = new VariableUiElement(State.state.locationControl.map(location => {
|
2020-09-17 20:59:05 +02:00
|
|
|
if (location.zoom < layer.layerDef.minzoom) {
|
2020-09-17 19:11:16 +02:00
|
|
|
return Translations.t.general.zoomInToSeeThisLayer
|
|
|
|
.SetClass("alert")
|
2020-09-17 20:59:05 +02:00
|
|
|
.SetStyle("display: block ruby;width:min-content;")
|
2020-09-17 19:11:16 +02:00
|
|
|
.Render();
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}))
|
2020-09-17 20:59:05 +02:00
|
|
|
const style = "display:flex;align-items:center;"
|
2020-07-31 16:17:16 +02:00
|
|
|
this._checkboxes.push(new CheckBox(
|
2020-09-17 20:59:05 +02:00
|
|
|
new Combine([icon, name, zoomStatus]).SetStyle(style),
|
|
|
|
new Combine([iconUnselected, "<del>", name, "</del>", zoomStatus]).SetStyle(style),
|
2020-09-13 03:29:44 +02:00
|
|
|
layer.isDisplayed)
|
|
|
|
.SetStyle("margin:0.3em;")
|
|
|
|
);
|
|
|
|
}
|
2020-07-22 11:49:01 +02:00
|
|
|
}
|
|
|
|
|
2020-09-13 03:29:44 +02:00
|
|
|
InnerRender(): string {
|
|
|
|
return new Combine(this._checkboxes)
|
|
|
|
.SetStyle("display:flex;flex-direction:column;")
|
|
|
|
.Render();
|
2020-07-22 11:49:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|