Start working on csv

This commit is contained in:
Bertrand Benjamin 2021-08-05 12:51:51 +02:00
parent 4a9e49fc20
commit 791aa12d2d
9 changed files with 8353 additions and 8492 deletions

0
jsconfig.json Normal file
View File

View File

@ -15,6 +15,7 @@
"dependencies": { "dependencies": {
"core-js": "^3.6.5", "core-js": "^3.6.5",
"date-fns": "^2.23.0", "date-fns": "^2.23.0",
"papaparse": "^5.3.1",
"vls": "^0.7.4", "vls": "^0.7.4",
"vue": "^3.0.0", "vue": "^3.0.0",
"vue-router": "^4.0.8", "vue-router": "^4.0.8",

View File

@ -69,6 +69,9 @@ export default {
methods: { methods: {
...mapActions('travail', { ...mapActions('travail', {
'updateMonth': 'updateMonth', 'updateMonth': 'updateMonth',
}),
...mapActions('config', {
'loadData': 'loadData',
}), }),
toggleEdit: function () { toggleEdit: function () {
this.editing = !this.editing this.editing = !this.editing

42
src/store/config/index.js Normal file
View 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

View File

@ -1,10 +1,12 @@
import { createStore } from 'vuex' import { createStore } from 'vuex'
import travailStore from "./travail" import travailStore from "./travail"
import configStore from "./config"
// Create a new store instance. // Create a new store instance.
const store = createStore({ const store = createStore({
modules:{ modules:{
travail: travailStore, travail: travailStore,
config: configStore,
} }
}) })

View File

@ -1,3 +1,4 @@
function monthCA(month) { function monthCA(month) {
if (month.ca_react) { if (month.ca_react) {
return month.ca_react return month.ca_react
@ -94,6 +95,10 @@ const travail = {
return acc; return acc;
}, {}) }, {})
}, },
monthsAll: (state) => {
// Get in range months
return state.months
},
getMonth: (state) => (date) => { getMonth: (state) => (date) => {
return state.months[date] return state.months[date]
}, },
@ -190,7 +195,6 @@ const travail = {
setRange(context, range) { setRange(context, range) {
context.commit("setRange", range) context.commit("setRange", range)
}, },
}, },
} }

View File

@ -1,5 +1,6 @@
<template> <template>
<h1>Home</h1> <h1>Home</h1>
<button @click="writeData" ></button>
<section id="selector"> <section id="selector">
<month-selector> <month-selector>
</month-selector> </month-selector>
@ -18,7 +19,7 @@
</template> </template>
<script> <script>
import { mapGetters, mapActions } from 'vuex' import { mapActions } from 'vuex'
import MonthsList from '../components/MonthsUl.vue' import MonthsList from '../components/MonthsUl.vue'
import CreateMonth from '../components/CreateMonth.vue' import CreateMonth from '../components/CreateMonth.vue'
import MonthSelector from '../components/monthSelector.vue' import MonthSelector from '../components/monthSelector.vue'
@ -35,13 +36,15 @@ export default {
return {} return {}
}, },
computed: { computed: {
...mapGetters({
count: "datas/count",
})
}, },
methods: { methods: {
...mapActions({ ...mapActions('config', {
}) 'loadData': 'loadData',
'writeData': 'writeData',
}),
},
mounted () {
this.loadData()
}, },
} }
</script> </script>

1
userDir/datas.csv Normal file
View File

@ -0,0 +1 @@
ca_theo, nbr_seances, ca_retro, ca_react, retro, remuneration,
1 ca_theo nbr_seances ca_retro ca_react retro remuneration

16765
yarn.lock

File diff suppressed because it is too large Load Diff