Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Sort Food by Label on Data Management Page #4631

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading