forked from MapComplete/MapComplete
Fix some crashes in TagRenderingQuestion
This commit is contained in:
parent
16686dd281
commit
9ead113555
1 changed files with 21 additions and 14 deletions
|
@ -31,6 +31,7 @@
|
||||||
import { TrashIcon } from "@rgossiaux/svelte-heroicons/solid"
|
import { TrashIcon } from "@rgossiaux/svelte-heroicons/solid"
|
||||||
import { Tag } from "../../../Logic/Tags/Tag"
|
import { Tag } from "../../../Logic/Tags/Tag"
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
|
import Markdown from "../../Base/Markdown.svelte"
|
||||||
|
|
||||||
export let config: TagRenderingConfig
|
export let config: TagRenderingConfig
|
||||||
export let tags: UIEventSource<Record<string, string>>
|
export let tags: UIEventSource<Record<string, string>>
|
||||||
|
@ -75,8 +76,10 @@
|
||||||
}
|
}
|
||||||
return !m.hideInAnswer.matchesProperties(tgs)
|
return !m.hideInAnswer.matchesProperties(tgs)
|
||||||
})
|
})
|
||||||
selectedMapping = mappings.findIndex(mapping => mapping.if.matchesProperties(tgs) || mapping.alsoShowIf?.matchesProperties(tgs))
|
selectedMapping = mappings?.findIndex(mapping => mapping.if.matchesProperties(tgs) || mapping.alsoShowIf?.matchesProperties(tgs))
|
||||||
|
if(selectedMapping < 0){
|
||||||
|
selectedMapping = undefined
|
||||||
|
}
|
||||||
// We received a new config -> reinit
|
// We received a new config -> reinit
|
||||||
unit = layer?.units?.find((unit) => unit.appliesToKeys.has(config.freeform?.key))
|
unit = layer?.units?.find((unit) => unit.appliesToKeys.has(config.freeform?.key))
|
||||||
|
|
||||||
|
@ -99,7 +102,7 @@
|
||||||
seenFreeforms.push(newProps[confg.freeform.key])
|
seenFreeforms.push(newProps[confg.freeform.key])
|
||||||
}
|
}
|
||||||
return matches
|
return matches
|
||||||
}),
|
})
|
||||||
]
|
]
|
||||||
|
|
||||||
if (tgs !== undefined && confg.freeform) {
|
if (tgs !== undefined && confg.freeform) {
|
||||||
|
@ -207,7 +210,7 @@
|
||||||
dispatch("saved", { config, applied: selectedTags })
|
dispatch("saved", { config, applied: selectedTags })
|
||||||
const change = new ChangeTagAction(tags.data.id, selectedTags, tags.data, {
|
const change = new ChangeTagAction(tags.data.id, selectedTags, tags.data, {
|
||||||
theme: tags.data["_orig_theme"] ?? state.layout.id,
|
theme: tags.data["_orig_theme"] ?? state.layout.id,
|
||||||
changeType: "answer",
|
changeType: "answer"
|
||||||
})
|
})
|
||||||
freeformInput.set(undefined)
|
freeformInput.set(undefined)
|
||||||
selectedMapping = undefined
|
selectedMapping = undefined
|
||||||
|
@ -259,6 +262,9 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if config.questionhint}
|
{#if config.questionhint}
|
||||||
|
{#if config.questionHintIsMd}
|
||||||
|
<Markdown src={config.questionHint} />
|
||||||
|
{:else}
|
||||||
<div class="max-h-60 overflow-y-auto">
|
<div class="max-h-60 overflow-y-auto">
|
||||||
<SpecialTranslation
|
<SpecialTranslation
|
||||||
t={config.questionhint}
|
t={config.questionhint}
|
||||||
|
@ -269,6 +275,7 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
{/if}
|
||||||
</legend>
|
</legend>
|
||||||
|
|
||||||
{#if config.mappings?.length >= 8}
|
{#if config.mappings?.length >= 8}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue