forked from MapComplete/MapComplete
		
	Studio: fix #1750
This commit is contained in:
		
							parent
							
								
									3d5e117989
								
							
						
					
					
						commit
						b7f044e976
					
				
					 4 changed files with 23 additions and 23 deletions
				
			
		|  | @ -35,7 +35,6 @@ | |||
| 
 | ||||
|   onDestroy( | ||||
|     currentLang.addCallbackAndRunD((currentLang) => { | ||||
|       console.log("Applying current lang:", currentLang) | ||||
|       if (!translations.data) { | ||||
|         translations.data = {} | ||||
|       } | ||||
|  |  | |||
|  | @ -63,7 +63,6 @@ | |||
|     if (config.id === highlighted) { | ||||
|       htmlElem.classList.add("glowing-shadow") | ||||
|       htmlElem.tabIndex = -1 | ||||
|       console.log("Scrolling to", htmlElem) | ||||
|       htmlElem.scrollIntoView({ behavior: "smooth" }) | ||||
|       Utils.focusOnFocusableChild(htmlElem) | ||||
|     } else { | ||||
|  |  | |||
|  | @ -128,7 +128,6 @@ | |||
|   } | ||||
| 
 | ||||
|   freeformInput.addCallbackAndRun((freeformValue) => { | ||||
|     console.log("FreeformValue:", freeformValue) | ||||
|     if (!mappings || mappings?.length == 0 || config.freeform?.key === undefined) { | ||||
|       return | ||||
|     } | ||||
|  |  | |||
|  | @ -16,6 +16,23 @@ | |||
|   export let schema: ConfigMeta | ||||
|   export let startInEditModeIfUnset: boolean = schema.hints && !schema.hints.ifunset | ||||
| 
 | ||||
|   function mightBeBoolean(type: undefined | JsonSchemaType): boolean { | ||||
|     if (type === undefined) { | ||||
|       return false | ||||
|     } | ||||
|     if (type["type"]) { | ||||
|       type = type["type"] | ||||
|     } | ||||
|     if (type === "boolean") { | ||||
|       return true | ||||
|     } | ||||
|     if (!Array.isArray(type)) { | ||||
|       return false | ||||
|     } | ||||
| 
 | ||||
|     return type.some((t) => mightBeBoolean(t)) | ||||
|   } | ||||
| 
 | ||||
|   const isTranslation = | ||||
|     schema.hints?.typehint === "translation" || | ||||
|     schema.hints?.typehint === "rendered" || | ||||
|  | @ -67,6 +84,7 @@ | |||
|           }, | ||||
|   } | ||||
|   | ||||
| 
 | ||||
|   if (schema.hints.default) { | ||||
|     configJson.mappings = [ | ||||
|       { | ||||
|  | @ -77,6 +95,7 @@ | |||
|           schema.hints.default + | ||||
|           "</b> will be used. " + | ||||
|           (schema.hints.ifunset ?? ""), | ||||
|         hideInAnswer: mightBeBoolean(schema.type) | ||||
|       }, | ||||
|     ] | ||||
|   } else if (!schema.required) { | ||||
|  | @ -88,22 +107,6 @@ | |||
|     ] | ||||
|   } | ||||
| 
 | ||||
|   function mightBeBoolean(type: undefined | JsonSchemaType): boolean { | ||||
|     if (type === undefined) { | ||||
|       return false | ||||
|     } | ||||
|     if (type["type"]) { | ||||
|       type = type["type"] | ||||
|     } | ||||
|     if (type === "boolean") { | ||||
|       return true | ||||
|     } | ||||
|     if (!Array.isArray(type)) { | ||||
|       return false | ||||
|     } | ||||
| 
 | ||||
|     return type.some((t) => mightBeBoolean(t)) | ||||
|   } | ||||
|    | ||||
|   if (mightBeBoolean(schema.type)) { | ||||
|     configJson.mappings = configJson.mappings ?? [] | ||||
|  | @ -135,7 +138,7 @@ | |||
|     err = path.join(".") + " " + e | ||||
|   } | ||||
|   let startValue = state.getCurrentValueFor(path) | ||||
|   let startInEditMode = !startValue && startInEditModeIfUnset | ||||
|   let startInEditMode = startValue === undefined && startInEditModeIfUnset | ||||
|   const tags = new UIEventSource<Record<string, string>>({ value: startValue }) | ||||
|   try { | ||||
|     onDestroy( | ||||
|  | @ -156,7 +159,7 @@ | |||
|             if (v === "true" || v === "yes" || v === "1") { | ||||
|               return true | ||||
|             } | ||||
|             if (v === "false" || v === "no" || v === "0") { | ||||
|             if (v === "false" || v === "no" || v === "0" || (<any> v) === false) { | ||||
|               return false | ||||
|             } | ||||
|           } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue