makes updating Template work
This commit is contained in:
@@ -82,6 +82,15 @@ Template.prototype.findIndexByKey = function(slotKey) {
|
|||||||
return day_idx * 3 + meal_idx;
|
return day_idx * 3 + meal_idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Template.prototype.updateJson = function(data) {
|
||||||
|
var i;
|
||||||
|
for (i in data.items) {
|
||||||
|
let item = data.items[i];
|
||||||
|
let idx = this.findIndexByKey(item.key);
|
||||||
|
this.items[idx].value = item.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Planner',
|
name: 'Planner',
|
||||||
data () {
|
data () {
|
||||||
@@ -99,7 +108,7 @@ export default {
|
|||||||
this.is_loading = false;
|
this.is_loading = false;
|
||||||
return res.json();}
|
return res.json();}
|
||||||
)
|
)
|
||||||
.then((data) => this.template = data) //TODO: update
|
.then((data) => this.template.updateJson(data))
|
||||||
.catch((err) => console.log(err));
|
.catch((err) => console.log(err));
|
||||||
},
|
},
|
||||||
unsetMeal: function(mealKey) {
|
unsetMeal: function(mealKey) {
|
||||||
|
|||||||
Reference in New Issue
Block a user