Skip to content

Open source personal finance application

update 3.11.1

ilkome8b547f97667f
diff --git a/components/filter/FilterRow.vue b/components/filter/FilterRow.vue
index f3ea83e8..726b92e2 100644
--- a/components/filter/FilterRow.vue
+++ b/components/filter/FilterRow.vue
@@ -1,7 +1,18 @@
<script>
+import useFilter from '~/modules/filter/useFilter'
+
export default {
name: 'FilterRow',
+ setup () {
+ const { setCategoryFilter, setWalletFilter } = useFilter()
+
+ return {
+ setCategoryFilter,
+ setWalletFilter
+ }
+ },
+
computed: {
filterCategory () {
return this.$store.state.categories.items[this.$store.state.filter.categoryId]
@@ -18,16 +29,16 @@ export default {
methods: {
clearCategoryFilter () {
- const nextCategory = this.filterCategory.parentId !== 0 ? this.filterCategory.parentId : null
- this.$store.dispatch('filter/setFilterCategoryId', nextCategory)
+ const nextCategoryId = this.filterCategory.parentId !== 0 ? this.filterCategory.parentId : null
+ this.setCategoryFilter(nextCategoryId)
},
clearParentCategoryFilter () {
- this.$store.dispatch('filter/setFilterCategoryId', null)
+ this.setCategoryFilter(null)
},
clearWalletFilter () {
- this.$store.dispatch('filter/setFilterWalletId', null)
+ this.setWalletFilter(null)
}
}
}
diff --git a/components/stat/Mobile.vue b/components/stat/Mobile.vue
index 1225d359..64004715 100644
--- a/components/stat/Mobile.vue
+++ b/components/stat/Mobile.vue
@@ -3,6 +3,7 @@ import dayjs from 'dayjs'
import { computed, useContext } from '@nuxtjs/composition-api'
import useUIView from '~/components/layout/useUIView'
import useStat from '~/modules/stat/useStat'
+import useFilter from '~/modules/filter/useFilter'
export default {
name: 'StatMobile',
@@ -59,7 +60,7 @@ export default {
</script>
<template lang="pug">
-.pageWrap
+.pageWrapScroll
.baseBox(v-if="ui.showMainChart && isShowChart")
LazyChartMobileStatLines(v-if="ui.showMainChart && isShowChart")
@@ -196,7 +197,7 @@ export default {
<style lang="stylus" scoped>
@import '~assets/stylus/variables'
-.pageWrap
+.pageWrapScroll
overflow hidden
overflow-y auto
scrollbar()
diff --git a/components/stat/StatItem.vue b/components/stat/StatItem.vue
index 2eb9550f..f2a31ff4 100644
--- a/components/stat/StatItem.vue
+++ b/components/stat/StatItem.vue
@@ -61,7 +61,7 @@ export default {
},
methods: {
- toogleShowInside (categoryId) {
+ toogleShowInside () {
this.showInside = !this.showInside
}
}
@@ -71,7 +71,7 @@ export default {
<template lang="pug">
.statItem(
:class="{ _active: showInside }"
- @click="toogleShowInside(categoryId)"
+ @click="toogleShowInside"
)
.statItem__content
.statItem__graph: .statItem__graph__in(:style="styles")
diff --git a/components/stat/StatItemRound.vue b/components/stat/StatItemRound.vue
index e2b98241..18cd91ac 100644
--- a/components/stat/StatItemRound.vue
+++ b/components/stat/StatItemRound.vue
@@ -1,4 +1,6 @@
<script>
+import useFilter from '~/modules/filter/useFilter'
+
export default {
name: 'StatItemRound',
@@ -29,6 +31,14 @@ export default {
}
},
+ setup () {
+ const { setCategoryFilter } = useFilter()
+
+ return {
+ setCategoryFilter
+ }
+ },
+
computed: {
trnsIds () {
return this.$store.getters['trns/getTrns']({
@@ -50,7 +60,7 @@ export default {
<template lang="pug">
.statItemRound(
- @click="$store.dispatch('filter/handleSetFilterCategory', categoryId)"
+ @click="setCategoryFilter(categoryId)"
)
.statItemRound__icon
Icon(
diff --git a/modules/filter/useFilter.ts b/modules/filter/useFilter.ts
new file mode 100644
index 00000000..b2907ccb
--- /dev/null
+++ b/modules/filter/useFilter.ts
@@ -0,0 +1,25 @@
+import { useContext } from '@nuxtjs/composition-api'
+
+export default function useFilter () {
+ const { store } = useContext()
+
+ function scrollTop () {
+ const page = document.querySelector('.pageWrapScroll')
+ page.scrollTop = 0
+ }
+
+ function setCategoryFilter (id) {
+ store.dispatch('filter/handleSetFilterCategory', id)
+ scrollTop()
+ }
+
+ function setWalletFilter (id) {
+ store.dispatch('filter/handleSetFilterWallet', id)
+ scrollTop()
+ }
+
+ return {
+ setCategoryFilter,
+ setWalletFilter
+ }
+}
diff --git a/store/filter/mutations.js b/store/filter/mutations.js
index 1c32eb8d..a4041ed9 100644
--- a/store/filter/mutations.js
+++ b/store/filter/mutations.js
@@ -1,12 +1,5 @@
import dayjs from 'dayjs'
-// setDate
-// setFilterCategoryId
-// setFilterDateNow
-// setFilterWalletId
-// setPeriod
-// setPeriodNext
-// setPeriodPrev
export default {
setDate (state, date) {
state.date = dayjs(date).valueOf()