autoamtically keep meal plan to date relative to from date
This commit is contained in:
parent
0a814fa896
commit
05d971835f
@ -209,8 +209,14 @@ export default {
|
|||||||
},
|
},
|
||||||
deep: true,
|
deep: true,
|
||||||
},
|
},
|
||||||
entryEditing: {
|
'entryEditing.from_date': {
|
||||||
handler(newVal) {
|
handler(newVal, oldVal) {
|
||||||
|
if (newVal !== undefined && oldVal !== undefined) {
|
||||||
|
if (newVal !== oldVal) {
|
||||||
|
let change = Math.abs(moment(oldVal).diff(moment(this.entryEditing.to_date), 'days')) // even though negative numbers might be correct, they would be illogical as to needs to always be larger than from
|
||||||
|
this.entryEditing.to_date = moment(newVal).add(change, 'd').format("YYYY-MM-DD")
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
deep: true,
|
deep: true,
|
||||||
},
|
},
|
||||||
@ -312,7 +318,7 @@ export default {
|
|||||||
this.entryEditing.servings = 1
|
this.entryEditing.servings = 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
changeDate(date, change){
|
changeDate(date, change) {
|
||||||
return moment(date).add(change, 'd').format("YYYY-MM-DD")
|
return moment(date).add(change, 'd').format("YYYY-MM-DD")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user