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>
<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>

View File

@ -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) {

View File

@ -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