Open source personal finance application
feat (ui): update
ilkomeae597805c996
diff --git a/components/chart/StatChartLines.vue b/components/chart/StatChartLines.vueindex 14986da7..ed2de09f 100644--- a/components/chart/StatChartLines.vue+++ b/components/chart/StatChartLines.vue@@ -62,19 +62,23 @@ export default {const chartObj = ref({})const chartCallback = (v) => { chartObj.value = v }- const onClickChart = (event) => {+ const onClickChart = async (event) => {const chart = chartObj.valueif (!chart)return- const nEvent = chart.pointer.normalize(event)- const value = chart.series[0].searchPoint(nEvent, true) || chart.series[0].searchPoint(nEvent, false) || chart.series[1].searchPoint(nEvent, true)- if (value) {- if (store.state.filter.period === 'all')- store.dispatch('filter/setPeriod', 'year')- if (value.date)- store.dispatch('filter/setDate', parseInt(value.date))- }+ const nEvent = await chart.pointer.normalize(event)+ let value = chart.series[0].searchPoint(nEvent, true) || chart.series[0].searchPoint(nEvent, false) || chart.series[1].searchPoint(nEvent, true)+ setTimeout(() => {+ value = chart.series[0].searchPoint(nEvent, true) || chart.series[0].searchPoint(nEvent, false) || chart.series[1].searchPoint(nEvent, true)++ if (value) {+ if (store.state.filter.period === 'all')+ store.dispatch('filter/setPeriod', 'year')+ if (value.date)+ store.dispatch('filter/setDate', parseInt(value.date))+ }+ }, 100)}watch(() => store.state.filter.date, async (date) => {@@ -181,6 +185,8 @@ export default {}}+ const fakeLineDate = expensesData.map(i => ({ date: i.date, y: periodsTotalIncomes / periods || periodsTotalExpenses / periodsExpenses }))+const data = {series: [{zIndex: 3,@@ -202,15 +208,26 @@ export default {marker: {lineColor: this.categoryId ? this.$store.state.categories.items[this.categoryId].color : 'var(--c-expenses-1)'}+ // Fake data to make good hover on bar chart}, {zIndex: 1,- visible: false,- type: 'areaspline',- name: this.$t('money.total'),- color: '#c1c1c1',- data: totalData,+ visible: true,+ type: 'line',+ name: '',+ color: 'transparent',+ data: fakeLineDate,marker: {- lineColor: '#c1c1c1'+ enabled: false,+ symbol: 'circle',+ radius: 0,+ lineWidth: 0,+ states: {+ hover: {+ fillColor: 'transparent',+ lineColor: 'transparent',+ lineWidth: 0+ }+ }}}],categories,@@ -238,13 +255,13 @@ export default {opacity: 0.5,color: 'var(--c-expenses-opacity)',value: data.averageExpenses,- width: '1',+ width: '2',zIndex: 1}, {opacity: 0.5,color: 'var(--c-incomes-opacity)',value: data.averageIncomes,- width: '1',+ width: '2',zIndex: 1}]},diff --git a/components/chart/MobileStatLines.vue b/components/chart/Total.vuesimilarity index 85%rename from components/chart/MobileStatLines.vuerename to components/chart/Total.vueindex 69352e5c..e3fcbae0 100644--- a/components/chart/MobileStatLines.vue+++ b/components/chart/Total.vue@@ -1,7 +1,6 @@<script>import { computed, useContext } from '@nuxtjs/composition-api'import useFilter from '~/modules/filter/useFilter'-import useStat from '~/modules/stat/useStat'export default {name: 'ChartMobileStatLines',@@ -9,10 +8,10 @@ export default {setup () {const { store } = useContext()const { filterPeriodNameAllReplacedToYear } = useFilter()- const { isEmptyStat } = useStat()const activeTabStat = computed(() => store.state.ui.activeTabStat)const periods = computed(() => store.state.chart.periods)+ const filter = computed(() => store.state.filter)const filterPeriod = computed(() => store.state.filter.period)const chartType = computed(() => {@@ -25,9 +24,9 @@ export default {})return {- isEmptyStat,activeTabStat,periods,+ filter,filterPeriod,chartType}@@ -37,16 +36,14 @@ export default {<template lang="pug">.chart- .chart__content(v-if="!isEmptyStat")+ .chart__contentLazyChartStatChartLines(- v-if="!isEmptyStat":isShowIncomes="activeTabStat === 'incomes' || activeTabStat === 'details' || activeTabStat === 'history'":isShowExpenses="activeTabStat === 'expenses' || activeTabStat === 'details' || activeTabStat === 'history'"+ :categoryId="filter.categoryId"+ :chartColor="filter.categoryId && $store.state.categories.items[filter.categoryId].color":chartType="chartType"- :disableCategoryFilter="true")-- ChartPeriods</template><style lang="stylus" scoped>diff --git a/components/date/MobileSelector.vue b/components/date/MobileSelector.vueindex 988740cc..dac67157 100644--- a/components/date/MobileSelector.vue+++ b/components/date/MobileSelector.vue@@ -61,6 +61,11 @@ export default {align-items centerjustify-content center+ +media(800px)+ align-items flex-start+ justify-content flex-start+ padding 0+.menuDotscursor pointerdisplay flexdiff --git a/components/filter/FilterRow.vue b/components/filter/FilterRow.vueindex b137a7a3..d007501c 100644--- a/components/filter/FilterRow.vue+++ b/components/filter/FilterRow.vue@@ -77,7 +77,7 @@ export default {.filterRowoverflow hidden- overflow-x scroll+ overflow-x autodisplay flexalign-items centerwidth 100%diff --git a/components/shared/contextMenu/ContextMenu.vue b/components/shared/contextMenu/ContextMenu.vueindex 85b7af7e..c3a656ba 100644--- a/components/shared/contextMenu/ContextMenu.vue+++ b/components/shared/contextMenu/ContextMenu.vue@@ -1,18 +1,8 @@<script>export default {props: {- visible: {- type: Boolean,- default: false- },- openerCircle: {- type: Boolean,- default: false- },- position: {- type: Object,- default: () => {}- }+ visible: { type: Boolean, default: false },+ position: { type: Object, default: () => {} }},computed: {@@ -27,18 +17,21 @@ export default {positionStyles () {if (this.position && this.position.left && typeof this.position.left === 'string') {return {- left: this.position.left+ left: this.position.left,+ maxWidth: `${this.$store.state.ui.width - 24}px`}}if (this.position && this.position.right && typeof this.position.right === 'string') {if (this.position.top && typeof this.position.top === 'string') {return {right: this.position.right,- top: this.position.top+ top: this.position.top,+ maxWidth: `${this.$store.state.ui.width - 24}px`}}return {- right: this.position.right+ right: this.position.right,+ maxWidth: `${this.$store.state.ui.width - 24}px`}}@@ -72,10 +65,7 @@ export default {template(v-if="$slots.opener")slot(name="opener")template(v-else)- template(v-if="openerCircle")- .d-button-cirle: .mdi.mdi-dots-horizontal- template(v-else)- .d-button._noPadding._grey: .mdi.mdi-tune+ .d-button._noPadding._grey: .mdi.mdi-tune</template><style lang="stylus" scoped>@@ -84,6 +74,7 @@ export default {.context-menuz-index 6position relative+ width 100%&__openerz-index 22@@ -96,15 +87,13 @@ export default {left 0width 100%height 100%- // anim()- // background rgba(0, 0, 0, .4)&__popupoverflow hiddenz-index 10position absolutetop 48px- min-width 200px+ min-width 360pxbackground var(--c-bg-5)border 1px solid var(--c-bg-1)border-radius $m6diff --git a/components/shared/contextMenu/ContextMenuItem.vue b/components/shared/contextMenu/ContextMenuItem.vueindex 8df05187..64b49dd4 100644--- a/components/shared/contextMenu/ContextMenuItem.vue+++ b/components/shared/contextMenu/ContextMenuItem.vue@@ -51,11 +51,11 @@ export default {cursor pointerdisplay flexalign-items center+ flex-grow 1height 44pxmargin $m4 $m4padding 0 $m6font-size 14px- white-space nowrapborder-radius $m5@media $media-laptopdiff --git a/components/stat/Dashboard.vue b/components/stat/Dashboard.vueindex 0c307397..1e9a3e0d 100644--- a/components/stat/Dashboard.vue+++ b/components/stat/Dashboard.vue@@ -111,6 +111,13 @@ export default {return stat})+ const onClickTitle = (type) => {+ if (activeTabStat.value === 'details')+ store.dispatch('ui/setActiveTabStat', type === 0 ? 'expenses' : 'incomes')+ else+ store.dispatch('ui/setActiveTabStat', 'details')+ }+return {isShowChart,@@ -133,7 +140,9 @@ export default {statToday,statWithLastPeriods,- isEmptyStat+ isEmptyStat,++ onClickTitle}}}@@ -141,80 +150,111 @@ export default {<template lang="pug">.pageWrapScroll- .baseBox._chart(v-if="ui.showMainChart && isShowChart")- LazyChartMobileStatLines(v-if="ui.showMainChart && isShowChart")+ .baseBox._date+ ChartPeriods.baseBox._dateDateMobilePrevNextArrow- DateMobileSelector- LayoutMobileStatMenu+ DateMobileSelector+ StatDashboardMenu.baseBox._filter(v-if="isShowFilter")LazyFilterRow(v-if="isShowFilter")- .noStat(v-if="isEmptyStat")- .noStat__title {{ $t('stat.empty') }}- .noStat__desc {{ $t('stat.emptyDesc') }}-- template(v-if="activeTabStat !== 'history'")+ template//- Total- template(v-if="activeTabStat === 'details' && statAverage.incomes !== 0 && statAverage.expenses !== 0 && $store.state.filter.period !== 'all'")- .baseBox._total- .baseBox__title {{ $t('money.total') }}- .boxSummary2- .boxSummary2__item- Amount(- :currency="$store.state.currencies.base"- :type="(statCurrentPeriod.incomes.total - statCurrentPeriod.expenses.total) > 0 ? 1 : 0"- :value="statCurrentPeriod.incomes.total - statCurrentPeriod.expenses.total"- size="xl"- vertical="left"- )- StatSummaryRowItemView(- :type="(statAverage.incomes - statAverage.expenses) > 0 ? 1 : 0"- :amount="statAverage.incomes - statAverage.expenses"- :title="$t('money.averageTotal')"- )+ .baseBox._total+ .baseBoxIn+ template(v-if="(activeTabStat === 'details' || activeTabStat === 'history') && $store.state.filter.period !== 'all'")+ div+ .baseBox__title {{ $t('money.total') }}+ .boxSummary2+ .boxSummary2__item+ Amount(+ :currency="$store.state.currencies.base"+ :type="(statCurrentPeriod.incomes.total - statCurrentPeriod.expenses.total) > 0 ? 1 : 0"+ :value="statCurrentPeriod.incomes.total - statCurrentPeriod.expenses.total"+ size="xl"+ vertical="left"+ )+ StatSummaryRowItemView(+ :type="(statAverage.incomes - statAverage.expenses) > 0 ? 1 : 0"+ :amount="statAverage.incomes - statAverage.expenses"+ :title="$t('money.averageTotal')"+ )- //- Loop throw incomes / expenses- .statMoneyTypes- template(- v-for="item in moneyTypes"- v-if="activeTabStat === 'details' || (activeTabStat === 'incomes' && item.id === 'incomes') || (activeTabStat === 'expenses' && item.id === 'expenses')"- )- template(v-if="statCurrentPeriod[item.id].total > 0 || (statAverage && statAverage[item.id] !== 0) || $store.state.filter.period === 'all'")- .baseBox._noBdMedia._mw- .baseBox__title {{ $t(`money.${item.id}`) }}+ template(v-if="activeTabStat === 'incomes' || activeTabStat === 'expenses'")+ .sumBox(@click="onClickTitle()")+ .baseBox__title {{ $t(`money.${activeTabStat}`) }}.boxSummary2.boxSummary2__itemAmount(:currency="$store.state.currencies.base"- :type="item.type"- :value="statCurrentPeriod[item.id].total"+ :type="activeTabStat === 'incomes' ? 1 : 0"+ :value="statCurrentPeriod[activeTabStat].total"size="xl"vertical="left")StatSummaryRowItemView(- :type="item.type"- :amount="statAverage[item.id]"- :title="$t(`money.average.${item.id}`)"+ :type="activeTabStat === 'incomes' ? 1 : 0"+ :amount="statAverage[activeTabStat]"+ :title="$t(`money.average.${activeTabStat}`)")StatSummaryRowItemView(- v-if="statToday && statToday[item.id].total !== 0 && $store.state.filter.period !== 'day'"- :type="item.type"- :amount="statToday[item.id].total"+ v-if="statToday && statToday[activeTabStat].total !== 0 && $store.state.filter.period !== 'day'"+ :type="activeTabStat === 'incomes' ? 1 : 0"+ :amount="statToday[activeTabStat].total":title="$t('dates.day.today')")+ div+ .baseBox._chart(v-if="ui.showMainChart && isShowChart")+ LazyChartTotal(v-if="ui.showMainChart && isShowChart")- .statChartLines(v-if="filter.categoryId")- LazyChartStatChartLines(- v-if="filter.categoryId && $store.getters['trns/hasTrns']"- :categoryId="filter.categoryId"- :chartColor="$store.state.categories.items[filter.categoryId].color"- :isShowExpenses="item.type === 0"- :isShowIncomes="item.type === 1"- )+ .noStat(v-if="isEmptyStat")+ .noStat__title {{ $t('stat.empty') }}+ .noStat__desc {{ $t('stat.emptyDesc') }}++ //- Loop throw incomes / expenses+ .statMoneyTypes+ template(+ v-for="item in moneyTypes"+ v-if="activeTabStat === 'details' || (activeTabStat === 'incomes' && item.id === 'incomes') || (activeTabStat === 'expenses' && item.id === 'expenses')"+ )+ template(v-if="statCurrentPeriod[item.id].total > 0 || (statAverage && statAverage[item.id] !== 0) || $store.state.filter.period === 'all'")+ .baseBox._noBdMedia._mw+ template(v-if="activeTabStat === 'details' && (statAverage.incomes !== 0 && statAverage.expenses !== 0)")+ .sumBox(@click="onClickTitle(item.type)")+ .baseBox__title {{ $t(`money.${item.id}`) }}+ .boxSummary2+ .boxSummary2__item+ Amount(+ :currency="$store.state.currencies.base"+ :type="item.type"+ :value="statCurrentPeriod[item.id].total"+ size="xl"+ vertical="left"+ )+ StatSummaryRowItemView(+ :type="item.type"+ :amount="statAverage[item.id]"+ :title="$t(`money.average.${item.id}`)"+ )+ StatSummaryRowItemView(+ v-if="statToday && statToday[item.id].total !== 0 && $store.state.filter.period !== 'day'"+ :type="item.type"+ :amount="statToday[item.id].total"+ :title="$t('dates.day.today')"+ )++ .statChartLines(v-if="filter.categoryId")+ LazyChartStatChartLines(+ v-if="filter.categoryId && $store.getters['trns/hasTrns']"+ :categoryId="filter.categoryId"+ :chartColor="$store.state.categories.items[filter.categoryId].color"+ :isShowExpenses="item.type === 0"+ :isShowIncomes="item.type === 1"+ ).boxEmpty(v-if="statCurrentPeriod[item.id].categoriesIds.length === 0") {{ $t('stat.empty') }}@@ -227,7 +267,7 @@ export default {//- Cats vertical chartStatCatsPeriodCatsChart(- v-if="ui.showCatsVerticalChart && !filter.categoryId && $store.state.ui.catsChart === 'visible' && statCurrentPeriod[item.id].categoriesIds.length > 1 && (!filter.categoryId || filter.categoryId && $store.getters['categories/getChildCategoriesIds'](filter.categoryId).length !== 0)"+ v-if="ui.showCatsVerticalChart && !filter.categoryId && statCurrentPeriod[item.id].categoriesIds.length > 1 && (!filter.categoryId || filter.categoryId && $store.getters['categories/getChildCategoriesIds'](filter.categoryId).length !== 0)":type="item.id")@@ -308,9 +348,9 @@ export default {.trnsList__daypadding-bottom 0- &:first-child- margin-top 0- padding-top $m5+ // &:first-child+ // margin-top 0+ // padding-top $m5.trnItem._historymargin 0@@ -321,6 +361,10 @@ export default {<style lang="stylus" scoped>@import '~assets/stylus/variables'+.sumBox+ cursor pointer+ display inline-block+.noStatoverflow hiddenpadding $m10 $m7@@ -342,6 +386,9 @@ export default {scrollbar()height 100%+ +media(800px)+ padding-right 40px+// ------------------------------------.statMoneyTypesalign-items start@@ -422,13 +469,13 @@ export default {overflow initialmargin-top 0margin-bottom 0- padding-top 0- padding-bottom 0+ padding 0+ padding-right $m7background noneborder none+media(600px)- padding-bottom $m5+ padding-right $m8&._filtermargin-top 0@@ -441,13 +488,11 @@ export default {&._totalmargin-top 0padding-top $m4+ padding-right 0background none+media(800px)- margin-top 0- margin-bottom 0- padding-top 0- padding-bottom $m6+ padding-bottom 0&__titlez-index 9@@ -484,9 +529,18 @@ export default {padding 0 $m5padding-bottom $m5+ &._alt+ +media(800px)+ display block+&__itempadding-right $m9+ &._alt+ +media(800px)+ padding-right 0+ padding-bottom $m9+// ------------------------------------.statItemsTilesdisplay griddiff --git a/components/layout/mobile/StatMenu.vue b/components/stat/DashboardMenu.vuesimilarity index 98%rename from components/layout/mobile/StatMenu.vuerename to components/stat/DashboardMenu.vueindex 24e09994..109edc7f 100644--- a/components/layout/mobile/StatMenu.vue+++ b/components/stat/DashboardMenu.vue@@ -2,7 +2,7 @@import { computed, useContext } from '@nuxtjs/composition-api'export default {- name: 'LayoutMobileStatMenu',+ name: 'StatDashboardMenu',setup () {const { store } = useContext()diff --git a/components/stat/chartOptions.js b/components/stat/chartOptions.jsindex bb3f1a52..a9323ae7 100644--- a/components/stat/chartOptions.js+++ b/components/stat/chartOptions.js@@ -42,7 +42,7 @@ export default {},spline: {- lineWidth: 3,+ lineWidth: 2,states: {hover: {lineWidth: 2@@ -74,7 +74,7 @@ export default {marker: {radius: 3,fillColor: 'var(--c-bg-4)',- lineWidth: 3,+ lineWidth: 2,lineColor: 'var(--c-incomes-1)',symbol: 'circle'},diff --git a/modules/stat/useStat.ts b/modules/stat/useStat.tsindex 527f55bf..1eb9aa08 100644--- a/modules/stat/useStat.ts+++ b/modules/stat/useStat.ts@@ -10,7 +10,7 @@ const moneyTypes = [{export default function useStat () {const { store } = useContext()- const isEmptyStat = computed(() => store.getters['stat/statAverage'].total === 0 && store.getters['trns/selectedTrnsIdsWithDate'].length === 0)+ const isEmptyStat = computed(() => store.getters['stat/statAverage'].total === 0)return {moneyTypes,