Start working on csv
This commit is contained in:
parent
4a9e49fc20
commit
791aa12d2d
0
jsconfig.json
Normal file
0
jsconfig.json
Normal file
@ -15,6 +15,7 @@
|
||||
"dependencies": {
|
||||
"core-js": "^3.6.5",
|
||||
"date-fns": "^2.23.0",
|
||||
"papaparse": "^5.3.1",
|
||||
"vls": "^0.7.4",
|
||||
"vue": "^3.0.0",
|
||||
"vue-router": "^4.0.8",
|
||||
|
@ -69,6 +69,9 @@ export default {
|
||||
methods: {
|
||||
...mapActions('travail', {
|
||||
'updateMonth': 'updateMonth',
|
||||
}),
|
||||
...mapActions('config', {
|
||||
'loadData': 'loadData',
|
||||
}),
|
||||
toggleEdit: function () {
|
||||
this.editing = !this.editing
|
||||
|
42
src/store/config/index.js
Normal file
42
src/store/config/index.js
Normal file
@ -0,0 +1,42 @@
|
||||
import path from 'path'
|
||||
import Papa from 'papaparse'
|
||||
|
||||
const config = {
|
||||
namespaced: true,
|
||||
state() {
|
||||
return {
|
||||
//userDir: '~/.config/sousmargot/',
|
||||
userDir: './userDir/',
|
||||
dataFile: 'datas.csv'
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
userDir (state) { return state.userDir },
|
||||
dataFilePath (state) { return path.join(state.userDir, state.dataFile) },
|
||||
},
|
||||
mutations: {
|
||||
},
|
||||
actions: {
|
||||
loadConfig (context) {
|
||||
// load config file at ~/.config/sousmargot/config.json
|
||||
return context.state.userDir
|
||||
},
|
||||
loadData (context) {
|
||||
// load data in userDir on dataFile
|
||||
console.log("Loading data")
|
||||
console.log(context.getters.dataFilePath)
|
||||
},
|
||||
writeData (context) {
|
||||
// overwrite the dataFile with months datas
|
||||
console.log("Writing data")
|
||||
console.log(context.getters.dataFilePath)
|
||||
const months = context.rootGetters['travail/monthsAll']
|
||||
console.log(Object.keys(months).map(k => {return { ...months[k], date: k}}))
|
||||
const csv = Papa.unparse(context.rootGetters['travail/monthsAll'])
|
||||
console.log(csv)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export default config
|
||||
|
@ -1,10 +1,12 @@
|
||||
import { createStore } from 'vuex'
|
||||
import travailStore from "./travail"
|
||||
import configStore from "./config"
|
||||
|
||||
// Create a new store instance.
|
||||
const store = createStore({
|
||||
modules:{
|
||||
travail: travailStore,
|
||||
config: configStore,
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
function monthCA(month) {
|
||||
if (month.ca_react) {
|
||||
return month.ca_react
|
||||
@ -94,6 +95,10 @@ const travail = {
|
||||
return acc;
|
||||
}, {})
|
||||
},
|
||||
monthsAll: (state) => {
|
||||
// Get in range months
|
||||
return state.months
|
||||
},
|
||||
getMonth: (state) => (date) => {
|
||||
return state.months[date]
|
||||
},
|
||||
@ -190,7 +195,6 @@ const travail = {
|
||||
setRange(context, range) {
|
||||
context.commit("setRange", range)
|
||||
},
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<h1>Home</h1>
|
||||
<button @click="writeData" ></button>
|
||||
<section id="selector">
|
||||
<month-selector>
|
||||
</month-selector>
|
||||
@ -18,7 +19,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters, mapActions } from 'vuex'
|
||||
import { mapActions } from 'vuex'
|
||||
import MonthsList from '../components/MonthsUl.vue'
|
||||
import CreateMonth from '../components/CreateMonth.vue'
|
||||
import MonthSelector from '../components/monthSelector.vue'
|
||||
@ -35,13 +36,15 @@ export default {
|
||||
return {}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
count: "datas/count",
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
...mapActions({
|
||||
})
|
||||
...mapActions('config', {
|
||||
'loadData': 'loadData',
|
||||
'writeData': 'writeData',
|
||||
}),
|
||||
},
|
||||
mounted () {
|
||||
this.loadData()
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
1
userDir/datas.csv
Normal file
1
userDir/datas.csv
Normal file
@ -0,0 +1 @@
|
||||
ca_theo, nbr_seances, ca_retro, ca_react, retro, remuneration,
|
|
Loading…
Reference in New Issue
Block a user