forked from MapComplete/MapComplete
		
	Studio: first working version
This commit is contained in:
		
							parent
							
								
									4fe0c41628
								
							
						
					
					
						commit
						632dd6dfb1
					
				
					 8 changed files with 36 additions and 23 deletions
				
			
		|  | @ -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, | ||||
|  |  | |||
|  | @ -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") | ||||
|  |  | |||
|  | @ -515,7 +515,6 @@ class MappedStore<TIn, T> extends Store<T> { | |||
|     } | ||||
| 
 | ||||
|     private unregisterFromUpstream() { | ||||
|         console.debug("Unregistering callbacks for", this.tag) | ||||
|         this._callbacksAreRegistered = false | ||||
|         this._unregisterFromUpstream() | ||||
|         this._unregisterFromExtraStores?.forEach((unr) => unr()) | ||||
|  |  | |||
|  | @ -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 { | ||||
|     /** | ||||
|  |  | |||
|  | @ -28,8 +28,7 @@ | |||
| </script> | ||||
| 
 | ||||
| {#if $badge} | ||||
|   <slot/> | ||||
|  <!-- {#if !ignoreLoading && $loadingStatus === "loading"} | ||||
|   {#if !ignoreLoading && $loadingStatus === "loading"} | ||||
|     <slot name="loading"> | ||||
|       <Loading /> | ||||
|     </slot> | ||||
|  | @ -42,5 +41,5 @@ | |||
|     <slot /> | ||||
|   {:else if $loadingStatus === "not-attempted"} | ||||
|     <slot name="not-logged-in" /> | ||||
|   {/if} --> | ||||
|   {/if}  | ||||
| {/if} | ||||
|  |  | |||
|  | @ -180,26 +180,30 @@ export default class EditLayerState { | |||
|     public setValueAt(path: ReadonlyArray<string | number>, 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() | ||||
|     } | ||||
|  |  | |||
|  | @ -96,13 +96,10 @@ | |||
|         err = path.join(".") + " " + e | ||||
|     } | ||||
|     let startValue = state.getCurrentValueFor(path) | ||||
|     const tags = new UIEventSource<Record<string, string>>({value: startValue ?? ""}) | ||||
|     const tags = new UIEventSource<Record<string, string>>({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 | ||||
|             } | ||||
|  |  | |||
|  | @ -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") { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue