FIX: saving w/ navigation
This commit is contained in:
parent
b234b6ac7b
commit
d96faaa5b1
|
@ -60,8 +60,8 @@ Litedom({
|
||||||
|
|
||||||
// delete entry
|
// delete entry
|
||||||
db.entries.delete(this.data.history[idx].id).then(() => {
|
db.entries.delete(this.data.history[idx].id).then(() => {
|
||||||
// update entries list
|
// update entries
|
||||||
this.entries();
|
this.setDate(0);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
modify(e) {
|
modify(e) {
|
||||||
|
@ -89,7 +89,7 @@ Litedom({
|
||||||
modified: Date.now(),
|
modified: Date.now(),
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
// refresh entries
|
// refresh entries
|
||||||
this.entries();
|
this.setDate(0);
|
||||||
|
|
||||||
// clear choices
|
// clear choices
|
||||||
this.data.choices = [];
|
this.data.choices = [];
|
||||||
|
@ -122,12 +122,15 @@ Litedom({
|
||||||
target: 'calorie',
|
target: 'calorie',
|
||||||
type: source(calories),
|
type: source(calories),
|
||||||
value: Number(calories.value),
|
value: Number(calories.value),
|
||||||
day: this.data.today,
|
day: this.data.current.day,
|
||||||
created: Date.now(),
|
created: Date.now(),
|
||||||
modified: Date.now(),
|
modified: Date.now(),
|
||||||
}).then(async () => {
|
}).then(async () => {
|
||||||
// update todays history
|
// update
|
||||||
this.entries();
|
this.setDate(0);
|
||||||
|
|
||||||
|
// clear choices
|
||||||
|
this.data.choices = [];
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
|
@ -138,9 +141,16 @@ Litedom({
|
||||||
// set focus
|
// set focus
|
||||||
document.getElementById('calories').focus();
|
document.getElementById('calories').focus();
|
||||||
},
|
},
|
||||||
async setDate(date, change) {
|
async setDate(change = 0) {
|
||||||
// currently selected data
|
|
||||||
let current = new Date(Date.parse(date));
|
let current;
|
||||||
|
|
||||||
|
// currently selected date
|
||||||
|
if (this.data.current.day) {
|
||||||
|
current = new Date(Date.parse(this.data.current.day));
|
||||||
|
} else {
|
||||||
|
current = new Date();
|
||||||
|
}
|
||||||
|
|
||||||
// date back one day
|
// date back one day
|
||||||
let alter = new Date(current.setDate(current.getDate() + Number(change)));
|
let alter = new Date(current.setDate(current.getDate() + Number(change)));
|
||||||
|
@ -164,19 +174,13 @@ Litedom({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async back() {
|
async back() {
|
||||||
// currently selected data
|
await this.setDate(-1);
|
||||||
let current = new Date(Date.parse(this.data.current.day));
|
|
||||||
|
|
||||||
await this.setDate(current, -1);
|
|
||||||
},
|
},
|
||||||
async today() {
|
async today() {
|
||||||
await this.setDate(new Date(), 0);
|
await this.setDate(0);
|
||||||
},
|
},
|
||||||
async forward() {
|
async forward() {
|
||||||
// currently selected data
|
await this.setDate(+1);
|
||||||
let current = new Date(Date.parse(this.data.current.day));
|
|
||||||
|
|
||||||
await this.setDate(current, +1);
|
|
||||||
},
|
},
|
||||||
addWeight() {
|
addWeight() {
|
||||||
console.log('add weight');
|
console.log('add weight');
|
||||||
|
|
Loading…
Reference in New Issue