From cec66edd759de9b9c93ccb89ed811de5ec561c0e Mon Sep 17 00:00:00 2001 From: Michael Genson <71845777+michael-genson@users.noreply.github.com> Date: Sat, 30 Nov 2024 17:10:15 +0000 Subject: [PATCH 1/2] allow custom sort on crud table items --- frontend/components/global/CrudTable.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/components/global/CrudTable.vue b/frontend/components/global/CrudTable.vue index 1c7bfe3c9c2..6e427220df1 100644 --- a/frontend/components/global/CrudTable.vue +++ b/frontend/components/global/CrudTable.vue @@ -99,6 +99,8 @@ export interface TableHeaders { value: string; show: boolean; align?: string; + sortable?: boolean; + sort?: (a: any, b: any) => number; } export interface BulkAction { From 79a30bebe9f7b67bf0c97f31348a8d713c367179 Mon Sep 17 00:00:00 2001 From: Michael Genson <71845777+michael-genson@users.noreply.github.com> Date: Sat, 30 Nov 2024 17:10:23 +0000 Subject: [PATCH 2/2] fixed food label sort --- frontend/pages/group/data/foods.vue | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frontend/pages/group/data/foods.vue b/frontend/pages/group/data/foods.vue index cb41a09bd2d..bdc2c484859 100644 --- a/frontend/pages/group/data/foods.vue +++ b/frontend/pages/group/data/foods.vue @@ -290,6 +290,7 @@ import MultiPurposeLabel from "~/components/Domain/ShoppingList/MultiPurposeLabe import { useLocales } from "~/composables/use-locales"; import { useFoodStore, useLabelStore } from "~/composables/store"; import { VForm } from "~/types/vuetify"; +import { MultiPurposeLabelOut } from "~/lib/api/types/labels"; export default defineComponent({ components: { MultiPurposeLabel, RecipeDataAliasManagerDialog }, @@ -325,6 +326,11 @@ export default defineComponent({ text: i18n.tc("shopping-list.label"), value: "label", show: true, + sort: (label1: MultiPurposeLabelOut | null, label2: MultiPurposeLabelOut | null) => { + const label1Name = label1?.name || ""; + const label2Name = label2?.name || ""; + return label1Name.localeCompare(label2Name); + }, }, { text: i18n.tc("tool.on-hand"),