Refact: rename poste to tag

This commit is contained in:
Bertrand Benjamin 2018-12-03 12:00:41 +01:00
parent bb46323d7b
commit 9d9f511f2c
8 changed files with 37 additions and 72 deletions

View File

@ -1,5 +1,5 @@
---
postes:
tags:
cash:
name: Cash
variant: info

View File

@ -1,15 +1,15 @@
<template>
<b-card v-if="poste"
:bg-variant="poste.variant"
<b-card v-if="tag"
:bg-variant="tag.variant"
text-variant="white"
class="text-center">
<div class="card-text">
<div class="icon">
<font-awesome-icon :icon="poste.icon" class="fa-3x"/>
<font-awesome-icon :icon="tag.icon" class="fa-3x"/>
</div>
<div class="amount">
<h3>{{ total() }}</h3>
{{ poste.name }}
{{ tag.name }}
</div>
</div>
</b-card>
@ -21,12 +21,12 @@ import { total } from '../libs/data_processing'
export default {
name: 'box',
props: [
'postename',
'tagname',
'rows'
],
data () {
return {
default_poste: {
default_tag: {
name: 'Tout',
variant: 'info',
icon: 'file-invoice-dollar'
@ -35,25 +35,25 @@ export default {
},
computed: {
...mapGetters('config', [
'postes'
'tags'
]),
...mapGetters('datas', [
'tag_filter_rows'
]),
poste () {
if (this.postename) {
return this.postes[this.postename]
tag () {
if (this.tagname) {
return this.tags[this.tagname]
} else {
return this.default_poste
return this.default_tag
}
}
},
methods: {
filter_rows () {
if (this.poste === this.default_poste) {
if (this.tag === this.default_tag) {
return this.tag_filter_rows([])
} else {
return this.tag_filter_rows([this.poste.name])
return this.tag_filter_rows([this.tag.name])
}
},
total () {

View File

@ -55,7 +55,6 @@ export default {
}
})
tagsSpendings[tagsSpendings.length - 1] = total(this.tag_filter_rows([])) - tagsSpendings.reduce((sum, a) => sum + a, 0)
console.log(tagsSpendings)
return tagsSpendings
}
},

View File

@ -8,7 +8,7 @@ export default {
data_dir: '/home/lafrite/scripts/comptes/data/',
config_dir: '/home/lafrite/scripts/comptes/config/',
config_filename: 'config.yml',
postes: {}
tags: {}
},
getters: {
data_dir: (state) => {
@ -20,13 +20,13 @@ export default {
config_filename: (state) => {
return state.config_filename
},
postes: (state) => {
return state.postes
tags: (state) => {
return state.tags
}
},
mutations: {
SET_POSTES: (state, { postes }) => {
state.postes = postes
SET_TAGS: (state, { tags }) => {
state.tags = tags
}
},
actions: {
@ -39,7 +39,7 @@ export default {
header: true
}
var parsed = yaml.safeLoad(content, parseConfig)
context.commit('SET_POSTES', { postes: parsed.postes })
context.commit('SET_TAGS', { tags: parsed.tags })
}
})
}

View File

@ -136,10 +136,10 @@ export default {
})
},
clean_store_data (context, parsed) {
var postes = Object.values(context.rootGetters['config/postes'])
var tags = Object.values(context.rootGetters['config/tags'])
parsed.data = parsed.data.filter(x => x.Libellé !== undefined)
parsed.data.forEach(row => {
appendTag(row, postes, 'Libellé')
appendTag(row, tags, 'Libellé')
})
context.commit('SET_DATA', { data: parsed })

View File

@ -1,5 +1,5 @@
<template>
<div class="postes">
<h1>Postes</h1>
<div class="tags">
<h1>Tags</h1>
</div>
</template>

View File

@ -15,13 +15,13 @@
</b-container>
<b-card-group deck class="mb-3">
<box @click.native="set_postes_filter([])"></box>
<box @click.native="set_postes_filter(['cash'])" postename="cash"></box>
<box @click.native="set_postes_filter(['CB'])" postename="CB"></box>
<box @click.native="set_postes_filter(['virements'])" postename="virements"></box>
<box @click.native="set_tags_filter([])"></box>
<box @click.native="set_tags_filter(['cash'])" tagname="cash"></box>
<box @click.native="set_tags_filter(['CB'])" tagname="CB"></box>
<box @click.native="set_tags_filter(['virements'])" tagname="virements"></box>
</b-card-group>
<postes-comparison></postes-comparison>
<tags-comparison></tags-comparison>
<b-table striped hover :items="filtered_rows" :fields='fields'>
<template slot="tags" slot-scope="data">
@ -32,21 +32,19 @@
</div>
</template>
</b-table>
>>>>>>> chartjs
</div>
</template>
<script>
import { mapGetters, mapActions } from 'vuex'
import box from '../components/box'
import postesComparison from '../components/postes_comparison'
import tagsComparison from '../components/tags_comparison'
export default {
name: 'home',
components: {
box: box,
postesComparison: postesComparison
tagsComparison: tagsComparison
},
data () {
return {
@ -68,12 +66,12 @@ export default {
key: 'tags',
}
],
default_poste: {
default_tag: {
name: 'Tout',
variant: 'info',
icon: 'file-invoice-dollar'
},
postes_filter: []
tags_filter: []
}
},
mounted: function () {
@ -86,10 +84,10 @@ export default {
'tag_filter_rows': 'datas/tag_filter_rows',
'start': 'datas/start',
'end': 'datas/end',
'postes': 'config/postes'
'tags': 'config/tags'
}),
filtered_rows () {
return this.tag_filter_rows(this.postes_filter)
return this.tag_filter_rows(this.tags_filter)
}
},
@ -103,8 +101,8 @@ export default {
table_date_format (date) {
return date
},
set_postes_filter (postenames) {
this.postes_filter = postenames
set_tags_filter (tagnames) {
this.tags_filter = tagnames
}
}
}

View File

@ -1,32 +0,0 @@
<template>
<div class="home">
<b-form-input v-model="icon_name"
type="text"
placeholder="Enter icon name">
</b-form-input>
<p>
Value: {{ icon_name }} -> <font-awesome-icon :icon="icon_name" />
</p>
<p>{{ available_icons }}</p>
</div>
</template>
<script>
// @ is an alias to /src
import { library } from '@fortawesome/fontawesome-svg-core'
export default {
name: 'home',
components: {
},
data () {
return {
icon_name: 'coffee'
}
},
computed: {
available_icons () {
return Object.keys(library.definitions.fas)
}
}
}
</script>