working lists

This commit is contained in:
vabene1111
2020-06-03 18:10:34 +02:00
parent 3b5b505116
commit b95c3f6685

View File

@@ -52,22 +52,31 @@
<tbody> <tbody>
<tr v-for="mp in meal_plan"> <tr v-for="mp in meal_plan">
<td v-for="d in mp.days"> <td v-for="d in mp.days">
<draggable class="list-group" :list="d.items" group="plan" @change="log('l2', $event)"> <draggable class="list-group" :list="d.items" group="plan" @change="log(d.date, $event)"
<div :empty-insert-threshold="100">
class="list-group-item" <div class="list-group-item" v-for="(element, index) in d.items" :key="element.id">
v-for="(element, index) in d.items" [[element.title]] - [[element.id]]
:key="element.id"
>
[[element.name]] - [[element.id]]
</div> </div>
</draggable> </draggable>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
[[plan_entries]]
[[meal_types]] [[meal_plan]]
<br/>
<br/>
entries
<ul>
<li v-for="e in plan_entries">[[e]]</li>
</ul>
types
<ul>
<li v-for="t in meal_types">[[t]]</li>
</ul>
</div> </div>
@@ -84,11 +93,11 @@
days: moment.weekdays(), days: moment.weekdays(),
plan_entries: [], plan_entries: [],
meal_types: [], meal_types: [],
meal_plan: [ meal_plan: {}
],
}, },
mounted: function () { mounted: function () {
console.log("MOUNTED")
this.getPlanEntries(); this.getPlanEntries();
}, },
methods: { methods: {
@@ -116,21 +125,24 @@
}) })
}, },
buildGrid: function () { buildGrid: function () {
console.log("BUILD GRID EXECUTED")
for (t of this.meal_types) { for (t of this.meal_types) {
console.log(t.name) this.$set(this.meal_plan, t.id, {
var type = {
name: t.name, name: t.name,
days: [] meal_type: t.id,
} days: {}
})
for (d of this.days) { for (d of this.days) {
type.days.push({ date = moment().day(d).week(week).format('YYYY-MM-DD')
this.$set(this.meal_plan[t.id].days, date, {
name: d, name: d,
items: [ date: date,
{'id':Math.round(Math.random()*1000), "name": "Test"} items: []
]
}) })
} }
this.meal_plan.push(type) }
for (e of this.plan_entries) {
this.meal_plan[e.meal_type].days[e.date].items.push(e)
} }
}, },
log: function (param, evt) { log: function (param, evt) {