Open source personal finance application
ui(Stat): update
ilkome640f0ea70327
diff --git a/components/stat/chart/Options.vue b/components/stat/chart/Options.vueindex b1a96132..601e6065 100644--- a/components/stat/chart/Options.vue+++ b/components/stat/chart/Options.vue@@ -1,26 +1,17 @@<script setup lang="ts">import useChart from '~/components/chart/useChart'import useFilter from '~/modules/filter/useFilter'-import useStat from '~/modules/stat/useStat'-import useUIView from '~/components/layout/useUIView'import useStatChart from '~/components/stat/useStatChart'const { $store } = useNuxtApp()const { chartState, toggleChart } = useStatChart()--const { ui, setUI } = useUIView()-function toggleView(name) {- setUI({ name, value: !ui[name] })-}--const { isEmptyStat } = useStat()const periods = computed(() => $store.state.chart.periods)const { filterPeriodNameAllReplacedToYear } = useFilter()const { isShowDataLabels, toggleChartsView } = useChart()</script><template lang="pug">-.flex-center(v-if="!isEmptyStat")+.flex-center.cursor-pointer.w-10.py-2.px-3.flex-center.rounded-md.hocus_bg-skin-item-main-hover(:class="{ 'text-skin-item-base-up': chartState.show.income }"@click="toggleChart('income')"diff --git a/components/stat/chart/Periods.vue b/components/stat/chart/Periods.vueindex ead05876..204668ea 100644--- a/components/stat/chart/Periods.vue+++ b/components/stat/chart/Periods.vue@@ -55,7 +55,7 @@ export default {.cursor-pointer.py-2.px-3.rounded-md.hocus_bg-skin-item-main-hover(v-for="periodItem in periodsNames":key="periodItem.slug"- :class="{ 'cursor-default text-skin-accent-base bg-skin-item-main-active': periodItem.slug === filterPeriodNameAllReplacedToYear }"+ :class="{ 'cursor-default text-skin-item-base-up': periodItem.slug === filterPeriodNameAllReplacedToYear }"@click="$store.dispatch('filter/setPeriod', periodItem.slug)")span.pr-1(v-if="periodItem.slug === filterPeriodNameAllReplacedToYear")diff --git a/components/stat/group/Round.vue b/components/stat/group/Round.vueindex cca760f2..30e20b7a 100644--- a/components/stat/group/Round.vue+++ b/components/stat/group/Round.vue@@ -41,7 +41,7 @@ watch(isShow, updateWidth, { immediate: true })</script><template lang="pug">-.my-6.rounded-lg.bg-skin-item-main-bg.border.dark_border-neutral-800(v-if="isShow" ref="roundRef")+.my-6.border-t.border-b.dark_border-neutral-800(v-if="isShow" ref="roundRef").items.grid.py-2(:data-type-text="`${typeText}`")LazyStatGroupRoundItem(v-if="isShow"diff --git a/components/stat/group/Vertical.vue b/components/stat/group/Vertical.vueindex ff7db9f8..7754da9d 100644--- a/components/stat/group/Vertical.vue+++ b/components/stat/group/Vertical.vue@@ -14,7 +14,7 @@ const isShow = computed(() => ui.showCatsVerticalChart && statPage.current[typeT</script><template lang="pug">-.my-6.py-1.flex.flex-col.gap-2.rounded-lg.bg-skin-item-main-bg.border.dark_border-neutral-800(+.my-6.py-1.flex.flex-col.gap-2.border-t.border-b.dark_border-neutral-800(v-if="isShow")LazyStatCatsPeriodCatsChart(diff --git a/components/stat/mobile/Menu.vue b/components/stat/mobile/Menu.vueindex 69f3eb45..f12a98cd 100644--- a/components/stat/mobile/Menu.vue+++ b/components/stat/mobile/Menu.vue@@ -1,40 +1,51 @@<script setup lang="ts">-const props = defineProps<{- slider: any-}>()+const { $store, nuxt2Context: { i18n } } = useNuxtApp()-const { $store } = useNuxtApp()-const { nuxt2Context: { i18n } } = useNuxtApp()+const activeTabStat = computed(() => $store.state.ui.activeTabStat)-function onClickStatMenu(idx) {- props.slider.slideTo(idx, 0)+function onClickStatMenu(tabName) {+ $store.dispatch('ui/setActiveTabStat', tabName)+ const page = document.querySelector('.js_scroll_page')+ const content = page?.querySelector('[data-scroll-ref="stat"') as HTMLElement | null+ const h = 78++ if (!page && !content)+ return++ if (page.scrollTop > content?.offsetTop - h)+ page.scrollTop = content.offsetTop - h}const menu = computed(() => [{idx: 0,+ id: 'details',name: i18n.t('stat.periods'),}, {idx: 1,+ id: 'expense',name: i18n.t('money.expense'),}, {idx: 2,+ id: 'income',name: i18n.t('money.income'),}, {idx: 3,+ id: 'trns',name: i18n.t('trns.shortTitle'),}, {idx: 4,+ id: 'history',name: i18n.t('trns.history'),}])</script><template lang="pug">-UiTabs2(v-if="slider")+UiTabs2UiTabsItem2(v-for="item in menu"v-if="!item.isPrivate || $store.getters['user/isDevUser']"- :key="item.name"- :isActive="slider.activeIndex === item.idx"- @click="onClickStatMenu(item.idx)"+ :key="item.id"+ :isActive="item.id === activeTabStat"+ @click="onClickStatMenu(item.id)") {{ item.name }}</template>diff --git a/components/stat/mobile/MenuSlider.vue b/components/stat/mobile/MenuSlider.vuenew file mode 100644index 00000000..69f3eb45--- /dev/null+++ b/components/stat/mobile/MenuSlider.vue@@ -0,0 +1,40 @@+<script setup lang="ts">+const props = defineProps<{+ slider: any+}>()++const { $store } = useNuxtApp()+const { nuxt2Context: { i18n } } = useNuxtApp()++function onClickStatMenu(idx) {+ props.slider.slideTo(idx, 0)+}++const menu = computed(() => [{+ idx: 0,+ name: i18n.t('stat.periods'),+}, {+ idx: 1,+ name: i18n.t('money.expense'),+}, {+ idx: 2,+ name: i18n.t('money.income'),+}, {+ idx: 3,+ name: i18n.t('trns.shortTitle'),+}, {+ idx: 4,+ name: i18n.t('trns.history'),+}])+</script>++<template lang="pug">+UiTabs2(v-if="slider")+ UiTabsItem2(+ v-for="item in menu"+ v-if="!item.isPrivate || $store.getters['user/isDevUser']"+ :key="item.name"+ :isActive="slider.activeIndex === item.idx"+ @click="onClickStatMenu(item.idx)"+ ) {{ item.name }}+</template>diff --git a/components/stat/mobile/View.vue b/components/stat/mobile/View.vueindex cd8de16d..0f15b1a4 100644--- a/components/stat/mobile/View.vue+++ b/components/stat/mobile/View.vue@@ -1,109 +1,145 @@<script setup lang="ts">-import SwiperCore from 'swiper'-import 'swiper/swiper-bundle.css'import useStat from '~/modules/stat/useStat'import useStatChart from '~/components/stat/useStatChart'import useStatPage from '~/components/stat/useStatPage'import useUIView from '~/components/layout/useUIView'import useWallets from '~/components/wallets/useWallets'-const { walletsCurrencies } = useWallets()const { $store } = useNuxtApp()const { statPage } = useStatPage()const { ui } = useUIView()-const { isEmptyStat } = useStat()--const sliderRef = ref(null)-const sliderObject = ref(null)-const chartKeyDirtyFix = ref(null)--onMounted(() => {- sliderObject.value = new SwiperCore(sliderRef.value, {- observer: true,- slidesPerView: 1,- touchStartPreventDefault: false,- autoHeight: false,- initialSlide: 1,- shortSwipes: false,- longSwipesRatio: 0.1,- longSwipesMs: 60,- })- sliderObject.value.on('slideChangeTransitionEnd', (slider) => {- if (slider.activeIndex === 0)- chartKeyDirtyFix.value = `hide${sliderObject.value.activeIndex}`- })-})+const { moneyTypes, isEmptyStat } = useStat()const { onWatch } = useStatChart()onWatch()+const isShowGroup = (type) => {+ const p1 = statPage.activeTab === 'details'+ || statPage.activeTab === 'balance'+ || (statPage.activeTab === 'income' && type === 'income')+ || (statPage.activeTab === 'expense' && type === 'expense')++ const p2 = statPage.current[type].total > 0+ || (statPage.average && statPage.average[type] !== 0)+ || $store.state.filter.period === 'all'++ return p1 && p2+}++const isShowTrns = computed(() => {+ return statPage.activeTab === 'details'+ && statPage.average?.income !== 0+ && statPage.average?.expense !== 0+ && $store.getters['trns/selectedTrnsIdsWithDate'].length > 0+})++const isShowGroupTrns = computed(() => {+ const p1 = statPage.activeTab === 'income' || statPage.activeTab === 'expense'+ const p2 = statPage.average?.sum === 0+ return (p1 || p2) && statPage.activeTab !== 'history'+})++const chartKeyDirtyFix = ref('show')onActivated(async () => {await nextTick()- chartKeyDirtyFix.value = `hide${sliderObject.value.activeIndex}`+ chartKeyDirtyFix.value = 'hide'})onDeactivated(async () => {await nextTick()- chartKeyDirtyFix.value = `show${sliderObject.value.activeIndex}`+ chartKeyDirtyFix.value = 'show'})</script><template lang="pug">-.overflow-y-auto.h-full.js_scroll_page- .fixed.top-0.left-0.w-full.z-20.backdrop-blur(- class="bg-white/70 dark_bg-dark3/70"- )- .px-0.flex.items-center.justify-between.gap-4- StatDate.grow(- wrapClasses="px-0"- dateClasses="text-base"- )+.overflow-y-auto.h-full.pb-8.js_scroll_page+ .max-w-4xl.pb-6+ .px-2.flex.items-center.justify-between.gap-4.sticky.top-0.z-20.backdrop-blur(+ class="h-[44px] bg-white/70 dark_bg-dark3/70"+ )+ StatDate.grow.cursor-pointer.py-2.px-4.text-xs.text-skin-item-base-down.rounded-md.hocus_bg-skin-item-main-hover(v-if="walletsCurrencies.length > 1"@click="$store.commit('currencies/showBaseCurrenciesModal')")| {{ $store.state.currencies.base }}- StatMobileMenu(:slider="sliderObject")+ .-mt-1+ StatChartOptions+ .px-2.border-t.border-b.dark_border-neutral-800+ LazyStatChartWrap(+ :key="chartKeyDirtyFix"+ v-if="ui.showMainChart && statPage.isHasTrns"+ )+ .pt-1+ StatChartPeriods++ .my-4.mx-2.p-3.rounded-lg.bg-skin-item-main-active(v-if="statPage.filter.isShow")+ LazyStatFilter(v-if="statPage.filter.isShow")++ .my-4.px-2.sticky.z-20.backdrop-blur(+ class="top-[44px] bg-white/70 dark_bg-dark3/70"+ )+ StatMobileMenu- .swiper-container.overflow-hidden.h-full(ref="sliderRef")- .swiper-wrapper- //- Summary- StatMobileSlide- .my-4.px-2- StatSumGroup(typeText="income")- StatSumGroup(typeText="expense")+ div(+ class="min-h-[calc(100vh-130px)]"+ data-scroll-ref="stat"+ )+ template(v-if="statPage.activeTab !== 'trns' && statPage.activeTab !== 'history'")+ .my-6.px-2(v-if="statPage.activeTab === 'details'")+ StatViewConfigStatSumTotal- .my-6.mx-2.rounded-lg.bg-skin-item-main-bg.border.dark_border-neutral-800- LazyStatChartWrap(- :key="chartKeyDirtyFix"- v-if="ui.showMainChart && statPage.isHasTrns"- )- .sm_flex.justify-between.px-2.pb-2- StatChartPeriods- StatChartOptions-- //- Expense- StatMobileSlide- .px-2- StatGroupItem(typeText="expense")- LazyStatGroupTrns(isShowExpense)+ //- Loop throw income / expense+ .mb-8.md_mb-4.px-2+ .grid.grid-cols-1.gap-y-5(class="md_grid-cols-2 md_gap-x-20")+ div(+ v-for="item in moneyTypes"+ v-show="isShowGroup(item.id)"+ :key="item.id"+ class="max-w-[420px]"+ )+ StatSumGroup(+ :typeText="item.id"+ )- //- Income- StatMobileSlide- .px-2- StatGroupItem(typeText="income")- LazyStatGroupTrns(isShowIncome)+ template(v-if="statPage.activeTab !== 'balance'")+ StatGroupEmpty(:typeText="item.id")+ StatGroupPie(:typeText="item.id")+ StatGroupVertical(:typeText="item.id")+ StatGroupRound(:typeText="item.id")+ StatGroupHorizontal(:typeText="item.id")++ template(v-if="statPage.activeTab === 'balance'")+ StatGroupBudget(:typeText="item.id")++ //- LazyStatGroupTrns(+ //- v-if="isShowGroupTrns && !isEmptyStat"+ //- :isShowExpense="statPage.activeTab === 'expense'"+ //- :isShowIncome="statPage.activeTab === 'income'"+ //- )- //- Transactions- StatMobileSlide.px-2- LazyStatTrns(v-if="!isEmptyStat")+ StatEmpty+ //- .grid.md_grid-cols-2.md_gap-x-20+ //- LazyStatTrns(v-if="isShowTrns && !isEmptyStat")++ //- Trns+ template(v-if="statPage.activeTab === 'trns'")+ .my-6.px-2+ .pb-2.text-lg.leading-none.font-nunito.font-semibold.text-skin-item-base+ | {{ $t('trns.inPeriodTitle') }}++ .grid.md_grid-cols-2.md_gap-x-20+ TrnsList(+ :size="50"+ classNames="md_grid-cols-1"+ )//- History- StatMobileSlide- .px-2+ template(v-if="statPage.activeTab === 'history'")+ .my-6.px-2StatHistory</template>diff --git a/components/stat/mobile/ViewSlider.vue b/components/stat/mobile/ViewSlider.vuenew file mode 100644index 00000000..cd8de16d--- /dev/null+++ b/components/stat/mobile/ViewSlider.vue@@ -0,0 +1,116 @@+<script setup lang="ts">+import SwiperCore from 'swiper'+import 'swiper/swiper-bundle.css'+import useStat from '~/modules/stat/useStat'+import useStatChart from '~/components/stat/useStatChart'+import useStatPage from '~/components/stat/useStatPage'+import useUIView from '~/components/layout/useUIView'+import useWallets from '~/components/wallets/useWallets'++const { walletsCurrencies } = useWallets()++const { $store } = useNuxtApp()+const { statPage } = useStatPage()+const { ui } = useUIView()+const { isEmptyStat } = useStat()++const sliderRef = ref(null)+const sliderObject = ref(null)+const chartKeyDirtyFix = ref(null)++onMounted(() => {+ sliderObject.value = new SwiperCore(sliderRef.value, {+ observer: true,+ slidesPerView: 1,+ touchStartPreventDefault: false,+ autoHeight: false,+ initialSlide: 1,+ shortSwipes: false,+ longSwipesRatio: 0.1,+ longSwipesMs: 60,+ })+ sliderObject.value.on('slideChangeTransitionEnd', (slider) => {+ if (slider.activeIndex === 0)+ chartKeyDirtyFix.value = `hide${sliderObject.value.activeIndex}`+ })+})++const { onWatch } = useStatChart()+onWatch()++onActivated(async () => {+ await nextTick()+ chartKeyDirtyFix.value = `hide${sliderObject.value.activeIndex}`+})+onDeactivated(async () => {+ await nextTick()+ chartKeyDirtyFix.value = `show${sliderObject.value.activeIndex}`+})+</script>++<template lang="pug">+.overflow-y-auto.h-full.js_scroll_page+ .fixed.top-0.left-0.w-full.z-20.backdrop-blur(+ class="bg-white/70 dark_bg-dark3/70"+ )+ .px-0.flex.items-center.justify-between.gap-4+ StatDate.grow(+ wrapClasses="px-0"+ dateClasses="text-base"+ )+ .cursor-pointer.py-2.px-4.text-xs.text-skin-item-base-down.rounded-md.hocus_bg-skin-item-main-hover(+ v-if="walletsCurrencies.length > 1"+ @click="$store.commit('currencies/showBaseCurrenciesModal')"+ )+ | {{ $store.state.currencies.base }}++ StatMobileMenu(:slider="sliderObject")++ .swiper-container.overflow-hidden.h-full(ref="sliderRef")+ .swiper-wrapper+ //- Summary+ StatMobileSlide+ .my-4.px-2+ StatSumGroup(typeText="income")+ StatSumGroup(typeText="expense")+ StatSumTotal++ .my-6.mx-2.rounded-lg.bg-skin-item-main-bg.border.dark_border-neutral-800+ LazyStatChartWrap(+ :key="chartKeyDirtyFix"+ v-if="ui.showMainChart && statPage.isHasTrns"+ )+ .sm_flex.justify-between.px-2.pb-2+ StatChartPeriods+ StatChartOptions++ //- Expense+ StatMobileSlide+ .px-2+ StatGroupItem(typeText="expense")+ LazyStatGroupTrns(isShowExpense)++ //- Income+ StatMobileSlide+ .px-2+ StatGroupItem(typeText="income")+ LazyStatGroupTrns(isShowIncome)++ //- Transactions+ StatMobileSlide+ .px-2+ LazyStatTrns(v-if="!isEmptyStat")++ //- History+ StatMobileSlide+ .px-2+ StatHistory+</template>++<style lang="stylus">+.firefoxBackdropFix+ @supports (not (-webkit-backdrop-filter: none)) and (not (backdrop-filter: none))+ background theme('colors.dark3') !important+ /.light &+ background theme('colors.white') !important+</style>diff --git a/components/ui/Header.vue b/components/ui/Header.vueindex 6a8b9d8b..f479ff47 100644--- a/components/ui/Header.vue+++ b/components/ui/Header.vue@@ -3,9 +3,11 @@</script><template lang="pug">-.flex+.flex.px-2.flex.items-center.justify-between.gap-4.sticky.top-0.z-20.backdrop-blur(+ class="bg-white/70 dark_bg-dark3/70"+)slot- .flex.gap-3.py-4.pr-3+ .flex.gap-2.py-1.pr-0slot(name="actions")</template>diff --git a/components/ui/HeaderLink.vue b/components/ui/HeaderLink.vueindex c5666d2e..283f1b5c 100644--- a/components/ui/HeaderLink.vue+++ b/components/ui/HeaderLink.vue@@ -1,5 +1,5 @@<template lang="pug">-.cursor-pointer.group.w-10.h-10.flex-center.rounded-full.bg-gray-50.dark_bg-dark5.hocus-text-white.hocus_bg-skin-accent-base(+.cursor-pointer.group.w-10.h-10.flex-center.rounded-full.hocus-text-white.hocus_bg-skin-accent-base(@click="$emit('click')")slotdiff --git a/components/ui/HeaderTitle.vue b/components/ui/HeaderTitle.vueindex fe95d10b..42a2d1fe 100644--- a/components/ui/HeaderTitle.vue+++ b/components/ui/HeaderTitle.vue@@ -3,6 +3,6 @@</script><template lang="pug">-.grow.py-6.px-3.font-nunito.text-neutral-800.dark_text-white.text-2xl.leading-none.font-semibold+.grow.py-1.px-3.font-nunito.text-neutral-800.dark_text-white.text-xl.leading-none.font-semiboldslot</template>diff --git a/components/ui/TabsItem.vue b/components/ui/TabsItem.vueindex adef7973..db5fa986 100644--- a/components/ui/TabsItem.vue+++ b/components/ui/TabsItem.vue@@ -7,7 +7,7 @@ const emit = defineEmits(['click'])</script><template lang="pug">-.cursor-pointer.max-w-xs.px-5.py-3.grow.whitespace-nowrap.hocus_bg-skin-item-main-hover(+.cursor-pointer.max-w-xs.px-5.py-2.grow.whitespace-nowrap.hocus_bg-skin-item-main-hover(:class="{ 'cursor-default text-skin-accent-base !bg-skin-item-main-active': isActive }"@click="emit('click')")diff --git a/components/wallets/page/List.vue b/components/wallets/page/List.vueindex 2de9b5ef..dbbf038c 100644--- a/components/wallets/page/List.vue+++ b/components/wallets/page/List.vue@@ -22,10 +22,10 @@ UiPageUiHeaderTitle {{ $t('wallets.name') }}template(#actions)UiHeaderLink(@click="$store.dispatch('ui/setActiveTab', 'walletsSort')")- UiIconSort.w-6.h-6.group-hover_text-white+ UiIconSort.w-5.h-5.group-hover_text-whiteUiHeaderLink(@click="$router.push('/wallets/new')")- UiIconAdd.w-6.h-6.group-hover_text-white+ UiIconAdd.w-5.h-5.group-hover_text-white.pb-6.px-3(v-if="walletsCurrencies.length > 1")WalletsCurrenciesChanger