Open source personal finance application
feat(Trns): improvments
ilkomedc5779091e5b
diff --git a/components/categories/page/id/Index.vue b/components/categories/page/id/Index.vueindex 43ef8e5e..595f9195 100644--- a/components/categories/page/id/Index.vue+++ b/components/categories/page/id/Index.vue@@ -16,20 +16,14 @@ if (!category.value)const trnsItems = computed(() => $store.state.trns.items)const backLink = computed(() => category.value?.parentId ? `/categories/${category.value.parentId}` : '/categories')-const filter = reactive({ trnType: null })--const categoryChildIds = computed(() => category.value.childIds?.sort((a, b) => {- if ($store.state.categories.items[a].name < $store.state.categories.items[b].name)- return -1- if ($store.state.categories.items[a].name > $store.state.categories.items[b].name)- return 1- return 0-}))+const categoryChildIds = computed(() => category.value.childIds+ ?.sort((a, b) => $store.state.categories.items[b].name - $store.state.categories.items[a].name))const trnsIds = computed(() =>getTrnsIds({- categoriesIds: category.value?.childIds?.length > 0 ? category.value?.childIds : [categoryId.value],- trnType: filter.trnType,+ categoriesIds: category.value?.childIds?.length > 0+ ? category.value?.childIds+ : [categoryId.value],trnsItems: trnsItems.value,}))@@ -96,12 +90,7 @@ UiPage(v-if="category")//- History.px-2- TrnsHistory(- :trnsIds="trnsIds"- :trnType="filter.trnType"- hideTransfers- @setFilterTrnType="value => filter.trnType = value"- )+ TrnsListWithControl(:trnsIds="trnsIds")</template><i18n lang="json5">diff --git a/components/stat/Date.vue b/components/stat/Date.vueindex 7f874108..32888366 100644--- a/components/stat/Date.vue+++ b/components/stat/Date.vue@@ -9,7 +9,7 @@ const isShowDateSelector = ref(false)<template lang="pug">.z-10.hocus_bg-skin-item-main-hover//- Date- .cursor-pointer.px-2.flex.items-center.text-lg(+ .cursor-pointer.px-3.flex.items-center.text-lg(@click="isShowDateSelector = true"class="wrapClasses")diff --git a/components/stat/History.vue b/components/stat/History.vuedeleted file mode 100644index 8688d78c..00000000--- a/components/stat/History.vue+++ /dev/null@@ -1,36 +0,0 @@-<script setup lang="ts">-import { getCategoriesIds } from '~/components/categories/getCategories'-import { getTrnsIds } from '~/components/trns/getTrns'--const { $store } = useNuxtApp()-const categoriesItems = computed(() => $store.state.categories.items)-const trnsItems = computed(() => $store.state.trns.items)-const storeFilter = computed(() => $store.state.filter)-const filterTrnType = ref(null)--const trnsIds = computed(() => {- // TODO: move it to a separate function getFilterParams- const categoriesIds = storeFilter.value.catsIds.length > 0- ? getCategoriesIds(storeFilter.value.catsIds, categoriesItems.value)- : null- const walletsIds = storeFilter.value.walletsIds.length > 0- ? storeFilter.value.walletsIds- : null-- return getTrnsIds({- categoriesIds,- walletsIds,- trnType: filterTrnType.value,- trnsItems: trnsItems.value,- })-})-</script>--<template lang="pug">-.my-4.md_max-w-none(class="max-w-[420px]")- TrnsHistory(- :trnsIds="trnsIds"- :trnType="filterTrnType"- @setFilterTrnType="value => filterTrnType = value"- )-</template>diff --git a/components/stat/Page.vue b/components/stat/Page.vueindex 136e49cf..d16e9f4d 100644--- a/components/stat/Page.vue+++ b/components/stat/Page.vue@@ -1,12 +1,5 @@<script lang="ts">-import { useWindowSize } from '@vueuse/core'export default {- setup() {- const { width } = useWindowSize()-- return { width }- },-head() {return {title: this.$t('stat.title'),@@ -18,8 +11,7 @@ export default {<template lang="pug">.overflow-hidden.h-fulltemplate(v-if="$store.getters['trns/hasTrns']")- LazyStatLaptopView(v-if="width >= 1024")- LazyStatMobileView(v-else)+ LazyStatViewLazyStatWelcomeActions(v-if="!$store.getters['trns/hasTrns']")</template>diff --git a/components/stat/View.vue b/components/stat/View.vuenew file mode 100644index 00000000..ae0853d7--- /dev/null+++ b/components/stat/View.vue@@ -0,0 +1,196 @@+<script setup lang="ts">+import { useWindowSize } from '@vueuse/core'+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 { $store } = useNuxtApp()+const { walletsCurrencies } = useWallets()+const { statPage } = useStatPage()+const { ui } = useUIView()+const { moneyTypes } = useStat()+const { width } = useWindowSize()++const isMobileView = computed(() => width.value <= 1024)++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 = $store.state.filter.period === 'all'+ return p1 || p2+}++const isShowGroupTrns = computed(() => {+ const p1 = statPage.activeTab === 'income' || statPage.activeTab === 'expense'+ const p2 = statPage.average?.sum === 0+ return (p1 || p2) && statPage.activeTab !== 'history'+})++const combinedTrnsIds = computed(() => {+ const trnsItems = $store.state.trns.items+ const trnsIds = $store.getters['trns/selectedTrnsIdsWithDate']++ return {+ all: trnsIds,+ income: trnsIds.filter(id => trnsItems[id].type === 1),+ expense: trnsIds.filter(id => trnsItems[id].type === 0),+ }+})++const chartKeyDirtyFix = ref('show')+onActivated(async () => {+ await nextTick()+ chartKeyDirtyFix.value = 'hide'+})+onDeactivated(async () => {+ await nextTick()+ chartKeyDirtyFix.value = 'show'+})+</script>++<template lang="pug">+.overflow-y-auto.h-full.pb-8.js_scroll_page+ .max-w-4xl.pb-6+ .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++ template(v-if="isMobileView")+ .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 }}++ template(v-if="!isMobileView")+ .pb-6.px-2(v-if="walletsCurrencies.length > 1")+ WalletsCurrenciesChanger++ .mx-2.mb-4.rounded-lg.bg-skin-item-main-bg.border.dark_border-neutral-800+ LazyStatChartWrap(+ v-if="ui.showMainChart"+ :key="chartKeyDirtyFix"+ )+ .sm_flex.justify-between.px-2.pb-2+ StatChartPeriods+ StatChartOptions++ template(v-if="isMobileView")+ .-mt-1+ StatChartOptions+ .px-2.border-t.border-b.dark_border-neutral-800+ LazyStatChartWrap(+ v-if="ui.showMainChart"+ :key="chartKeyDirtyFix"+ )++ .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")++ template(v-if="!isMobileView")+ .px-2.flex.flex-wrap.items-center.justify-between.gap-x-6+ StatSumTotal+ StatViewConfig++ .mb-4.px-2+ StatMenuLaptop++ template(v-if="isMobileView")+ .my-4.px-2.sticky.z-20.backdrop-blur(+ class="top-[44px] bg-white/70 dark_bg-dark3/70"+ )+ StatMenuMobile++ div(+ class="min-h-[calc(100vh-130px)]"+ data-scroll-ref="stat"+ )+ template(v-if="statPage.activeTab !== 'trns' && statPage.activeTab !== 'history'")+ template(v-if="isMobileView")+ .my-6.px-2(v-if="statPage.activeTab === 'details'")+ StatViewConfig+ StatSumTotal++ //- 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")++ 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")++ template(v-if="!isMobileView")+ div(+ v-if="statPage.activeTab === 'details' && statPage.current[item.id].total !== 0 && combinedTrnsIds[item.id].length > 0"+ )+ .my-6(class="max-w-[420px]")+ .pb-2.text-lg.leading-none.font-nunito.font-semibold.text-skin-item-base+ | {{ $t('trns.inPeriodTitle') }}++ TrnsList(+ :size="12"+ :trnsIds="combinedTrnsIds[item.id]"+ isShowFilter+ uiHistory+ )++ //- All+ template(v-if="!isMobileView")+ div(+ v-if="isShowGroupTrns && !isEmptyStat && statPage.activeTab !== 'details' && combinedTrnsIds[statPage.activeTab].length > 0"+ )+ .my-6(class="max-w-[420px]")+ .pb-2.text-lg.leading-none.font-nunito.font-semibold.text-skin-item-base+ | {{ $t('trns.inPeriodTitle') }}++ TrnsList(+ :size="12"+ :trnsIds="combinedTrnsIds[statPage.activeTab]"+ classNames="md_grid-cols-1"+ isShowFilter+ uiHistory+ )++ //- Trns+ template(v-if="statPage.activeTab === 'trns'")+ .my-4.px-2+ TrnsListWithControl(+ :trnsIds="statPage.current.trnsIds"+ defaultPeriod="period"+ )+</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/stat/chart/Wrap.vue b/components/stat/chart/Wrap.vueindex a91b73cc..0077514e 100644--- a/components/stat/chart/Wrap.vue+++ b/components/stat/chart/Wrap.vue@@ -17,7 +17,7 @@ const chartType = computed(() => {</script><template lang="pug">-.h-48(v-if="chartState.show.expense || chartState.show.income")+.h-48LazyStatChartView(:categoryId="filter.categoryId":chartType="chartType"diff --git a/components/stat/group/HorizontalItem.vue b/components/stat/group/HorizontalItem.vueindex 6193f9dc..aa0e172c 100644--- a/components/stat/group/HorizontalItem.vue+++ b/components/stat/group/HorizontalItem.vue@@ -87,6 +87,7 @@ const trnsIds = computed(() => {TrnsList(:trnsIds="trnsIds":isShowGroupDate="false"+ classNames="md_grid-cols-1"uiCat)</template>diff --git a/components/stat/group/Trns.vue b/components/stat/group/Trns.vueindex e40f1122..b9acbc27 100644--- a/components/stat/group/Trns.vue+++ b/components/stat/group/Trns.vue@@ -1,18 +1,34 @@<script setup lang="ts">-defineProps<{- isShowIncome: Boolean- isShowExpense: Boolean+const props = defineProps<{+ isShowIncome: boolean+ isShowExpense: boolean}>()++const { $store } = useNuxtApp()++const trnsIds = computed(() => {+ const trnsItems = $store.state.trns.items+ let trnsIds = $store.getters['trns/selectedTrnsIdsWithDate']++ // filter type+ if (props.isShowIncome)+ trnsIds = trnsIds.filter(id => trnsItems[id].type === 1)+ if (props.isShowExpense)+ trnsIds = trnsIds.filter(id => trnsItems[id].type === 0)++ return trnsIds+})</script><template lang="pug">.my-6(class="max-w-[420px]")- .pb-2.text-lg.leading-none.font-nunito.font-semibold.text-skin-item-base {{ $t('trns.inPeriodTitle') }}+ .pb-2.text-lg.leading-none.font-nunito.font-semibold.text-skin-item-base+ | {{ $t('trns.inPeriodTitle') }}TrnsList(- :expense="isShowExpense"- :income="isShowIncome":size="12"- classNames="md_grid-cols-1"+ :trnsIds="trnsIds"+ isShowFilter+ uiHistory)</template>diff --git a/components/stat/laptop/Menu.vue b/components/stat/laptop/Menu.vuedeleted file mode 100644index db399998..00000000--- a/components/stat/laptop/Menu.vue+++ /dev/null@@ -1,37 +0,0 @@-<script setup lang="ts">-const { $store } = useNuxtApp()-const activeTabStat = computed(() => $store.state.ui.activeTabStat)--function onClickStatMenu(tabName) {- $store.dispatch('ui/setActiveTabStat', tabName)-}-</script>--<template lang="pug">-UiTabs- UiTabsItem(- :isActive="activeTabStat === 'details'"- @click="onClickStatMenu('details')"- ) {{ $t('stat.periods') }}-- UiTabsItem(- :isActive="activeTabStat === 'expense'"- @click="onClickStatMenu('expense')"- ) {{ $t('money.expense') }}-- UiTabsItem(- :isActive="activeTabStat === 'income'"- @click="onClickStatMenu('income')"- ) {{ $t('money.income') }}-- UiTabsItem(- :isActive="activeTabStat === 'trns'"- @click="onClickStatMenu('trns')"- ) {{ $t('trns.shortTitle') }}-- UiTabsItem(- :isActive="activeTabStat === 'history'"- @click="onClickStatMenu('history')"- )- span {{ $t('trns.history') }}-</template>diff --git a/components/stat/laptop/View.vue b/components/stat/laptop/View.vuedeleted file mode 100644index c6b133a9..00000000--- a/components/stat/laptop/View.vue+++ /dev/null@@ -1,152 +0,0 @@-<script setup lang="ts">-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 { 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'-})-onDeactivated(async () => {- await nextTick()- chartKeyDirtyFix.value = 'show'-})-</script>--<template lang="pug">-.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="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 }}-- .pb-6.px-2(v-if="walletsCurrencies.length > 1")- WalletsCurrenciesChanger-- .mx-2.mb-4.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-- .my-4.mx-2.p-3.rounded-lg.bg-skin-item-main-active(v-if="statPage.filter.isShow")- LazyStatFilter(v-if="statPage.filter.isShow")-- .px-2.flex.flex-wrap.items-center.justify-between.gap-x-6- StatSumTotal- StatViewConfig-- .pb-4.px-2- StatLaptopMenu-- template(v-if="statPage.activeTab !== 'trns' && statPage.activeTab !== 'history'")- //- 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"- )-- 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="statPage.activeTab === 'details' && statPage.current[item.id].total !== 0"- :isShowExpense="item.id === 'expense'"- :isShowIncome="item.id === 'income'"- )-- LazyStatGroupTrns(- v-if="isShowGroupTrns && !isEmptyStat && statPage.activeTab !== 'details'"- :isShowExpense="statPage.activeTab === 'expense'"- :isShowIncome="statPage.activeTab === 'income'"- )-- .px-2- StatEmpty-- //- Trns- template(v-if="statPage.activeTab === 'trns'")- .my-4.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- template(v-if="statPage.activeTab === 'history'")- .my-4.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/stat/menu/Laptop.vue b/components/stat/menu/Laptop.vuenew file mode 100644index 00000000..4005c90d--- /dev/null+++ b/components/stat/menu/Laptop.vue@@ -0,0 +1,22 @@+<script setup lang="ts">+import useStatPage from '~/components/stat/useStatPage'++const { $store } = useNuxtApp()+const { menu } = useStatPage()+const activeTabStat = computed(() => $store.state.ui.activeTabStat)++function onClickStatMenu(tabName) {+ $store.dispatch('ui/setActiveTabStat', tabName)+}+</script>++<template lang="pug">+UiTabs+ UiTabsItem(+ v-for="item in menu"+ v-if="!item.isPrivate || $store.getters['user/isDevUser']"+ :key="item.id"+ :isActive="item.id === activeTabStat"+ @click="onClickStatMenu(item.id)"+ ) {{ item.name }}+</template>diff --git a/components/stat/mobile/Menu.vue b/components/stat/menu/Mobile.vuesimilarity index 64%rename from components/stat/mobile/Menu.vuerename to components/stat/menu/Mobile.vueindex f12a98cd..08ba0fd9 100644--- a/components/stat/mobile/Menu.vue+++ b/components/stat/menu/Mobile.vue@@ -1,42 +1,22 @@<script setup lang="ts">-const { $store, nuxt2Context: { i18n } } = useNuxtApp()+import useStatPage from '~/components/stat/useStatPage'+const { $store } = useNuxtApp()+const { menu } = useStatPage()const activeTabStat = computed(() => $store.state.ui.activeTabStat)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 = 78if (!page && !content)return+ const h = 78if (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">diff --git a/components/stat/mobile/View.vue b/components/stat/mobile/View.vuedeleted file mode 100644index 8ae69448..00000000--- a/components/stat/mobile/View.vue+++ /dev/null@@ -1,133 +0,0 @@-<script setup lang="ts">-import useStat from '~/modules/stat/useStat'-import useStatChart from '~/components/stat/useStatChart'-import useStatPage from '~/components/stat/useStatPage'-import useTrns from '~/components/trns/useTrns'-import useUIView from '~/components/layout/useUIView'-import useWallets from '~/components/wallets/useWallets'--const { $store } = useNuxtApp()-const { walletsCurrencies } = useWallets()-const { statPage } = useStatPage()-const { ui } = useUIView()-const { moneyTypes } = useStat()-const { allTrnsWithFilter } = useTrns()--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 chartKeyDirtyFix = ref('show')-onActivated(async () => {- await nextTick()- chartKeyDirtyFix.value = 'hide'-})-onDeactivated(async () => {- await nextTick()- chartKeyDirtyFix.value = 'show'-})-</script>--<template lang="pug">-.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 }}-- .-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-- 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'")- StatViewConfig- StatSumTotal-- //- 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")-- 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")-- .px-2- StatEmpty-- //- 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"- :trnsIds="statPage.current.trnsIds"- classNames="md_grid-cols-1"- uiHistory- )-- //- History- template(v-if="statPage.activeTab === 'history'")- .my-4.px-2.md_max-w-none(class="max-w-[420px]")- TrnsListWithControl(:trnsIds="allTrnsWithFilter")-</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/stat/useStatChart.ts b/components/stat/useStatChart.tsindex 6a008398..0b7e17f5 100644--- a/components/stat/useStatChart.ts+++ b/components/stat/useStatChart.ts@@ -34,6 +34,10 @@ export default function useStatChart() {setChart('income', true)setChart('expense', true)break+ case 'trns':+ setChart('income', true)+ setChart('expense', true)+ break}})}diff --git a/components/stat/useStatPage.ts b/components/stat/useStatPage.tsindex e3e0e34a..79b6d22e 100644--- a/components/stat/useStatPage.ts+++ b/components/stat/useStatPage.ts@@ -1,5 +1,5 @@export default function useStatPage() {- const { $store } = useNuxtApp()+ const { $store, nuxt2Context: { i18n } } = useNuxtApp()const activeTabStat = computed(() => $store.state.ui.activeTabStat)const statCurrentPeriod = computed(() => $store.getters['stat/statCurrentPeriod'])@@ -10,6 +10,28 @@ export default function useStatPage() {const isShowFilter = computed(() => $store.state.filter.catsIds.length > 0 || $store.state.filter.walletsIds.length > 0)const isHasTrns = computed(() => $store.getters['trns/hasTrns'])+ 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'),+ }])+return {statPage: reactive({activeTab: activeTabStat,@@ -25,5 +47,7 @@ export default function useStatPage() {isHasTrns,}),++ menu,}}diff --git a/components/trnForm/TrnsSlide.vue b/components/trnForm/TrnsSlide.vuenew file mode 100644index 00000000..1a9cb27b--- /dev/null+++ b/components/trnForm/TrnsSlide.vue@@ -0,0 +1,118 @@+<script setup lang="ts">+import { getTrnsIds } from '~/components/trns/getTrns'++const props = defineProps<{+ slider: object+}>()+const emit = defineEmits(['onClickEdit'])++const { $store } = useNuxtApp()++const filterBy = ref('wallet')++const filteredTrnsIds = computed(() => {+ const trnsItems = $store.state.trns.items++ const filter = {+ walletsIds: null,+ categoriesIds: null,+ }++ if (filterBy.value === 'wallet') {+ filter.walletsIds = [$store.state.trnForm.values.walletId]+ }+ else if (filterBy.value === 'walletAndCategory') {+ const catId = $store.state.trnForm.values.categoryId+ const category = $store.state.categories.items[catId]++ filter.walletsIds = [$store.state.trnForm.values.walletId]+ filter.categoriesIds = category?.childIds ?? [catId]+ }++ return getTrnsIds({ ...filter, trnsItems })+})++function changeFilter(value) {+ const trnForm = document.querySelector('.trnForm')+ const trnsListScroll = trnForm.querySelector('.trnsListScroll')+ trnsListScroll.scrollTop = 0++ filterBy.value = value+ setTimeout(() => {+ props.slider.slideTo(0, 0)+ }, 100)+}++function onClickEdit() {+ props.slider.slideTo(1)+}+</script>++<template lang="pug">+.contentWrap+ template(v-if="filteredTrnsIds.length === 0")+ .contentWrap__box.trnsListScroll.scrollerBlock+ .containerWrap No transactions++ template(v-if="filteredTrnsIds.length > 0")+ .contentWrap__box.trnsListScroll.scrollerBlock+ .scrollBlock+ .pt-5+ .subTitle.text-center.pb-1.text-xs {{ $t('trns.history') }}++ .px-3+ TrnsListWithControl(+ :trnsIds="filteredTrnsIds"+ trnsClassNames=""+ @onClickEdit="onClickEdit"+ )++ .pt-2.pb-6.px-3+ UiTabs+ UiTabsItem(+ :isActive="filterBy === 'wallet'"+ @click="changeFilter('wallet')"+ ) {{ $t('trnForm.filterWallet') }}++ UiTabsItem(+ :isActive="filterBy === 'walletAndCategory'"+ @click="changeFilter('walletAndCategory')"+ ) {{ $t('trnForm.filterWalletAndCategory') }}++ UiTabsItem(+ :isActive="filterBy === 'all'"+ @click="changeFilter('all')"+ ) {{ $t('trnForm.filterAll') }}+</template>++<style lang="stylus" scoped>+.containerWrap+ display flex+ align-items center+ justify-content center+ height 100%+ min-height 100%+ padding $m10 $m7+ color var(--c-font-3)+ font-size 26px+ font-weight 700+ text-align center+ fontFamilyNunito()++.contentWrap+ position relative+ display grid+ grid-template-rows 1fr auto+ height 100%++ &__box+ overflow hidden+ overflow-y auto+ scrollbar()++.subTitle+ color var(--c-font-4)+ letter-spacing 0+ font-weight 600+ text-transform uppercase+</style>diff --git a/components/trnForm/Types.vue b/components/trnForm/Types.vueindex 8739cd19..603d106b 100644--- a/components/trnForm/Types.vue+++ b/components/trnForm/Types.vue@@ -1,40 +1,28 @@-<script>-export default {- setup() {- const { $store } = useNuxtApp()+<script setup lang="ts">+const { $store } = useNuxtApp()+const amountType = computed(() => $store.state.trnForm.values.amountType)- const amountType = computed(() => $store.state.trnForm.values.amountType)-- function setAmountType(amountType) {- $store.commit('trnForm/setTrnFormValues', {- amountType,- })- }-- return {- amountType,- setAmountType,- }- },+function setAmountType(amountType) {+ $store.commit('trnForm/setTrnFormValues', { amountType })}</script><template lang="pug">-.px-4.pb-4.text-center- .overflow-hidden.flex.items-center.text-sm.rounded-md.bg-gray-50.dark_bg-dark4.dark_shadow- .cursor-pointer.px-5.py-3.grow.hocus_bg-gray-200.dark_hocus_bg-neutral-800(- :class="{ '_active cursor-default text-blue3 dark_text-blue1 bg-gray-100 dark_bg-232323': amountType === 0 }"- @click="() => setAmountType(0)"+.px-4.pb-4+ UiTabs+ UiTabsItem(+ :isActive="amountType === 0"+ @click="setAmountType(0)") {{ $t('money.expense') }}- .cursor-pointer.px-5.py-3.grow.hocus_bg-gray-200.dark_hocus_bg-neutral-800(- :class="{ '_active cursor-default text-blue3 dark_text-blue1 bg-gray-100 dark_bg-232323': amountType === 1 }"- @click="() => setAmountType(1)"+ UiTabsItem(+ :isActive="amountType === 1"+ @click="setAmountType(1)") {{ $t('money.income') }}- .cursor-pointer.px-5.py-3.grow.hocus_bg-gray-200.dark_hocus_bg-neutral-800(+ UiTabsItem(v-if="$store.getters['wallets/walletsSortedIds'].length > 1"- :class="{ '_active cursor-default text-blue3 dark_text-blue1 bg-gray-100 dark_bg-232323': amountType === 2 }"- @click="() => setAmountType(2)"+ :isActive="amountType === 2"+ @click="setAmountType(2)") {{ $t('trnForm.transferTitle') }}</template>diff --git a/components/trns/History.vue b/components/trns/History.vuedeleted file mode 100644index 271fcf2d..00000000--- a/components/trns/History.vue+++ /dev/null@@ -1,64 +0,0 @@-<script setup lang="ts">-import type { TrnID } from '~/components/trns/types'--type TrnType = null | 0 | 1 | 2--const props = withDefaults(defineProps<{- hideTransfers?: boolean- trnsIds: TrnID[]- trnType: TrnType-}>(), {- hideTransfers: false,-})--const emit = defineEmits(['setFilterTrnType'])--const trnsCount = computed(() => props.trnsIds.length)-const setTrnType = (value: TrnType) => emit('setFilterTrnType', value)-</script>--<template lang="pug">-div- //- Trns: Title- .pb-2.flex.gap-2.text-lg.leading-none.font-nunito.font-semibold.text-skin-item-base(class="!pb-3")- div {{ $t('trns.inPeriodTitle') }}:- div {{ trnsCount }}-- //- Trns: TypeSelector- .overflow-hidden.rounded-md.scrollbar.mb-4.bg-gray-50.dark_bg-dark4.dark_shadow- .overflow-hidden.overflow-x-auto.flex.items-center.text-sm.text-center.max-w-md- .cursor-pointer.px-5.py-3.grow.hocus_bg-gray-200.dark_hocus_bg-neutral-800(- :class="{ '_active cursor-default text-blue3 dark_text-blue1 bg-gray-100 dark_bg-232323': props.trnType === null }"- @click="setTrnType(null)"- ) {{ $t('common.all') }}-- .cursor-pointer.px-5.py-3.grow.hocus_bg-gray-200.dark_hocus_bg-neutral-800(- :class="{ '_active cursor-default text-blue3 dark_text-blue1 bg-gray-100 dark_bg-232323': props.trnType === 0 }"- @click="setTrnType(0)"- ) {{ $t('money.expense') }}-- .cursor-pointer.px-5.py-3.grow.hocus_bg-gray-200.dark_hocus_bg-neutral-800(- :class="{ '_active cursor-default text-blue3 dark_text-blue1 bg-gray-100 dark_bg-232323': props.trnType === 1 }"- @click="setTrnType(1)"- ) {{ $t('money.income') }}-- .cursor-pointer.px-5.py-3.grow.hocus_bg-gray-200.dark_hocus_bg-neutral-800(- v-if="!hideTransfers"- :class="{ '_active cursor-default text-blue3 dark_text-blue1 bg-gray-100 dark_bg-232323': trnType === 2 }"- @click="setTrnType(2)"- ) {{ $t('transfer.titleMany') }}-- //- Trns: Nothing- .py-6.text-center(v-if="trnsCount === 0")- .text-7xl.mdi.mdi-palm-tree- .text-md No Transactions-- //- Trns: Items- .pb-10- .grid.md_grid-cols-2.md_gap-x-20- TrnsListHistory(- :size="50"- :trnsIds="trnsIds"- isShowFilter- )-</template>diff --git a/components/trns/List.vue b/components/trns/List.vuenew file mode 100644index 00000000..cd9dc31f--- /dev/null+++ b/components/trns/List.vue@@ -0,0 +1,147 @@+<script setup lang="ts">+import dayjs from 'dayjs'+import type { TrnID } from '~/components/trns/types'+import useCalculator from '~/components/trnForm/calculator/useCalculator'+import useFilter from '~/modules/filter/useFilter'++const props = withDefaults(defineProps<{+ limit: number+ size: number+ trnsIds: TrnID[]++ isShowFilter?: boolean+ isShowGroupDate?: boolean+ uiCat?: boolean+ uiHistory?: boolean+}>(), {+ isShowFilter: false,+ isShowGroupDate: true,+ limit: 0,+ size: 30,+ uiHistory: false,+})+const emit = defineEmits(['onClickEdit'])++const { $store } = useNuxtApp()+const { setExpression } = useCalculator()+const { setFilterCatsId } = useFilter()++const pageNumber = ref(1)+const isShowTrnsWithDesc = ref(false)++const isTrnsWithDescription = computed(() =>+ props.trnsIds.some(id => $store.state.trns.items[id].description))++const trnsIdsWithLimit = computed(() => {+ const trnsItems = $store.state.trns.items++ if (props.isShowFilter && isShowTrnsWithDesc.value && isTrnsWithDescription.value)+ return props.trnsIds.filter(id => trnsItems[id].description)++ if (props.limit > 0)+ return props.trnsIds.slice(0, props.limit)++ return props.trnsIds+})++const paginatedTrnsIds = computed(() =>+ trnsIdsWithLimit.value.slice(0, pageNumber.value * props.size))++const isShowedAllTrns = computed(() =>+ paginatedTrnsIds.value.length === trnsIdsWithLimit.value.length)++// TODO: duplicate function+const groupedTrns = computed(() => {+ const trnsItems = $store.state.trns.items+ const trnsIds = paginatedTrnsIds.value++ return trnsIds.reduce((acc, trnId) => {+ const date = dayjs(trnsItems[trnId].date).startOf('day').valueOf()+ acc[date] ??= []+ acc[date].push(trnId)+ return acc+ }, {})+})++function showMoreTrns() {+ pageNumber.value += 1+}++function toggleTrnsWithDesc() {+ isShowTrnsWithDesc.value = !isShowTrnsWithDesc.value+}++const actions = trnItem => ({+ onOpenDetails: () => {+ if (!$store.state.trns.modal.show) {+ $store.commit('trns/showTrnModal')+ $store.commit('trns/setTrnModalId', trnItem.id)+ }+ },++ onOpenEdit: (event) => {+ event.stopPropagation()+ setExpression(trnItem.type === 2 && trnItem.incomeAmount ? trnItem.incomeAmount : trnItem.amount)+ $store.dispatch('trnForm/openTrnForm', { action: 'edit', trnId: trnItem.id })+ },++ onSetFilter: (event) => {+ event.stopPropagation()+ setFilterCatsId(trnItem.categoryId)+ $store.commit('filter/setFilterDateNow')+ $store.commit('trns/hideTrnModal')+ $store.commit('trns/setTrnModalId', null)+ $store.dispatch('ui/setActiveTabStat', 'details')+ },+})++function onClickEdit(props) {+ emit('onClickEdit', props)+}+</script>++<template lang="pug">+div(v-if="trnsIds && trnsIds.length > 0")+ .pb-2(v-if="isShowFilter && isTrnsWithDescription")+ SharedContextMenuItem(+ :checkboxValue="isShowTrnsWithDesc"+ :grow="false"+ :title="$t('trns.filter.showTrnsWithDesc')"+ icon="mdi mdi-comment-text-outline"+ showCheckbox+ @onClick="toggleTrnsWithDesc"+ )++ .grid(+ :class="{ 'gap-2': uiHistory }"+ )+ .overflow-hidden.rounded-md.bg-white2(+ v-for="(trnsIds, date) in groupedTrns"+ :key="date"+ class="dark_bg-dark4"+ )+ .pt-4.pb-2.px-3(v-if="isShowGroupDate")+ DateTrnsDay(:date="date")++ .overflow-hidden.rounded-md+ TrnsItemBase.py-3.px-3.cursor-pointer(+ v-if="uiHistory"+ v-for="trnId in trnsIds"+ :key="trnId"+ :trnId="trnId"+ @onClickEdit="onClickEdit"+ )+ TrnsItemWithoutCat.py-3.px-3.cursor-pointer(+ v-if="uiCat"+ v-for="trnId in trnsIds"+ :actions="actions"+ :key="trnId"+ :trnId="trnId"+ )++ .py-4.pb-6.px-2.flex-center(v-if="!isShowedAllTrns")+ .cursor-pointer.grow.py-3.px-5.flex-center.rounded-full.text-sm.bg-skin-item-main-bg.hocus_bg-skin-item-main-hover(+ class="basis-1/2 max-w-[280px]"+ @click="showMoreTrns"+ ) {{ $t('trns.more') }}+</template>diff --git a/components/trns/ListWithControl.vue b/components/trns/ListWithControl.vuenew file mode 100644index 00000000..19614b1e--- /dev/null+++ b/components/trns/ListWithControl.vue@@ -0,0 +1,102 @@+<script setup lang="ts">+import type { TrnID, TrnItem, TrnType } from '~/components/trns/types'+import useTrns from '~/components/trns/useTrns'++const props = withDefaults(defineProps<{+ trnsIds: TrnID[]+ trnsClassNames?: string+ defaultPeriod?: string+}>(), {+ trnsClassNames: ' grid md_grid-cols-2 md_gap-x-20',+})+const emit = defineEmits(['onClickEdit'])++const { $store } = useNuxtApp()+const filterType = ref<TrnType>(null)+const filterAll = ref(props.defaultPeriod)+const { allTrnsIdsWithFilter } = useTrns()++const filteredTrnsIds = computed(() => {+ const trnsIds = props.defaultPeriod && filterAll.value === 'all'+ ? allTrnsIdsWithFilter.value+ : props.trnsIds++ if (filterType.value === null)+ return trnsIds++ const trnsItems: Record<TrnID, TrnItem> = $store.state.trns.items+ return trnsIds.filter(id => trnsItems[id].type === filterType.value)+})++const trnsCount = computed(() => filteredTrnsIds.value.length)++function setTrnType(type: TrnType) {+ filterType.value = type+}++function onClickEdit(props) {+ emit('onClickEdit', props)+}+</script>++<template lang="pug">+div+ //- Title+ .pb-2.flex.items-center.justify-between.gap-2.text-lg.text-skin-item-base(+ v-if="trnsIds.length > 0"+ class="!pb-3"+ )+ .flex.gap-2.leading-none.font-nunito.font-semibold+ div {{ $t('trns.inPeriodTitle') }}:+ div {{ trnsCount }}++ .div(v-if="defaultPeriod")+ UiTabs+ UiTabsItem(+ :isActive="filterAll === 'period'"+ @click="filterAll = 'period'"+ ) {{ $t('dates.period') }}+ UiTabsItem(+ :isActive="filterAll === 'all'"+ @click="filterAll = 'all'"+ ) {{ $t('common.all') }}++ //- TypeSelector+ .pb-2(v-if="trnsIds.length > 0")+ UiTabs+ UiTabsItem(+ :isActive="filterType === null"+ @click="setTrnType(null)"+ ) {{ $t('common.all') }}++ UiTabsItem(+ :isActive="filterType === 0"+ @click="setTrnType(0)"+ ) {{ $t('money.expense') }}++ UiTabsItem(+ :isActive="filterType === 1"+ @click="setTrnType(1)"+ ) {{ $t('money.income') }}++ UiTabsItem(+ :isActive="filterType === 2"+ @click="setTrnType(2)"+ ) {{ $t('transfer.titleMany') }}++ //- Nothing+ .py-6.text-center(v-if="trnsCount === 0")+ .text-7xl.mdi.mdi-palm-tree+ .text-md No Transactions++ //- List+ .pb-10+ div(:class="trnsClassNames")+ TrnsList(+ :trnsIds="filteredTrnsIds"+ :size="50"+ isShowFilter+ uiHistory+ @onClickEdit="onClickEdit"+ )+</template>diff --git a/components/trns/getTrns.ts b/components/trns/getTrns.tsindex fc8f3353..8af7e18f 100644--- a/components/trns/getTrns.ts+++ b/components/trns/getTrns.ts@@ -6,26 +6,22 @@ import type { WalletID } from '~/components/wallets/types'type Date = numberinterface Props {trnsItems: Record<string, TrnItem>- walletsIds?: WalletID[]categoriesIds?: WalletID[]- trnType?: TrnType- periodName?: PeriodNamesdate?: DatefromDate?: number+ periodName?: PeriodNames+ trnType?: TrnTypeuntilDate?: number+ walletsIds?: WalletID[]}+// TODO: sorting option?export const getTrnsIds = (props: Props) => {let trnsIds: TrnID[] = Object.keys(props.trnsItems)- const getTrn = (trnId: TrnID) => props.trnsItems[trnId]// Type- if (props.trnType !== undefined && props.trnType !== null) {- trnsIds = trnsIds.filter((trnId: TrnID) => {- const trn = getTrn(trnId)- return trn.type === props.trnType- })- }+ if (props.trnType !== undefined && props.trnType !== null)+ trnsIds = trnsIds.filter(trnId => props.trnsItems[trnId].type === props.trnType)// @deprecated: Dateif (props?.date && props?.periodName !== 'all') {@@ -41,16 +37,16 @@ export const getTrnsIds = (props: Props) => {// From dateif (props.fromDate)- trnsIds = trnsIds.filter(trnId => (props.trnsItems[trnId].date >= props.fromDate))+ trnsIds = trnsIds.filter(trnId => props.trnsItems[trnId].date >= props.fromDate)// Until dateif (props.untilDate)- trnsIds = trnsIds.filter(trnId => (props.trnsItems[trnId].date <= props.untilDate))+ trnsIds = trnsIds.filter(trnId => props.trnsItems[trnId].date <= props.untilDate)// Walletif (props.walletsIds?.length > 0) {trnsIds = trnsIds.filter((trnId: TrnID) => {- const trn = getTrn(trnId)+ const trn = props.trnsItems[trnId]return props.walletsIds?.includes(trn?.walletId)|| props.walletsIds?.includes(trn?.expenseWalletId)|| props.walletsIds?.includes(trn?.incomeWalletId)@@ -61,21 +57,9 @@ export const getTrnsIds = (props: Props) => {// Categoryif (props.categoriesIds?.length > 0) {- trnsIds = trnsIds.filter((trnId: TrnID) => {- const trn = getTrn(trnId)- return props.categoriesIds?.includes(trn?.categoryId)- })+ trnsIds = trnsIds.filter(+ (trnId: TrnID) => props.categoriesIds.includes(props.trnsItems[trnId].categoryId))}- // Sort- trnsIds = trnsIds- .sort((a, b) => {- if (props.trnsItems[a].date > props.trnsItems[b].date)- return -1- if (props.trnsItems[a].date < props.trnsItems[b].date)- return 1- return 0- })-- return trnsIds+ return trnsIds.sort((a, b) => props.trnsItems[b].date - props.trnsItems[a].date)}diff --git a/components/trns/item/History.vue b/components/trns/item/Base.vuesimilarity index 98%rename from components/trns/item/History.vuerename to components/trns/item/Base.vueindex 02934dca..79edec4d 100644--- a/components/trns/item/History.vue+++ b/components/trns/item/Base.vue@@ -8,6 +8,7 @@ const props = defineProps<{trnId: TrnIDslider: any}>()+const emit = defineEmits(['onClickEdit'])const { $store } = useNuxtApp()const { setExpression } = useCalculator()@@ -31,6 +32,7 @@ const actions = {setExpression(trnItem.value.type === 2 && trnItem.value.incomeAmount ? trnItem.value.incomeAmount : trnItem.value.amount)$store.dispatch('trnForm/openTrnForm', { action: 'edit', trnId: trnItem.value.id })+ emit('onClickEdit', props.trnId)},onSetFilter: (event) => {diff --git a/components/trns/list/TrnsList.vue b/components/trns/list/TrnsList.vuedeleted file mode 100644index b4b8ce5e..00000000--- a/components/trns/list/TrnsList.vue+++ /dev/null@@ -1,175 +0,0 @@-<script lang="ts">-import useCalculator from '~/components/trnForm/calculator/useCalculator'-import useFilter from '~/modules/filter/useFilter'--export default defineComponent({- props: {- categoryId: { type: String, default: null },- expense: { type: Boolean, default: false },- income: { type: Boolean, default: false },- isShowFilter: { type: Boolean, default: false },- limit: { type: Number, default: 0 },- size: { type: Number, required: false, default: 30 },- ui: { type: String, default: 'history' },- classNames: { type: String, default: '' },- },-- setup() {- const { $store } = useNuxtApp()- const { setExpression } = useCalculator()- const { setFilterCatsId } = useFilter()-- const actions = trnItem => ({- onOpenDetails: () => {- if (!$store.state.trns.modal.show) {- $store.commit('trns/showTrnModal')- $store.commit('trns/setTrnModalId', trnItem.id)- }- },-- onOpenEdit: (event) => {- event.stopPropagation()- setExpression(trnItem.type === 2 && trnItem.incomeAmount ? trnItem.incomeAmount : trnItem.amount)- $store.dispatch('trnForm/openTrnForm', { action: 'edit', trnId: trnItem.id })- },-- onSetFilter: (event) => {- event.stopPropagation()- setFilterCatsId(trnItem.categoryId)- $store.commit('filter/setFilterDateNow')- $store.commit('trns/hideTrnModal')- $store.commit('trns/setTrnModalId', null)- $store.dispatch('ui/setActiveTabStat', 'details')- },- })-- return { actions }- },-- data() {- return {- pageNumber: 1,- isShowTrnsWithDesc: false,- }- },-- computed: {- trnsIds() {- const trns = this.$store.state.trns.items- let trnsIds = this.$store.getters['trns/selectedTrnsIdsWithDate']-- // from category- if (this.categoryId)- trnsIds = trnsIds.filter(trnId => trns[trnId].categoryId === this.categoryId)-- // filter type- if (this.income)- trnsIds = trnsIds.filter(id => trns[id].type === 1)- if (this.expense)- trnsIds = trnsIds.filter(id => trns[id].type === 0)-- return trnsIds- },-- isShowedAllTrns() {- return this.paginatedTrnsIds.length === this.trnsIdsWithLimit.length- },-- isTrnsWithDescription() {- const trns = this.$store.state.trns.items- return this.trnsIds.filter(id => trns[id].description).length > 0- },-- trnsIdsWithLimit() {- const trns = this.$store.state.trns.items-- if (this.isShowFilter && this.isShowTrnsWithDesc && this.isTrnsWithDescription)- return this.trnsIds.filter(id => trns[id].description)-- if (this.limit > 0)- return this.trnsIds.slice(0, this.limit)-- return this.trnsIds- },-- paginatedTrnsIds() {- const end = this.pageNumber * this.size- return this.trnsIdsWithLimit.slice(0, end)- },-- // TODO: duplicate function- groupedTrns() {- const trnsItems = this.$store.state.trns.items- const trnsIds = this.paginatedTrnsIds-- return trnsIds.reduce((acc, trnId) => {- const date = this.$day(trnsItems[trnId].date).startOf('day').valueOf()- acc[date] ??= []- acc[date].push(trnId)- return acc- }, {})- },- },-- methods: {- showMoreTrns() {- this.pageNumber = this.pageNumber + 1- },-- showTrnsWithDesc() {- this.isShowTrnsWithDesc = !this.isShowTrnsWithDesc- },- },-})-</script>--<template lang="pug">-div- .flex.pb-3(v-if="isShowFilter && isTrnsWithDescription")- SharedContextMenuItem(- :checkboxValue="isShowTrnsWithDesc"- :grow="false"- :title="$t('trns.filter.showTrnsWithDesc')"- icon="mdi mdi-comment-text-outline"- showCheckbox- @onClick="isShowTrnsWithDesc = !isShowTrnsWithDesc"- )-- div(v-if="trnsIds.length > 0")- //- History view- .grid.gap-y-2(- v-if="ui === 'history'"- :class="classNames"- )- .overflow-hidden.rounded-md.bg-white2.shadow-sm(- v-for="(trnsIds, date) in groupedTrns"- :key="date"- class="dark_bg-dark4"- )- .pt-4- .pb-2.px-3- TrnsListDate(:date="date")-- .overflow-hidden.rounded-md- TrnsItemHistory.py-3.px-3.cursor-pointer(- v-for="trnId in trnsIds"- :key="trnId"- :actions="actions"- :trnId="trnId"- )-- //- Stat view- div(v-if="ui !== 'history'")- TrnsItemWithoutCat.py-3.px-3.cursor-pointer(- v-for="trnId in paginatedTrnsIds"- :key="trnId"- :actions="actions"- :trnId="trnId"- )-- .py-4.pb-6.px-3.flex-center(v-if="!isShowedAllTrns")- .cursor-pointer.grow.py-3.px-5.flex-center.rounded-full.text-sm.bg-skin-item-main-bg.hocus_bg-skin-item-main-hover(- class="basis-1/2 max-w-[280px]"- @click="showMoreTrns"- ) {{ $t('trns.more') }}-</template>diff --git a/components/trns/list/TrnsListHistory.vue b/components/trns/list/TrnsListHistory.vuedeleted file mode 100644index 715952cd..00000000--- a/components/trns/list/TrnsListHistory.vue+++ /dev/null@@ -1,148 +0,0 @@-<script setup lang="ts">-import useCalculator from '~/components/trnForm/calculator/useCalculator'-import useFilter from '~/modules/filter/useFilter'--const { $store } = useNuxtApp()-const { setExpression } = useCalculator()-const { setFilterCatsId } = useFilter()--const actions = trnItem => ({- onOpenDetails: () => {- if (!$store.state.trns.modal.show) {- $store.commit('trns/showTrnModal')- $store.commit('trns/setTrnModalId', trnItem.id)- }- },-- onOpenEdit: (event) => {- event.stopPropagation()- setExpression(trnItem.type === 2 && trnItem.incomeAmount ? trnItem.incomeAmount : trnItem.amount)- $store.dispatch('trnForm/openTrnForm', { action: 'edit', trnId: trnItem.id })- },-- onSetFilter: (event) => {- event.stopPropagation()- setFilterCatsId(trnItem.categoryId)- $store.commit('filter/setFilterDateNow')- $store.commit('trns/hideTrnModal')- $store.commit('trns/setTrnModalId', null)- $store.dispatch('ui/setActiveTabStat', 'details')- },-})-</script>--<script lang="ts">-export default defineComponent({- props: {- trnsIds: { type: Array, required: true },- isShowFilter: { type: Boolean, default: false },- isShowGroupDate: { type: Boolean, default: true },- uiHistory: { type: Boolean, default: true },- uiCat: { type: Boolean, default: false },- limit: { type: Number, default: 0 },- size: { type: Number, required: false, default: 30 },- },-- data() {- return {- pageNumber: 1,- isShowTrnsWithDesc: false,- }- },-- computed: {- isShowedAllTrns() {- return this.paginatedTrnsIds.length === this.trnsIdsWithLimit.length- },-- isTrnsWithDescription() {- const trns = this.$store.state.trns.items- return this.trnsIds.filter(id => trns[id].description).length > 0- },-- trnsIdsWithLimit() {- const trns = this.$store.state.trns.items-- if (this.isShowFilter && this.isShowTrnsWithDesc && this.isTrnsWithDescription)- return this.trnsIds.filter(id => trns[id].description)-- if (this.limit > 0)- return this.trnsIds.slice(0, this.limit)-- return this.trnsIds- },-- paginatedTrnsIds() {- const end = this.pageNumber * this.size- return this.trnsIdsWithLimit.slice(0, end)- },-- // TODO: duplicate function- groupedTrns() {- const trnsItems = this.$store.state.trns.items- const trnsIds = this.paginatedTrnsIds-- return trnsIds.reduce((acc, trnId) => {- const date = this.$day(trnsItems[trnId].date).startOf('day').valueOf()- acc[date] ??= []- acc[date].push(trnId)- return acc- }, {})- },- },-- methods: {- showMoreTrns() {- this.pageNumber = this.pageNumber + 1- },-- showTrnsWithDesc() {- this.isShowTrnsWithDesc = !this.isShowTrnsWithDesc- },- },-})-</script>--<template lang="pug">-div- .pb-3(v-if="isShowFilter && isTrnsWithDescription")- SharedContextMenuItem(- :checkboxValue="isShowTrnsWithDesc"- :grow="false"- :title="$t('trns.filter.showTrnsWithDesc')"- icon="mdi mdi-comment-text-outline"- showCheckbox- @onClick="isShowTrnsWithDesc = !isShowTrnsWithDesc"- )-- template(v-if="trnsIds.length > 0")- .grid.gap-2- .overflow-hidden.rounded-md.bg-white2(- v-for="(trnsIds, date) in groupedTrns"- :key="date"- class="dark_bg-dark4"- )- .pt-4.pb-2.px-3(v-if="isShowGroupDate")- TrnsListDate(:date="date")-- .overflow-hidden.rounded-md- TrnsItemHistory.py-3.px-3.cursor-pointer(- v-if="uiHistory"- v-for="trnId in trnsIds"- :key="trnId"- :trnId="trnId"- )- TrnsItemWithoutCat.py-3.px-3.cursor-pointer(- v-if="uiCat"- v-for="trnId in trnsIds"- :actions="actions"- :key="trnId"- :trnId="trnId"- )-- .py-4.pb-6.px-2.flex-center(v-if="!isShowedAllTrns")- .cursor-pointer.grow.py-3.px-5.flex-center.rounded-full.text-sm.bg-skin-item-main-bg.hocus_bg-skin-item-main-hover(- class="basis-1/2 max-w-[280px]"- @click="showMoreTrns"- ) {{ $t('trns.more') }}-</template>diff --git a/components/trns/pages/History.vue b/components/trns/pages/History.vueindex 6df53e0f..ef14ff07 100644--- a/components/trns/pages/History.vue+++ b/components/trns/pages/History.vue@@ -1,31 +1,6 @@<script setup lang="ts">-import { getCategoriesIds } from '~/components/categories/getCategories'-import { getTrnsIds } from '~/components/trns/getTrns'import useStatPage from '~/components/stat/useStatPage'--const { $store } = useNuxtApp()const { statPage } = useStatPage()-const categoriesItems = computed(() => $store.state.categories.items)-const trnsItems = computed(() => $store.state.trns.items)-const storeFilter = computed(() => $store.state.filter)-const filterTrnType = ref(null)--const trnsIds = computed(() => {- // TODO: move it to a separate function getFilterParams- const categoriesIds = storeFilter.value.catsIds.length > 0- ? getCategoriesIds(storeFilter.value.catsIds, categoriesItems.value)- : null- const walletsIds = storeFilter.value.walletsIds.length > 0- ? storeFilter.value.walletsIds- : null-- return getTrnsIds({- categoriesIds,- walletsIds,- trnType: filterTrnType.value,- trnsItems: trnsItems.value,- })-})</script><script lang="ts">@@ -47,10 +22,6 @@ export default defineComponent({.pb-8(v-if="statPage.filter.isShow")LazyStatFilter- //- History- TrnsHistory(- :trnsIds="trnsIds"- :trnType="filterTrnType"- @setFilterTrnType="value => filterTrnType = value"- )+ .my-4.px-2.md_max-w-none(class="max-w-[420px]")+ TrnsListWithControl(:trnsIds="allTrnsWithFilter")</template>diff --git a/components/trns/useTrns.ts b/components/trns/useTrns.tsnew file mode 100644index 00000000..ec01bf92--- /dev/null+++ b/components/trns/useTrns.ts@@ -0,0 +1,30 @@+import { getCategoriesIds } from '~/components/categories/getCategories'+import { getTrnsIds } from '~/components/trns/getTrns'++export default function useTrns() {+ const { $store } = useNuxtApp()++ const allTrnsIdsWithFilter = computed(() => {+ const categoriesItems = computed(() => $store.state.categories.items)+ const trnsItems = computed(() => $store.state.trns.items)+ const storeFilter = computed(() => $store.state.filter)++ // TODO: move it to a separate function getFilterParams+ const categoriesIds = storeFilter.value.catsIds.length > 0+ ? getCategoriesIds(storeFilter.value.catsIds, categoriesItems.value)+ : null+ const walletsIds = storeFilter.value.walletsIds.length > 0+ ? storeFilter.value.walletsIds+ : null++ return getTrnsIds({+ categoriesIds,+ walletsIds,+ trnsItems: trnsItems.value,+ })+ })++ return {+ allTrnsIdsWithFilter,+ }+}diff --git a/components/wallets/page/id/Index.vue b/components/wallets/page/id/Index.vueindex c379e7f7..81b5a452 100644--- a/components/wallets/page/id/Index.vue+++ b/components/wallets/page/id/Index.vue@@ -14,22 +14,17 @@ if (!wallet.value)router.replace('/wallets')const total = computed(() => $store.getters['wallets/walletsTotal'][walletId.value])-const filter = reactive({ trnType: null })const trnsItems = computed(() => $store.state.trns.items)const trnsIds = computed(() =>getTrnsIds({walletsIds: [walletId.value],- trnType: filter.trnType,trnsItems: trnsItems.value,}),)-const periodTrnsIds = computed(() =>- $store.getters['trns/selectedTrnsIdsWithDate'].filter(- trnId => $store.state.trns.items[trnId].walletId === walletId.value,- ),-)+const periodTrnsIds = computed(() => $store.getters['trns/selectedTrnsIdsWithDate']+ .filter(trnId => $store.state.trns.items[trnId].walletId === walletId.value))function handleSetFilterWallet() {setFilterWalletsId(walletId.value)@@ -102,11 +97,7 @@ UiPage(v-if="wallet")//- History.px-2- TrnsHistory(- :trnsIds="trnsIds"- :trnType="filter.trnType"- @setFilterTrnType="value => filter.trnType = value"- )+ TrnsListWithControl(:trnsIds="trnsIds")</template><i18n lang="json5">diff --git a/store/stat/getters.ts b/store/stat/getters.tsindex 30fa6100..6aa1515f 100644--- a/store/stat/getters.ts+++ b/store/stat/getters.ts@@ -194,7 +194,7 @@ export default {// When just this period and lastconst delimiter = periodsToShow - 1- if (delimiter === 1)+ if (delimiter <= 1)return emptyDatareturn {