forked from MapComplete/MapComplete
		
	Studio: further documenting the format
This commit is contained in:
		
							parent
							
								
									f18a2b9184
								
							
						
					
					
						commit
						e8c84a70b1
					
				
					 14 changed files with 314 additions and 144 deletions
				
			
		|  | @ -16,7 +16,7 @@ | |||
|     /** | ||||
|      * Blacklist for the general area tab | ||||
|      */ | ||||
|     const regionBlacklist = ["hidden",undefined,"infobox", "tagrenderings","maprendering"] | ||||
|     const regionBlacklist = ["hidden",undefined,"infobox", "tagrenderings","maprendering", "editing"] | ||||
|     const allNames =  Utils.Dedup(layerSchema.map(meta => meta.hints.group)) | ||||
| 
 | ||||
|     const perRegion: Record<string, ConfigMeta[]> = {} | ||||
|  | @ -24,26 +24,27 @@ | |||
|         perRegion[region] = layerSchema.filter(meta => meta.hints.group === region) | ||||
|     } | ||||
|      | ||||
|     const baselayerRegions: string[] = ["Basic", "presets", "editing","filters","advanced","expert"] | ||||
|     const baselayerRegions: string[] = ["Basic", "presets","filters","advanced","expert"] | ||||
|     for (const baselayerRegion of baselayerRegions) { | ||||
|         if(perRegion[baselayerRegion] === undefined){ | ||||
|             console.error("BaseLayerRegions in editLayer: no items have group '"+baselayerRegion+'"') | ||||
|         } | ||||
|     } | ||||
|     const generalTabRegions : string[] = allNames.filter(r => regionBlacklist.indexOf(r) <0) | ||||
|     const leftoverRegions : string[] = allNames.filter(r => regionBlacklist.indexOf(r) <0 && baselayerRegions.indexOf(r) <0 ) | ||||
| </script> | ||||
| 
 | ||||
| <h3>Edit layer</h3> | ||||
| 
 | ||||
| <div class="m4"> | ||||
|     {allNames} | ||||
| <TabbedGroup tab={new UIEventSource(0)}> | ||||
| <TabbedGroup tab={new UIEventSource(1)}> | ||||
|     <div slot="title0">General properties</div> | ||||
|     <div class="flex flex-col" slot="content0"> | ||||
|         {#each baselayerRegions as region} | ||||
|             <Region {state} configs={perRegion[region]} title={region}/> | ||||
|         {/each} | ||||
|         {#each generalTabRegions as region} | ||||
|          | ||||
|         {#each leftoverRegions as region} | ||||
|             <Region {state} configs={perRegion[region]} title={region}/> | ||||
|         {/each} | ||||
|     </div> | ||||
|  | @ -52,6 +53,7 @@ | |||
|     <div slot="content1"> | ||||
|         <Region {state} configs={perRegion["infobox"]} title="Infobox"/> | ||||
|         <Region {state} configs={perRegion["tagrenderings"]} title="Infobox"/> | ||||
|         <Region {state} configs={perRegion["editing"]} title="Other editing elements"/> | ||||
|     </div> | ||||
| 
 | ||||
|     <div slot="title2">Rendering on the map</div> | ||||
|  |  | |||
|  | @ -51,9 +51,9 @@ export default class EditLayerState { | |||
|         value: Store<any>, | ||||
|         noInitialSync: boolean = false | ||||
|     ): () => void { | ||||
|         const unsync = value.addCallback((v) => this.update(path, v)) | ||||
|         const unsync = value.addCallback((v) => this.setValueAt(path, v)) | ||||
|         if (!noInitialSync) { | ||||
|             this.update(path, value.data) | ||||
|             this.setValueAt(path, value.data) | ||||
|         } | ||||
|         return unsync | ||||
|     } | ||||
|  | @ -73,7 +73,7 @@ export default class EditLayerState { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     private update(path: ReadonlyArray<string | number>, v: any) { | ||||
|     public setValueAt(path: ReadonlyArray<string | number>, v: any) { | ||||
|         { | ||||
|             let entry = this.configuration.data | ||||
|             for (let i = 0; i < path.length - 1; i++) { | ||||
|  |  | |||
|  | @ -1,17 +1,19 @@ | |||
| <script lang="ts"> | ||||
| 
 | ||||
|     import EditLayerState from "./EditLayerState"; | ||||
|     import type {ConfigMeta} from "./configMeta"; | ||||
|     import {UIEventSource} from "../../Logic/UIEventSource"; | ||||
|     import type { ConfigMeta } from "./configMeta"; | ||||
|     import { UIEventSource } from "../../Logic/UIEventSource"; | ||||
|     import type { | ||||
|         QuestionableTagRenderingConfigJson | ||||
|     } from "../../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson"; | ||||
|     import TagRenderingEditable from "../Popup/TagRendering/TagRenderingEditable.svelte"; | ||||
|     import TagRenderingConfig from "../../Models/ThemeConfig/TagRenderingConfig"; | ||||
|     import {onDestroy} from "svelte"; | ||||
|     import { onDestroy } from "svelte"; | ||||
|     import SchemaBasedInput from "./SchemaBasedInput.svelte"; | ||||
|     import type {JsonSchemaType} from "./jsonSchema"; | ||||
|     import nmd from "nano-markdown" | ||||
|     import type { JsonSchemaType } from "./jsonSchema"; | ||||
|     // @ts-ignore | ||||
|     import nmd from "nano-markdown"; | ||||
| 
 | ||||
|     /** | ||||
|      * If 'types' is defined: allow the user to pick one of the types to input. | ||||
|      */ | ||||
|  | @ -102,7 +104,13 @@ | |||
|     let chosenOption: number = defaultOption | ||||
|     let subSchemas: ConfigMeta[] = [] | ||||
|     onDestroy(tags.addCallbackAndRun(tags => { | ||||
|         const oldOption = chosenOption | ||||
|         chosenOption = tags["value"] ? Number(tags["value"]) : defaultOption | ||||
|         if(chosenOption !== oldOption){ | ||||
|             // Reset the values beneath | ||||
|             subSchemas = [] | ||||
|             state.setValueAt(path, undefined) | ||||
|         } | ||||
|         const type = schema.type[chosenOption] | ||||
|         if (!type) { | ||||
|             return | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue