Skip to content

Open source personal finance application

improvements: refactor

ilkome219d68b5bbbe
diff --git a/components/stat/View.vue b/components/stat/View.vue
index 4c74a25a..0f1a488e 100644
--- a/components/stat/View.vue
+++ b/components/stat/View.vue
@@ -130,7 +130,6 @@ onDeactivated(async () => {
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")
diff --git a/components/stat/group/Item.vue b/components/stat/group/Item.vue
index 36c66841..6a55f2e3 100644
--- a/components/stat/group/Item.vue
+++ b/components/stat/group/Item.vue
@@ -17,7 +17,6 @@ div
StatViewConfig
template(v-if="statPage.activeTab !== 'balance'")
- StatGroupEmpty(:typeText="typeText")
StatGroupPie(:typeText="typeText")
StatGroupVertical(:typeText="typeText")
StatGroupRound(:typeText="typeText")
diff --git a/components/trnForm/Index.vue b/components/trnForm/Index.vue
index 4c8681ac..9bbbc382 100644
--- a/components/trnForm/Index.vue
+++ b/components/trnForm/Index.vue
@@ -211,7 +211,7 @@ function handleSubmitForm() {
//- Main
.swiper-slide.getHeight
.scroll.scrollerBlock(:style="{ maxHeight: `${$store.state.ui.height}px` }")
- .subTitle.text-center.pt-5.pb-2.text-xs
+ .text-center.pt-2.text-sm.font-medium.text-xs
template(v-if="$store.state.trnForm.values.trnId") {{ $t('trnForm.titleEditTrn') }}
template(v-if="!$store.state.trnForm.values.trnId") {{ $t('trnForm.createTrn') }}
@@ -234,7 +234,9 @@ function handleSubmitForm() {
.scroll.scrollerBlock
//- Wallets
.pt-5.pb-7
- .subTitle.text-center.pb-2.text-xs {{ $t('wallets.title') }}
+ .px-3.pb-2.text-sm.font-medium(
+ @click="$store.commit('trnForm/showTrnFormModal', 'wallets')"
+ ) {{ $t('wallets.title') }}
WalletsList(
:limit="4"
@@ -270,8 +272,9 @@ function handleSubmitForm() {
//- Favorite categories
.pb-7(v-if="$store.getters['categories/favoriteCategoriesIds'].length > 0")
- .subTitle.text-center.pb-2.text-xs
- | {{ $t('categories.favoriteTitle') }} {{ $t('categories.title') }}
+ .px-3.pb-2.text-sm.font-medium(
+ @click="$store.commit('trnForm/showTrnFormModal', 'categories')"
+ ) {{ $t('categories.favoriteTitle') }} {{ $t('categories.title') }}
.px-3
CategoriesList(
@@ -285,8 +288,9 @@ function handleSubmitForm() {
//- Recent categories
.pb-7(v-if="$store.getters['categories/recentCategoriesIds'].length > 0")
- .subTitle.text-center.pb-2.text-xs
- | {{ $t('categories.lastUsedTitle') }} {{ $t('categories.title') }}
+ .px-3.pb-2.text-sm.font-medium(
+ @click="$store.commit('trnForm/showTrnFormModal', 'categories')"
+ ) {{ $t('categories.lastUsedTitle') }} {{ $t('categories.title') }}
.px-3
CategoriesList(
@@ -298,19 +302,6 @@ function handleSubmitForm() {
@onClick="onCategoryClick"
)
- .pb-6.px-3.flex.justify-evenly.gap-6
- //- Wallets
- .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="$store.commit('trnForm/showTrnFormModal', 'wallets')"
- ) {{ $t('wallets.title') }}
-
- //- Categories
- .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="$store.commit('trnForm/showTrnFormModal', 'categories')"
- ) {{ $t('categories.title') }}
-
.trnForm__pagination
//- Modals
@@ -411,12 +402,6 @@ function handleSubmitForm() {
padding-top $m4
padding-bottom $m9
-.subTitle
- color var(--c-font-4)
- letter-spacing 0
- font-weight 600
- text-transform uppercase
-
.scroll
overflow hidden
overflow-y auto
diff --git a/components/trnForm/TrnsSlide.vue b/components/trnForm/TrnsSlide.vue
index 1a9cb27b..bf519588 100644
--- a/components/trnForm/TrnsSlide.vue
+++ b/components/trnForm/TrnsSlide.vue
@@ -4,9 +4,8 @@ import { getTrnsIds } from '~/components/trns/getTrns'
const props = defineProps<{
slider: object
}>()
-const emit = defineEmits(['onClickEdit'])
-const { $store } = useNuxtApp()
+const { $store, nuxt2Context: { i18n } } = useNuxtApp()
const filterBy = ref('wallet')
@@ -46,43 +45,39 @@ function changeFilter(value) {
function onClickEdit() {
props.slider.slideTo(1)
}
+
+const tabs = computed(() => [{
+ id: 'wallets',
+ name: i18n.t('trnForm.filterWallet'),
+}, {
+ id: 'walletAndCategory',
+ name: i18n.t('trnForm.filterWalletAndCategory'),
+}, {
+ id: 'all',
+ name: i18n.t('trnForm.filterAll'),
+}])
</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
+ .contentWrap__box.trnsListScroll(
+ :class="{ 'grid items-center': filteredTrnsIds.length === 0 }"
+ )
+ .pt-5.px-3
+ TrnsListWithControl(
+ :trnsIds="filteredTrnsIds"
+ trnsClassNames=""
+ @onClickEdit="onClickEdit"
+ )
+
+ .pt-2.pb-6.px-3(v-if="filteredTrnsIds.length > 0")
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') }}
+ v-for="tab in tabs"
+ :key="tab.id"
+ :isActive="tab.id === filterBy"
+ @click="changeFilter(tab.id)"
+ ) {{ tab.name }}
</template>
<style lang="stylus" scoped>
@@ -109,10 +104,4 @@ function onClickEdit() {
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/calculator/TrnFormCalculator.vue b/components/trnForm/calculator/TrnFormCalculator.vue
index c68ac085..10ac4e63 100644
--- a/components/trnForm/calculator/TrnFormCalculator.vue
+++ b/components/trnForm/calculator/TrnFormCalculator.vue
@@ -1,46 +1,30 @@
-<script lang="ts">
+<script setup lang="ts">
import useCalculator from './useCalculator'
import './long-press-event'
-export default {
- name: 'TrnFormCalculator',
-
- setup() {
- const { $store } = useNuxtApp()
- const amountType = computed(() => $store.state.trnForm.values.amountType)
-
- const deleteRef = ref(document.createElement('div'))
-
- const {
- clearExpression,
- handleTouch,
- isSum,
- keyboardHandler,
- } = useCalculator()
-
- // Mounted
- onMounted(() => {
- document.addEventListener('keydown', keyboardHandler)
-
- // Long press for delete
- const element: HTMLElement = deleteRef.value
- element.addEventListener('long-press', clearExpression)
- })
-
- // Unmounted
- onUnmounted(() => {
- document.removeEventListener('keydown', keyboardHandler)
- })
-
- return {
- amountType,
-
- isSum,
- deleteRef,
- handleTouch,
- }
- },
-}
+const { $store } = useNuxtApp()
+const amountType = computed(() => $store.state.trnForm.values.amountType)
+
+const deleteRef = ref(document.createElement('div'))
+
+const {
+ clearExpression,
+ handleTouch,
+ isSum,
+ keyboardHandler,
+} = useCalculator()
+
+// Mounted
+onMounted(() => {
+ document.addEventListener('keydown', keyboardHandler)
+
+ // Long press for delete
+ const element: HTMLElement = deleteRef.value
+ element.addEventListener('long-press', clearExpression)
+})
+
+// Unmounted
+onUnmounted(() => document.removeEventListener('keydown', keyboardHandler))
</script>
<template lang="pug">
@@ -103,11 +87,12 @@ export default {
.calcItem__in
template(v-if="isSum")
.mdi.mdi-check
- template(v-else)
+ template(v-if="!isSum")
.mdi.mdi-equal
</template>
<style lang="stylus" scoped>
+// TODO: style
.trnFormCalculator
display grid
grid-template-columns auto 1fr auto
diff --git a/components/trns/ListWithControl.vue b/components/trns/ListWithControl.vue
index 7db35329..70cc972b 100644
--- a/components/trns/ListWithControl.vue
+++ b/components/trns/ListWithControl.vue
@@ -93,7 +93,7 @@ div
//- Nothing
.py-6.text-center(v-if="trnsCount === 0")
.text-7xl.mdi.mdi-palm-tree
- .text-md No Transactions
+ .text-md {{ $t('trns.noTrns') }}
//- List
.pb-10
diff --git a/locales/en-US.js b/locales/en-US.js
index b311df62..efd7a0b6 100644
--- a/locales/en-US.js
+++ b/locales/en-US.js
@@ -212,7 +212,6 @@ export default {
shortTitle: 'Stat',
periods: 'Summary',
balanceTitle: 'Balance',
- empty: 'No stat for this period',
emptyDesc: 'Change filter, period or add new transactions.',
customize: {
showHistory: 'Show history',
@@ -250,6 +249,7 @@ export default {
filter: {
showTrnsWithDesc: 'Only with description',
},
+ noTrns: 'No transactions',
},
create: {
diff --git a/locales/ru-RU.js b/locales/ru-RU.js
index 43356e4e..b8c8d2c5 100644
--- a/locales/ru-RU.js
+++ b/locales/ru-RU.js
@@ -251,6 +251,7 @@ export default {
filter: {
showTrnsWithDesc: 'Только с описанием',
},
+ noTrns: 'Нет транзакций',
},
create: {