1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-19 13:19:41 +02:00

replace v-for/v-if with computed ref

This commit is contained in:
Michael Genson 2024-02-23 19:22:39 +00:00
parent ae8ea16dab
commit aa4527e5f7
2 changed files with 18 additions and 7 deletions

View file

@ -3,8 +3,7 @@
<BaseDialog v-if="shoppingListDialog" v-model="dialog" :title="$t('recipe.add-to-list')" :icon="$globals.icons.cartCheck">
<v-card-text>
<v-card
v-for="list in shoppingLists"
v-if="showAll || $auth.user && $auth.user.id == list.userId"
v-for="list in shoppingListChoices"
:key="list.id"
hover
class="my-2 left-border"
@ -177,7 +176,7 @@ export default defineComponent({
},
},
setup(props, context) {
const { i18n } = useContext();
const { $auth, i18n } = useContext();
const api = useUserApi();
// v-model support
@ -197,6 +196,10 @@ export default defineComponent({
showAll: false,
});
const shoppingListChoices = computed(() => {
return props.shoppingLists.filter((list) => state.showAll || list.userId === $auth.user?.id);
});
const recipeIngredientSections = ref<ShoppingListRecipeIngredientSection[]>([]);
const selectedShoppingList = ref<ShoppingListSummary | null>(null);
@ -348,6 +351,7 @@ export default defineComponent({
return {
dialog,
shoppingListChoices,
...toRefs(state),
addRecipesToList,
bulkCheckIngredients,