Skip to content

Commit 7744ff1

Browse files
committed
fix(admin): remove Auto entity type, make entityType required in form config wizard
1 parent 2144d83 commit 7744ff1

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

packages/admin/src/stores/programDraft.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ export const useProgramDraftStore = defineStore('programDraft', () => {
385385
}
386386

387387
draft.value.entityForms.forEach((form) => {
388-
const formErrors: { name?: string; title?: string; formio?: string } = {}
388+
const formErrors: { name?: string; title?: string; formio?: string; entityType?: string } = {}
389389
if (!form.name.trim()) {
390390
formErrors.name = 'Name is required'
391391
valid = false
@@ -394,6 +394,10 @@ export const useProgramDraftStore = defineStore('programDraft', () => {
394394
formErrors.title = 'Title is required'
395395
valid = false
396396
}
397+
if (!form.entityType) {
398+
formErrors.entityType = 'Entity type is required'
399+
valid = false
400+
}
397401
if (!form.formio) {
398402
formErrors.formio = 'Form definition is required'
399403
valid = false
@@ -614,10 +618,9 @@ export const useProgramDraftStore = defineStore('programDraft', () => {
614618
description: draft.value.description,
615619
version: draft.value.version,
616620
entityForms: draft.value.entityForms.map((form) => {
617-
const { entityType, nameField, ...rest } = form
621+
const { nameField, ...rest } = form
618622
const withId = { id: form.name, ...rest }
619-
const withType = entityType ? { ...withId, entityType } : withId
620-
return nameField ? { ...withType, nameField } : withType
623+
return nameField ? { ...withId, nameField } : withId
621624
}),
622625
externalSync: draft.value.externalSync,
623626
authConfigs: draft.value.authConfigs,

packages/admin/src/views/wizard/FormsStep.vue

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,15 @@ const onSpecFileSelection = async (value: File[] | File | null) => {
240240
<v-select
241241
v-model="form.entityType"
242242
:items="[
243-
{ title: '(Auto - infer from topology)', value: '' },
244-
{ title: 'Group', value: 'group' },
243+
{ title: 'Group / Household', value: 'group' },
245244
{ title: 'Individual', value: 'individual' },
246-
{ title: 'Record', value: 'record' },
245+
{ title: 'Record (activity linked to an entity)', value: 'record' },
247246
]"
248247
item-title="title"
249248
item-value="value"
250-
label="Entity Type (Optional)"
251-
placeholder="Auto"
252-
hint="Override the entity type. Use 'Individual' for standalone individuals without a parent group."
249+
label="Entity Type"
250+
:rules="[(v: string) => !!v || 'Entity type is required']"
251+
hint="Determines how this form's data is stored and synced. Cannot be changed after creation."
253252
persistent-hint
254253
variant="outlined"
255254
density="compact"

packages/backend/src/routes/appConfigRoutes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const AppConfigSchema = z.object({
4141
name: z.string(),
4242
title: z.string(),
4343
dependsOn: z.string().nullish(),
44-
entityType: z.enum(["group", "individual", "record"]).nullish(),
44+
entityType: z.enum(["group", "individual", "record"]).optional(),
4545
nameField: z.string().nullish(),
4646
formio: z.record(z.string(), z.unknown()),
4747
})).nullish(),

0 commit comments

Comments
 (0)