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
|
||||
var config = {
|
||||
categories: context.state.categories,
|
||||
tags: context.state.tags,
|
||||
tags: context.state.tags
|
||||
}
|
||||
var yamlConfig = yaml.safeDump(config)
|
||||
writeFile(path.join(context.getters.config_dir, context.getters.config_filename), yamlConfig, (err) => {
|
||||
if (err) throw err
|
||||
console.log('The file has been saved!')
|
||||
})
|
||||
context.dispatch('datas/compute_tags', null, { root: true })
|
||||
},
|
||||
edit_tag (context, tag) {
|
||||
// Edit or append a tag to config
|
||||
|
@ -192,6 +192,19 @@ export default {
|
||||
{ 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) {
|
||||
var next = moment(context.getters.month).add(1, 'months')
|
||||
context.commit('SET_MONTH', { month: next })
|
||||
|
Loading…
Reference in New Issue
Block a user