From 558265eba9b0f3e73b388a5a29cc6c53e022b04a Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Fri, 12 Mar 2021 14:52:34 +0100 Subject: [PATCH] Further fixes to clear up the fullscreen --- Docs/Tools/csvGrapher.py | 1 + InitUiElements.ts | 6 ++-- Logic/Actors/SelectedFeatureHandler.ts | 2 ++ Logic/Web/Hash.ts | 9 ++++++ Models/Constants.ts | 2 +- UI/Base/ScrollableFullScreen.ts | 33 +++++++++++++++++---- UI/BigComponents/FullWelcomePaneWithTabs.ts | 2 +- UI/BigComponents/LayerControlPanel.ts | 2 +- UI/Popup/FeatureInfoBox.ts | 10 +++---- 9 files changed, 50 insertions(+), 17 deletions(-) diff --git a/Docs/Tools/csvGrapher.py b/Docs/Tools/csvGrapher.py index 6d9e195..e7c91e2 100644 --- a/Docs/Tools/csvGrapher.py +++ b/Docs/Tools/csvGrapher.py @@ -219,6 +219,7 @@ def changes_per_theme_daily(contents): for row in contents: + def main(): print("Creating graphs...") with open('stats.csv', newline='') as csvfile: diff --git a/InitUiElements.ts b/InitUiElements.ts index 5af961d..5fde430 100644 --- a/InitUiElements.ts +++ b/InitUiElements.ts @@ -280,7 +280,8 @@ export class InitUiElements { Translations.t.general.attribution.attributionContent, "
", new Attribution(undefined, undefined, State.state.layoutToUse, undefined) - ]) + ]), + "copyright" ) ; @@ -420,7 +421,8 @@ export class InitUiElements { const addNewPoint = new ScrollableFullScreen( () => Translations.t.general.add.title.Clone(), - () => new SimpleAddUI()); + () => new SimpleAddUI(), + "new"); addNewPoint.isShown.addCallback(isShown => { if (!isShown) { diff --git a/Logic/Actors/SelectedFeatureHandler.ts b/Logic/Actors/SelectedFeatureHandler.ts index ce36242..9555c52 100644 --- a/Logic/Actors/SelectedFeatureHandler.ts +++ b/Logic/Actors/SelectedFeatureHandler.ts @@ -18,7 +18,9 @@ export default class SelectedFeatureHandler { this._featureSource = featureSource; const self = this; hash.addCallback(h => { + console.log("SelectedFeatureHandler: hash is now ", h) if (h === undefined || h === "") { + console.log("Deselecting...") selectedFeature.setData(undefined); }else{ self.selectFeature(); diff --git a/Logic/Web/Hash.ts b/Logic/Web/Hash.ts index 473f3d1..035bb97 100644 --- a/Logic/Web/Hash.ts +++ b/Logic/Web/Hash.ts @@ -49,6 +49,15 @@ export default class Hash { } hash.setData(newValue) } + + window.addEventListener('popstate', e => { + let newValue = window.location.hash.substr(1); + console.log("Popstate: the hash is now:", newValue) + if (newValue === "") { + newValue = undefined; + } + hash.setData(newValue) + }) return hash; } diff --git a/Models/Constants.ts b/Models/Constants.ts index 6d39bbb..cbaf27a 100644 --- a/Models/Constants.ts +++ b/Models/Constants.ts @@ -2,7 +2,7 @@ import { Utils } from "../Utils"; export default class Constants { - public static vNumber = "0.5.7"; + public static vNumber = "0.5.8"; // The user journey states thresholds when a new feature gets unlocked public static userJourney = { diff --git a/UI/Base/ScrollableFullScreen.ts b/UI/Base/ScrollableFullScreen.ts index 2567676..ec58967 100644 --- a/UI/Base/ScrollableFullScreen.ts +++ b/UI/Base/ScrollableFullScreen.ts @@ -4,6 +4,7 @@ import Combine from "./Combine"; import Ornament from "./Ornament"; import {FixedUiElement} from "./FixedUiElement"; import {UIEventSource} from "../../Logic/UIEventSource"; +import Hash from "../../Logic/Web/Hash"; /** * Wraps some contents into a panel that scrolls the content _under_ the title @@ -13,13 +14,20 @@ export default class ScrollableFullScreen extends UIElement { public isShown: UIEventSource; private _component: UIElement; private _fullscreencomponent: UIElement; + private static readonly _actor = ScrollableFullScreen.InitActor(); + private _hashToSet: string; + private static _currentlyOpen : ScrollableFullScreen; - constructor(title: ((mode: string) => UIElement), content: ((mode: string) => UIElement), - isShown: UIEventSource = new UIEventSource(false)) { + constructor(title: ((mode: string) => UIElement), content: ((mode: string) => UIElement), + hashToSet: string, + isShown: UIEventSource = new UIEventSource(false) + ) { super(); this.isShown = isShown; + this._hashToSet = hashToSet; - this._component = this.BuildComponent(title("desktop"), content("desktop"), isShown); + this._component = this.BuildComponent(title("desktop"), content("desktop"), isShown) + .SetClass("hidden md:block"); this._fullscreencomponent = this.BuildComponent(title("mobile"), content("mobile"), isShown); this.dumbMode = false; const self = this; @@ -27,8 +35,7 @@ export default class ScrollableFullScreen extends UIElement { if (isShown) { self.Activate(); } else { - self.clear(); - + ScrollableFullScreen.clear(); } }) } @@ -40,7 +47,11 @@ export default class ScrollableFullScreen extends UIElement { Activate(): void { this.isShown.setData(true) this._fullscreencomponent.AttachTo("fullscreen"); + if(this._hashToSet != undefined){ + Hash.hash.setData(this._hashToSet) + } const fs = document.getElementById("fullscreen"); + ScrollableFullScreen._currentlyOpen = this; fs.classList.remove("hidden") } @@ -69,11 +80,21 @@ export default class ScrollableFullScreen extends UIElement { } - private clear() { + private static clear() { ScrollableFullScreen.empty.AttachTo("fullscreen") const fs = document.getElementById("fullscreen"); + ScrollableFullScreen._currentlyOpen.isShown.setData(false); fs.classList.add("hidden") + Hash.hash.setData(undefined); } + private static InitActor(){ + Hash.hash.addCallback(hash => { + if(hash === undefined || hash === ""){ + ScrollableFullScreen.clear() + } + }); + return true; + } } \ No newline at end of file diff --git a/UI/BigComponents/FullWelcomePaneWithTabs.ts b/UI/BigComponents/FullWelcomePaneWithTabs.ts index c0f945b..8738cfb 100644 --- a/UI/BigComponents/FullWelcomePaneWithTabs.ts +++ b/UI/BigComponents/FullWelcomePaneWithTabs.ts @@ -33,7 +33,7 @@ export default class FullWelcomePaneWithTabs extends UIElement { this._component = new ScrollableFullScreen( () => layoutToUse.title.Clone(), () => FullWelcomePaneWithTabs.GenerateContents(layoutToUse, State.state.osmConnection.userDetails), - isShown + "welcome" ,isShown ) } diff --git a/UI/BigComponents/LayerControlPanel.ts b/UI/BigComponents/LayerControlPanel.ts index 0357600..e945b44 100644 --- a/UI/BigComponents/LayerControlPanel.ts +++ b/UI/BigComponents/LayerControlPanel.ts @@ -11,7 +11,7 @@ import {UIEventSource} from "../../Logic/UIEventSource"; export default class LayerControlPanel extends ScrollableFullScreen { constructor(isShown: UIEventSource) { - super(LayerControlPanel.GenTitle, LayerControlPanel.GeneratePanel, isShown); + super(LayerControlPanel.GenTitle, LayerControlPanel.GeneratePanel, "layers", isShown); } private static GenTitle(): UIElement { diff --git a/UI/Popup/FeatureInfoBox.ts b/UI/Popup/FeatureInfoBox.ts index 0e56101..52f87b0 100644 --- a/UI/Popup/FeatureInfoBox.ts +++ b/UI/Popup/FeatureInfoBox.ts @@ -17,8 +17,9 @@ export default class FeatureInfoBox extends ScrollableFullScreen { tags: UIEventSource, layerConfig: LayerConfig ) { - super((mode:string) => FeatureInfoBox.GenerateTitleBar(tags, layerConfig, mode), - (mode:string) => FeatureInfoBox.GenerateContent(tags, layerConfig, mode)); + super(() => FeatureInfoBox.GenerateTitleBar(tags, layerConfig), + () => FeatureInfoBox.GenerateContent(tags, layerConfig), + tags.data.id); if (layerConfig === undefined) { throw "Undefined layerconfig"; @@ -48,10 +49,7 @@ export default class FeatureInfoBox extends ScrollableFullScreen { } private static GenerateContent(tags: UIEventSource, - layerConfig: LayerConfig, - mode: string): UIElement { - - + layerConfig: LayerConfig): UIElement { let questionBox: UIElement = undefined; if (State.state.featureSwitchUserbadge.data) { questionBox = new QuestionBox(tags, layerConfig.tagRenderings);