mirror of
https://github.com/LukeHagar/ui-development-kit.git
synced 2025-12-06 12:57:44 +00:00
Update +page.svelte
This commit is contained in:
@@ -10,9 +10,29 @@
|
|||||||
let inputs = {};
|
let inputs = {};
|
||||||
let loading = false;
|
let loading = false;
|
||||||
let formUrl: string;
|
let formUrl: string;
|
||||||
|
let conditions = new Map();
|
||||||
|
|
||||||
|
function parseFormConditions(conditions) {
|
||||||
|
let parsedConditionals = new Map();
|
||||||
|
console.log(conditions);
|
||||||
|
for (const condition of conditions || []) {
|
||||||
|
for (const rule of condition.rules) {
|
||||||
|
console.log(rule);
|
||||||
|
const temp = parsedConditionals.get(rule.source) || [];
|
||||||
|
parsedConditionals.set(rule.source, Array.from(new Set([...temp, rule.value])));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(parsedConditionals);
|
||||||
|
return parsedConditionals;
|
||||||
|
}
|
||||||
|
|
||||||
|
$: if (selectedForm) {
|
||||||
|
conditions = parseFormConditions(selectedForm.object?.formConditions);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<dialog class="card text-white p-8" bind:this={dialog}>
|
<dialog class="card p-8" bind:this={dialog}>
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
{#if selectedForm}
|
{#if selectedForm}
|
||||||
<p id="name" class="text-center">
|
<p id="name" class="text-center">
|
||||||
@@ -26,7 +46,16 @@
|
|||||||
<p>Form Inputs:</p>
|
<p>Form Inputs:</p>
|
||||||
{#if selectedForm.object?.formInput}
|
{#if selectedForm.object?.formInput}
|
||||||
{#each selectedForm.object?.formInput as input}
|
{#each selectedForm.object?.formInput as input}
|
||||||
{#if input.label}
|
{#if conditions.get(input.label)}
|
||||||
|
<label class="label" for={input.label}>
|
||||||
|
<span>{input.label}</span>
|
||||||
|
<select class="input" id={input.label} bind:value={inputs[input.label]}>
|
||||||
|
{#each conditions.get(input.label) as condition}
|
||||||
|
<option value={condition}>{condition}</option>
|
||||||
|
{/each}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
{:else}
|
||||||
<label class="label" for={input.label}>
|
<label class="label" for={input.label}>
|
||||||
<span>{input.label}</span>
|
<span>{input.label}</span>
|
||||||
<input
|
<input
|
||||||
@@ -108,7 +137,7 @@
|
|||||||
<p>Form Inputs:</p>
|
<p>Form Inputs:</p>
|
||||||
{#if form.object?.formInput}
|
{#if form.object?.formInput}
|
||||||
{#each form.object?.formInput as input}
|
{#each form.object?.formInput as input}
|
||||||
<p class="text-center">
|
<p class="">
|
||||||
{input.label}
|
{input.label}
|
||||||
</p>
|
</p>
|
||||||
{/each}
|
{/each}
|
||||||
@@ -122,7 +151,7 @@
|
|||||||
dialog.showModal();
|
dialog.showModal();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Open form
|
Assign form
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
Reference in New Issue
Block a user