add weight functionality
This commit is contained in:
parent
f0f8dc54d3
commit
b8b3133f30
|
@ -192,14 +192,14 @@
|
|||
<table>
|
||||
<tr>
|
||||
<th colspan="2">
|
||||
{this.date}
|
||||
{this.current.date}
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Weight</th>
|
||||
<td>
|
||||
<!-- TODO: should show last weight -->
|
||||
<input type="number" placeholder="100">
|
||||
<input id="weight" type="number" placeholder="100" >
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
@ -4,7 +4,8 @@ const db = new Dexie('fast');
|
|||
|
||||
db.version(1).stores({
|
||||
catalog: '++id, value, type, target',
|
||||
entries: '++id, day, type'
|
||||
entries: '++id, day, type',
|
||||
weight: 'date'
|
||||
});
|
||||
|
||||
db.open().catch(function (err) {
|
||||
|
|
|
@ -182,8 +182,17 @@ Litedom({
|
|||
async forward() {
|
||||
await this.setDate(+1);
|
||||
},
|
||||
addWeight() {
|
||||
console.log('add weight');
|
||||
addWeight(e) {
|
||||
// capture weight entry
|
||||
let weight = document.getElementById('weight');
|
||||
|
||||
db.weight.put({
|
||||
date: Date.parse(this.data.current.day),
|
||||
value: Number(weight.value)
|
||||
}).then(() => {
|
||||
// update
|
||||
this.setDate(0);
|
||||
});
|
||||
},
|
||||
created() {
|
||||
// start service worker
|
||||
|
|
Loading…
Reference in New Issue