+
-
-
+
+
+
+
+ | [[x.amount]] |
+ [[x.unit.name]] |
+ [[x.food.name]] |
+
+
+
-
-
- Non Edit
-
-
+
{% endblock %}
@@ -139,23 +144,44 @@
},
addRecipeToList: function (recipe) {
console.log(this.shopping_list)
- this.shopping_list.recipes.push({
+
+ let slr = {
+ "id": Math.random() * 1000,
"recipe": recipe,
"multiplier": 1
- })
+ }
+ this.shopping_list.recipes.push(slr)
for (let s of recipe.steps) {
for (let i of s.ingredients) {
- this.shopping_list.entries.push({
- 'list_recipe': recipe.id,
- 'food': i.food,
- 'unit': i.unit,
- 'amount': i.amount,
- 'order': 0
- })
+
+ if (!i.is_header) {
+ this.shopping_list.entries.push({
+ 'list_recipe': slr.id,
+ 'food': i.food,
+ 'unit': ((i.unit !== undefined) ? i.unit : {'name': ''}),
+ 'amount': i.amount,
+ '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) {
this.keywords_loading = true
this.$http.get("{% url 'api:keyword-list' %}" + '?query=' + query + '&limit=10').then((response) => {