forked from MapComplete/MapComplete
Add various improvements and fixes to studio, should fix #2055
This commit is contained in:
parent
b19d9ef077
commit
d1ec9a43fc
19 changed files with 532 additions and 419 deletions
|
@ -1,11 +1,13 @@
|
|||
<script lang="ts">
|
||||
import type { ConfigMeta } from "./configMeta"
|
||||
import EditLayerState from "./EditLayerState"
|
||||
import EditLayerState, { EditJsonState } from "./EditLayerState"
|
||||
import * as questions from "../../assets/generated/layers/questions.json"
|
||||
import { ImmutableStore, Store } from "../../Logic/UIEventSource"
|
||||
import TagRenderingEditable from "../Popup/TagRendering/TagRenderingEditable.svelte"
|
||||
import TagRenderingConfig from "../../Models/ThemeConfig/TagRenderingConfig"
|
||||
import type { QuestionableTagRenderingConfigJson } from "../../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson.js"
|
||||
import type {
|
||||
QuestionableTagRenderingConfigJson,
|
||||
} from "../../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson.js"
|
||||
import type { TagRenderingConfigJson } from "../../Models/ThemeConfig/Json/TagRenderingConfigJson"
|
||||
import FromHtml from "../Base/FromHtml.svelte"
|
||||
import ShowConversionMessage from "./ShowConversionMessage.svelte"
|
||||
|
@ -31,15 +33,25 @@
|
|||
if (typeof x === "string") {
|
||||
return perId[x]
|
||||
} else {
|
||||
return [x]
|
||||
return <any>[x]
|
||||
}
|
||||
})
|
||||
let configs: Store<TagRenderingConfig[]> = configJson.map((configs) => {
|
||||
if (!configs) {
|
||||
return [{ error: "No configuartions found" }]
|
||||
}
|
||||
console.log("Regenerating configs")
|
||||
return configs.map((config) => {
|
||||
if (config["builtin"]) {
|
||||
let override = ""
|
||||
if (config["override"]) {
|
||||
override = ". Some items are changed with an override. Editing this is not yet supported with Studio."
|
||||
}
|
||||
return new TagRenderingConfig({
|
||||
render: {
|
||||
"en": "This question reuses <b>" + JSON.stringify(config["builtin"]) + "</b>" + override,
|
||||
},
|
||||
})
|
||||
}
|
||||
try {
|
||||
return new TagRenderingConfig(config)
|
||||
} catch (e) {
|
||||
|
@ -47,15 +59,6 @@
|
|||
}
|
||||
})
|
||||
})
|
||||
let id: Store<string> = value.mapD((c) => {
|
||||
if (c?.id) {
|
||||
return c.id
|
||||
}
|
||||
if (typeof c === "string") {
|
||||
return c
|
||||
}
|
||||
return undefined
|
||||
})
|
||||
|
||||
let tags = state.testTags
|
||||
|
||||
|
@ -66,11 +69,18 @@
|
|||
|
||||
<div class="flex">
|
||||
<div class="m-4 flex w-full flex-col">
|
||||
<NextButton clss="primary" on:click={() => state.highlightedItem.setData({ path, schema })}>
|
||||
{#if schema.hints.question}
|
||||
{schema.hints.question}
|
||||
{/if}
|
||||
</NextButton>
|
||||
{#if $configJson.some(config => config["builtin"] !== undefined)}
|
||||
<div class="interactive p-2 rounded-2xl">
|
||||
This question uses an advanced 'builtin'+'override' construction in the source code.
|
||||
Editing this with Studio is not supported.
|
||||
</div>
|
||||
{:else}
|
||||
<NextButton clss="primary" on:click={() => state.highlightedItem.setData({ path, schema })}>
|
||||
{#if schema.hints.question}
|
||||
{schema.hints.question}
|
||||
{/if}
|
||||
</NextButton>
|
||||
{/if}
|
||||
{#if description}
|
||||
<Markdown src={description} />
|
||||
{/if}
|
||||
|
@ -86,6 +96,7 @@
|
|||
{#each $configs as config}
|
||||
{#if config.error !== undefined}
|
||||
<div class="alert">Could not create a preview of this tagRendering: {config.error}</div>
|
||||
{JSON.stringify($value)}
|
||||
{:else if config.condition && !config.condition.matchesProperties($tags)}
|
||||
This tagRendering is currently not shown. It will appear if the feature matches the
|
||||
condition
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue