mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-03 04:25:24 +02:00
fix: shopping list label editor (#1333)
* remove head props * lazily compute itemsByLabel with watcher on fetch * remove unused import
This commit is contained in:
parent
52fbf6b833
commit
5a0c034391
3 changed files with 12 additions and 10 deletions
|
@ -130,7 +130,6 @@ import { validators } from "~/composables/use-validators";
|
|||
import { useUserApi } from "~/composables/api";
|
||||
import { IngredientFood } from "~/types/api-types/recipe";
|
||||
import MultiPurposeLabel from "~/components/Domain/ShoppingList/MultiPurposeLabel.vue";
|
||||
import { MultiPurposeLabelSummary } from "~/types/api-types/labels";
|
||||
import { useLocales } from "~/composables/use-locales";
|
||||
import { useFoodStore, useLabelStore } from "~/composables/store";
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@
|
|||
<script lang="ts">
|
||||
import draggable from "vuedraggable";
|
||||
|
||||
import { defineComponent, useAsync, useRoute, computed, ref } from "@nuxtjs/composition-api";
|
||||
import { defineComponent, useAsync, useRoute, computed, ref, watch } from "@nuxtjs/composition-api";
|
||||
import { useToggle } from "@vueuse/core";
|
||||
import { useCopyList } from "~/composables/use-copy";
|
||||
import { useUserApi } from "~/composables/api";
|
||||
|
@ -367,11 +367,13 @@ export default defineComponent({
|
|||
return labels;
|
||||
});
|
||||
|
||||
const itemsByLabel = computed(() => {
|
||||
const items: { [prop: string]: ShoppingListItemCreate[] } = {};
|
||||
const itemsByLabel = ref<{ [key: string]: ShoppingListItemOut[] }>({});
|
||||
|
||||
function updateItemsByLabel() {
|
||||
const items: { [prop: string]: ShoppingListItemOut[] } = {};
|
||||
|
||||
const noLabel = {
|
||||
"No Label": [] as ShoppingListItemCreate[],
|
||||
"No Label": [] as ShoppingListItemOut[],
|
||||
};
|
||||
|
||||
shoppingList.value?.listItems?.forEach((item) => {
|
||||
|
@ -394,7 +396,11 @@ export default defineComponent({
|
|||
items["No Label"] = noLabel["No Label"];
|
||||
}
|
||||
|
||||
return items;
|
||||
itemsByLabel.value = items;
|
||||
}
|
||||
|
||||
watch(shoppingList, () => {
|
||||
updateItemsByLabel();
|
||||
});
|
||||
|
||||
async function refreshLabels() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue