diff --git a/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/admin/settings/workflow-definitions/edit/+page.server.ts b/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/admin/settings/workflow-definitions/edit/+page.server.ts
index f7105486c..f40cc22ce 100644
--- a/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/admin/settings/workflow-definitions/edit/+page.server.ts
+++ b/source/SIL.AppBuilder.Portal/src/routes/(authenticated)/admin/settings/workflow-definitions/edit/+page.server.ts
@@ -6,16 +6,19 @@ import { superValidate } from 'sveltekit-superforms';
import { valibot } from 'sveltekit-superforms/adapters';
import * as v from 'valibot';
import type { Actions, PageServerLoad } from './$types';
+import { ProductType, WorkflowAdminRequirements } from 'sil.appbuilder.portal.common/workflow';
const editSchema = v.object({
id: idSchema,
name: v.nullable(v.string()),
storeType: idSchema,
+ productType: v.pipe(idSchema, v.enum(ProductType)),
workflowType: idSchema,
workflowScheme: v.nullable(v.string()),
workflowBusinessFlow: v.nullable(v.string()),
description: v.nullable(v.string()),
properties: v.nullable(v.string()),
+ adminRequirements: v.array(v.pipe(idSchema, v.enum(WorkflowAdminRequirements))),
enabled: v.boolean()
});
export const load = (async ({ url }) => {
@@ -29,22 +32,27 @@ export const load = (async ({ url }) => {
}
});
if (!data) return redirect(302, base + '/admin/settings/workflow-definitions');
- const options = await prisma.storeTypes.findMany();
+ const storeTypes = await prisma.storeTypes.findMany();
const form = await superValidate(
{
id: data.Id,
name: data.Name,
storeType: data.StoreTypeId!,
+ productType: data.ProductType,
workflowType: data.Type,
workflowScheme: data.WorkflowScheme,
workflowBusinessFlow: data.WorkflowBusinessFlow,
description: data.Description,
properties: data.Properties,
+ adminRequirements:
+ data.AdminRequirements.length > 1 || data.AdminRequirements[0]
+ ? data.AdminRequirements
+ : [],
enabled: data.Enabled
},
valibot(editSchema)
);
- return { form, options };
+ return { form, storeTypes };
}) satisfies PageServerLoad;
export const actions = {
@@ -63,7 +71,9 @@ export const actions = {
storeType,
workflowBusinessFlow,
workflowScheme,
- workflowType
+ workflowType,
+ adminRequirements,
+ productType
} = form.data;
await DatabaseWrites.workflowDefinitions.update({
where: {
@@ -77,7 +87,9 @@ export const actions = {
StoreTypeId: storeType,
Description: description,
Properties: properties,
- Enabled: enabled
+ Enabled: enabled,
+ ProductType: productType,
+ AdminRequirements: adminRequirements.length ? adminRequirements : [0]
}
});
return { ok: true, form };
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 5e33eaa13..a36172aab 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
@@ -4,10 +4,17 @@
import * as m from '$lib/paraglide/messages';
import { superForm } from 'sveltekit-superforms';
import type { ActionData, PageData } from './$types';
+ import { ProductType, WorkflowAdminRequirements } from 'sil.appbuilder.portal.common/workflow';
export let data: PageData;
export let form: ActionData;
- const { form: superFormData, enhance, allErrors } = superForm(data.form);
+ const {
+ form: superFormData,
+ enhance,
+ allErrors
+ } = superForm(data.form, {
+ dataType: 'json'
+ });
$: if (form?.ok) goto('/admin/settings/workflow-definitions');
@@ -25,11 +32,29 @@