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 @@ + + + + + + + + + + + @@ -127,10 +155,7 @@ /> - + - - - - {{ labelOpenState[key] ? $globals.icons.chevronDown : $globals.icons.chevronRight }} - - {{ key }} - - - - + + + + {{ key }} + + - - - - - - - - - - - - - - - - - - - + + + + - - - - - - - {{ showChecked ? $globals.icons.chevronDown : $globals.icons.chevronRight }} - - - {{ $t('shopping-list.items-checked-count', listItems.checked ? listItems.checked.length : 0) }} - - - - - - - - - - + + + + + + {{ $t('shopping-list.items-checked-count', listItems.checked ? listItems.checked.length : 0) }} + + + + + + + + - - - + + + @@ -316,7 +276,7 @@ ? shoppingList.recipeReferences.length : 0) }} - + import { VueDraggable } from "vue-draggable-plus"; +import RecipeList from "~/components/Domain/Recipe/RecipeList.vue"; import MultiPurposeLabelSection from "~/components/Domain/ShoppingList/MultiPurposeLabelSection.vue"; import ShoppingListItem from "~/components/Domain/ShoppingList/ShoppingListItem.vue"; -import RecipeList from "~/components/Domain/Recipe/RecipeList.vue"; import ShoppingListItemEditor from "~/components/Domain/ShoppingList/ShoppingListItemEditor.vue"; -import { useFoodStore, useLabelStore, useUnitStore } from "~/composables/store"; -import { useShoppingListPreferences } from "~/composables/use-users/preferences"; -import { getTextColor } from "~/composables/use-text-color"; import { useShoppingListPage } from "~/composables/shopping-list-page/use-shopping-list-page"; +import { useFoodStore, useLabelStore, useUnitStore } from "~/composables/store"; +import { getTextColor } from "~/composables/use-text-color"; +import { useShoppingListPreferences } from "~/composables/use-users/preferences"; export default defineNuxtComponent({ components: { @@ -417,8 +377,19 @@ export default defineNuxtComponent({ }); - diff --git a/frontend/types/components.d.ts b/frontend/types/components.d.ts index bcee9b06c..6ebc0529c 100644 --- a/frontend/types/components.d.ts +++ b/frontend/types/components.d.ts @@ -13,6 +13,7 @@ import type BaseButtonGroup from "@/components/global/BaseButtonGroup.vue"; import type BaseCardSectionTitle from "@/components/global/BaseCardSectionTitle.vue"; import type BaseDialog from "@/components/global/BaseDialog.vue"; import type BaseDivider from "@/components/global/BaseDivider.vue"; +import type BaseExpansionPanels from "@/components/global/BaseExpansionPanels.vue"; import type BaseOverflowButton from "@/components/global/BaseOverflowButton.vue"; import type BasePageTitle from "@/components/global/BasePageTitle.vue"; import type BaseStatCard from "@/components/global/BaseStatCard.vue"; @@ -54,6 +55,7 @@ declare module "vue" { BaseCardSectionTitle: typeof BaseCardSectionTitle; BaseDialog: typeof BaseDialog; BaseDivider: typeof BaseDivider; + BaseExpansionPanels: typeof BaseExpansionPanels; BaseOverflowButton: typeof BaseOverflowButton; BasePageTitle: typeof BasePageTitle; BaseStatCard: typeof BaseStatCard;