1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-04 13:05:21 +02:00

fix: "No Label" on Shopping List can't be toggled (#4513)

Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
This commit is contained in:
Michael Genson 2024-11-05 17:12:52 -06:00 committed by GitHub
parent 62300deea0
commit f4bde93960
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -56,7 +56,7 @@
<!-- View By Label --> <!-- View By Label -->
<div v-else> <div v-else>
<div v-for="(value, key) in itemsByLabel" :key="key" class="mb-6"> <div v-for="(value, key) in itemsByLabel" :key="key" class="pb-4">
<v-btn <v-btn
:color="getLabelColor(value[0]) ? getLabelColor(value[0]) : '#959595'" :color="getLabelColor(value[0]) ? getLabelColor(value[0]) : '#959595'"
:style="{ :style="{
@ -470,7 +470,7 @@ export default defineComponent({
}); });
// ===================================== // =====================================
// Collapsables // Collapsable Labels
const labelOpenState = ref<{ [key: string]: boolean }>({}); const labelOpenState = ref<{ [key: string]: boolean }>({});
const initializeLabelOpenStates = () => { const initializeLabelOpenStates = () => {
@ -480,8 +480,8 @@ export default defineComponent({
let hasChanges = false; let hasChanges = false;
for (const item of shoppingList.value.listItems) { for (const item of shoppingList.value.listItems) {
const labelName = item.label?.name; const labelName = item.label?.name || i18n.tc("shopping-list.no-label");
if (labelName && !existingLabels.has(labelName) && !(labelName in labelOpenState.value)) { if (!existingLabels.has(labelName) && !(labelName in labelOpenState.value)) {
labelOpenState.value[labelName] = true; labelOpenState.value[labelName] = true;
hasChanges = true; hasChanges = true;
} }
@ -492,9 +492,13 @@ export default defineComponent({
} }
}; };
const labelNames = computed(() => const labelNames = computed(() => {
new Set(shoppingList.value?.listItems?.map(item => item.label?.name).filter(Boolean) ?? []) return new Set(
shoppingList.value?.listItems
?.map(item => item.label?.name || i18n.tc("shopping-list.no-label"))
.filter(Boolean) ?? []
); );
});
watch(labelNames, initializeLabelOpenStates, { immediate: true }); watch(labelNames, initializeLabelOpenStates, { immediate: true });