add weight functionality

This commit is contained in:
Geoff Doty 2020-10-04 17:51:20 -04:00
parent f0f8dc54d3
commit b8b3133f30
3 changed files with 15 additions and 5 deletions

View File

@ -192,14 +192,14 @@
<table> <table>
<tr> <tr>
<th colspan="2"> <th colspan="2">
{this.date} {this.current.date}
</th> </th>
</tr> </tr>
<tr> <tr>
<th>Weight</th> <th>Weight</th>
<td> <td>
<!-- TODO: should show last weight --> <!-- TODO: should show last weight -->
<input type="number" placeholder="100"> <input id="weight" type="number" placeholder="100" >
</td> </td>
</tr> </tr>
</table> </table>

View File

@ -4,7 +4,8 @@ const db = new Dexie('fast');
db.version(1).stores({ db.version(1).stores({
catalog: '++id, value, type, target', catalog: '++id, value, type, target',
entries: '++id, day, type' entries: '++id, day, type',
weight: 'date'
}); });
db.open().catch(function (err) { db.open().catch(function (err) {

View File

@ -182,8 +182,17 @@ Litedom({
async forward() { async forward() {
await this.setDate(+1); await this.setDate(+1);
}, },
addWeight() { addWeight(e) {
console.log('add weight'); // 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() { created() {
// start service worker // start service worker