Open source personal finance application
Refactor Stat components
ilkome44c9560038b9
diff --git a/src/components/stat/StatChartsLine.vue b/src/components/stat/StatChartsLine.vueindex 2c34af83..c87f1020 100644--- a/src/components/stat/StatChartsLine.vue+++ b/src/components/stat/StatChartsLine.vue@@ -101,7 +101,7 @@ export default {: diff = this.periods[filterPeriod].showedPeriods}if (diff <= 0) diff = 1- this.$store.commit('setDiffPeriods', diff)+ this.$store.dispatch('setDiffPeriods', diff)return diff},@@ -179,11 +179,11 @@ export default {</script><template lang="pug">-.charts(v-if="$store.state.ui.statGraphsVisible")+.charts(v-if="$store.state.ui.statGraphsVisibility === 'visible'")template(v-if="$store.state.filter.period === 'all'").charts__allData Change period to see charttemplate(v-if="$store.state.filter.period !== 'all'")- .charts__nav+ .charts__nav(v-if="$store.state.ui.mobile")ChartMenu.charts__content@@ -218,7 +218,7 @@ export default {//- popuptemplate(v-if="$store.state.ui.pc && $store.state.chart.hoveredPeriod.values")- ChartPopup(v-if="")+ ChartPopup</template><style lang="stylus" scoped>@@ -229,13 +229,19 @@ export default {@import "~@/stylus/variables/scrollbar".charts- z-index 2position relativebackground var(--c-bg-2)border-bottom 1px solid var(--c-bg-1)@media $media-laptop- min-height 178px+ z-index 3+ min-height 163px+ opacity .7+ anim-all()++ &:hover+ @media $media-laptop+ opacity 1&__allDatadisplay flexdiff --git a/src/components/stat/StatCustomizeMenuMobile.vue b/src/components/stat/StatCustomizeMenuMobile.vuenew file mode 100644index 00000000..559bc510--- /dev/null+++ b/src/components/stat/StatCustomizeMenuMobile.vue@@ -0,0 +1,70 @@+<script>+import ContextMenu from '@/components/shared/contextMenu/ContextMenu'+import ContextMenuItem from '@/components/shared/contextMenu/ContextMenuItem'+import Dropdown from '@/components/shared/dropdown/Dropdown'++export default {+ components: {+ ContextMenu,+ ContextMenuItem,+ Dropdown+ },++ data () {+ return {+ visibleCustomizeMenu: false+ }+ }+}+</script>++<template lang="pug">+ContextMenu(+ :position="{ left: true, bottom: true }"+ :visible="visibleCustomizeMenu"+ v-on:onClickOpener="visibleCustomizeMenu = !visibleCustomizeMenu")+ template(slot="opener")+ Dropdown._inline(+ :active="visibleCustomizeMenu"+ :title="$lang.settings.customize")+ template(slot="content")+ ContextMenuItem(+ icon="mdi mdi-credit-card-multiple"+ title="Wallets"+ :showCheckbox="true"+ :checkboxValue="$store.state.ui.stat.walletsVisibility === 'visible'"+ v-on:onClick="$store.dispatch('toogleStatWalletsVisibility')")+ ContextMenuItem(+ icon="mdi mdi-chart-bar-stacked"+ title="Periods chart"+ :showCheckbox="true"+ :checkboxValue="$store.state.ui.statGraphsVisibility === 'visible'"+ v-on:onClick="$store.dispatch('toogleShowStatGraphs')")+ ContextMenuItem(+ icon="mdi mdi-numeric"+ title="Summary"+ :showCheckbox="true"+ :checkboxValue="$store.state.ui.statSummuryVisibility === 'visible'"+ v-on:onClick="$store.dispatch('toogleStatSummuryVisibility')")+ ContextMenuItem(+ icon="mdi mdi-chart-bubble"+ title="Stat categories chart"+ :showCheckbox="true"+ :checkboxValue="$store.state.ui.catsChart === 'visible'"+ v-on:onClick="$store.dispatch('toogleVisibleCatsChart')")+ ContextMenuItem(+ icon="mdi mdi-chart-gantt"+ title="Stat categories list"+ :showCheckbox="true"+ :checkboxValue="$store.state.ui.statItems === 'visible'"+ v-on:onClick="$store.dispatch('toogleVisibilityStatItems')")+ .context-menu-sep+ ContextMenuItem(+ icon="mdi mdi-palette"+ title="Change theme"+ v-on:onClick="$store.dispatch('changeTheme')")+</template>++<style lang="stylus" scoped>++</style>diff --git a/src/components/stat/StatItem.vue b/src/components/stat/StatItem.vueindex 963006c3..5ca082e7 100644--- a/src/components/stat/StatItem.vue+++ b/src/components/stat/StatItem.vue@@ -80,13 +80,17 @@ export default {<template lang="pug">.statItem(@click="toogleShowTrnsInCategory(categoryId)"- :class="{ _active: showTrns }"-)+ :class="{ _active: showTrns }")+.statItem__content.statItem__graph: .statItem__graph__in(:style="styles").statItem__icon(@click.stop="() => $store.dispatch('handleSetFilterCategory', categoryId)")- Icon(:background="category.color", :icon="category.icon")+ Icon(+ :background="category.color"+ :icon="category.icon"+ :round="true")+.statItem__name {{ category.name }}.statItem__amountAmount(@@ -120,13 +124,16 @@ export default {border 1px solid transparent@media $media-laptop- padding $m7 $m8+ padding 10px 10px+ margin (- 8px) 0px&:last-childmargin-bottom 0&:hover@media $media-laptop+ padding 10px 10px+ margin -8px 0pxbackground var(--c-bg-1)border 1px solid var(--c-bg-5)@@ -139,14 +146,20 @@ export default {background var(--c-bg-3)border 1px solid var(--c-bg-7)+ @media $media-laptop+ padding 0+ margin 10px 0px+&:first-childmargin-top (- $m7)+ @media $media-laptop+ margin-top -10px&__contentdisplay gridgrid-template-columns minmax(10px, max-content) 1fr minmax(10px, max-content)grid-template-rows repeat(2, minmax(10px, max-content))- grid-column-gap $m9+ grid-column-gap 20px^[0]._active &padding $m7 $m7@@ -154,7 +167,7 @@ export default {border-bottom 1px solid var(--c-bg-1)@media $media-laptop- padding $m7 $m8+ padding 12px 10px/.theme-light &background var(--c-bg-10)@@ -185,6 +198,7 @@ export default {color var(--c-font-2)&__icon+ width 32pxgrid-column 1 / 2grid-row 1 / -1diff --git a/src/components/stat/StatItemChildCatsItem.vue b/src/components/stat/StatItemChildCatsItem.vueindex 91341737..c4d6a316 100644--- a/src/components/stat/StatItemChildCatsItem.vue+++ b/src/components/stat/StatItemChildCatsItem.vue@@ -98,7 +98,8 @@ export default {border-bottom 1px solid transparent@media $media-laptop- padding $m7 $m8+ padding 10px 10px+ margin (- 8px) 0&:hover@media $media-laptop@@ -129,14 +130,17 @@ export default {display gridgrid-template-columns minmax(10px, max-content) 1fr minmax(10px, max-content)grid-template-rows repeat(2, minmax(10px, max-content))- grid-column-gap $m9+ grid-column-gap 20px++ @media $media-laptop+ grid-column-gap 20px^[0]._active &- padding $m6 $m7+ padding $m7 $m7background var(--c-bg-4)@media $media-laptop- padding $m7 $m8+ padding 10px&__graphoverflow hidden@@ -163,6 +167,9 @@ export default {color var(--c-font-3)&__icon+ display flex+ justify-content center+ width 32pxgrid-column 1 / 2grid-row 1 / -1diff --git a/src/components/stat/StatMobile.vue b/src/components/stat/StatMobile.vueindex 88dbd428..bea80366 100644--- a/src/components/stat/StatMobile.vue+++ b/src/components/stat/StatMobile.vue@@ -1,37 +1,25 @@<script>import Amount from '@/components/amount/Amount'-import ContextMenu from '@/components/shared/contextMenu/ContextMenu'-import ContextMenuItem from '@/components/shared/contextMenu/ContextMenuItem'-import Dropdown from '@/components/shared/dropdown/Dropdown'import EmptyData from '@/components/shared/emptyData/EmptyData'import FilterItem from '@/components/filter/FilterItem'import Icon from '@/components/icon/Icon'import PeriodCatsChart from '@/components/stat/cats/PeriodCatsChart'+import StatCustomizeMenuMobile from '@/components/stat/StatCustomizeMenuMobile'import StatItem from '@/components/stat/StatItem'import StatSummaryMobile from '@/components/stat/StatSummaryMobile'import TrnsList from '@/components/trns/list/TrnsList'-import TrnsListViewEasy from '@/components/trns/list/TrnsListViewEasy'export default {components: {Amount,- ContextMenu,- ContextMenuItem,- Dropdown,EmptyData,FilterItem,Icon,PeriodCatsChart,+ StatCustomizeMenuMobile,StatItem,StatSummaryMobile,- TrnsList,- TrnsListViewEasy- },-- data () {- return {- visibleCustomizeMenu: false- }+ TrnsList},computed: {@@ -69,7 +57,7 @@ export default {<template lang="pug">.stat- StatSummaryMobile+ StatSummaryMobile(v-if="$store.state.ui.statSummuryVisibility === 'visible'").stat__filter(v-if="$store.state.filter.categoryId || $store.state.filter.walletId")template(v-if="$store.state.filter.walletId")@@ -178,44 +166,7 @@ export default {:total="stat.categories[categoryId].expenses").customize- ContextMenu(- :position="{ left: true, bottom: true }"- :visible="visibleCustomizeMenu"- v-on:onClickOpener="visibleCustomizeMenu = !visibleCustomizeMenu")- template(slot="opener")- Dropdown._inline(- :active="visibleCustomizeMenu"- :title="$lang.settings.customize")- template(slot="content")- ContextMenuItem(- icon="mdi mdi-credit-card-multiple"- title="Wallets"- :showCheckbox="true"- :checkboxValue="$store.state.ui.stat.walletsVisibility === 'visible'"- v-on:onClick="$store.dispatch('setStatWalletsVisibility')")- ContextMenuItem(- icon="mdi mdi-chart-bar-stacked"- title="Periods chart"- :showCheckbox="true"- :checkboxValue="$store.state.ui.statGraphsVisible"- v-on:onClick="$store.dispatch('toogleShowStatGraphs')")- ContextMenuItem(- icon="mdi mdi-chart-bubble"- title="Cats chart"- :showCheckbox="true"- :checkboxValue="$store.state.ui.catsChart === 'visible'"- v-on:onClick="$store.dispatch('toogleVisibleCatsChart')")- ContextMenuItem(- icon="mdi mdi-chart-gantt"- title="Cats stat"- :showCheckbox="true"- :checkboxValue="$store.state.ui.statItems === 'visible'"- v-on:onClick="$store.dispatch('toogleVisibilityStatItems')")- .context-menu-sep- ContextMenuItem(- icon="mdi mdi-palette"- title="Change theme"- v-on:onClick="$store.dispatch('changeTheme')")+ StatCustomizeMenuMobile</template><style lang="stylus" scoped>@@ -231,16 +182,20 @@ export default {.stat&__filter- padding $m8 $m7+ padding 10px $m7background var(--c-bg-4)&__chartspadding-bottom $m7&:last-child- padding-bottom $m5+ padding-bottom 0.statGrouppadding-top $m9+ padding-bottom 10px++ & + &+ border-top 1px solid var(--c-bg-6).statItem-headerpadding-bottom $m8diff --git a/src/components/stat/StatPc.vue b/src/components/stat/StatPc.vueindex a3c2aea5..f09188e9 100644--- a/src/components/stat/StatPc.vue+++ b/src/components/stat/StatPc.vue@@ -69,22 +69,21 @@ export default {padding 0 $mb2&__content- display grid- grid-template-columns repeat(auto-fit, minMax(450px, 1fr))-- @media $media-pc- grid-column-gap $mb1-- @media $media-xl- grid-column-gap 150px+ display flex+ justify-content space-between&__item- flex 1 1 450px+ flex 1+ max-width 400pxpadding-top $m9+ &:first-child+ align-self start+ &:last-child+ align-self start&__chart@media $media-laptop- padding-bottom $m7+ padding-bottom 12px&__catsmax-width 470pxdiff --git a/src/components/stat/StatSummaryMobile.vue b/src/components/stat/StatSummaryMobile.vueindex e156ebd5..a54f38ed 100644--- a/src/components/stat/StatSummaryMobile.vue+++ b/src/components/stat/StatSummaryMobile.vue@@ -62,7 +62,7 @@ export default {.summarydisplay flexpadding $m7 0- background var(--c-bg-3)+ background var(--c-bg-4)border-bottom 1px solid var(--c-bg-1)&__itemdiff --git a/src/components/stat/StatSummaryPc.vue b/src/components/stat/StatSummaryPc.vueindex 42dbf8d7..87c4b9c4 100644--- a/src/components/stat/StatSummaryPc.vue+++ b/src/components/stat/StatSummaryPc.vue@@ -38,7 +38,7 @@ export default {.summary__row(v-if="period !== 'all' && statAverage.expenses > 0").summary__average.summary__average__icon: .mdi.mdi-chart-timeline- .summary__average__title Average+ .summary__average__title {{ $lang.money.average }}.summary__amount._averageAmount(:currency="$store.state.currencies.base"@@ -49,7 +49,7 @@ export default {.summary__item(:class="{ _total: statAverage.total !== 0 || period === 'all' }")template(v-if="statAverage.total !== 0 || period === 'all'").summary__row- .summary__title Total+ .summary__title {{ $lang.money.total }}.summary__amountAmount(:big="true"@@ -60,7 +60,7 @@ export default {.summary__row.summary__average.summary__average__icon: .mdi.mdi-chart-timeline- .summary__average__title Average+ .summary__average__title {{ $lang.money.average }}.summary__amount._averageAmount(:currency="$store.state.currencies.base"@@ -98,14 +98,11 @@ export default {.summaryoverflow hiddendisplay flex- flex-flow column- padding $m9 0+ flex-flow row+ justify-content space-between- @media $media-pc- display grid- grid-template-columns repeat(3, 1fr)- grid-column-gap 120px- padding 0+ @media $media-laptop+ display flex&__itemflex-grow 0@@ -118,24 +115,32 @@ export default {@media $media-phoneborder-bottom 1px solid var(--c-bg-5)- @media $media-pc- // max-width 280px+ @media $media-laptop+ min-width 250px+ padding 0margin 0+ @media $media-pc+ padding $m3 $m9+ padding-right 0+&._expenses- border-left 2px solid rgba(200, 30, 50, .3)+ @media $media-pc+ border-left 2px solid rgba(200, 30, 50, .3)@media $media-phoneorder 1&._totalalign-self center- border-left 2px solid var(--c-bg-5)+ @media $media-pc+ border-left 2px solid var(--c-bg-5)@media $media-phoneorder 3&._incomesalign-self end- border-left 2px solid rgba(44, 173, 34, .5)+ @media $media-pc+ border-left 2px solid rgba(44, 173, 34, .5)@media $media-phoneorder 2diff --git a/src/components/stat/cats/PeriodCatsChart.vue b/src/components/stat/cats/PeriodCatsChart.vueindex f4bd3a0e..747f4128 100644--- a/src/components/stat/cats/PeriodCatsChart.vue+++ b/src/components/stat/cats/PeriodCatsChart.vue@@ -23,6 +23,14 @@ export default {},computed: {+ className () {+ return {+ _mobile: this.$store.state.ui.mobile,+ _pc: this.$store.state.ui.pc,+ _incomes: this.type === 'incomes',+ _expenses: this.type === 'expenses'+ }+ },biggestAmount () {return this.$store.getters.stat[this.type].biggest},@@ -46,7 +54,7 @@ export default {</script><template lang="pug">-.cats-chart+.cats-chart(:class="className").cats-chart__items(v-if="stat[type].categoriesIds.length > 0")PeriodCatsChartItem(@@ -56,35 +64,40 @@ export default {:categoryId="categoryId":key="`charts-${categoryId}`":total="stat.categories[categoryId][type]"- v-on:onActiveCategoryChange="handleActiveCategoryChange"- )+ v-on:onActiveCategoryChange="handleActiveCategoryChange")+.cats-chart__popup(v-if="this.$store.state.ui.pc"- v-show="activeCategoryId"- )+ v-show="activeCategoryId")PeriodCatsChartPopup(:offset="offset":categoryId="activeCategoryId"- :type="type"- )+ :type="type")</template>-<style lang="stylus">-.stat__item:first-child .cats-chart- border-left 2px solid rgba(200, 30, 50, .3)--.stat__item:last-child .cats-chart- border-left 2px solid rgba(44, 173, 34, .3)-</style>-<style lang="stylus" scoped>+@import "~@/stylus/variables/animations"@import "~@/stylus/variables/margins"@import "~@/stylus/variables/media"@import "~@/stylus/variables/scrollbar".cats-chartposition relative- background var(--c-bg-3)+ @media $media-laptop+ opacity .7+ anim-all(100)++ &:hover+ @media $media-laptop+ opacity 1++ &._incomes+ @media $media-laptop+ border-bottom 2px solid rgba(44, 173, 34, .5)++ &._expenses+ @media $media-laptop+ border-bottom 2px solid rgba(200, 30, 50, .3)&__itemsoverflow hidden@@ -94,7 +107,7 @@ export default {padding $m7@media $media-laptop- padding $m8 $m8+ padding 10px 10px&:aftercontent ""diff --git a/src/components/stat/cats/PeriodCatsChartItem.vue b/src/components/stat/cats/PeriodCatsChartItem.vueindex b7ac240b..d41e26d3 100644--- a/src/components/stat/cats/PeriodCatsChartItem.vue+++ b/src/components/stat/cats/PeriodCatsChartItem.vue@@ -85,8 +85,15 @@ export default {@import "~@/stylus/variables/margins".statCatsItem- padding-top $m6- padding-right $m4+ padding-top 12px+ margin-right 10px++ &:hover+ @media $media-laptop+ @media (hover: hover)+ padding 32px 10px 20px 10px+ margin -20px 0px -20px -10px+ background var(--c-bg-6)&__graphposition relative@@ -113,16 +120,12 @@ export default {&__icondisplay none- transform scale(0.8)display flexalign-items centerjustify-content center- font-size 18px- width 32px- height 32px+ font-size 16px+ width 28px+ height 28pxmargin 0 auto- margin-top $m5- margin-bottom (- $m5)color var(--c-font-1)- border-radius 50%</style>diff --git a/src/components/stat/cats/PeriodCatsChartPopup.vue b/src/components/stat/cats/PeriodCatsChartPopup.vueindex af20f40d..ecf24981 100644--- a/src/components/stat/cats/PeriodCatsChartPopup.vue+++ b/src/components/stat/cats/PeriodCatsChartPopup.vue@@ -23,10 +23,14 @@ export default {computed: {amount () {- return this.$store.getters.stat.categories[this.categoryId][this.type]+ if (this.$store.getters.stat.categories[this.categoryId]) {+ return this.$store.getters.stat.categories[this.categoryId][this.type]+ }},categoryName () {- return this.$store.state.categories.items[this.categoryId].name+ if (this.$store.state.categories.items[this.categoryId]) {+ return this.$store.state.categories.items[this.categoryId].name+ }}}}@@ -34,7 +38,7 @@ export default {<template lang="pug">.chart-popup(- v-if="categoryId"+ v-if="categoryId && amount && categoryName":style="{ left: `${offset}px` }").chart-popup__name {{ categoryName }}@@ -42,8 +46,7 @@ export default {Amount(:value="amount":currency="$store.state.currencies.base"- :type="type === 'incomes' ? 1 : 0"- )+ :type="type === 'incomes' ? 1 : 0")</template><style lang="stylus" scoped>@@ -61,7 +64,7 @@ export default {white-space nowrapbackground var(--c-bg-6)border-radius $m4- transform translate(-50%, calc(100% + 26px))+ transform translate(-50%, calc(100% + 40px))&:afterposition absolutediff --git a/src/components/stat/chart/ChartItem.vue b/src/components/stat/chart/ChartItem.vueindex 205f5004..7bec135f 100644--- a/src/components/stat/chart/ChartItem.vue+++ b/src/components/stat/chart/ChartItem.vue@@ -130,7 +130,7 @@ export default {border-right 1px solid transparent@media $media-laptop- padding $m8 $m5+ padding 12px $m5&._weekmin-width 50px@@ -149,6 +149,10 @@ export default {border-color transparentmin-width 0+ &._grouped._day+ padding-left 4px+ padding-right 4px+&._grouped._weekpadding-left $m6padding-right $m6@@ -158,8 +162,8 @@ export default {padding-right $m5@media $media-laptop- padding-left $m6- padding-right $m6+ padding-left 6px+ padding-right 6px&:hoverbackground var(--c-bg-1)@@ -167,12 +171,12 @@ export default {&._activecolor var(--c-font-2)- background var(--c-bg-3)+ background var(--c-bg-4)border-left 1px solid var(--c-bg-1)border-right 1px solid var(--c-bg-1)&._active._grouped- border-right 1px solid var(--c-bg-1)+ border-right 1px solid var(--c-bg-1)&__nametext-align centerdiff --git a/src/components/stat/chart/ChartMenu.vue b/src/components/stat/chart/ChartMenu.vueindex 94aad7c0..364758dd 100644--- a/src/components/stat/chart/ChartMenu.vue+++ b/src/components/stat/chart/ChartMenu.vue@@ -2,11 +2,20 @@import localforage from 'localforage'import ContextMenu from '@/components/shared/contextMenu/ContextMenu'import ContextMenuItem from '@/components/shared/contextMenu/ContextMenuItem'+import Dropdown from '@/components/shared/dropdown/Dropdown'export default {components: {ContextMenu,- ContextMenuItem+ ContextMenuItem,+ Dropdown+ },++ props: {+ showDropdown: {+ type: Boolean,+ default: false+ }},data () {@@ -29,12 +38,6 @@ export default {this.periods[this.filterPeriod].grouped? this.$store.commit('addElementsToChart', { periodName: this.filterPeriod, periodType: 'showedGroups' }): this.$store.commit('addElementsToChart', { periodName: this.filterPeriod, periodType: 'showedPeriods' })-- // Should remove?- // this.$nextTick(() => {- // const box = document.querySelector('.charts__items')- // if (box) box.scrollLeft = box.clientWidth- // })this.saveChartsPeriodsToLocalStorage()},@@ -53,6 +56,7 @@ export default {saveChartsPeriodsToLocalStorage () {localforage.setItem('next.chart.periods', this.periods)+ this.$store.dispatch('saveUiView')}}}@@ -60,29 +64,34 @@ export default {<template lang="pug">ContextMenu(- :position="{ right: true }"+ :position="{ right: showDropdown ? '-12px' : true }":visible="visibleContextMenu":openerCircle="true"- v-on:onClickOpener="visibleContextMenu = !visibleContextMenu"-)+ v-on:onClickOpener="visibleContextMenu = !visibleContextMenu")++ template(v-if="showDropdown")+ template(slot="opener")+ Dropdown._noBd(+ :active="visibleContextMenu"+ title="Chart")+template(slot="content")template(v-if="filterPeriod !== 'year'")ContextMenuItem(icon="mdi mdi-ungroup":title="periods[filterPeriod].grouped ? 'Simple charts' : 'Grouped charts'"- v-on:onClick="toogleChartsView"- )+ v-on:onClick="toogleChartsView")+ContextMenuItem(icon="mdi mdi-plus":title="periods[filterPeriod].grouped ? 'Add group' : 'Add period'"- v-on:onClick="addPeriodOrGroup"- )+ v-on:onClick="addPeriodOrGroup")+ContextMenuItem(v-if="(periods[filterPeriod].grouped && periods[filterPeriod].showedGroups > 1) || (!periods[filterPeriod].grouped && periods[filterPeriod].showedPeriods > 1)"icon="mdi mdi-minus":title="periods[filterPeriod].grouped ? 'Remove group' : 'Remove period'"- v-on:onClick="removePeriodOrGroup"- )+ v-on:onClick="removePeriodOrGroup")template(slot="desc")template(v-if="periods[filterPeriod].grouped") Showed {{ periods[filterPeriod].showedGroups }} groups