comptes/src/components/box.vue

86 lines
1.5 KiB
Vue
Raw Normal View History

2018-11-30 17:36:30 +00:00
<template>
2018-12-03 11:00:41 +00:00
<b-card v-if="tag"
:bg-variant="tag.variant"
2018-11-30 17:36:30 +00:00
text-variant="white"
class="text-center">
2018-11-30 21:07:08 +00:00
<div class="card-text">
<div class="icon">
2018-12-03 11:00:41 +00:00
<font-awesome-icon :icon="tag.icon" class="fa-3x"/>
2018-11-30 21:07:08 +00:00
</div>
<div class="amount">
<h3>{{ total() }}</h3>
2018-12-03 11:00:41 +00:00
{{ tag.name }}
2018-11-30 21:07:08 +00:00
</div>
</div>
2018-11-30 17:36:30 +00:00
</b-card>
</template>
<script>
import { mapGetters } from 'vuex'
2018-12-03 10:53:01 +00:00
import { total } from '../libs/data_processing'
2018-11-30 17:36:30 +00:00
export default {
name: 'box',
props: [
2018-12-03 11:00:41 +00:00
'tagname',
2018-11-30 17:36:30 +00:00
'rows'
],
data () {
return {
2018-12-03 11:00:41 +00:00
default_tag: {
2018-12-03 09:41:57 +00:00
name: 'Tout',
variant: 'info',
icon: 'file-invoice-dollar'
}
2018-11-30 17:36:30 +00:00
}
},
computed: {
...mapGetters('config', [
2018-12-03 11:00:41 +00:00
'tags'
2018-11-30 17:36:30 +00:00
]),
2018-12-01 13:49:02 +00:00
...mapGetters('datas', [
2018-12-03 09:41:57 +00:00
'tag_filter_rows'
2018-12-01 13:49:02 +00:00
]),
2018-12-03 11:00:41 +00:00
tag () {
if (this.tagname) {
return this.tags[this.tagname]
2018-12-03 09:41:57 +00:00
} else {
2018-12-03 11:00:41 +00:00
return this.default_tag
2018-12-03 09:41:57 +00:00
}
2018-11-30 17:36:30 +00:00
}
},
methods: {
filter_rows () {
2018-12-03 11:00:41 +00:00
if (this.tag === this.default_tag) {
2018-12-03 09:41:57 +00:00
return this.tag_filter_rows([])
} else {
2018-12-03 11:00:41 +00:00
return this.tag_filter_rows([this.tag.name])
2018-12-03 09:41:57 +00:00
}
2018-11-30 17:36:30 +00:00
},
total () {
2018-12-03 10:53:01 +00:00
return total(this.filter_rows())
2018-11-30 17:36:30 +00:00
},
count () {
}
2018-12-01 14:03:38 +00:00
}
2018-11-30 17:36:30 +00:00
}
</script>
<style scoped>
2018-11-30 21:07:08 +00:00
.card-body {
padding: 10px;
}
.card-text {
display: flex;
}
.icon {
flex: 40%;
2018-12-01 13:49:02 +00:00
align-self: center;
2018-11-30 21:07:08 +00:00
}
.amount {
flex: 50%;
text-align: right;
margin-left: 10px;
}
2018-11-30 17:36:30 +00:00
</style>