diff --git a/langs/en.json b/langs/en.json index 3e55ff894..28dded7a2 100644 --- a/langs/en.json +++ b/langs/en.json @@ -275,6 +275,7 @@ }, "levelSelection": { "addNewOnLevel": "Is the new point location on level {level}?", + "cancel": "See all levels", "confirmLevel": "Yes, add {preset} on level {level}" }, "loading": "Loading…", diff --git a/src/Logic/State/LayerState.ts b/src/Logic/State/LayerState.ts index a2ca76292..c686ab988 100644 --- a/src/Logic/State/LayerState.ts +++ b/src/Logic/State/LayerState.ts @@ -158,6 +158,7 @@ export default class LayerState { icon: "./assets/svg/elevator.svg", confirmAddNew: t.confirmLevel.PartialSubs({ level }), safetyCheck: t.addNewOnLevel.Subs({ level }), + cancel: t.cancel }, }) this.globalFilters.ping() diff --git a/src/Models/GlobalFilter.ts b/src/Models/GlobalFilter.ts index 42100245f..ec0c634b4 100644 --- a/src/Models/GlobalFilter.ts +++ b/src/Models/GlobalFilter.ts @@ -14,6 +14,7 @@ export interface GlobalFilter { safetyCheck: Translation icon: string confirmAddNew: TypedTranslation<{ preset: Translation }> - tags: Tag[] + tags: Tag[], + cancel?: Translation } } diff --git a/src/UI/BigComponents/LevelSelector.svelte b/src/UI/BigComponents/LevelSelector.svelte index c63bb3883..949025766 100644 --- a/src/UI/BigComponents/LevelSelector.svelte +++ b/src/UI/BigComponents/LevelSelector.svelte @@ -5,6 +5,7 @@ import LayerState from "../../Logic/State/LayerState" import FloorSelector from "../InputElement/Helpers/FloorSelector.svelte" import { Store, UIEventSource } from "../../Logic/UIEventSource" + import { onDestroy } from "svelte" export let layerState: LayerState export let floors: Store @@ -35,6 +36,15 @@ }, [floors, zoom] ) + + onDestroy( + layerState.globalFilters.addCallbackD(globalFilters => { + console.log("Global filters are now", globalFilters) + if (!globalFilters.some(gf => gf.id === "level")) { + selectedFloor.set(all) + } + }) + ) {#if $zoom >= maxZoom} diff --git a/src/UI/InputElement/Helpers/FloorSelector.svelte b/src/UI/InputElement/Helpers/FloorSelector.svelte index b0ee1da35..f62fbe2ca 100644 --- a/src/UI/InputElement/Helpers/FloorSelector.svelte +++ b/src/UI/InputElement/Helpers/FloorSelector.svelte @@ -72,6 +72,10 @@ top = Math.max(top, 0) } + value.addCallbackAndRun(level => { + forceIndex = floors.data.indexOf(level) + }) + Stores.Chronic(50).addCallback(() => stabilize()) floors.addCallback((floors) => { forceIndex = floors.findIndex((s) => s === value.data) @@ -103,7 +107,7 @@ style={`height: calc(${HEIGHT}px * ${$floors.length}); width: calc( 96px )`} >
+ style="margin: -0.25rem; width: calc(100% + 0.5rem); height: calc(100% + 0.5rem); background: rgba(255,255,255, 0.65); backdrop-filter: blur(2px); ">
{#each $floors as floor, i} diff --git a/src/UI/Map/ShowDataLayer.ts b/src/UI/Map/ShowDataLayer.ts index 38e96484d..d16aa8e57 100644 --- a/src/UI/Map/ShowDataLayer.ts +++ b/src/UI/Map/ShowDataLayer.ts @@ -262,9 +262,33 @@ class LineRenderingLayer { this._visibility = visibility this._fetchStore = fetchStore this._onClick = onClick - features.features.addCallbackAndRunD(() => this.update(features.features)) - map.on("styledata", () => this.update(features.features)) + const updateNeededSrc = new UIEventSource(false) + updateNeededSrc.stabilized(100).addCallbackAndRunD(async updateNeeded => { + if (updateNeeded) { + await this.awaitStyleLoaded() + await this.update(features.features.data) + if (features.features.data.length === 0 && "mapcomplete_pedestrian_path_linerendering_2" === this._layername) { + console.trace(this._layername, "is empty") + } + updateNeededSrc.set(false) + } + }) + features.features.addCallbackAndRunD(() => { + console.log("New features!", this._layername, features.features.data.length) + updateNeededSrc.set(true) + }) + map.on("styledata", () => updateNeededSrc.set(true)) + this.awaitStyleLoaded().then(() => { + + const feats = features.features.data + if (feats.length > 0) { + this.update(feats) + } else { + updateNeededSrc.set(true) + } + } + ) } public destruct(): void { @@ -343,20 +367,15 @@ class LineRenderingLayer { return calculatedProps } - private async update(featureSource: Store) { - const map = this._map - while (!map.isStyleLoaded()) { + private async awaitStyleLoaded() { + while (!this._map.isStyleLoaded()) { await Utils.waitFor(100) } + } + + private async update(features: Feature[]) { + const map = this._map - // After waiting 'till the map has loaded, the data might have changed already - // As such, we only now read the features from the featureSource and compare with the previously set data - const features = featureSource.data - if (!features || features.length === 0) { - // This is a very ugly workaround for https://source.mapcomplete.org/MapComplete/MapComplete/issues/2312, - // but I couldn't find the root cause - return - } const src = map.getSource(this._layername) { // Add source to the map or update the feature source diff --git a/src/UI/Popup/AddNewPoint/AddNewPoint.svelte b/src/UI/Popup/AddNewPoint/AddNewPoint.svelte index 091b27220..6e16fe754 100644 --- a/src/UI/Popup/AddNewPoint/AddNewPoint.svelte +++ b/src/UI/Popup/AddNewPoint/AddNewPoint.svelte @@ -303,29 +303,35 @@ {:else if _globalFilter?.length > 0 && _globalFilter?.length > checkedOfGlobalFilters} - - { - checkedOfGlobalFilters = checkedOfGlobalFilters + 1 - }} - > - - - - { - globalFilter.setData([]) - abort() - }} - > - - - + +
+ + + +
+ +
+ + {checkedOfGlobalFilters = checkedOfGlobalFilters + 1}}> + + + + +
+ +
+ {:else if !creating}