From 157eb140ebe2a66315a8c81fc1ebafb4a77c699c Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sat, 10 Aug 2024 00:40:03 +0800 Subject: [PATCH] hide multiple accounts / categories item when there are no accounts / categories --- src/views/desktop/transactions/ListPage.vue | 30 +++++++++++++++++-- src/views/mobile/transactions/ListPage.vue | 33 +++++++++++++++++++-- 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/src/views/desktop/transactions/ListPage.vue b/src/views/desktop/transactions/ListPage.vue index c8f76e83..2d2983f8 100644 --- a/src/views/desktop/transactions/ListPage.vue +++ b/src/views/desktop/transactions/ListPage.vue @@ -146,7 +146,8 @@ + :append-icon="(query.categoryIds && queryAllFilterCategoryIdsCount > 1 ? icons.check : null)" + v-if="allAvailableCategoriesCount > 0">
@@ -158,7 +159,7 @@ - + @@ -313,6 +316,7 @@ class="no-margin-vertical" :key="categoryType" v-for="(categories, categoryType) in allPrimaryCategories" + v-show="categories && categories.length" > - + @@ -657,6 +664,9 @@ export default { allAccounts() { return this.accountsStore.allAccountsMap; }, + allAvailableAccountsCount() { + return this.accountsStore.allAvailableAccountsCount; + }, allCategories() { return this.transactionCategoriesStore.allTransactionCategoriesMap; }, @@ -677,6 +687,25 @@ export default { return primaryCategories; }, + allAvailableCategoriesCount() { + let totalCount = 0; + + for (const categoryType in this.transactionCategoriesStore.allTransactionCategories) { + if (!Object.prototype.hasOwnProperty.call(this.transactionCategoriesStore.allTransactionCategories, categoryType)) { + continue; + } + + if (this.query.type && this.getTransactionTypeFromCategoryType(categoryType) !== this.query.type) { + continue; + } + + if (this.transactionCategoriesStore.allTransactionCategories[categoryType]) { + totalCount += this.transactionCategoriesStore.allTransactionCategories[categoryType].length; + } + } + + return totalCount; + }, allTransactionTags() { return this.transactionTagsStore.allTransactionTagsMap; },