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: cash:
name: Cash name: Cash
variant: info variant: info

View File

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

View File

@ -8,7 +8,7 @@ export default {
data_dir: '/home/lafrite/scripts/comptes/data/', data_dir: '/home/lafrite/scripts/comptes/data/',
config_dir: '/home/lafrite/scripts/comptes/config/', config_dir: '/home/lafrite/scripts/comptes/config/',
config_filename: 'config.yml', config_filename: 'config.yml',
postes: {} tags: {}
}, },
getters: { getters: {
data_dir: (state) => { data_dir: (state) => {
@ -20,13 +20,13 @@ export default {
config_filename: (state) => { config_filename: (state) => {
return state.config_filename return state.config_filename
}, },
postes: (state) => { tags: (state) => {
return state.postes return state.tags
} }
}, },
mutations: { mutations: {
SET_POSTES: (state, { postes }) => { SET_TAGS: (state, { tags }) => {
state.postes = postes state.tags = tags
} }
}, },
actions: { actions: {
@ -39,7 +39,7 @@ export default {
header: true header: true
} }
var parsed = yaml.safeLoad(content, parseConfig) 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) { 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 = parsed.data.filter(x => x.Libellé !== undefined)
parsed.data.forEach(row => { parsed.data.forEach(row => {
appendTag(row, postes, 'Libellé') appendTag(row, tags, 'Libellé')
}) })
context.commit('SET_DATA', { data: parsed }) context.commit('SET_DATA', { data: parsed })

View File

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

View File

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