Studio: first working version

This commit is contained in:
Pieter Vander Vennet 2023-10-17 01:36:22 +02:00
parent 4fe0c41628
commit 632dd6dfb1
8 changed files with 36 additions and 23 deletions

View file

@ -95,6 +95,19 @@
} }
], ],
"multiAnswer": true "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, "deletion": true,

View file

@ -174,7 +174,10 @@ export class OsmConnection {
public AttemptLogin() { public AttemptLogin() {
this.UpdateCapabilities() 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) { if (this.fakeUser) {
this.loadingStatus.setData("logged-in") this.loadingStatus.setData("logged-in")
console.log("AttemptLogin called, but ignored as fakeUser is set") console.log("AttemptLogin called, but ignored as fakeUser is set")

View file

@ -515,7 +515,6 @@ class MappedStore<TIn, T> extends Store<T> {
} }
private unregisterFromUpstream() { private unregisterFromUpstream() {
console.debug("Unregistering callbacks for", this.tag)
this._callbacksAreRegistered = false this._callbacksAreRegistered = false
this._unregisterFromUpstream() this._unregisterFromUpstream()
this._unregisterFromExtraStores?.forEach((unr) => unr()) this._unregisterFromExtraStores?.forEach((unr) => unr())

View file

@ -1,7 +1,6 @@
import { TagConfigJson } from "./TagConfigJson" import { TagConfigJson } from "./TagConfigJson"
import { TagRenderingConfigJson } from "./TagRenderingConfigJson" import { TagRenderingConfigJson } from "./TagRenderingConfigJson"
import type { Translatable } from "./Translatable" import type { Translatable } from "./Translatable"
import { TagsFilter } from "../../../Logic/Tags/TagsFilter"
export interface MappingConfigJson { export interface MappingConfigJson {
/** /**

View file

@ -28,8 +28,7 @@
</script> </script>
{#if $badge} {#if $badge}
<slot/> {#if !ignoreLoading && $loadingStatus === "loading"}
<!-- {#if !ignoreLoading && $loadingStatus === "loading"}
<slot name="loading"> <slot name="loading">
<Loading /> <Loading />
</slot> </slot>
@ -42,5 +41,5 @@
<slot /> <slot />
{:else if $loadingStatus === "not-attempted"} {:else if $loadingStatus === "not-attempted"}
<slot name="not-logged-in" /> <slot name="not-logged-in" />
{/if} --> {/if}
{/if} {/if}

View file

@ -180,26 +180,30 @@ export default class EditLayerState {
public setValueAt(path: ReadonlyArray<string | number>, v: any) { public setValueAt(path: ReadonlyArray<string | number>, v: any) {
let entry = this.configuration.data let entry = this.configuration.data
const isUndefined = const isUndefined =
v !== undefined && v === undefined ||
v !== null && v === null ||
v !== "" && v === "" ||
!(typeof v === "object" && Object.keys({}).length === 0) (typeof v === "object" && Object.keys(v).length === 0)
for (let i = 0; i < path.length - 1; i++) { for (let i = 0; i < path.length - 1; i++) {
const breadcrumb = path[i] const breadcrumb = path[i]
if (entry[breadcrumb] === undefined) { 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[breadcrumb] = typeof path[i + 1] === "number" ? [] : {}
} }
entry = entry[breadcrumb] 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) { if (isUndefined) {
entry[path.at(-1)] = v if (entry && entry[lastBreadcrumb]) {
} else if (entry) { console.log("Deleting", lastBreadcrumb, "of", path.join("."))
delete entry[path.at(-1)] delete entry[lastBreadcrumb]
}
} else {
entry[lastBreadcrumb] = v
} }
this.configuration.ping() this.configuration.ping()
} }

View file

@ -96,13 +96,10 @@
err = path.join(".") + " " + e err = path.join(".") + " " + e
} }
let startValue = state.getCurrentValueFor(path) let startValue = state.getCurrentValueFor(path)
const tags = new UIEventSource<Record<string, string>>({value: startValue ?? ""}) const tags = new UIEventSource<Record<string, string>>({value: startValue})
try { try {
onDestroy(state.register(path, tags.map(tgs => { onDestroy(state.register(path, tags.map(tgs => {
const v = tgs["value"]; const v = tgs["value"];
if(v !== ""){
console.log("Registering",path,"setting value to", v)
}
if(typeof v !== "string"){ if(typeof v !== "string"){
return v return v
} }

View file

@ -90,7 +90,6 @@
const existingValue = state.getCurrentValueFor(path); const existingValue = state.getCurrentValueFor(path);
console.log("Initial, existing value for", path.join(".") ,"is", existingValue);
if (hasBooleanOption >= 0 && (existingValue === true || existingValue === false)) { if (hasBooleanOption >= 0 && (existingValue === true || existingValue === false)) {
tags.setData({ value: "" + existingValue }); tags.setData({ value: "" + existingValue });
} else if (lastIsString && typeof existingValue === "string") { } else if (lastIsString && typeof existingValue === "string") {