diff --git a/UI/Base/CheckBox.ts b/UI/Base/CheckBox.ts index 6fd9214..db98ec3 100644 --- a/UI/Base/CheckBox.ts +++ b/UI/Base/CheckBox.ts @@ -1,17 +1,18 @@ import {UIElement} from "../UIElement"; import {UIEventSource} from "../UIEventSource"; +import { FilteredLayer } from "../../Logic/FilteredLayer"; export class CheckBox extends UIElement{ - constructor(data: UIEventSource) { + constructor(data: UIEventSource, name: String) { super(data); - + this.data = data; + this.name = name } - protected InnerRender(): string { - return ""; + return `${this.data.data? `

${this.name}

`: `

${this.name}

`}`; } } \ No newline at end of file diff --git a/index.css b/index.css index d247f1c..2e43338 100644 --- a/index.css +++ b/index.css @@ -254,6 +254,30 @@ form { pointer-events: all; } +#filterui { + padding: 2em; + padding-top: 1em; + padding-bottom: 1em; + z-index: 5000; + background-color: white; + border-radius: 2em; + pointer-events: all; + list-style: none; +} + +#filterui li span { + display: flex; + align-items: center; +} + +.checkbox__label--checked { + margin-left: .7rem; +} + +.checkbox__label--unchecked { + margin-left: 2.45rem; +} + @media only screen and (max-width: 600px) { #messagesbox-wrapper { diff --git a/index.html b/index.html index 16c5387..0a03567 100644 --- a/index.html +++ b/index.html @@ -36,6 +36,8 @@
+ diff --git a/index.ts b/index.ts index 12c91c0..4412997 100644 --- a/index.ts +++ b/index.ts @@ -21,7 +21,9 @@ import {VariableUiElement} from "./UI/Base/VariableUIElement"; import {SearchAndGo} from "./UI/SearchAndGo"; import {CollapseButton} from "./UI/Base/CollapseButton"; import {AllKnownLayouts} from "./Customizations/AllKnownLayouts"; -import {All} from "./Customizations/Layouts/All"; +import { All } from "./Customizations/Layouts/All"; +import {CheckBox} from "./UI/Base/CheckBox"; +import { DrinkingWater } from "./Customizations/Layers/DrinkingWater"; // --------------------- Read the URL parameters ----------------- @@ -48,7 +50,7 @@ if (location.hostname === "localhost" || location.hostname === "127.0.0.1") { // ----------------- SELECT THE RIGHT QUESTSET ----------------- -let defaultLayout = "buurtnatuur" +let defaultLayout = "walkbybrussels" // Run over all questsets. If a part of the URL matches a searched-for part in the layout, it'll take that as the default @@ -177,6 +179,9 @@ for (const layer of layoutToUse.layers) { } addButtons.push(addButton); flayers.push(flayer); + + console.log(flayers); + } const layerUpdater = new LayerUpdater(bm, minZoom, flayers); @@ -276,4 +281,20 @@ new GeoLocationHandler(bm).AttachTo("geolocate-button"); // --------------- Send a ping to start various action -------- locationControl.ping(); -messageBox.update(); \ No newline at end of file +messageBox.update(); + +// --------------- Setting up filter ui -------- + +for (let i = 0; i < flayers.length; i++) { + const listItem = document.createElement(`li`); + listItem.setAttribute(`id`,`${flayers[i].name}`) + document.querySelector(`#filterui`).appendChild(listItem); + const eventSource = new UIEventSource(flayers[i].isDisplayed.data); + new CheckBox(eventSource, flayers[i].name) + .onClick(() => { + eventSource.setData(!eventSource.data); + flayers[i].isDisplayed.setData(eventSource.data); + }) + .AttachTo(flayers[i].name); +} + \ No newline at end of file