From 8144799733188dd06eb072c0fe2cd5acab8636d4 Mon Sep 17 00:00:00 2001 From: Michael Genson <71845777+michael-genson@users.noreply.github.com> Date: Thu, 26 Feb 2026 10:50:45 -0600 Subject: [PATCH] feat: Improve auto-form layout (#7150) --- .../components/Domain/Group/GroupDataPage.vue | 17 +- frontend/components/global/AutoForm.vue | 207 +++++++++--------- .../partials/use-actions-factory.ts | 6 + .../composables/use-group-recipe-actions.ts | 8 +- frontend/composables/use-users/user-form.ts | 8 + frontend/lang/messages/en-US.json | 8 +- frontend/pages/admin/manage/users/[id].vue | 180 ++++++++------- frontend/pages/admin/manage/users/create.vue | 50 +++-- frontend/pages/group/data/categories.vue | 2 + frontend/pages/group/data/foods.vue | 2 + frontend/pages/group/data/labels.vue | 8 +- frontend/pages/group/data/recipe-actions.vue | 14 +- frontend/pages/group/data/tags.vue | 2 + frontend/pages/group/data/tools.vue | 2 + frontend/pages/group/data/units.vue | 19 +- frontend/types/auto-forms.ts | 4 +- 16 files changed, 313 insertions(+), 224 deletions(-) diff --git a/frontend/components/Domain/Group/GroupDataPage.vue b/frontend/components/Domain/Group/GroupDataPage.vue index 1865373fc..99b9b981a 100644 --- a/frontend/components/Domain/Group/GroupDataPage.vue +++ b/frontend/components/Domain/Group/GroupDataPage.vue @@ -2,9 +2,11 @@ @@ -22,18 +25,22 @@ + @@ -153,6 +160,12 @@ defineProps({ type: String, required: true, }, + createTitle: { + type: String, + }, + editTitle: { + type: String, + }, tableConfig: { type: Object as PropType, default: () => ({ diff --git a/frontend/components/global/AutoForm.vue b/frontend/components/global/AutoForm.vue index 8407e7603..473131712 100644 --- a/frontend/components/global/AutoForm.vue +++ b/frontend/components/global/AutoForm.vue @@ -7,115 +7,118 @@ :width="width" class="my-2" > - - - + + - - {{ inputField.section }} - - + + {{ inputField.section }} + + + {{ inputField.sectionDetails }} + + + - {{ inputField.sectionDetails }} - + + + + + {{ inputField.label }} + + + - - - - - {{ inputField.label }} - - - + + - - + + - - + + - - - - - - - - + + + + + + diff --git a/frontend/composables/partials/use-actions-factory.ts b/frontend/composables/partials/use-actions-factory.ts index bf6a6fcfa..b9e57a305 100644 --- a/frontend/composables/partials/use-actions-factory.ts +++ b/frontend/composables/partials/use-actions-factory.ts @@ -26,8 +26,10 @@ export function useReadOnlyActions( api: BaseCRUDAPIReadOnly, allRef: Ref | null, loading: Ref, + defaultQueryParams: Record = {}, ): ReadOnlyStoreActions { function getAll(page = 1, perPage = -1, params = {} as Record) { + params = { ...defaultQueryParams, ...params }; params.orderBy ??= "name"; params.orderDirection ??= "asc"; @@ -56,6 +58,7 @@ export function useReadOnlyActions( } async function refresh(page = 1, perPage = -1, params = {} as Record) { + params = { ...defaultQueryParams, ...params }; params.orderBy ??= "name"; params.orderDirection ??= "asc"; @@ -86,8 +89,10 @@ export function useStoreActions( api: BaseCRUDAPI, allRef: Ref | null, loading: Ref, + defaultQueryParams: Record = {}, ): StoreActions { function getAll(page = 1, perPage = -1, params = {} as Record) { + params = { ...defaultQueryParams, ...params }; params.orderBy ??= "name"; params.orderDirection ??= "asc"; @@ -116,6 +121,7 @@ export function useStoreActions( } async function refresh(page = 1, perPage = -1, params = {} as Record) { + params = { ...defaultQueryParams, ...params }; params.orderBy ??= "name"; params.orderDirection ??= "asc"; diff --git a/frontend/composables/use-group-recipe-actions.ts b/frontend/composables/use-group-recipe-actions.ts index 7d75bdb51..90ff6d3c0 100644 --- a/frontend/composables/use-group-recipe-actions.ts +++ b/frontend/composables/use-group-recipe-actions.ts @@ -78,7 +78,13 @@ export const useGroupRecipeActions = function ( }; const actions = { - ...useStoreActions("group-recipe-actions", api.groupRecipeActions, groupRecipeActions, loading), + ...useStoreActions( + "group-recipe-actions", + api.groupRecipeActions, + groupRecipeActions, + loading, + { orderBy: orderBy }, + ), flushStore() { groupRecipeActions.value = []; }, diff --git a/frontend/composables/use-users/user-form.ts b/frontend/composables/use-users/user-form.ts index 8b787cf11..788c163a0 100644 --- a/frontend/composables/use-users/user-form.ts +++ b/frontend/composables/use-users/user-form.ts @@ -26,6 +26,7 @@ export const useUserForm = () => { rules: [validators.required], }, { + cols: 6, label: i18n.t("user.password"), varName: "password", disableUpdate: true, @@ -33,6 +34,7 @@ export const useUserForm = () => { rules: [validators.required, validators.minLength(8)], }, { + cols: 6, label: i18n.t("user.authentication-method"), varName: "authMethod", type: fieldTypes.SELECT, @@ -42,36 +44,42 @@ export const useUserForm = () => { }, { section: i18n.t("user.permissions"), + cols: 6, label: i18n.t("user.administrator"), varName: "admin", type: fieldTypes.BOOLEAN, rules: [validators.required], }, { + cols: 6, label: i18n.t("user.user-can-invite-other-to-group"), varName: "canInvite", type: fieldTypes.BOOLEAN, rules: [validators.required], }, { + cols: 6, label: i18n.t("user.user-can-manage-group"), varName: "canManage", type: fieldTypes.BOOLEAN, rules: [validators.required], }, { + cols: 6, label: i18n.t("user.user-can-organize-group-data"), varName: "canOrganize", type: fieldTypes.BOOLEAN, rules: [validators.required], }, { + cols: 6, label: i18n.t("user.user-can-manage-household"), varName: "canManageHousehold", type: fieldTypes.BOOLEAN, rules: [validators.required], }, { + cols: 6, label: i18n.t("user.enable-advanced-features"), varName: "advanced", type: fieldTypes.BOOLEAN, diff --git a/frontend/lang/messages/en-US.json b/frontend/lang/messages/en-US.json index 389b4f2d2..8929adc94 100644 --- a/frontend/lang/messages/en-US.json +++ b/frontend/lang/messages/en-US.json @@ -1168,7 +1168,11 @@ "recipe-actions-data": "Recipe Actions Data", "new-recipe-action": "New Recipe Action", "edit-recipe-action": "Edit Recipe Action", - "action-type": "Action Type" + "action-type": "Action Type", + "action-types": { + "link": "Link", + "post": "Post" + } }, "create-alias": "Create Alias", "manage-aliases": "Manage Aliases", @@ -1447,4 +1451,4 @@ "min-length": "Must Be At Least {min} Characters", "max-length": "Must Be At Most {max} Character|Must Be At Most {max} Characters" } -} \ No newline at end of file +} diff --git a/frontend/pages/admin/manage/users/[id].vue b/frontend/pages/admin/manage/users/[id].vue index 1908277f4..d7ea1a0a8 100644 --- a/frontend/pages/admin/manage/users/[id].vue +++ b/frontend/pages/admin/manage/users/[id].vue @@ -27,92 +27,102 @@ variant="outlined" style="border-color: lightgrey;" > - - - {{ $t("user.user-id-with-value", { id: user.id }) }} - - - - - - - {{ $t("user.generate-password-reset-link") }} - - - - - - {{ resetUrl }} - - - - - {{ $t("general.close") }} - - - - - {{ $globals.icons.email }} - - {{ $t("user.email") }} - - - - + + + + {{ $t("user.user-id-with-value", { id: user.id }) }} + + - - + + + + + + + + + + + {{ $t("user.generate-password-reset-link") }} + + + + + + + {{ resetUrl }} + + + + + {{ $t("general.close") }} + + + + + {{ $globals.icons.email }} + + {{ $t("user.email") }} + + + + + + + + - - + + + + + + + + + + - + + + + + diff --git a/frontend/pages/group/data/recipe-actions.vue b/frontend/pages/group/data/recipe-actions.vue index da709b119..3de1d786b 100644 --- a/frontend/pages/group/data/recipe-actions.vue +++ b/frontend/pages/group/data/recipe-actions.vue @@ -3,6 +3,8 @@ (() => [ { label: i18n.t("general.title"), varName: "title", @@ -78,10 +80,14 @@ const formItems: AutoFormItems = [ label: i18n.t("data-pages.recipe-actions.action-type"), varName: "actionType", type: fieldTypes.SELECT, - options: [{ text: "link" }, { text: "post" }], + options: [ + { text: i18n.t("data-pages.recipe-actions.action-types.link"), value: "link" }, + { text: i18n.t("data-pages.recipe-actions.action-types.post"), value: "post" }, + ], + selectReturnValue: "value", rules: [validators.required], }, -]; +]); // ============================================================ // Create diff --git a/frontend/pages/group/data/tags.vue b/frontend/pages/group/data/tags.vue index cac08b337..77c998839 100644 --- a/frontend/pages/group/data/tags.vue +++ b/frontend/pages/group/data/tags.vue @@ -3,6 +3,8 @@ boolean | string; export interface FormSelectOption { text: string; + value?: string; } export interface FormField { section?: string; sectionDetails?: string; + cols?: number | "auto"; label?: string; hint?: string; varName: string; @@ -19,7 +21,7 @@ export interface FormField { disableUpdate?: boolean; disableCreate?: boolean; options?: FormSelectOption[]; - selectReturnValue?: string; + selectReturnValue?: "text" | "value"; } export type AutoFormItems = FormField[];
{{ $t("user.user-id-with-value", { id: user.id }) }}
- {{ resetUrl }} -
+ {{ resetUrl }} +