2024-05-20 12:16:39 +00:00
|
|
|
<template>
|
2024-10-13 08:19:36 +00:00
|
|
|
<h3>Purchased {{ shoppingList?.purchased_date?.toLocaleDateString({ year: 'numeric', month: '2-digit', day: '2-digit' }) || '' }}</h3>
|
2024-05-20 12:16:39 +00:00
|
|
|
|
|
|
|
|
<h4>Included Meals</h4>
|
|
|
|
|
<meal-selection-list :checked="includedMeals" :meals="includedMeals" />
|
|
|
|
|
|
|
|
|
|
<ul class="full-shopping-list">
|
2024-10-13 08:19:36 +00:00
|
|
|
<li v-for="item in listByProduct" :key="item.id">
|
|
|
|
|
<shopping-list-item :productGrouping="item" />
|
2024-05-20 12:16:39 +00:00
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
|
|
.full-shopping-list li {
|
|
|
|
|
list-style-type: none;
|
|
|
|
|
|
|
|
|
|
border: 1px solid #ccc;
|
|
|
|
|
border-radius: 0.5em;
|
|
|
|
|
margin-bottom: 1em;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.full-shopping-list {
|
|
|
|
|
padding: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
|
|
import data from '@/data.js'
|
2024-10-13 08:19:36 +00:00
|
|
|
import { purchasedToProductModel } from './shopping.js'
|
2024-05-20 12:16:39 +00:00
|
|
|
|
|
|
|
|
import MealSelectionList from './MealSelectionList.vue'
|
|
|
|
|
import ShoppingListItem from './ShoppingListItem.vue'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'FullShoppingListPage',
|
|
|
|
|
components: { MealSelectionList, ShoppingListItem },
|
|
|
|
|
props: {
|
|
|
|
|
id: [String, Number]
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
shoppingList: null,
|
|
|
|
|
includedMeals: [],
|
|
|
|
|
listByProduct: [],
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
async beforeMount() {
|
|
|
|
|
this.shoppingList = await data.getShoppingList(this.id);
|
|
|
|
|
this.includedMeals = this.shoppingList.requests.map(r => r.meal).filter(m => m);
|
2024-10-13 08:19:36 +00:00
|
|
|
this.listByProduct = purchasedToProductModel(this.shoppingList);
|
2024-05-20 12:16:39 +00:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</script>
|