From 9d6da23b0cf370afc0a0c10c070f41455a5a821c Mon Sep 17 00:00:00 2001 From: luke-hagar-sp <98849695+luke-hagar-sp@users.noreply.github.com> Date: Thu, 29 Feb 2024 10:43:50 -0500 Subject: [PATCH] Update +page.svelte --- .../routes/home/form-integration/+page.svelte | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/Sveltekit-App/src/routes/home/form-integration/+page.svelte b/Sveltekit-App/src/routes/home/form-integration/+page.svelte index b108065..c90da7f 100644 --- a/Sveltekit-App/src/routes/home/form-integration/+page.svelte +++ b/Sveltekit-App/src/routes/home/form-integration/+page.svelte @@ -10,9 +10,29 @@ let inputs = {}; let loading = false; 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); + } - +
{#if selectedForm}

@@ -26,7 +46,16 @@

Form Inputs:

{#if selectedForm.object?.formInput} {#each selectedForm.object?.formInput as input} - {#if input.label} + {#if conditions.get(input.label)} + + {:else}
{/each}