From 15f816e1728a5a286f10c48c222daacb2490ba41 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Thu, 17 Sep 2020 23:53:57 +0200 Subject: [PATCH] Add some tweaks to hide the add-poi-marker when a layer is enabled --- InitUiElements.ts | 3 +-- Logic/Leaflet/StrayClickHandler.ts | 10 ++++++++++ State.ts | 9 ++++++--- UI/SimpleAddUI.ts | 12 +++++++++--- UI/i18n/Translations.ts | 4 ++++ 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/InitUiElements.ts b/InitUiElements.ts index d3e2ec6..61383e9 100644 --- a/InitUiElements.ts +++ b/InitUiElements.ts @@ -378,8 +378,7 @@ export class InitUiElements { , new Combine([Img.closedFilterButton]) .SetStyle("display:block;border-radius:50%;background:white;padding:1em;"), - QueryParameters.GetQueryParameter("layer-control-toggle", "false") - .map((str) => str !== "false", [], b => "" + b) + State.state.layerControlIsOpened ); checkbox .AttachTo("layer-selection"); diff --git a/Logic/Leaflet/StrayClickHandler.ts b/Logic/Leaflet/StrayClickHandler.ts index 0572b63..77042f1 100644 --- a/Logic/Leaflet/StrayClickHandler.ts +++ b/Logic/Leaflet/StrayClickHandler.ts @@ -15,6 +15,16 @@ export class StrayClickHandler { this._uiToShow = uiToShow; const self = this; const map = State.state.bm.map; + State.state.filteredLayers.data.forEach((filteredLayer) => { + filteredLayer.isDisplayed.addCallback(isEnabled => { + if(isEnabled){ + // When a layer is activated, we remove the 'last click location' in order to force the user to reclick + // This reclick might be at a location where a feature now appeared... + map.removeLayer(self._lastMarker); + } + }) + }) + State.state.bm.LastClickLocation.addCallback(function (lastClick) { State.state.selectedElement.setData(undefined); diff --git a/State.ts b/State.ts index ef2a7ce..d33897d 100644 --- a/State.ts +++ b/State.ts @@ -22,7 +22,7 @@ export class State { // The singleton of the global state public static state: State; - public static vNumber = "0.0.8a"; + public static vNumber = "0.0.8b"; // The user journey states thresholds when a new feature gets unlocked public static userJourney = { @@ -114,8 +114,11 @@ export class State { public layoutDefinition: string; public installedThemes: UIEventSource<{ layout: Layout; definition: string }[]>; - public welcomeMessageOpenedTab = QueryParameters.GetQueryParameter("tab","0").map( - str => isNaN(Number(str)) ? 0 : Number(str),[],n => ""+n + public layerControlIsOpened: UIEventSource = QueryParameters.GetQueryParameter("layer-control-toggle", "false") + .map((str) => str !== "false", [], b => "" + b) + + public welcomeMessageOpenedTab = QueryParameters.GetQueryParameter("tab", "0").map( + str => isNaN(Number(str)) ? 0 : Number(str), [], n => "" + n ); constructor(layoutToUse: Layout) { diff --git a/UI/SimpleAddUI.ts b/UI/SimpleAddUI.ts index a0f9409..ee6177a 100644 --- a/UI/SimpleAddUI.ts +++ b/UI/SimpleAddUI.ts @@ -27,6 +27,7 @@ export class SimpleAddUI extends UIElement { }> = new UIEventSource(undefined); private confirmButton: UIElement = undefined; + private openLayerControl: UIElement; private cancelButton: UIElement; private goToInboxButton: UIElement = new SubtleButton("./assets/envelope.svg", Translations.t.general.goToInbox, {url:"https://www.openstreetmap.org/messages/inbox", newTab: false}); @@ -100,19 +101,24 @@ export class SimpleAddUI extends UIElement { } ) - - this._addButtons.push(button); } } - + this.cancelButton = new SubtleButton( "./assets/close.svg", Translations.t.general.cancel ).onClick(() => { self._confirmPreset.setData(undefined); }) + + this.openLayerControl = new SubtleButton( + "./assets/layers.svg", + Translations.t.general.add.openLayerControl + ).onClick(() => { + State.state.layerControlIsOpened.setData(true); + }) } private CreatePoint(tags: Tag[], layerToAddTo: FilteredLayer) { diff --git a/UI/i18n/Translations.ts b/UI/i18n/Translations.ts index 0887dd6..b612be5 100644 --- a/UI/i18n/Translations.ts +++ b/UI/i18n/Translations.ts @@ -379,6 +379,10 @@ export default class Translations { fr: "Ajouter un/une {category} ici", gl: "Engadir {category} aquí", de: "Hier eine {category} hinzufügen" + }), + openLayerControl: new T({ + "en": "Open the layer control box", + "nl": "Open de laag-instellingen" }) }, pickLanguage: new T({