forked from MapComplete/MapComplete
more custom filter on layers
This commit is contained in:
parent
2c9f737cbd
commit
34b87e7b7e
5 changed files with 89 additions and 7 deletions
|
@ -10,6 +10,7 @@ import LayerConfig from "../../Customizations/JSON/LayerConfig";
|
|||
import BaseUIElement from "../BaseUIElement";
|
||||
import { Translation } from "../i18n/Translation";
|
||||
import ScrollableFullScreen from "../Base/ScrollableFullScreen";
|
||||
import Svg from "../../Svg";
|
||||
|
||||
/**
|
||||
* Shows the filter
|
||||
|
@ -26,14 +27,54 @@ export default class FilterView extends ScrollableFullScreen {
|
|||
}
|
||||
|
||||
private static Generatecontent(): BaseUIElement {
|
||||
let filterPanel: BaseUIElement = new FixedUiElement("more stuff");
|
||||
let filterPanel: BaseUIElement = new FixedUiElement("");
|
||||
|
||||
if (State.state.filteredLayers.data.length > 1) {
|
||||
let layers = State.state.filteredLayers;
|
||||
console.log(layers);
|
||||
filterPanel = new Combine(["layerssss", "<br/>", filterPanel]);
|
||||
}
|
||||
let activeLayers = State.state.filteredLayers;
|
||||
|
||||
return filterPanel;
|
||||
if (activeLayers === undefined) {
|
||||
throw "ActiveLayers should be defined...";
|
||||
}
|
||||
|
||||
const checkboxes: BaseUIElement[] = [];
|
||||
|
||||
for (const layer of activeLayers.data) {
|
||||
const icon = new Combine([Svg.checkbox_filled]).SetStyle(
|
||||
"width:1.5rem;height:1.5rem"
|
||||
);
|
||||
const iconUnselected = new Combine([Svg.checkbox_empty]).SetStyle(
|
||||
"width:1.5rem;height:1.5rem"
|
||||
);
|
||||
|
||||
if (layer.layerDef.name === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const style = "display:flex;align-items:center;color:#007759";
|
||||
|
||||
const name: Translation = Translations.WT(layer.layerDef.name)?.Clone();
|
||||
name.SetStyle("font-size:large;");
|
||||
|
||||
const layerChecked = new Combine([icon, name.Clone()]).SetStyle(style);
|
||||
|
||||
const layerNotChecked = new Combine([
|
||||
iconUnselected,
|
||||
name.Clone(),
|
||||
]).SetStyle(style);
|
||||
|
||||
checkboxes.push(
|
||||
new Toggle(layerChecked, layerNotChecked, layer.isDisplayed)
|
||||
.ToggleOnClick()
|
||||
.SetStyle("margin:0.3em;")
|
||||
);
|
||||
}
|
||||
|
||||
let combinedCheckboxes = new Combine(checkboxes);
|
||||
combinedCheckboxes.SetStyle("display:flex;flex-direction:column;");
|
||||
|
||||
filterPanel = new Combine([combinedCheckboxes]);
|
||||
|
||||
return filterPanel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue