Compare commits
2 Commits
7121137145
...
e29d664f0e
| Author | SHA1 | Date | |
|---|---|---|---|
| e29d664f0e | |||
| c522c23dfe |
@@ -59,9 +59,8 @@ export default {
|
|||||||
closeActiveView: function() {
|
closeActiveView: function() {
|
||||||
this.active_view = -1;
|
this.active_view = -1;
|
||||||
},
|
},
|
||||||
addToPlanning: function(idx) {
|
addToPlanning: function(mealKey, id) {
|
||||||
let mealKey = ["Lundi", "Lunch"];
|
let mealData = this.items.find((recipe) => recipe.id == id);
|
||||||
let mealData = this.items[idx];
|
|
||||||
this.$refs.weekPlanning.setMeal(mealKey, mealData);
|
this.$refs.weekPlanning.setMeal(mealKey, mealData);
|
||||||
},
|
},
|
||||||
deleteRecipe: function(id) {
|
deleteRecipe: function(id) {
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<br class="is-hidden-mobile"/>
|
<br class="is-hidden-mobile"/>
|
||||||
<SlotSelect />
|
<SlotSelect v-on:add="addToPlanning" />
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<h4 class="title">{{ item.title }}</h4>
|
<h4 class="title">{{ item.title }}</h4>
|
||||||
@@ -51,6 +51,11 @@ export default {
|
|||||||
return {
|
return {
|
||||||
categories: categories,
|
categories: categories,
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
addToPlanning: function(slotKey) {
|
||||||
|
this.$emit('add', slotKey, this.item.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,22 +1,36 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="box">
|
||||||
<a @click="$emit('add', item.id)"
|
<div class="columns">
|
||||||
|
<div class="column">
|
||||||
|
<div class="field">
|
||||||
|
<div class="control is-expanded">
|
||||||
|
<div class="select is-small is-fullwidth">
|
||||||
|
<select v-model="selected_day">
|
||||||
|
<option value="Lundi">Lundi</option>
|
||||||
|
<option value="Mardi">Mardi</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<p class="control">
|
||||||
|
<div class="select is-small">
|
||||||
|
<select v-model="selected_meal">
|
||||||
|
<option value="Breakfast">Breakfast</option>
|
||||||
|
<option value="Lunch">Lunch</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="column">
|
||||||
|
<a @click="$emit('add', getSelectedKey)"
|
||||||
class="has-text-success">
|
class="has-text-success">
|
||||||
<span class="icon is-large">
|
<span class="icon is-large">
|
||||||
<i class="mdi mdi-36px mdi-table-plus"></i>
|
<i class="mdi mdi-36px mdi-table-plus"></i>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<div class="select">
|
</div>
|
||||||
<select>
|
|
||||||
<option>Lundi</option>
|
|
||||||
<option>Mardi</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="select">
|
|
||||||
<select>
|
|
||||||
<option>Breakfast</option>
|
|
||||||
<option>Lunch</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -24,6 +38,16 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'SlotSelect',
|
name: 'SlotSelect',
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
selected_day: "Lundi",
|
||||||
|
selected_meal: "Breakfast",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
getSelectedKey: function() {
|
||||||
|
return [this.selected_day, this.selected_meal];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user