From 632dd6dfb1ea2fdfe2aa9a00b2ce8fa6f5fb026b Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Tue, 17 Oct 2023 01:36:22 +0200 Subject: [PATCH] Studio: first working version --- .../layers/animal_shelter/animal_shelter.json | 15 ++++++++++- src/Logic/Osm/OsmConnection.ts | 5 +++- src/Logic/UIEventSource.ts | 1 - .../QuestionableTagRenderingConfigJson.ts | 1 - src/UI/Base/LoginToggle.svelte | 5 ++-- src/UI/Studio/EditLayerState.ts | 26 +++++++++++-------- src/UI/Studio/SchemaBasedField.svelte | 5 +--- src/UI/Studio/SchemaBasedMultiType.svelte | 1 - 8 files changed, 36 insertions(+), 23 deletions(-) diff --git a/assets/layers/animal_shelter/animal_shelter.json b/assets/layers/animal_shelter/animal_shelter.json index 1972139c00..c77f92ae45 100644 --- a/assets/layers/animal_shelter/animal_shelter.json +++ b/assets/layers/animal_shelter/animal_shelter.json @@ -95,6 +95,19 @@ } ], "multiAnswer": true + }, + { + "question": { + "en": "When is this animal shelter opened?" + }, + "id": "7", + "render": { + "en": "{opening_hours_table()}" + }, + "freeform": { + "key": "opening_hours", + "type": "opening_hours" + } } ], "deletion": true, @@ -105,4 +118,4 @@ "description": { "en": "An animal shelter is a facility where animals in trouble are brought and facility's staff (volunteers or not) feeds them and cares of them, rehabilitating and healing them if necessary. This definition includes kennels for abandoned dogs, catteries for abandoned cats, shelters for other abandoned pets and wildlife recovery centres. " } -} +} \ No newline at end of file diff --git a/src/Logic/Osm/OsmConnection.ts b/src/Logic/Osm/OsmConnection.ts index 4a2336de99..fcf758dd2f 100644 --- a/src/Logic/Osm/OsmConnection.ts +++ b/src/Logic/Osm/OsmConnection.ts @@ -174,7 +174,10 @@ export class OsmConnection { public AttemptLogin() { this.UpdateCapabilities() - this.loadingStatus.setData("loading") + if (this.loadingStatus.data !== "logged-in") { + // Stay 'logged-in' if we are already logged in; this simply means we are checking for messages + this.loadingStatus.setData("loading") + } if (this.fakeUser) { this.loadingStatus.setData("logged-in") console.log("AttemptLogin called, but ignored as fakeUser is set") diff --git a/src/Logic/UIEventSource.ts b/src/Logic/UIEventSource.ts index 20fb6ead84..5beca660df 100644 --- a/src/Logic/UIEventSource.ts +++ b/src/Logic/UIEventSource.ts @@ -515,7 +515,6 @@ class MappedStore extends Store { } private unregisterFromUpstream() { - console.debug("Unregistering callbacks for", this.tag) this._callbacksAreRegistered = false this._unregisterFromUpstream() this._unregisterFromExtraStores?.forEach((unr) => unr()) diff --git a/src/Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson.ts b/src/Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson.ts index 7d3bf555c9..6350b2b08b 100644 --- a/src/Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson.ts +++ b/src/Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson.ts @@ -1,7 +1,6 @@ import { TagConfigJson } from "./TagConfigJson" import { TagRenderingConfigJson } from "./TagRenderingConfigJson" import type { Translatable } from "./Translatable" -import { TagsFilter } from "../../../Logic/Tags/TagsFilter" export interface MappingConfigJson { /** diff --git a/src/UI/Base/LoginToggle.svelte b/src/UI/Base/LoginToggle.svelte index 8aa8e7fcf4..24d6b0e4a8 100644 --- a/src/UI/Base/LoginToggle.svelte +++ b/src/UI/Base/LoginToggle.svelte @@ -28,8 +28,7 @@ {#if $badge} - - + {/if} {/if} diff --git a/src/UI/Studio/EditLayerState.ts b/src/UI/Studio/EditLayerState.ts index 82abb0435d..be807922d5 100644 --- a/src/UI/Studio/EditLayerState.ts +++ b/src/UI/Studio/EditLayerState.ts @@ -180,26 +180,30 @@ export default class EditLayerState { public setValueAt(path: ReadonlyArray, v: any) { let entry = this.configuration.data const isUndefined = - v !== undefined && - v !== null && - v !== "" && - !(typeof v === "object" && Object.keys({}).length === 0) + v === undefined || + v === null || + v === "" || + (typeof v === "object" && Object.keys(v).length === 0) for (let i = 0; i < path.length - 1; i++) { const breadcrumb = path[i] if (entry[breadcrumb] === undefined) { + if (isUndefined) { + // we have a dead end _and_ we do not need to set a value - we do an early return + return + } entry[breadcrumb] = typeof path[i + 1] === "number" ? [] : {} } entry = entry[breadcrumb] - if (entry === undefined && isUndefined) { - // Nothing to do anymore: we cannot traverse the object, but don't have to set something anyway - return - } } + const lastBreadcrumb = path.at(-1) if (isUndefined) { - entry[path.at(-1)] = v - } else if (entry) { - delete entry[path.at(-1)] + if (entry && entry[lastBreadcrumb]) { + console.log("Deleting", lastBreadcrumb, "of", path.join(".")) + delete entry[lastBreadcrumb] + } + } else { + entry[lastBreadcrumb] = v } this.configuration.ping() } diff --git a/src/UI/Studio/SchemaBasedField.svelte b/src/UI/Studio/SchemaBasedField.svelte index 272d8389ff..d7ebe9338d 100644 --- a/src/UI/Studio/SchemaBasedField.svelte +++ b/src/UI/Studio/SchemaBasedField.svelte @@ -96,13 +96,10 @@ err = path.join(".") + " " + e } let startValue = state.getCurrentValueFor(path) - const tags = new UIEventSource>({value: startValue ?? ""}) + const tags = new UIEventSource>({value: startValue}) try { onDestroy(state.register(path, tags.map(tgs => { const v = tgs["value"]; - if(v !== ""){ - console.log("Registering",path,"setting value to", v) - } if(typeof v !== "string"){ return v } diff --git a/src/UI/Studio/SchemaBasedMultiType.svelte b/src/UI/Studio/SchemaBasedMultiType.svelte index a9df2a859c..0f32073b76 100644 --- a/src/UI/Studio/SchemaBasedMultiType.svelte +++ b/src/UI/Studio/SchemaBasedMultiType.svelte @@ -90,7 +90,6 @@ const existingValue = state.getCurrentValueFor(path); - console.log("Initial, existing value for", path.join(".") ,"is", existingValue); if (hasBooleanOption >= 0 && (existingValue === true || existingValue === false)) { tags.setData({ value: "" + existingValue }); } else if (lastIsString && typeof existingValue === "string") {