Feat: write data on edit

This commit is contained in:
Bertrand Benjamin 2021-08-09 11:48:24 +02:00
parent 899fd95dbd
commit 5020479b0a
4 changed files with 11 additions and 4 deletions

View File

@ -74,10 +74,14 @@ export default {
...mapActions('travail', {
'createMonth': 'createMonth',
}),
...mapActions('config', {
'writeData': 'writeData',
}),
save: function () {
console.log("save")
console.log(this.monthCopy)
this.createMonth({date: this.monthDate, month: this.monthCopy})
this.writeData()
},
cancel: function () {
this.monthCopy = this.theEmptyMonth

View File

@ -71,13 +71,14 @@ export default {
'updateMonth': 'updateMonth',
}),
...mapActions('config', {
'loadData': 'loadData',
'writeData': 'writeData',
}),
toggleEdit: function () {
this.editing = !this.editing
},
save: function () {
this.updateMonth({date: this.TheDate, month: {...this.monthCopy}})
this.writeData()
this.toggleEdit()
},
cancel: function () {

View File

@ -71,6 +71,8 @@ export default {
retrocessionMean: "retrocessionMean",
})
},
mounted () {
},
methods: {
},
}

View File

@ -183,11 +183,11 @@ const travail = {
},
loadMonths (context) {
// import all months from storage
readFile(context.rootGetters["config/dataFilePath"], (err, data) => {
if (err) throw err;
const months = Papa.parse(data.toString(), {header: true, dynamicTyping:true})
.data.reduce(
const months = Papa.parse(data.toString(), {header: true, dynamicTyping:true, skipEmptyLines:true})
.data
.reduce(
(acc, el) => {
acc[el.date] = el;
return acc