Open source personal finance application
refactoring
ilkomeedab2f56a244
diff --git a/components/Metrica.vue b/components/Metrica.vueindex d9152bb6..44ca64f2 100644--- a/components/Metrica.vue+++ b/components/Metrica.vue@@ -1,5 +1,7 @@<script>-export default { }+export default {+ name: 'Metrica'+}</script><template lang="html">diff --git a/components/categories/CategoryStatModal.vue b/components/categories/CategoryStatModal.vueindex 368efdf4..cda61a5d 100644--- a/components/categories/CategoryStatModal.vue+++ b/components/categories/CategoryStatModal.vue@@ -56,8 +56,8 @@ Portal()template(v-if="showChildCategories")- StatItemChildCats2(:categoryId="categoryId", :type="0")- StatItemChildCats2(:categoryId="categoryId", :type="1")+ StatItemChildCats(:categoryId="categoryId", :type="0")+ StatItemChildCats(:categoryId="categoryId", :type="1")template(v-else)TrnsList(@@ -69,5 +69,5 @@ Portal(</template><style lang="stylus" scoped>-//+// styles here...</style>diff --git a/components/layout/LayoutMobile.vue b/components/layout/LayoutMobile.vueindex 764b3975..30194d85 100644--- a/components/layout/LayoutMobile.vue+++ b/components/layout/LayoutMobile.vue@@ -8,13 +8,6 @@ export default {data () {return {slider: null,- visibleContextMenu: false,-- selectedPeriodAmount: {- label: '',- incomes: '',- expenses: ''- },periods: [{slug: 'day',@@ -115,14 +108,11 @@ export default {.page__wrap.page__navh1: Date- //- .page__customize- //- .opener(@click="$store.dispatch('ui/setActiveTab', 'customize')")- //- .mdi.mdi-tune.page__content.chartBar(v-show="$store.state.ui.statGraphsVisibility === 'visible'")ChartMenu2- StatChartsLine2+ StatChartsLine.switcher(:class="{ _round: $store.state.ui.statGraphsVisibility === 'hidden' }").switcher__content@@ -145,7 +135,7 @@ export default {@click="$store.dispatch('filter/setPeriodPrev')"): .mdi.mdi-chevron-right- StatMobile2+ StatMobile//- Categories.swiper-slidediff --git a/components/layout/LayoutMobileMenu.vue b/components/layout/LayoutMobileMenu.vueindex 7853390c..66f74466 100644--- a/components/layout/LayoutMobileMenu.vue+++ b/components/layout/LayoutMobileMenu.vue@@ -51,28 +51,20 @@ export default {handleSetActiveTab (tab) {switch (tab) {case 'wallets':- // this.$store.dispatch('ui/setActiveTab', 'stat')- // this.$store.dispatch('ui/setActiveTabStat', 'stat')this.slider.slideTo(0)breakcase 'stat':- // this.$store.dispatch('ui/setActiveTab', 'stat')- // this.$store.dispatch('ui/setActiveTabStat', 'stat')this.slider.slideTo(1)breakcase 'categories':- // this.$store.dispatch('ui/setActiveTab', 'stat')- // this.$store.dispatch('ui/setActiveTabStat', 'history')this.slider.slideTo(2)breakcase 'menu':this.$store.dispatch('ui/setActiveTab', 'menu')breakdefault:- // this.$store.dispatch('ui/setActiveTab', tab)this.slider.slideTo(0)}- // this.$router.push('/')}}}diff --git a/components/shared/emptyData/EmptyData.vue b/components/shared/emptyData/EmptyData.vueindex 2f5a5d1f..d3e23256 100644--- a/components/shared/emptyData/EmptyData.vue+++ b/components/shared/emptyData/EmptyData.vue@@ -11,7 +11,7 @@ export default {<template lang="pug">.empty- .empty__icon: .mdi.mdi-cat+ .empty__icon: .mdi.mdi-palm-tree.empty__text {{ text }}</template>@@ -25,9 +25,10 @@ export default {&__iconpadding-bottom $m8color var(--c-font-4)- font-size 160px+ font-size 100px&__textcolor var(--c-font-4)- font-size 18px+ font-size 16px+ line-height 22px</style>diff --git a/components/stat/StatChartsLine2.vue b/components/stat/StatChartsLine2.vuedeleted file mode 100644index 66a41c2b..00000000--- a/components/stat/StatChartsLine2.vue+++ /dev/null@@ -1,281 +0,0 @@-<script>-import dayjs from 'dayjs'--export default {- name: 'StatChartsLine2',-- computed: {- periods () {- return this.$store.state.chart.periods- },- filterPeriod () {- return this.$store.state.filter.period- },- activePeriodNumber () {- const statFromDate = dayjs().startOf(this.$store.state.filter.period)- return statFromDate.diff(this.$store.state.filter.date, this.$store.state.filter.period) + 1- },- periodsValues () {- const trns = this.$store.state.trns.items- const transferCategoryId = this.$store.getters['categories/transferCategoryId']- const trnsIds = this.$store.getters['trns/selectedTrnsIds']- const filterPeriod = this.$store.state.filter.period- const diff = this.getNumberShowedPeriods()-- const values = {}- for (let period = 0; period < diff; period++) {- const periodStartDate = dayjs().subtract(period, filterPeriod).startOf(filterPeriod)- const periodEndDate = dayjs().subtract(period, filterPeriod).endOf(filterPeriod)- const ids = trnsIds- .filter((trnId) => {- return trns[trnId].date >= periodStartDate &&- trns[trnId].date <= periodEndDate &&- trns[trnId].categoryId !== transferCategoryId- })-- values[periodStartDate.valueOf()] = {- date: periodStartDate.valueOf(),- ...this.$store.getters['trns/getTotalOfTrnsIds'](ids)- }- }-- return values- },- periodsGroupedValues () {- const filterPeriod = this.$store.state.filter.period- const periodsValues = this.periodsValues- const groupedBy = this.periods[filterPeriod].groupedBy- const groupedValues = {}-- for (const date in periodsValues) {- const periodStartDateValue = dayjs(parseInt(date)).startOf(groupedBy).valueOf()- const periodEndDateValue = dayjs(parseInt(date)).endOf(groupedBy).valueOf()-- if (date >= periodStartDateValue && date <= periodEndDateValue) {- groupedValues[periodStartDateValue]- ? groupedValues[periodStartDateValue].push({ date, ...periodsValues[date] })- : groupedValues[periodStartDateValue] = [{ date, ...periodsValues[date] }]- }- }-- return groupedValues- },- maxAmountValue () {- const periodsValues = this.periodsValues- let biggest = 0-- for (const date in periodsValues) {- const incomes = periodsValues[date].incomes- const expenses = periodsValues[date].expenses- if (incomes > biggest) { biggest = incomes }- if (expenses > biggest) { biggest = expenses }- }- return biggest- }- },-- created () {- this.defaultPeriods = this.$store.state.chart.periods- },-- methods: {- getNumberShowedPeriods () {- const filterPeriod = this.$store.state.filter.period- let diff = 0-- if (this.periods[filterPeriod].grouped) {- diff = this.getGroupedPeriods()- }- else {- this.activePeriodNumber > this.periods[filterPeriod].showedPeriods- ? diff = this.activePeriodNumber- : diff = this.periods[filterPeriod].showedPeriods- }- if (diff <= 0) { diff = 1 }- this.$store.dispatch('stat/setDiffPeriods', diff)-- return diff- },-- getGroupedPeriods () {- const filterPeriod = this.filterPeriod- const groupedBy = this.periods[filterPeriod].groupedBy- const showedGroups = this.periods[filterPeriod].showedGroups- let numberOfPeriods = 0-- // periods in current group- const getPeriodsInCurrentGroup = () => {- let currentGroupPeriods- if (filterPeriod === 'day') { currentGroupPeriods = parseInt(dayjs().format('D')) }- if (filterPeriod === 'week') { currentGroupPeriods = dayjs().week() - dayjs().startOf('month').week() + 1 }- if (filterPeriod === 'month') { currentGroupPeriods = parseInt(dayjs().format('MM')) }- return currentGroupPeriods- }-- // periods in prev group- const getPeriodsInPrevGroup = () => {- let prevGroupsPeriods = 0- for (let index = 1; index < showedGroups; index++) {- prevGroupsPeriods = prevGroupsPeriods + getPeriodsInPrevGroup2(index)- }- return prevGroupsPeriods- }-- const getPeriodsInPrevGroup2 = (hey) => {- const groupDateStart = dayjs().subtract(hey, groupedBy).startOf(groupedBy)- const groupDateEnd = dayjs().subtract(hey, groupedBy).endOf(groupedBy)-- let periodsInGroup = 0- filterPeriod === 'week'- ? periodsInGroup = groupDateEnd.week() - groupDateStart.week()- : periodsInGroup = groupDateEnd.diff(groupDateStart, filterPeriod) + 1-- return periodsInGroup- }-- const periodsInCurrentGroup = getPeriodsInCurrentGroup()-- showedGroups === 1- ? numberOfPeriods = periodsInCurrentGroup- : numberOfPeriods = periodsInCurrentGroup + getPeriodsInPrevGroup()-- // when view old data- if (this.activePeriodNumber >= numberOfPeriods) {- numberOfPeriods = periodsInCurrentGroup- let index = 1- while (this.activePeriodNumber >= numberOfPeriods) {- numberOfPeriods = numberOfPeriods + getPeriodsInPrevGroup2(index)- index++- }- }-- return numberOfPeriods- },-- formatGroupName (date, groupedBy) {- const dateValueOf = parseInt(date)- let format- switch (groupedBy) {- case 'month':- format = 'MMMM'- break- case 'year':- format = 'YYYY'- break- }- return dayjs(dateValueOf).format(format)- }- }-}-</script>--<template lang="pug">-.charts.swiper-no-swiping- template(v-if="$store.state.filter.period === 'all'")- .charts__allData Change period to see chart-- template(v-if="$store.state.filter.period !== 'all'")- .charts__content- //- grouped- template(v-if="periods[filterPeriod].grouped")- .charts__items._grouped- template(v-for="(periodGroups, groupDate) in periodsGroupedValues")- .chart-group(:class="{ _grouped: periods[filterPeriod].grouped }")- .chart-group__name(v-show="periods[filterPeriod].grouped")- template(v-if="periods[filterPeriod].grouped") {{ formatGroupName(groupDate, periods[filterPeriod].groupedBy) }}-- .chart-group__content- template(v-for="period in periodGroups")- ChartItem(- :key="period.date"- :maxAmountValue="maxAmountValue"- :period="period"- parentClassName=".charts__items"- )-- //- simple- template(v-else)- .charts__items- template(v-for="period in periodsValues")- ChartItem(- :key="period.date"- :maxAmountValue="maxAmountValue"- :period="period"- parentClassName=".charts__items")-- //- popup- template(v-if="$store.state.ui.pc && $store.state.chart.hoveredPeriod.values")- ChartPopup-</template>--<style lang="stylus" scoped>-@import "~assets/stylus/variables/animations"-@import "~assets/stylus/variables/margins"-@import "~assets/stylus/variables/fonts"-@import "~assets/stylus/variables/media"-@import "~assets/stylus/variables/scroll"--.charts- z-index 5- position relative-- &__allData- display flex- align-items center- justify-content center- font-size 14px- opacity .7-- &__items- cursor grab- scrollbar()- overflow hidden- overflow-x auto- display flex- flex-direction row-reverse-- &._grouped- padding 0 $m4-- &__nav- z-index 2- position absolute- right $m7- bottom $m7--.chart-group- position relative- flex-grow 1- margin-left 20px- padding-left 20px- border-left 1px solid var(--c-bg-4)-- &:last-child- margin-left 0- padding-left 0- border 0-- &__name- opacity .7- position absolute- right 0- width 100%- height 42px- padding-top 0- padding-bottom $m4- font-secondary()- font-size 14px- text-transform uppercase- white-space nowrap- text-align center- letter-spacing .5px-- &__content- display flex- flex-direction row-reverse- padding-top 20px--.chart-space- &:last-child- min-width 40px-</style>diff --git a/components/stat/StatItem.vue b/components/stat/StatItem.vueindex 91c7e4e0..274fa4d3 100644--- a/components/stat/StatItem.vue+++ b/components/stat/StatItem.vue@@ -92,7 +92,7 @@ export default {template(v-if="showInside").statItem__inside(@click.stop="")template(v-if="showChildCategories")- StatItemChildCats2(:categoryId="categoryId", :type="type")+ StatItemChildCats(:categoryId="categoryId", :type="type")template(v-else)TrnsList(diff --git a/components/stat/StatItemChildCats.vue b/components/stat/StatItemChildCats.vueindex fd0c5649..84dbeb89 100644--- a/components/stat/StatItemChildCats.vue+++ b/components/stat/StatItemChildCats.vue@@ -1,6 +1,8 @@<script>export default {+ name: 'StatItemChildCats',+props: {categoryId: {type: String,diff --git a/components/stat/StatItemChildCats2.vue b/components/stat/StatItemChildCats2.vuedeleted file mode 100644index 475999ff..00000000--- a/components/stat/StatItemChildCats2.vue+++ /dev/null@@ -1,78 +0,0 @@--<script>-export default {- name: 'StatItemChildCats2',-- props: {- categoryId: {- type: String,- required: true- },- type: {- type: Number,- required: true- }- },-- computed: {- statCategories () {- const categoriesIds = this.$store.getters['categories/getChildCategoriesIds'](this.categoryId)- let stat = []-- for (const categoryId of categoriesIds) {- const trnsIds = this.getTrnsByCategoryId(categoryId)- if (trnsIds.length > 0) {- const categoryStat = this.getCategoryStat({ categoryId, trnsIds })- stat.push(categoryStat)- }- }-- stat = stat.sort((a, b) => {- if (a[this.typeName] > b[this.typeName]) { return -1 }- if (a[this.typeName] < b[this.typeName]) { return 1 }- return 0- })-- return stat- },-- typeName () {- return this.type === 1 ? 'incomes' : 'expenses'- }- },-- methods: {- getTrnsByCategoryId (categoryId) {- const trns = this.$store.state.trns.items- let trnsIds = this.$store.getters['trns/selectedTrnsIdsWithDate']- trnsIds = trnsIds.filter(id => trns[id].categoryId === categoryId)- trnsIds = trnsIds.filter(id => trns[id].type === this.type)- return trnsIds- },-- getCategoryStat ({ categoryId, trnsIds }) {- return {- categoryId,- ...this.$store.getters['trns/getTotalOfTrnsIds'](trnsIds)- }- }- }-}-</script>--<template lang="pug">-.items- template(v-for="category in statCategories")- StatItemChildCatsItem2(- :biggest="$store.getters['stat/statCurrentPeriod'][typeName].biggest"- :category="$store.state.categories.items[category.categoryId]"- :categoryId="category.categoryId"- :key="category.categoryId"- :type="type"- :total="category[typeName]"- )-</template>--<style lang="stylus" scoped>--</style>diff --git a/components/stat/StatItemChildCatsItem.vue b/components/stat/StatItemChildCatsItem.vueindex 5e31c9a0..65a205d0 100644--- a/components/stat/StatItemChildCatsItem.vue+++ b/components/stat/StatItemChildCatsItem.vue@@ -25,7 +25,7 @@ export default {data () {return {- showTrns: false+ isShowInside: false}},@@ -39,8 +39,8 @@ export default {},methods: {- toogleShowTrnsInCategory (categoryId) {- this.showTrns = !this.showTrns+ toogleShowInside () {+ this.isShowInside = !this.isShowInside}}}@@ -48,14 +48,13 @@ export default {<template lang="pug">.statItemChild(- @click="toogleShowTrnsInCategory(categoryId)"- :class="{ _active: showTrns }")-+ @click="toogleShowInside(categoryId)"+ :class="{ _active: isShowInside }"+).statItemChild__content.statItemChild__graph: .statItemChild__graph__in(:style="styles")- .statItemChild__icon(- @click.stop="() => $store.dispatch('filter/handleSetFilterCategory', categoryId)")+ .statItemChild__icon(@click.stop="() => $store.dispatch('filter/handleSetFilterCategory', categoryId)")Icon(:background="category.color":icon="category.icon"@@ -68,7 +67,7 @@ export default {:currency="$store.state.currencies.base":value="total")- .statItemChild__trns(@click.stop="" v-if="showTrns")+ .statItemChild__trns(@click.stop="" v-if="isShowInside")TrnsList(ui="stat":incomes="type === 1"diff --git a/components/stat/StatItemChildCatsItem2.vue b/components/stat/StatItemChildCatsItem2.vuedeleted file mode 100644index 65a205d0..00000000--- a/components/stat/StatItemChildCatsItem2.vue+++ /dev/null@@ -1,126 +0,0 @@-<script>-export default {- props: {- category: {- type: Object,- required: true- },- categoryId: {- type: String,- required: true- },- total: {- type: Number,- required: true- },- type: {- type: Number,- required: true- },- biggest: {- type: Number,- required: true- }- },-- data () {- return {- isShowInside: false- }- },-- computed: {- styles () {- return {- width: `${Math.abs(this.total) / Math.abs(this.biggest) * 100}%`,- background: this.category.color- }- }- },-- methods: {- toogleShowInside () {- this.isShowInside = !this.isShowInside- }- }-}-</script>--<template lang="pug">-.statItemChild(- @click="toogleShowInside(categoryId)"- :class="{ _active: isShowInside }"-)- .statItemChild__content- .statItemChild__graph: .statItemChild__graph__in(:style="styles")-- .statItemChild__icon(@click.stop="() => $store.dispatch('filter/handleSetFilterCategory', categoryId)")- Icon(- :background="category.color"- :icon="category.icon"- :round="true")-- .statItemChild__name {{ category.name }}-- .statItemChild__amount- Amount(- :currency="$store.state.currencies.base"- :value="total")-- .statItemChild__trns(@click.stop="" v-if="isShowInside")- TrnsList(- ui="stat"- :incomes="type === 1"- :expenses="type === 0"- :categoryId="categoryId")-</template>--<style lang="stylus" scoped>-@import "~assets/stylus/variables/margins"-@import "~assets/stylus/variables/fonts"-@import "~assets/stylus/variables/media"-@import "~assets/stylus/variables/scroll"--.statItemChild- border-bottom 1px solid var(--c-bg-5)- &:last-child- border 0-- &__content- display grid- grid-template-columns minmax(10px, max-content) 1fr minmax(10px, max-content)- grid-template-rows repeat(2, minmax(10px, max-content))- grid-column-gap 20px- padding 10px 10px-- &__graph- overflow hidden- grid-column 2 / -1- grid-row 2 / -1- align-self center- margin-top 6px- background var(--c-bg-6)- border-radius 2px-- &__in- height 4px- min-width 2px-- &__name- overflow hidden- align-self center- color var(--c-font-4)- font-size 16px- white-space nowrap- text-overflow ellipsis-- &__icon- display flex- justify-content center- width 32px- grid-column 1 / 2- grid-row 1 / -1-- &__amount- align-self center-</style>diff --git a/components/stat/StatMobile.vue b/components/stat/StatMobile.vueindex a8f94aea..67079552 100644--- a/components/stat/StatMobile.vue+++ b/components/stat/StatMobile.vue@@ -1,5 +1,13 @@<script>export default {+ name: 'StatMobile',++ data () {+ return {+ view: 'expenses'+ }+ },+computed: {activeTabStat () {return this.$store.state.ui.stat.activeTab@@ -9,12 +17,6 @@ export default {return this.$store.getters['stat/statCurrentPeriod']},- isEmptyData () {- return this.statCurrentPeriod.incomes.categoriesIds.length === 0 &&- this.statCurrentPeriod.expenses.categoriesIds.length === 0 &&- this.$store.getters['trns/selectedTrnsIdsWithDate'].length === 0- },-filterCategory () {return this.$store.state.categories.items[this.$store.state.filter.categoryId]},@@ -47,212 +49,164 @@ export default {<template lang="pug">.stat+ //- Filter+ //---------------------------------------------------------------------------.stat__filter.swiper-no-swiping(v-if="$store.state.filter.categoryId || $store.state.filter.walletId")+ //- Wallettemplate(v-if="$store.state.filter.walletId")FilterItem(:color="filterWallet.color || $store.state.ui.defaultBgColor":name="filterWallet.name"icon="mdi mdi-credit-card-multiple"- @onClick="clearWalletFilter")+ @onClick="clearWalletFilter"+ )+ //- Categorytemplate(v-if="$store.state.filter.categoryId")+ //- Parenttemplate(v-if="filterCategory.parentId !== 0")FilterItem(:color="filterCategoryParent.color || $store.state.ui.defaultBgColor":icon="filterCategoryParent.icon":name="filterCategoryParent.name"- @onClick="clearParentCategoryFilter")+ @onClick="clearParentCategoryFilter"+ )+ //- ChildFilterItem(:color="filterCategory.color || $store.state.ui.defaultBgColor":icon="filterCategory.icon":name="filterCategory.name"- @onClick="clearCategoryFilter")+ @onClick="clearCategoryFilter"+ )++ //- Header+ //---------------------------------------------------------------------------+ .stat__header(:class="{ _withFilter: ($store.state.filter.categoryId || $store.state.filter.walletId) }")+ .statItem-header(+ :class="{ _active: activeTabStat === 'incomes' }"+ @click="$store.dispatch('ui/setActiveTabStat', 'incomes')"+ )+ .statItem-total+ .statItem-total__title {{ $t('money.incomes') }}+ .statItem-total__amount+ Amount(+ :currency="$store.state.currencies.base"+ :type="1"+ :value="statCurrentPeriod.incomes.total"+ size="md"+ )- .block- StatSummaryMobile+ .statItem-header(+ :class="{ _active: activeTabStat === 'expenses' }"+ @click="$store.dispatch('ui/setActiveTabStat', 'expenses')"+ )+ .statItem-total+ .statItem-total__title {{ $t('money.expenses') }}+ .statItem-total__amount+ Amount(+ :currency="$store.state.currencies.base"+ :type="0"+ :value="statCurrentPeriod.expenses.total"+ size="md"+ )- template(v-if="!$store.getters['trns/hasTrns']")- .startSomething- .options__item(v-if="$store.getters['wallets/hasWallets'] && $store.getters['categories/hasCategories']")- Button._grey._center(- :title="$t('createTrn')"- @onClick="$store.dispatch('trnForm/openTrnForm', { action: 'create' })"+ .statItem-header(+ :class="{ _active: activeTabStat === 'history' }"+ @click="$store.dispatch('ui/setActiveTabStat', 'history')"+ )+ .statItem-total+ .statItem-total__title {{ $t('trns.shortTitle') }}+ .statItem-total__amount+ Amount(+ :currency="$store.state.currencies.base"+ :type="3"+ :value="statCurrentPeriod.incomes.total - statCurrentPeriod.expenses.total"+ size="md")- .options__item(v-if="$store.state.demo.hasDemo")- Button._blue._center(- size="xl"- :title="$t('welcome.demo.btn')"- @onClick="$router.push('/welcome')"+ //- Content+ //---------------------------------------------------------------------------+ .stat__content+ //- Incomes+ //-------------------------------------------------------------------------+ .statGroup(v-show="activeTabStat === 'incomes'")+ EmptyData(+ v-if="$store.getters['trns/hasTrns'] && statCurrentPeriod.incomes.categoriesIds.length === 0"+ :text="$t('stat.empty')"+ )++ //- Categories charts+ .stat__charts(v-show="$store.state.ui.catsChart === 'visible'")+ PeriodCatsChart(type="incomes")++ //- Categories list+ .stat__cats(v-show="$store.state.ui.statItems === 'visible'")+ StatItem(+ v-for="categoryId in statCurrentPeriod.incomes.categoriesIds"+ :biggest="statCurrentPeriod.incomes.biggest"+ :category="$store.state.categories.items[categoryId]"+ :categoryId="categoryId"+ :currency="$store.state.currencies.base"+ :key="categoryId"+ :total="statCurrentPeriod.categories[categoryId].incomes"+ :type="1")- //- empty- //------------------------------------------------- EmptyData(- v-if="isEmptyData && $store.getters['trns/hasTrns']"- :text="$t('stat.empty')"- )+ //- Expenses+ //-------------------------------------------------------------------------+ .statGroup(v-show="activeTabStat === 'expenses'")+ EmptyData(+ v-if="$store.getters['trns/hasTrns'] && statCurrentPeriod.expenses.categoriesIds.length === 0"+ :text="$t('stat.empty')"+ )++ //- Categories charts+ .stat__charts(v-show="$store.state.ui.catsChart === 'visible'")+ PeriodCatsChart(type="expenses")++ //- Categories list+ .stat__cats(v-show="$store.state.ui.statItems === 'visible'")+ StatItem(+ v-for="categoryId in statCurrentPeriod.expenses.categoriesIds"+ :biggest="statCurrentPeriod.expenses.biggest"+ :category="$store.state.categories.items[categoryId]"+ :categoryId="categoryId"+ :currency="$store.state.currencies.base"+ :key="categoryId"+ :total="statCurrentPeriod.categories[categoryId].expenses"+ :type="0"+ )- //- history- //------------------------------------------------- div(v-if="activeTabStat === 'history'")- TrnsList+ //- History+ //-------------------------------------------------------------------------+ .statGroup(v-show="activeTabStat === 'history'")+ EmptyData(+ v-if="$store.getters['trns/hasTrns'] && $store.getters['trns/selectedTrnsIdsWithDate'].length === 0"+ :text="$t('stat.empty')"+ )- div(v-if="activeTabStat === 'incomes'")- .stat__content- //- incomes- .statGroup(v-if="statCurrentPeriod.incomes.categoriesIds.length")- .statItem-header- .statItem-total- .statItem-total__title._incomes {{ $t('money.incomes') }}- .statItem-total__amount- Amount(- :currency="$store.state.currencies.base"- :type="1"- :value="statCurrentPeriod.incomes.total")- .statItem-average(v-if="$store.state.stat.showedPeriods > 1")- .statItem-average__title- .statItem-average__title-icon: .mdi.mdi-chart-timeline- .statItem-average__title-text {{ $t('money.average') }}- .statItem-average__amount- Amount(- :currency="$store.state.currencies.base"- :small="true"- :value="$store.getters['stat/statAverage'].incomes")-- //- incomes: cats charts- .stat__charts(v-show="$store.state.ui.catsChart === 'visible'")- PeriodCatsChart(type="incomes")-- //- incomes: cats stat item- .stat__cats(v-show="$store.state.ui.statItems === 'visible'")- StatItem(- v-for="categoryId in statCurrentPeriod.incomes.categoriesIds"- :biggest="statCurrentPeriod.incomes.biggest"- :category="$store.state.categories.items[categoryId]"- :categoryId="categoryId"- :currency="$store.state.currencies.base"- :key="categoryId"- :type="1"- :total="statCurrentPeriod.categories[categoryId].incomes")-- div(v-if="activeTabStat === 'expenses'")- .stat__content- .statGroup(v-if="statCurrentPeriod.expenses.categoriesIds.length")- .statItem-header- .statItem-total- .statItem-total__title._expenses {{ $t('money.expenses') }}- .statItem-total__amount- Amount(- :currency="$store.state.currencies.base"- :type="0"- :value="statCurrentPeriod.expenses.total")- .statItem-average(v-if="$store.state.stat.showedPeriods > 1")- .statItem-average__title- .statItem-average__title-icon: .mdi.mdi-chart-timeline- .statItem-average__title-text {{ $t('money.average') }}- .statItem-average__amount- Amount(- :currency="$store.state.currencies.base"- :small="true"- :value="$store.getters['stat/statAverage'].expenses"- )- //- expenses: cats charts- .stat__charts(v-show="$store.state.ui.catsChart === 'visible'")- PeriodCatsChart(type="expenses")-- //- expenses: cats stat item- .stat__cats(v-show="$store.state.ui.statItems === 'visible'")- StatItem(- v-for="categoryId in statCurrentPeriod.expenses.categoriesIds"- :biggest="statCurrentPeriod.expenses.biggest"- :category="$store.state.categories.items[categoryId]"- :categoryId="categoryId"- :currency="$store.state.currencies.base"- :key="categoryId"- :type="0"- :total="statCurrentPeriod.categories[categoryId].expenses")-- //- stat- //------------------------------------------------- div(v-show="activeTabStat === 'stat'")- .stat__content- //- incomes- .statGroup(v-if="statCurrentPeriod.incomes.categoriesIds.length")- .statItem-header- .statItem-total- .statItem-total__title._incomes {{ $t('money.incomes') }}- .statItem-total__amount- Amount(- :currency="$store.state.currencies.base"- :type="1"- :value="statCurrentPeriod.incomes.total")- .statItem-average(v-if="$store.state.stat.showedPeriods > 1")- .statItem-average__title- .statItem-average__title-icon: .mdi.mdi-chart-timeline- .statItem-average__title-text {{ $t('money.average') }}- .statItem-average__amount- Amount(- :currency="$store.state.currencies.base"- :small="true"- :value="$store.getters['stat/statAverage'].incomes")- //- incomes: cats charts- .stat__charts(v-show="$store.state.ui.catsChart === 'visible'")- PeriodCatsChart(type="incomes")-- //- incomes: cats stat item- .stat__cats(v-show="$store.state.ui.statItems === 'visible'")- StatItem(- v-for="categoryId in statCurrentPeriod.incomes.categoriesIds"- :biggest="statCurrentPeriod.incomes.biggest"- :category="$store.state.categories.items[categoryId]"- :categoryId="categoryId"- :currency="$store.state.currencies.base"- :key="categoryId"- :type="1"- :total="statCurrentPeriod.categories[categoryId].incomes")-- //- expenses- .statGroup(v-if="statCurrentPeriod.expenses.categoriesIds.length")- .statItem-header- .statItem-total- .statItem-total__title._expenses {{ $t('money.expenses') }}- .statItem-total__amount- Amount(- :currency="$store.state.currencies.base"- :type="0"- :value="statCurrentPeriod.expenses.total")- .statItem-average(v-if="$store.state.stat.showedPeriods > 1")- .statItem-average__title- .statItem-average__title-icon: .mdi.mdi-chart-timeline- .statItem-average__title-text {{ $t('money.average') }}- .statItem-average__amount- Amount(- :currency="$store.state.currencies.base"- :small="true"- :value="$store.getters['stat/statAverage'].expenses"- )- //- expenses: cats charts- .stat__charts(v-show="$store.state.ui.catsChart === 'visible'")- PeriodCatsChart(type="expenses")-- //- expenses: cats stat item- .stat__cats(v-show="$store.state.ui.statItems === 'visible'")- StatItem(- v-for="categoryId in statCurrentPeriod.expenses.categoriesIds"- :biggest="statCurrentPeriod.expenses.biggest"- :category="$store.state.categories.items[categoryId]"- :categoryId="categoryId"- :currency="$store.state.currencies.base"- :key="categoryId"- :type="0"- :total="statCurrentPeriod.categories[categoryId].expenses"- )-- .customize- StatCustomizeMenuMobile+ TrnsList</template>+<style lang="stylus">+.stat+ .cats-chart__items+ padding-right 8px+ padding-left 8px++ .trnsList+ .trnsList__grid+ padding 0++ .trnsList__day+ margin-top 0++ &:last-child+ margin-bottom 0+ padding-bottom 0+ border-bottom 0+</style>+<style lang="stylus" scoped>@import "~assets/stylus/variables/margins"@import "~assets/stylus/variables/media"@@ -261,35 +215,38 @@ export default {@import "~assets/stylus/variables/scroll".swiper-slide- height 100%overflow hiddenoverflow-y auto--.customize- display none-- @media $media-phone-sm- display block- padding 0 $m7- padding-bottom $m9- margin-top $m9+ height 100%.statposition relative+ margin 0 -8px&__filter- display flex- overflow hiddenoverflow auto- padding 16px 16px- padding-right 0- background var(--c-bg-4)+ z-index 10+ opacity .95+ position sticky+ top 34px+ display flex+ padding-top 16px+ background var(--c-bg-2)scrollbar()- &:after- display block- content ""- width 1px- flex 0 0 16px++ &__header+ z-index 10+ opacity .95+ position sticky+ top 50px+ display flex+ align-items center+ justify-content space-between+ margin-top $m5+ background var(--c-bg-2)++ &._withFilter+ top 86px&__chartspadding-bottom $m7@@ -306,27 +263,33 @@ export default {padding-bottom 20px.statGroup- padding-top $m9- padding-bottom 10px-- & + &- border-top 1px solid var(--c-bg-6)+ padding-top $m7.statItem-header- padding-bottom $m8+ flex-grow 1+ padding $m3+ padding-top $m6+ padding-bottom $m6+ border-bottom 2px solid transparent- &:last-child- padding-bottom 0+ &._active+ opacity 1+ border-bottom 2px solid var(--c-bg-9).statItem-total- padding 0 $m7display flexalign-items center+ flex-flow columnflex-grow 1+ padding 0 $m2++ &__amount+ padding-top $m5&__titleflex-grow 1- font-header-4()+ font-size 12px+ color var(--c-font-3)&._incomescolor var(--c-incomes-1)@@ -334,36 +297,7 @@ export default {&._expensescolor var(--c-expenses-1)-.statItem-average- display flex- align-items center- padding 0 $m7- padding-top $m5-- &__title- flex-grow 1- display flex- align-items center- color var(--c-font-4)-- &-icon- opacity .8- margin-right $m6-- &__amount- opacity .6-.statItem&__trnspadding-bottom $m8--.startSomething- padding 100px 20px- display flex- flex-flow column- align-items center- justify-content center-- .options__item- margin-bottom 40px</style>diff --git a/components/stat/StatMobile2.vue b/components/stat/StatMobile2.vuedeleted file mode 100644index 4ee4f954..00000000--- a/components/stat/StatMobile2.vue+++ /dev/null@@ -1,295 +0,0 @@-<script>-export default {- data () {- return {- view: 'expenses'- }- },-- computed: {- activeTabStat () {- return this.$store.state.ui.stat.activeTab- },-- statCurrentPeriod () {- return this.$store.getters['stat/statCurrentPeriod']- },-- isEmptyData () {- return this.statCurrentPeriod.incomes.categoriesIds.length === 0 &&- this.statCurrentPeriod.expenses.categoriesIds.length === 0 &&- this.$store.getters['trns/selectedTrnsIdsWithDate'].length === 0- },-- filterCategory () {- return this.$store.state.categories.items[this.$store.state.filter.categoryId]- },-- filterCategoryParent () {- return this.$store.state.categories.items[this.filterCategory.parentId]- },-- filterWallet () {- return this.$store.state.wallets.items[this.$store.state.filter.walletId]- },-- isShowIncomes () {- return this.view === 'incomes' && this.statCurrentPeriod.incomes.categoriesIds.length- },-- isShowExpenses () {- return this.view === 'expenses' && this.statCurrentPeriod.expenses.categoriesIds.length- },-- isShowHistory () {- return this.view === 'trns'- }- },-- methods: {- clearCategoryFilter () {- const nextCategory = this.filterCategory.parentId !== 0 ? this.filterCategory.parentId : null- this.$store.dispatch('filter/setFilterCategoryId', nextCategory)- },-- clearParentCategoryFilter () {- this.$store.dispatch('filter/setFilterCategoryId', null)- },-- clearWalletFilter () {- this.$store.dispatch('filter/setFilterWalletId', null)- }- }-}-</script>--<template lang="pug">-.stat- .stat__filter.swiper-no-swiping(v-if="$store.state.filter.categoryId || $store.state.filter.walletId")- template(v-if="$store.state.filter.walletId")- FilterItem(- :color="filterWallet.color || $store.state.ui.defaultBgColor"- :name="filterWallet.name"- icon="mdi mdi-credit-card-multiple"- @onClick="clearWalletFilter")-- template(v-if="$store.state.filter.categoryId")- template(v-if="filterCategory.parentId !== 0")- FilterItem(- :color="filterCategoryParent.color || $store.state.ui.defaultBgColor"- :icon="filterCategoryParent.icon"- :name="filterCategoryParent.name"- @onClick="clearParentCategoryFilter")- FilterItem(- :color="filterCategory.color || $store.state.ui.defaultBgColor"- :icon="filterCategory.icon"- :name="filterCategory.name"- @onClick="clearCategoryFilter")-- //- stat- //------------------------------------------------- .stat__view(:class="{ _withFilter: ($store.state.filter.categoryId || $store.state.filter.walletId) }")- .statItem-header(- :class="{ _active: view === 'incomes' }"- @click="view = 'incomes'"- )- .statItem-total- .statItem-total__title {{ $t('money.incomes') }}- .statItem-total__amount- Amount(- size="md"- :currency="$store.state.currencies.base"- :type="1"- :value="statCurrentPeriod.incomes.total")-- .statItem-header(- :class="{ _active: view === 'expenses' }"- @click="view = 'expenses'"- )- .statItem-total- .statItem-total__title {{ $t('money.expenses') }}- .statItem-total__amount- Amount(- size="md"- :currency="$store.state.currencies.base"- :type="0"- :value="statCurrentPeriod.expenses.total")-- .statItem-header(- :class="{ _active: view === 'trns' }"- @click="view = 'trns'"- )- .statItem-total- .statItem-total__title {{ $t('trns.shortTitle') }}- .statItem-total__amount- Amount(- size="md"- :currency="$store.state.currencies.base"- :type="3"- :value="statCurrentPeriod.incomes.total - statCurrentPeriod.expenses.total"- )-- //-- .stat__content- //- incomes- .statGroup(v-show="isShowIncomes")- //- incomes: cats charts- .stat__charts(v-show="$store.state.ui.catsChart === 'visible'")- PeriodCatsChart(type="incomes")-- //- incomes: cats stat item- .stat__cats(v-show="$store.state.ui.statItems === 'visible'")- StatItem(- v-for="categoryId in statCurrentPeriod.incomes.categoriesIds"- :biggest="statCurrentPeriod.incomes.biggest"- :category="$store.state.categories.items[categoryId]"- :categoryId="categoryId"- :currency="$store.state.currencies.base"- :key="categoryId"- :type="1"- :total="statCurrentPeriod.categories[categoryId].incomes")-- //- expenses- .statGroup(v-show="isShowExpenses")- //- expenses: cats charts- .stat__charts(v-show="$store.state.ui.catsChart === 'visible'")- PeriodCatsChart(type="expenses")-- //- expenses: cats stat item- .stat__cats(v-show="$store.state.ui.statItems === 'visible'")- StatItem(- v-for="categoryId in statCurrentPeriod.expenses.categoriesIds"- :biggest="statCurrentPeriod.expenses.biggest"- :category="$store.state.categories.items[categoryId]"- :categoryId="categoryId"- :currency="$store.state.currencies.base"- :key="categoryId"- :type="0"- :total="statCurrentPeriod.categories[categoryId].expenses"- )-- //- expenses- .statGroup(v-show="isShowHistory")- TrnsList-- //- empty- //------------------------------------------------- EmptyData(- v-if="isEmptyData && $store.getters['trns/hasTrns']"- :text="$t('stat.empty')"- )-</template>--<style lang="stylus">-.stat- .cats-chart__items- padding-right 8px- padding-left 8px-- .trnsList- .trnsList__grid- padding 0-- .trnsList__day- margin-top 0-- &:last-child- margin-bottom 0- padding-bottom 0- border-bottom 0-</style>--<style lang="stylus" scoped>-@import "~assets/stylus/variables/margins"-@import "~assets/stylus/variables/media"-@import "~assets/stylus/variables/flex"-@import "~assets/stylus/variables/fonts"-@import "~assets/stylus/variables/scroll"--.swiper-slide- overflow hidden- overflow-y auto- height 100%--.stat- position relative- margin 0 -8px-- &__filter- overflow auto- z-index 10- opacity .95- position sticky- top 34px- display flex- padding-top 16px- background var(--c-bg-2)- scrollbar()-- &__view- z-index 10- opacity .95- position sticky- top 50px- display flex- align-items center- justify-content space-between- margin-top $m5- background var(--c-bg-2)-- &._withFilter- top 86px-- &__charts- padding-bottom $m7- &:last-child- padding-bottom 0-- &__name- padding 0 10px- padding-bottom 10px- font-header-1()-- &__trns- padding 0 10px- padding-bottom 20px--.statGroup- padding-top $m7--.statItem-header- flex-grow 1- padding $m3- padding-top $m6- padding-bottom $m6- border-bottom 2px solid transparent-- &._active- opacity 1- border-bottom 2px solid var(--c-bg-9)--.statItem-total- display flex- align-items center- flex-flow column- flex-grow 1- padding 0 $m2-- &__amount- padding-top $m5-- &__title- flex-grow 1- font-size 12px- color var(--c-font-3)-- &._incomes- color var(--c-incomes-1)-- &._expenses- color var(--c-expenses-1)--.statItem- &__trns- padding-bottom $m8-</style>diff --git a/components/stat/StatSummaryMobile.vue b/components/stat/StatSummaryMobile.vueindex 449debb5..1bc4e267 100644--- a/components/stat/StatSummaryMobile.vue+++ b/components/stat/StatSummaryMobile.vue@@ -1,5 +1,7 @@<script>export default {+ name: 'StatSummaryMobile',+computed: {stat () {return this.$store.getters['stat/statCurrentPeriod']diff --git a/components/stat/StatSummaryMobile2.vue b/components/stat/StatSummaryMobile2.vuedeleted file mode 100644index 600657af..00000000--- a/components/stat/StatSummaryMobile2.vue+++ /dev/null@@ -1,89 +0,0 @@-<script>-export default {- name: 'StatSummaryMobile2',-- computed: {- stat () {- return this.$store.getters['stat/statCurrentPeriod']- },- statAverage () {- return this.$store.getters['stat/statAverage']- },- period () {- return this.$store.state.filter.period- }- }-}-</script>--<template lang="pug">-.summary- .summary__item._incomes(@click="$store.dispatch('ui/setActiveTabStat', 'incomes')")- template(v-if="statAverage.incomes > 0 || period === 'all'")- .summary__item__title._incomes {{ $t('money.incomes') }}- .summary__item__amount- Amount(- :center="true"- :currency="$store.state.currencies.base"- :type="1"- :value="stat.incomes.total"- )- template(v-else) .-- .summary__item._total(@click="$store.dispatch('ui/setActiveTabStat', 'stat')")- template(v-if="statAverage.total !== 0")- template(v-if="stat.incomes.total > 0 || stat.expenses.total > 0")- .summary__item__title {{ $t('money.total') }}- .summary__item__amount- Amount(- :center="true"- :currency="$store.state.currencies.base"- :value="stat.incomes.total - stat.expenses.total"- )- template(v-else) .-- .summary__item._expenses(@click="$store.dispatch('ui/setActiveTabStat', 'expenses')")- template(v-if="statAverage.expenses > 0 || period === 'all'")- .summary__item__title._expenses {{ $t('money.expenses') }}- .summary__item__amount- Amount(- :center="true"- :currency="$store.state.currencies.base"- :value="stat.expenses.total"- :type="0"- )- template(v-else) .-</template>--<style lang="stylus" scoped>-@import "~assets/stylus/variables/margins"--.summary- display flex- margin $m6- margin-bottom 0- padding $m6 0- background var(--c-bg-4)- // border-bottom 1px solid var(--c-bg-1)- border-radius $m5-- &__item- flex 1- text-align center- display flex- flex-flow column- align-items center- justify-content center-- &:first-child- align-items flex-start- padding-left $m7-- &:last-child- align-items flex-end- padding-right $m7-- &__title- padding-bottom $m5- color var(--c-font-4)-</style>diff --git a/components/SummaryRow2.vue b/components/stat/SummaryRow.vuesimilarity index 100%rename from components/SummaryRow2.vuerename to components/stat/SummaryRow.vuediff --git a/components/stat/chart/ChartMenu2.vue b/components/stat/chart/ChartMenu2.vueindex c18f2eba..4d3ffabd 100644--- a/components/stat/chart/ChartMenu2.vue+++ b/components/stat/chart/ChartMenu2.vue@@ -31,7 +31,9 @@ export default {methods: {toogleView () {- this.$store.commit('chart/toogleChartPeriodView', { periodName: this.periodName })+ if (this.periodName !== 'year') {+ this.$store.commit('chart/toogleChartPeriodView', { periodName: this.periodName })+ }},addPeriodOrGroup () {@@ -75,7 +77,10 @@ export default {): .mdi.mdi-dots-horizontaltemplate(v-if="visibleContextMenu")- .switcher__item(@click="toogleView") {{ $t('chart.view.toogle') }}+ .switcher__item(+ v-if="periodName !== 'year'"+ @click="toogleView"+ ) {{ $t('chart.view.toogle') }}.switcher__item(v-if="(periods[filterPeriod].grouped && periods[filterPeriod].showedGroups > 1) || (!periods[filterPeriod].grouped && periods[filterPeriod].showedPeriods > 1)"@click="removePeriodOrGroup"diff --git a/components/stat/chart/ChartPopup.vue b/components/stat/chart/ChartPopup.vueindex 47bf179f..bf05931d 100644--- a/components/stat/chart/ChartPopup.vue+++ b/components/stat/chart/ChartPopup.vue@@ -1,11 +1,12 @@<script>export default {+ name: 'ChartPopup'}</script><template lang="pug">.chart-popup(:style="{ left: $store.state.chart.hoveredPeriod.offset }")- SummaryRow2(+ SummaryRow(:incomesAmount="$store.state.chart.hoveredPeriod.values.incomes":expensesAmount="$store.state.chart.hoveredPeriod.values.expenses")diff --git a/locales/ru-RU.js b/locales/ru-RU.jsindex 036a46fc..11f184d3 100644--- a/locales/ru-RU.js+++ b/locales/ru-RU.js@@ -202,7 +202,7 @@ export default {stat: {shortTitle: 'Статистика',balanceTitle: 'Баланс',- empty: 'Статистики за выбранный период нетю :)',+ empty: 'Статистики по выбранным параметрам нет :)',customize: {showPeriodsChart: 'Показывать график периодов',showCategorisChart: 'Показывать график категорий',diff --git a/store/chart/index.js b/store/chart/index.jsindex 508321c9..de557d79 100644--- a/store/chart/index.js+++ b/store/chart/index.js@@ -10,26 +10,26 @@ const state = () => ({periods: {day: {groupedBy: 'month',- showedGroups: 2,+ showedGroups: 1,showedPeriods: 14,- grouped: true+ grouped: false},week: {groupedBy: 'month',- showedGroups: 5,- showedPeriods: 8,+ showedGroups: 3,+ showedPeriods: 6,grouped: true},month: {groupedBy: 'year',- showedGroups: 2,- showedPeriods: 8,- grouped: true+ showedGroups: 1,+ showedPeriods: 6,+ grouped: false},year: {groupedBy: 'year',- showedGroups: 3,- showedPeriods: 3,+ showedGroups: 2,+ showedPeriods: 2,grouped: false}}