mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-09 16:18:00 -05:00
basics of scaling
This commit is contained in:
@@ -27,6 +27,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<template v-if="shopping_list !== undefined">
|
||||||
|
|
||||||
|
|
||||||
<div v-if="edit_mode">
|
<div v-if="edit_mode">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -41,18 +43,21 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col col-md-6">
|
<div class="col col-md-6">
|
||||||
<ul class="list-group" style="margin-top: 8px" v-if="shopping_list !== undefined">
|
<ul class="list-group" style="margin-top: 8px">
|
||||||
<li class="list-group-item" v-for="x in shopping_list.recipes">[[x.recipe.name]] <input
|
<li class="list-group-item" v-for="x in shopping_list.recipes">[[x.recipe.name]] <input
|
||||||
type="number" v-model="x.multiplier">
|
type="number" v-model="x.multiplier" @change="updateMultiplier(x.id)">
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
|
||||||
|
<div class="row" style="margin-top: 8px">
|
||||||
<div class="col col-12">
|
<div class="col col-12">
|
||||||
<table>
|
<table class="table table-sm table-striped">
|
||||||
<tr v-for="x in shopping_list.entries">
|
<tr v-for="x in shopping_list.entries">
|
||||||
<td>[[x]]</td>
|
<td>[[x.amount]]</td>
|
||||||
|
<td>[[x.unit.name]]</td>
|
||||||
|
<td>[[x.food.name]]</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@@ -61,7 +66,7 @@
|
|||||||
<div v-else>
|
<div v-else>
|
||||||
Non Edit
|
Non Edit
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -139,22 +144,43 @@
|
|||||||
},
|
},
|
||||||
addRecipeToList: function (recipe) {
|
addRecipeToList: function (recipe) {
|
||||||
console.log(this.shopping_list)
|
console.log(this.shopping_list)
|
||||||
this.shopping_list.recipes.push({
|
|
||||||
|
let slr = {
|
||||||
|
"id": Math.random() * 1000,
|
||||||
"recipe": recipe,
|
"recipe": recipe,
|
||||||
"multiplier": 1
|
"multiplier": 1
|
||||||
})
|
}
|
||||||
|
this.shopping_list.recipes.push(slr)
|
||||||
|
|
||||||
for (let s of recipe.steps) {
|
for (let s of recipe.steps) {
|
||||||
for (let i of s.ingredients) {
|
for (let i of s.ingredients) {
|
||||||
|
|
||||||
|
if (!i.is_header) {
|
||||||
this.shopping_list.entries.push({
|
this.shopping_list.entries.push({
|
||||||
'list_recipe': recipe.id,
|
'list_recipe': slr.id,
|
||||||
'food': i.food,
|
'food': i.food,
|
||||||
'unit': i.unit,
|
'unit': ((i.unit !== undefined) ? i.unit : {'name': ''}),
|
||||||
'amount': i.amount,
|
'amount': i.amount,
|
||||||
'order': 0
|
'order': 0
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
updateMultiplier: function(slr_id) {
|
||||||
|
console.log('searching', slr_id)
|
||||||
|
let slr = undefined
|
||||||
|
for (let r of this.shopping_list.recipes){
|
||||||
|
console.log(r, r.id)
|
||||||
|
if (r.id === slr_id) {
|
||||||
|
console.log('FOUND')
|
||||||
|
slr = r
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let e of this.shopping_list.entries){
|
||||||
|
e.amount = (e.amount * slr.multiplier)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
searchKeywords: function (query) {
|
searchKeywords: function (query) {
|
||||||
this.keywords_loading = true
|
this.keywords_loading = true
|
||||||
|
|||||||
Reference in New Issue
Block a user