Add stocktake to query params
This commit is contained in:
parent
0d45938c18
commit
80726a22bd
2 changed files with 12 additions and 3 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<h3>Full shopping list</h3>
|
<h3>Full shopping list</h3>
|
||||||
|
|
||||||
<input type="checkbox" id="show-found" v-model="stockTaking" />
|
<input type="checkbox" id="show-found" @change="onCheckboxChange" :checked="stockTaking" />
|
||||||
<label for="show-found">Show Stocktaking</label>
|
<label for="show-found">Show Stocktaking</label>
|
||||||
|
|
||||||
<h4>Included Meals</h4>
|
<h4>Included Meals</h4>
|
||||||
|
|
@ -47,6 +47,12 @@ import ShoppingListItem from './ShoppingListItem.vue'
|
||||||
export default {
|
export default {
|
||||||
name: 'FullShoppingListPage',
|
name: 'FullShoppingListPage',
|
||||||
components: { MealSelectionList, ShoppingListItem },
|
components: { MealSelectionList, ShoppingListItem },
|
||||||
|
props: {
|
||||||
|
stockTaking: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
const from = new Date();
|
const from = new Date();
|
||||||
from.setTime(0);
|
from.setTime(0);
|
||||||
|
|
@ -54,7 +60,7 @@ export default {
|
||||||
const to = new Date();
|
const to = new Date();
|
||||||
to.setDate(to.getDate() + 7);
|
to.setDate(to.getDate() + 7);
|
||||||
|
|
||||||
return { from, to, availableMeals: [], shoppingList: null, includedMeals: [], listByProduct: [], stockTaking: false, productsToShow: []}
|
return { from, to, availableMeals: [], shoppingList: null, includedMeals: [], listByProduct: [], productsToShow: []}
|
||||||
},
|
},
|
||||||
async beforeMount() {
|
async beforeMount() {
|
||||||
const allMeals = await data.getUpcomingMeals(this.from, this.to);
|
const allMeals = await data.getUpcomingMeals(this.from, this.to);
|
||||||
|
|
@ -99,6 +105,9 @@ export default {
|
||||||
async markPurchased() {
|
async markPurchased() {
|
||||||
const result = await data.markCurrentShoppingListPurchased();
|
const result = await data.markCurrentShoppingListPurchased();
|
||||||
this.$router.push({ name: 'PurchasedShoppingListPage', params: { id: result.id } });
|
this.$router.push({ name: 'PurchasedShoppingListPage', params: { id: result.id } });
|
||||||
|
},
|
||||||
|
onCheckboxChange(event) {
|
||||||
|
this.$router.push({ query: { stockTaking: event.target.checked ? 'true' : undefined } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ const routes = [
|
||||||
{ path: '/mealplan', component: MealPlanPage },
|
{ path: '/mealplan', component: MealPlanPage },
|
||||||
{ path: '/login', component: LoginPage },
|
{ path: '/login', component: LoginPage },
|
||||||
{ path: '/shopping', component: MyShoppingPage },
|
{ path: '/shopping', component: MyShoppingPage },
|
||||||
{ path: '/shopping/current', component: CurrentShoppingListPage },
|
{ path: '/shopping/current', component: CurrentShoppingListPage, props: route => ({ stockTaking: !!route.query.stockTaking }) },
|
||||||
{ path: '/shopping/:id', component: PurchasedShoppingListPage, props : true },
|
{ path: '/shopping/:id', component: PurchasedShoppingListPage, props : true },
|
||||||
{ path: '/recipes', component: RecipesPage },
|
{ path: '/recipes', component: RecipesPage },
|
||||||
{ path: '/recipes/add', component: EditRecipePage },
|
{ path: '/recipes/add', component: EditRecipePage },
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue