Skip to content

Commit

Permalink
hide multiple accounts / categories item when there are no accounts /…
Browse files Browse the repository at this point in the history
… categories
  • Loading branch information
mayswind committed Aug 9, 2024
1 parent 83a0c27 commit 157eb14
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 5 deletions.
30 changes: 27 additions & 3 deletions src/views/desktop/transactions/ListPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@
</v-list-item>
<v-list-item key="multiple" value="multiple" class="text-sm" density="compact"
:class="{ 'list-item-selected': query.categoryIds && queryAllFilterCategoryIdsCount > 1 }"
:append-icon="(query.categoryIds && queryAllFilterCategoryIdsCount > 1 ? icons.check : null)">
:append-icon="(query.categoryIds && queryAllFilterCategoryIdsCount > 1 ? icons.check : null)"
v-if="allAvailableCategoriesCount > 0">
<v-list-item-title class="cursor-pointer"
@click="showFilterCategoryDialog = true">
<div class="d-flex align-center">
Expand All @@ -158,7 +159,7 @@

<template :key="categoryType"
v-for="(categories, categoryType) in allPrimaryCategories">
<v-list-item density="compact">
<v-list-item density="compact" v-show="categories && categories.length">
<v-list-item-title>
<span class="text-sm">{{ getTransactionTypeName(getTransactionTypeFromCategoryType(categoryType), 'Type') }}</span>
</v-list-item-title>
Expand Down Expand Up @@ -290,7 +291,8 @@
</v-list-item>
<v-list-item key="multiple" value="multiple" class="text-sm" density="compact"
:class="{ 'list-item-selected': query.accountIds && queryAllFilterAccountIdsCount > 1 }"
:append-icon="(query.accountIds && queryAllFilterAccountIdsCount > 1 ? icons.check : null)">
:append-icon="(query.accountIds && queryAllFilterAccountIdsCount > 1 ? icons.check : null)"
v-if="allAvailableAccountsCount > 0">
<v-list-item-title class="cursor-pointer"
@click="showFilterAccountDialog = true">
<div class="d-flex align-center">
Expand Down Expand Up @@ -896,6 +898,9 @@ export default {
allAccounts() {
return this.accountsStore.allAccountsMap;
},
allAvailableAccountsCount() {
return this.accountsStore.allAvailableAccountsCount;
},
allCategories() {
return this.transactionCategoriesStore.allTransactionCategoriesMap;
},
Expand All @@ -916,6 +921,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;
},
Expand Down
33 changes: 31 additions & 2 deletions src/views/mobile/transactions/ListPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,10 @@
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="!query.categoryIds"></f7-icon>
</template>
</f7-list-item>
<f7-list-item :class="{ 'list-item-selected': query.categoryIds && queryAllFilterCategoryIdsCount > 1 }" :title="$t('Multiple Categories')" @click="filterMultipleCategories()">
<f7-list-item :class="{ 'list-item-selected': query.categoryIds && queryAllFilterCategoryIdsCount > 1 }"
:title="$t('Multiple Categories')"
@click="filterMultipleCategories()"
v-if="allAvailableCategoriesCount > 0">
<template #media>
<f7-icon f7="rectangle_on_rectangle"></f7-icon>
</template>
Expand All @@ -313,6 +316,7 @@
class="no-margin-vertical"
:key="categoryType"
v-for="(categories, categoryType) in allPrimaryCategories"
v-show="categories && categories.length"
>
<f7-list-item divider :title="getTransactionTypeName(getTransactionTypeFromCategoryType(categoryType), 'Type')"></f7-list-item>
<f7-list-item accordion-item
Expand Down Expand Up @@ -371,7 +375,10 @@
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="!query.accountIds"></f7-icon>
</template>
</f7-list-item>
<f7-list-item :class="{ 'list-item-selected': query.accountIds && queryAllFilterAccountIdsCount > 1 }" :title="$t('Multiple Accounts')" @click="filterMultipleAccounts()">
<f7-list-item :class="{ 'list-item-selected': query.accountIds && queryAllFilterAccountIdsCount > 1 }"
:title="$t('Multiple Accounts')"
@click="filterMultipleAccounts()"
v-if="allAvailableAccountsCount > 0">
<template #media>
<f7-icon f7="rectangle_on_rectangle"></f7-icon>
</template>
Expand Down Expand Up @@ -657,6 +664,9 @@ export default {
allAccounts() {
return this.accountsStore.allAccountsMap;
},
allAvailableAccountsCount() {
return this.accountsStore.allAvailableAccountsCount;
},
allCategories() {
return this.transactionCategoriesStore.allTransactionCategoriesMap;
},
Expand All @@ -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;
},
Expand Down

0 comments on commit 157eb14

Please sign in to comment.