diff --git a/frontend/components/global/BaseExpansionPanels.vue b/frontend/components/global/BaseExpansionPanels.vue new file mode 100644 index 000000000..92a0a6eaf --- /dev/null +++ b/frontend/components/global/BaseExpansionPanels.vue @@ -0,0 +1,17 @@ + + + diff --git a/frontend/composables/shopping-list-page/sub-composables/use-shopping-list-labels.ts b/frontend/composables/shopping-list-page/sub-composables/use-shopping-list-labels.ts index 3cd9d5c1b..f3f23de1c 100644 --- a/frontend/composables/shopping-list-page/sub-composables/use-shopping-list-labels.ts +++ b/frontend/composables/shopping-list-page/sub-composables/use-shopping-list-labels.ts @@ -1,5 +1,5 @@ import { useToggle } from "@vueuse/core"; -import type { ShoppingListOut, ShoppingListItemOut } from "~/lib/api/types/household"; +import type { ShoppingListOut } from "~/lib/api/types/household"; /** * Composable for managing shopping list label state and operations @@ -36,14 +36,24 @@ export function useShoppingListLabels(shoppingList: Ref) ); }); + const labelColorByName = computed(() => { + const map: Record = {}; + shoppingList.value?.listItems?.forEach((item) => { + if (!item.label) return; + const labelName = item.label?.name || t("shopping-list.no-label"); + map[labelName] = item.label.color; + }); + return map; + }); + watch(labelNames, initializeLabelOpenStates, { immediate: true }); function toggleShowLabel(key: string) { labelOpenState.value[key] = !labelOpenState.value[key]; } - function getLabelColor(item: ShoppingListItemOut | null) { - return item?.label?.color; + function getLabelColor(label: string) { + return labelColorByName.value[label]; } const presentLabels = computed(() => { diff --git a/frontend/pages/shopping-lists/[id].vue b/frontend/pages/shopping-lists/[id].vue index c59173d67..05638affd 100644 --- a/frontend/pages/shopping-lists/[id].vue +++ b/frontend/pages/shopping-lists/[id].vue @@ -36,6 +36,34 @@ + + + + +
+ +
+
+
+
+