Feat(data): Compute tags instead of read again csv
This commit is contained in:
parent
af2330d2fa
commit
68653aaabe
@ -74,13 +74,14 @@ export default {
|
|||||||
// save config file
|
// save config file
|
||||||
var config = {
|
var config = {
|
||||||
categories: context.state.categories,
|
categories: context.state.categories,
|
||||||
tags: context.state.tags,
|
tags: context.state.tags
|
||||||
}
|
}
|
||||||
var yamlConfig = yaml.safeDump(config)
|
var yamlConfig = yaml.safeDump(config)
|
||||||
writeFile(path.join(context.getters.config_dir, context.getters.config_filename), yamlConfig, (err) => {
|
writeFile(path.join(context.getters.config_dir, context.getters.config_filename), yamlConfig, (err) => {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log('The file has been saved!')
|
console.log('The file has been saved!')
|
||||||
})
|
})
|
||||||
|
context.dispatch('datas/compute_tags', null, { root: true })
|
||||||
},
|
},
|
||||||
edit_tag (context, tag) {
|
edit_tag (context, tag) {
|
||||||
// Edit or append a tag to config
|
// Edit or append a tag to config
|
||||||
|
@ -192,6 +192,19 @@ export default {
|
|||||||
{ filename: filename, data: parsed }
|
{ filename: filename, data: parsed }
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
compute_tags (context) {
|
||||||
|
var tags = Object.values(context.rootGetters['config/tags'])
|
||||||
|
var categories = Object.values(context.rootGetters['config/categories'])
|
||||||
|
Object.values(context.state.csv).forEach(csv => {
|
||||||
|
csv.data.forEach(row => {
|
||||||
|
appendKeywordField(row, 'tags', tags, 'Libellé')
|
||||||
|
appendKeywordField(row, 'categorie', categories, 'Libellé')
|
||||||
|
})
|
||||||
|
context.commit('SET_DATA',
|
||||||
|
{ filename: csv.filename, data: csv }
|
||||||
|
)
|
||||||
|
})
|
||||||
|
},
|
||||||
next_month (context) {
|
next_month (context) {
|
||||||
var next = moment(context.getters.month).add(1, 'months')
|
var next = moment(context.getters.month).add(1, 'months')
|
||||||
context.commit('SET_MONTH', { month: next })
|
context.commit('SET_MONTH', { month: next })
|
||||||
|
Loading…
Reference in New Issue
Block a user