Feature: add debug info block in Questionbox.svelte

This commit is contained in:
Pieter Vander Vennet 2025-06-13 01:23:16 +02:00
parent 8fb123adc2
commit 5dd607a1c3
3 changed files with 26 additions and 2 deletions

View file

@ -14,6 +14,7 @@
import { onDestroy } from "svelte"
import TagRenderingQuestionDynamic from "./TagRenderingQuestionDynamic.svelte"
import LoginToggle from "../../Base/LoginToggle.svelte"
import AccordionSingle from "../../Flowbite/AccordionSingle.svelte"
export let layer: LayerConfig
export let tags: UIEventSource<Record<string, string>>
@ -45,7 +46,7 @@
}
let baseQuestions = (layer?.tagRenderings ?? [])?.filter(
(tr) => allowed(tr.labels) && tr.question !== undefined
(tr) => tr.question !== undefined && allowed(tr.labels),
)
/**
@ -121,6 +122,28 @@
</script>
{#if $loginEnabled}
{#if $debug}
<div class="subtle flex flex-col">
<AccordionSingle noBorder>
<div slot="header" class="small subtle text-sm">
Questionbox debug info: labels (whitelist) : {onlyForLabels?.join(",")}
</div>
<div class="flex flex-col" >
<div>
notForLabes (blacklist): {notForLabels?.join(",")} ;
</div>
<div>
baseQuestions: {baseQuestions.length === 0 ? "NONE" : baseQuestions.map(q => q.id)?.join(",")} ;
</div>
<div>
questionsMeetingConditions: {$questionsToAsk.length === 0 ? "NONE" : baseQuestions.map(q => q.id)?.join(",")}
;
</div>
</div>
</AccordionSingle>
</div>
{/if}
<div
bind:this={questionboxElem}
aria-live="polite"

View file

@ -13,6 +13,7 @@
import LayerConfig from "../../../Models/ThemeConfig/LayerConfig"
import WeblateLink from "../../Base/WeblateLink.svelte"
import BaseUIElement from "../../BaseUIElement"
import { FixedUiElement } from "../../Base/FixedUiElement"
/**
* The 'specialTranslation' renders a `Translation`-object, but interprets the special values as well
@ -61,6 +62,7 @@
"due to",
e
)
return new FixedUiElement("Could not construct visualization "+specpart.func.funcName+" due to "+e)
}
}
}

View file

@ -37,7 +37,6 @@ class QuestionViz implements SpecialVisualizationSvelte {
doc: "Either `no`, `yes` or `user-preference`. Indicates if all questions should be shown at once",
},
]
svelteBased = true
group: "default"
constr(