Compare commits
4 commits
6f3fc6daab
...
287bd47ffa
| Author | SHA1 | Date | |
|---|---|---|---|
| 287bd47ffa | |||
| 0470e381d2 | |||
| 7f9155558a | |||
| 37c0f26fd6 |
6 changed files with 70 additions and 45 deletions
|
|
@ -42,6 +42,7 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
#app {
|
#app {
|
||||||
font-family: Avenir, Helvetica, Arial, sans-serif;
|
font-family: Avenir, Helvetica, Arial, sans-serif;
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
|
|
@ -70,6 +71,10 @@ export default {
|
||||||
background-color: #333;
|
background-color: #333;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.nav li {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Style the links inside the navigation bar */
|
/* Style the links inside the navigation bar */
|
||||||
.nav a {
|
.nav a {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
@ -80,7 +85,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Have active route use different color */
|
/* Have active route use different color */
|
||||||
.nav a.active {
|
.nav li:has(> a.active) {
|
||||||
background-color: #4CAF50;
|
background-color: #4CAF50;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,19 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="meal-card">
|
<div class="meal-card">
|
||||||
<h3>{{ dayOfWeek }} <small>{{ date }}</small></h3>
|
<h3>{{ mealTitle }}</h3>
|
||||||
|
<h4>{{ dayOfWeek }} <small>{{ date }}</small></h4>
|
||||||
<p v-if="meal.recipes.length && meal.extra_ingredients.length">
|
|
||||||
<span v-for="(meal_recipe, index) in meal.recipes" :key="meal_recipe.recipe.id">
|
|
||||||
{{ meal_recipe.recipe.name }}{{ seperator(index, meal.recipes) }}
|
|
||||||
</span>
|
|
||||||
with
|
|
||||||
<span v-for="(ingredient, index) in meal.extra_ingredients" :key="ingredient.id">
|
|
||||||
{{ ingredient.name }}{{ seperator(index, meal.extra_ingredients) }}
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
<p v-else-if="meal.recipes.length">
|
|
||||||
<span v-for="(meal_recipe, index) in meal.recipes" :key="meal_recipe.recipe.id">
|
|
||||||
{{ meal_recipe.recipe.name }}{{ seperator(index, meal.recipes) }}
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
<p v-else-if="meal.extra_ingredients.length">
|
|
||||||
<span v-for="(ingredient, index) in meal.extra_ingredients" :key="ingredient.id">
|
|
||||||
{{ ingredient.name }}{{ seperator(index, meal.extra_ingredients) }}
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
<p v-else>
|
|
||||||
Nothing planned
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Cooked by
|
Cooked by
|
||||||
<span v-for="(chef, index) in meal.chefs" :key="chef.id">
|
<span v-for="(chef, index) in meal.chefs" :key="chef.id">
|
||||||
{{ chef.name }}{{ seperator(index, meal.chefs) }}
|
{{ chef.name }}{{ englishSeperator(index, meal.chefs) }}
|
||||||
</span>
|
</span>
|
||||||
<span v-if="!meal.chefs.length">somebody?</span>
|
<span v-if="!meal.chefs.length">somebody?</span>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
For
|
For
|
||||||
<span v-for="(consumer, index) in meal.consumers" :key="consumer.id">
|
<span v-for="(consumer, index) in meal.consumers" :key="consumer.id">
|
||||||
{{ consumer.name }}{{ seperator(index, meal.consumers) }}
|
{{ consumer.name }}{{ englishSeperator(index, meal.consumers) }}
|
||||||
</span>
|
</span>
|
||||||
<span v-if="!meal.consumers.length">somebody?</span>
|
<span v-if="!meal.consumers.length">somebody?</span>
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -52,6 +30,30 @@
|
||||||
|
|
||||||
import { ago } from '@/dateformats.js'
|
import { ago } from '@/dateformats.js'
|
||||||
|
|
||||||
|
function englishSeperator(index, list) {
|
||||||
|
switch (index) {
|
||||||
|
case list.length - 1:
|
||||||
|
return '';
|
||||||
|
case list.length - 2:
|
||||||
|
return ' and ';
|
||||||
|
default:
|
||||||
|
return ', ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function englishList(list) {
|
||||||
|
switch (list.length) {
|
||||||
|
case 0:
|
||||||
|
return '';
|
||||||
|
case 1:
|
||||||
|
return list[0];
|
||||||
|
case 2:
|
||||||
|
return `${list[0]} and ${list[1]}`;
|
||||||
|
default:
|
||||||
|
return `${list.slice(0, -1).join(', ')}, and ${list.slice(-1)}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'MealCard',
|
name: 'MealCard',
|
||||||
props: ['meal'],
|
props: ['meal'],
|
||||||
|
|
@ -62,18 +64,21 @@ export default {
|
||||||
dayOfWeek() {
|
dayOfWeek() {
|
||||||
return this.meal.suggested_date.toLocaleDateString('en-au', { weekday: 'long' })
|
return this.meal.suggested_date.toLocaleDateString('en-au', { weekday: 'long' })
|
||||||
},
|
},
|
||||||
},
|
mealTitle() {
|
||||||
methods: {
|
const recipesText = englishList(this.meal.recipes.map(mealRecipe => mealRecipe.recipe.name));
|
||||||
seperator(index, list) {
|
const ingredientsText = englishList(this.meal.extra_ingredients.map(ingredient => ingredient.name));
|
||||||
switch (index) {
|
|
||||||
case list.length - 1:
|
if (recipesText && ingredientsText) {
|
||||||
return '';
|
return `${recipesText} with ${ingredientsText}`;
|
||||||
case list.length - 2:
|
} else if (recipesText || ingredientsText) {
|
||||||
return ' and ';
|
return recipesText || ingredientsText;
|
||||||
default:
|
} else {
|
||||||
return ', ';
|
return 'Nothing planned';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
englishSeperator,
|
||||||
ago
|
ago
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
.recipe-search-box input {
|
.recipe-search-box input {
|
||||||
width: 100%;
|
width: calc(100% - 2em);
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,11 @@
|
||||||
<button v-else @click="showPurchased=true">⏷ Show Purchased ⏷</button>
|
<button v-else @click="showPurchased=true">⏷ Show Purchased ⏷</button>
|
||||||
|
|
||||||
<div v-if="showPurchased">
|
<div v-if="showPurchased">
|
||||||
|
<h4>Purchased Meals</h4>
|
||||||
|
<meal-selection-list @meal-selected="mealSelected" @meal-unselected="mealUnselected" :checked="includedMeals" :meals="purchasedMeals" />
|
||||||
|
|
||||||
<h4>
|
<h4>
|
||||||
Already Purchased
|
Purchased Items
|
||||||
</h4>
|
</h4>
|
||||||
<ul class="full-shopping-list">
|
<ul class="full-shopping-list">
|
||||||
<li v-for="item in purchasedGroups" :key="item.id">
|
<li v-for="item in purchasedGroups" :key="item.id">
|
||||||
|
|
@ -170,7 +173,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: [], productGroupsToPurchase: [], purchasedGroups: [], selected: [], showPurchased: false }
|
return { from, to, availableMeals: [], purchasedMeals: [], shoppingList: null, includedMeals: [], productGroupsToPurchase: [], purchasedGroups: [], selected: [], showPurchased: false }
|
||||||
},
|
},
|
||||||
async beforeMount() {
|
async beforeMount() {
|
||||||
this.loadData();
|
this.loadData();
|
||||||
|
|
@ -183,9 +186,17 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async loadData() {
|
async loadData() {
|
||||||
const allMeals = await data.getUpcomingMeals(this.from, this.to);
|
|
||||||
this.availableMeals = allMeals.filter(m => !m.purchase_date);
|
|
||||||
this.shoppingList = await data.getCurrentShoppingList();
|
this.shoppingList = await data.getCurrentShoppingList();
|
||||||
|
|
||||||
|
const upcomingMeals = await data.getUpcomingMeals(this.from, this.to);
|
||||||
|
const requestedMeals = this.shoppingList.requests.map(r => r.meal).filter(m => m);
|
||||||
|
|
||||||
|
const meals = {};
|
||||||
|
requestedMeals.forEach(m => meals[m.id] = m);
|
||||||
|
upcomingMeals.forEach(m => meals[m.id] = m);
|
||||||
|
|
||||||
|
this.purchasedMeals = Object.values(meals).filter(m => m.purchase_date);
|
||||||
|
this.availableMeals = Object.values(meals).filter(m => !m.purchase_date);
|
||||||
},
|
},
|
||||||
async updateLists() {
|
async updateLists() {
|
||||||
if (!this.shoppingList)
|
if (!this.shoppingList)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<li v-for="meal in meals" :key="meal.id">
|
<li v-for="meal in meals" :key="meal.id">
|
||||||
<!-- Have a checkbox and card for each meal, show the image and name -->
|
<!-- Have a checkbox and card for each meal, show the image and name -->
|
||||||
<!-- Emit meal-selected event on checked and meal-unselected on unchecked -->
|
<!-- Emit meal-selected event on checked and meal-unselected on unchecked -->
|
||||||
<input type="checkbox" :id="meal.id" :checked="isChecked(meal)" @change="mealCheckChanged" :disabled="!!meal.purchase_date" />
|
<input type="checkbox" :id="meal.id" :checked="isChecked(meal)" @change="mealCheckChanged" :disabled="disabled" />
|
||||||
<label :for="meal.id" :style="getImageStyling(meal)">
|
<label :for="meal.id" :style="getImageStyling(meal)">
|
||||||
{{ formatDate(meal.suggested_date) }}
|
{{ formatDate(meal.suggested_date) }}
|
||||||
</label>
|
</label>
|
||||||
|
|
@ -121,6 +121,10 @@ export default {
|
||||||
props: {
|
props: {
|
||||||
meals: Array,
|
meals: Array,
|
||||||
checked: Array,
|
checked: Array,
|
||||||
|
disabled: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
formatDate,
|
formatDate,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<h3>Purchased {{ shoppingList ? ago(shoppingList.created_date) : '' }}</h3>
|
<h3>Purchased {{ shoppingList ? ago(shoppingList.created_date) : '' }}</h3>
|
||||||
|
|
||||||
<h4>Included Meals</h4>
|
<h4>Included Meals</h4>
|
||||||
<meal-selection-list :checked="includedMeals" :meals="includedMeals" />
|
<meal-selection-list :checked="includedMeals" :meals="includedMeals" :disabled="true" />
|
||||||
|
|
||||||
<ul class="full-shopping-list">
|
<ul class="full-shopping-list">
|
||||||
<li v-for="item in listByProduct" :key="item.id">
|
<li v-for="item in listByProduct" :key="item.id">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue