From 84e08415f7d0100cb7d71a729a8f17df6084f17f Mon Sep 17 00:00:00 2001 From: Aidan Jones Date: Tue, 4 Feb 2025 11:13:56 -0500 Subject: [PATCH] Rename superFormData var to form The original code was necessary because there was a reactive declaration using a variable from the props named form to conditionally redirect if the form was accepted. This was factored out in the Svelte 5 upgrade. This changes in this commit were originally part of that PR, but were split out to make the Svelte 5 PR as minimal as possible. --- .../settings/organizations/edit/+page.svelte | 34 ++++++-------- .../product-definitions/edit/+page.svelte | 27 ++++------- .../settings/store-types/edit/+page.svelte | 17 ++----- .../admin/settings/stores/edit/+page.svelte | 19 +++----- .../workflow-definitions/edit/+page.svelte | 45 +++++-------------- .../[id]/settings/groups/+page.svelte | 1 - .../[id]/settings/info/+page.svelte | 11 +++-- .../[id]/settings/infrastructure/+page.svelte | 10 ++--- .../[id]/settings/products/+page.svelte | 10 ++--- .../[id]/settings/stores/+page.svelte | 8 +--- 10 files changed, 58 insertions(+), 124 deletions(-) diff --git a/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/admin/settings/organizations/edit/+page.svelte b/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/admin/settings/organizations/edit/+page.svelte index 16d247cc1..5bb1634ee 100644 --- a/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/admin/settings/organizations/edit/+page.svelte +++ b/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/admin/settings/organizations/edit/+page.svelte @@ -12,11 +12,7 @@ } let { data }: Props = $props(); - const { - form: superFormData, - enhance, - allErrors - } = superForm(data.form, { + const { form, enhance, allErrors } = superForm(data.form, { dataType: 'json', onUpdated(event) { if (event.form.valid) { @@ -25,23 +21,19 @@ } }); - let getStoreInfo = $derived((store: (typeof $superFormData)['stores'][0]) => - data.options.stores.find((s) => s.Id === store.storeId)); + let getStoreInfo = $derived((store: (typeof $form)['stores'][0]) => + data.options.stores.find((s) => s.Id === store.storeId) + );
- + - + - {#each data.options.users as option} {/each} @@ -52,7 +44,7 @@ name="websiteURL" class="input input-bordered w-full" type="text" - bind:value={$superFormData.websiteURL} + bind:value={$form.websiteURL} /> @@ -60,7 +52,7 @@ name="buildEngineURL" class="input input-bordered w-full" type="text" - bind:value={$superFormData.buildEngineURL} + bind:value={$form.buildEngineURL} /> @@ -68,7 +60,7 @@ name="buildEngineAccessToken" class="input input-bordered w-full" type="text" - bind:value={$superFormData.buildEngineAccessToken} + bind:value={$form.buildEngineAccessToken} /> @@ -76,7 +68,7 @@ name="logoURL" class="input input-bordered w-full" type="text" - bind:value={$superFormData.logoURL} + bind:value={$form.logoURL} />
@@ -94,14 +86,14 @@ name="publicByDefault" class="toggle toggle-accent" type="checkbox" - bind:checked={$superFormData.publicByDefault} + bind:checked={$form.publicByDefault} />
- {#each $superFormData.stores as store} + {#each $form.stores as store} --> - + - + - {#each workflows.filter((w) => w.Type) as workflow} {/each} @@ -59,7 +50,7 @@ {#each republishWorkflows.filter((w) => w.Type) as workflow} @@ -83,14 +74,14 @@ {#if $allErrors.length} diff --git a/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/admin/settings/store-types/edit/+page.svelte b/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/admin/settings/store-types/edit/+page.svelte index dac26f4ba..c4a1aa005 100644 --- a/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/admin/settings/store-types/edit/+page.svelte +++ b/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/admin/settings/store-types/edit/+page.svelte @@ -9,11 +9,7 @@ } let { data }: Props = $props(); - const { - form: superFormData, - enhance, - allErrors - } = superForm(data.form, { + const { form, enhance, allErrors } = superForm(data.form, { onUpdated(event) { if (event.form.valid) { goto('/admin/settings/store-types'); @@ -24,20 +20,15 @@ - + - + {#if $allErrors.length} diff --git a/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/admin/settings/stores/edit/+page.svelte b/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/admin/settings/stores/edit/+page.svelte index 335010163..57d723c17 100644 --- a/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/admin/settings/stores/edit/+page.svelte +++ b/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/admin/settings/stores/edit/+page.svelte @@ -9,11 +9,7 @@ } let { data }: Props = $props(); - const { - form: superFormData, - enhance, - allErrors - } = superForm(data.form, { + const { form, enhance, allErrors } = superForm(data.form, { onUpdated(event) { if (event.form.valid) { goto('/admin/settings/stores'); @@ -24,24 +20,19 @@ - + - + - {#each data.options as option} {/each} diff --git a/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/admin/settings/workflow-definitions/edit/+page.svelte b/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/admin/settings/workflow-definitions/edit/+page.svelte index 2444b4d4b..c59ec08c4 100644 --- a/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/admin/settings/workflow-definitions/edit/+page.svelte +++ b/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/admin/settings/workflow-definitions/edit/+page.svelte @@ -12,11 +12,7 @@ } let { data }: Props = $props(); - const { - form: superFormData, - enhance, - allErrors - } = superForm(data.form, { + const { form, enhance, allErrors } = superForm(data.form, { dataType: 'json', onUpdated(event) { if (event.form.valid) { @@ -43,28 +39,19 @@ - + - + - {#each data.storeTypes as storeType} {/each} - - @@ -90,15 +73,11 @@ - {#each data.schemes as scheme} {/each} @@ -108,7 +87,7 @@ @@ -157,7 +136,7 @@ name="enabled" class="toggle toggle-accent" type="checkbox" - bind:checked={$superFormData.enabled} + bind:checked={$form.enabled} /> diff --git a/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/organizations/[id]/settings/groups/+page.svelte b/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/organizations/[id]/settings/groups/+page.svelte index 7284b19ab..821394564 100644 --- a/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/organizations/[id]/settings/groups/+page.svelte +++ b/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/organizations/[id]/settings/groups/+page.svelte @@ -9,7 +9,6 @@ } let { data }: Props = $props(); - // export let form: ActionData; const { form: addForm, enhance: addEnhance, allErrors } = superForm(data.addForm); const { form: deleteForm, enhance: deleteEnhance } = superForm(data.deleteForm); diff --git a/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/organizations/[id]/settings/info/+page.svelte b/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/organizations/[id]/settings/info/+page.svelte index 387015cfb..c53a4f558 100644 --- a/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/organizations/[id]/settings/info/+page.svelte +++ b/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/organizations/[id]/settings/info/+page.svelte @@ -9,12 +9,11 @@ } let { data }: Props = $props(); - // export let form: ActionData; - const { form: superFormData, enhance, allErrors } = superForm(data.form, { resetForm: false }); + const { form, enhance, allErrors } = superForm(data.form, { resetForm: false }); - +
@@ -22,7 +21,7 @@ type="text" name="name" class="input w-full input-bordered" - bind:value={$superFormData.name} + bind:value={$form.name} /> @@ -30,13 +29,13 @@ type="text" name="logoUrl" class="input w-full input-bordered" - bind:value={$superFormData.logoUrl} + bind:value={$form.logoUrl} /> {org_noteLogUrl()}
- Logo + Logo
diff --git a/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/organizations/[id]/settings/infrastructure/+page.svelte b/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/organizations/[id]/settings/infrastructure/+page.svelte index 9a78cebae..9d093b00f 100644 --- a/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/organizations/[id]/settings/infrastructure/+page.svelte +++ b/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/organizations/[id]/settings/infrastructure/+page.svelte @@ -9,11 +9,11 @@ } let { data }: Props = $props(); - const { form: superFormData, enhance, allErrors } = superForm(data.form, { resetForm: false }); + const { form, enhance, allErrors } = superForm(data.form, { resetForm: false }); - +
@@ -28,7 +28,7 @@ name="useDefaultBuildEngine" class="toggle toggle-accent" type="checkbox" - bind:checked={$superFormData.useDefaultBuildEngine} + bind:checked={$form.useDefaultBuildEngine} />
@@ -38,7 +38,7 @@ type="text" name="buildEngineUrl" class="input w-full input-bordered" - bind:value={$superFormData.buildEngineUrl} + bind:value={$form.buildEngineUrl} /> @@ -46,7 +46,7 @@ type="text" name="buildEngineApiAccessToken" class="input w-full input-bordered" - bind:value={$superFormData.buildEngineApiAccessToken} + bind:value={$form.buildEngineApiAccessToken} />
diff --git a/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/organizations/[id]/settings/products/+page.svelte b/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/organizations/[id]/settings/products/+page.svelte index 3773d41f4..2c98303c2 100644 --- a/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/organizations/[id]/settings/products/+page.svelte +++ b/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/organizations/[id]/settings/products/+page.svelte @@ -10,11 +10,7 @@ let { data }: Props = $props(); - const { - form: superFormData, - enhance, - allErrors - } = superForm(data.form, { + const { form, enhance, allErrors } = superForm(data.form, { dataType: 'json', resetForm: false }); @@ -37,13 +33,13 @@ name="publicByDefault" class="toggle toggle-accent" type="checkbox" - bind:checked={$superFormData.publicByDefault} + bind:checked={$form.publicByDefault} />
- {#each $superFormData.products as productDef} + {#each $form.products as productDef} p.Id === productDef.productId)?.Name ?? ''} description={data.allProductDefs.find((p) => p.Id === productDef.productId)?.Description ?? diff --git a/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/organizations/[id]/settings/stores/+page.svelte b/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/organizations/[id]/settings/stores/+page.svelte index 341ad15a6..e02e800a5 100644 --- a/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/organizations/[id]/settings/stores/+page.svelte +++ b/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/organizations/[id]/settings/stores/+page.svelte @@ -10,11 +10,7 @@ let { data }: Props = $props(); - const { - form: superFormData, - enhance, - allErrors - } = superForm(data.form, { + const { form, enhance, allErrors } = superForm(data.form, { dataType: 'json', resetForm: false }); @@ -24,7 +20,7 @@
- {#each $superFormData.stores as store} + {#each $form.stores as store} p.Id === store.storeId)?.Name ?? ''} description={data.allStores.find((p) => p.Id === store.storeId)?.Description ?? ''}