1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-05 05:25:26 +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="{
@ -73,20 +73,20 @@
<v-divider/> <v-divider/>
<v-expand-transition group> <v-expand-transition group>
<div v-show="labelOpenState[key]"> <div v-show="labelOpenState[key]">
<draggable :value="value" handle=".handle" delay="250" :delay-on-touch-only="true" @start="loadingCounter += 1" @end="loadingCounter -= 1" @input="updateIndexUncheckedByLabel(key, $event)"> <draggable :value="value" handle=".handle" delay="250" :delay-on-touch-only="true" @start="loadingCounter += 1" @end="loadingCounter -= 1" @input="updateIndexUncheckedByLabel(key, $event)">
<v-lazy v-for="(item, index) in value" :key="item.id" class="ml-2 my-2"> <v-lazy v-for="(item, index) in value" :key="item.id" class="ml-2 my-2">
<ShoppingListItem <ShoppingListItem
v-model="value[index]" v-model="value[index]"
:show-label=false :show-label=false
:labels="allLabels || []" :labels="allLabels || []"
:units="allUnits || []" :units="allUnits || []"
:foods="allFoods || []" :foods="allFoods || []"
:recipes="recipeMap" :recipes="recipeMap"
@checked="saveListItem" @checked="saveListItem"
@save="saveListItem" @save="saveListItem"
@delete="deleteListItem(item)" @delete="deleteListItem(item)"
/> />
</v-lazy> </v-lazy>
</draggable> </draggable>
</div> </div>
</v-expand-transition> </v-expand-transition>
@ -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 });