Skip to content

Commit

Permalink
fix: Sort Food by Label on Data Management Page (#4631)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-genson authored Dec 10, 2024
1 parent eecda1b commit 02a545d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions frontend/components/global/CrudTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export interface TableHeaders {
value: string;
show: boolean;
align?: string;
sortable?: boolean;
sort?: (a: any, b: any) => number;
}
export interface BulkAction {
Expand Down
6 changes: 6 additions & 0 deletions frontend/pages/group/data/foods.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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"),
Expand Down

0 comments on commit 02a545d

Please sign in to comment.