Skip to content

Commit

Permalink
Replicate edit process for WorkflowDefinition creation
Browse files Browse the repository at this point in the history
  • Loading branch information
FyreByrd committed Nov 1, 2024
1 parent edc9038 commit 99b0a95
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,9 @@ import { superValidate } from 'sveltekit-superforms';
import { valibot } from 'sveltekit-superforms/adapters';
import * as v from 'valibot';
import type { Actions, PageServerLoad } from './$types';
import { workflowDefinitionSchemaBase } from '../common';

const createSchema = v.object({
name: v.nullable(v.string()),
storeType: v.pipe(v.number(), v.minValue(1), v.integer()),
workflowType: v.pipe(v.number(), v.minValue(1), v.integer()),
workflowScheme: v.nullable(v.string()),
workflowBusinessFlow: v.nullable(v.string()),
description: v.nullable(v.string()),
properties: v.nullable(v.string()),
enabled: v.boolean()
});
const createSchema = workflowDefinitionSchemaBase;

export const load = (async ({ url }) => {
const form = await superValidate(valibot(createSchema));
Expand All @@ -40,7 +32,9 @@ export const actions = {
storeType,
workflowBusinessFlow,
workflowScheme,
workflowType
workflowType,
productType,
adminRequirements
} = form.data;
await DatabaseWrites.workflowDefinitions.create({
data: {
Expand All @@ -51,7 +45,9 @@ export const actions = {
StoreTypeId: storeType,
WorkflowBusinessFlow: workflowBusinessFlow,
WorkflowScheme: workflowScheme,
Type: workflowType
Type: workflowType,
ProductType: productType,
AdminRequirements: adminRequirements.length ? adminRequirements : [0]
}
});
return { ok: true, form };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import * as m from '$lib/paraglide/messages';
import { superForm } from 'sveltekit-superforms';
import type { PageData } from './$types';
import { ProductType, WorkflowAdminRequirements } from 'sil.appbuilder.portal.common/workflow';
export let data: PageData;
const { form, enhance, allErrors } = superForm(data.form, {
dataType: 'json',
onUpdated(event) {
if (event.form.valid) {
goto('/admin/settings/workflow-definitions');
Expand All @@ -29,6 +31,24 @@
{/each}
</select>
</LabeledFormInput>
<div>
<label>
<!-- TODO: i18n (add to JSON) -->
<div class="label">
<span class="label-text">Product Type</span>
</div>
<select
class="select select-bordered"
name="productType"
bind:value={$form.productType}
>
<option value={ProductType.Android_GooglePlay}>Android GooglePlay</option>
<option value={ProductType.Android_S3}>Android S3</option>
<option value={ProductType.AssetPackage}>Asset Package</option>
<option value={ProductType.Web}>Web</option>
</select>
</label>
</div>
<LabeledFormInput name="admin_settings_workflowDefinitions_workflowType">
<select class="select select-bordered" name="workflowType" bind:value={$form.workflowType}>
<option value={1}>{m.admin_settings_workflowDefinitions_workflowTypes_1()}</option>
Expand Down Expand Up @@ -68,6 +88,40 @@
bind:value={$form.properties}
/>
</LabeledFormInput>
<div>
<label>
<!-- TODO: i18n (add to JSON) -->
<div class="label">
<span class="">Administrative Requirements</span>
</div>
<div class="label flex flex-row">
<div class="label">
<span class="label-text">
Require an organization admin to access the GooglePlay developer console.
</span>
</div>
<input
class="checkbox checkbox-info"
type="checkbox"
bind:group={$form.adminRequirements}
value={WorkflowAdminRequirements.StoreAccess}
/>
</div>
<div class="label flex flex-row">
<div class="label">
<span class="label-text">
Require approval by an organization admin before product is created.
</span>
</div>
<input
class="checkbox checkbox-info"
type="checkbox"
bind:group={$form.adminRequirements}
value={WorkflowAdminRequirements.ApprovalProcess}
/>
</div>
</label>
</div>
<div>
<label>
<div class="label flex flex-row">
Expand Down

0 comments on commit 99b0a95

Please sign in to comment.