fix the filter dropdown menu not display the selected items after selecting multiple hidden transaction categories or accounts

This commit is contained in:
MaysWind
2025-12-14 00:43:38 +08:00
parent b2fab42170
commit a12038e40c
4 changed files with 27 additions and 9 deletions
+2 -1
View File
@@ -440,7 +440,8 @@ html[dir="rtl"] i.icon.icon-with-direction {
font-weight: bold;
}
.list > ul > li.item-in-multiple-selection > .item-content > .item-inner > .item-title {
.list > ul > li.item-in-multiple-selection > .item-content > .item-inner > .item-title,
.list > ul > li.item-in-multiple-selection > .item-link > .item-content > .item-inner > .item-title {
font-weight: bold;
}
@@ -270,6 +270,20 @@ export function useTransactionListPageBase() {
return true;
});
function hasSubCategoryInQuery(category: TransactionCategory): boolean {
if (!category.subCategories || !category.subCategories.length) {
return false;
}
for (const subCategory of category.subCategories) {
if (queryAllFilterCategoryIds.value[subCategory.id]) {
return true;
}
}
return false;
}
function formatAmount(amount: number, hideAmount: boolean, currencyCode: string): string {
if (hideAmount) {
return formatAmountToLocalizedNumeralsWithCurrency(DISPLAY_HIDDEN_AMOUNT, currencyCode);
@@ -395,6 +409,7 @@ export function useTransactionListPageBase() {
currentMonthTransactionData,
canAddTransaction,
// functions
hasSubCategoryInQuery,
getDisplayTime,
getDisplayLongDate,
getDisplayLongYearMonth,
+6 -5
View File
@@ -266,7 +266,7 @@
</v-list-item>
<v-list-group :key="category.id" v-for="category in categories">
<template #activator="{ props }" v-if="!category.hidden || query.categoryIds === category.id || (allCategories[query.categoryIds] && allCategories[query.categoryIds]!.parentId === category.id)">
<template #activator="{ props }" v-if="!category.hidden || queryAllFilterCategoryIds[category.id] || allCategories[query.categoryIds]?.parentId === category.id || hasSubCategoryInQuery(category)">
<v-divider />
<v-list-item class="text-sm" density="compact"
:class="getCategoryListItemCheckedClass(category, queryAllFilterCategoryIds)"
@@ -296,12 +296,12 @@
<template :key="subCategory.id"
v-for="subCategory in category.subCategories">
<v-divider v-if="!subCategory.hidden || query.categoryIds === subCategory.id" />
<v-divider v-if="!subCategory.hidden || queryAllFilterCategoryIds[subCategory.id]" />
<v-list-item class="text-sm" density="compact"
:value="subCategory.id"
:class="{ 'list-item-selected': query.categoryIds === subCategory.id, 'item-in-multiple-selection': queryAllFilterCategoryIdsCount > 1 && queryAllFilterCategoryIds[subCategory.id] }"
:append-icon="(query.categoryIds === subCategory.id ? mdiCheck : undefined)"
v-if="!subCategory.hidden || query.categoryIds === subCategory.id">
v-if="!subCategory.hidden || queryAllFilterCategoryIds[subCategory.id]">
<v-list-item-title class="cursor-pointer"
@click="changeCategoryFilter(subCategory.id)">
<div class="d-flex align-center">
@@ -407,12 +407,12 @@
</v-list-item>
<template :key="account.id"
v-for="account in allAccounts">
<v-divider v-if="(!account.hidden && (!allAccountsMap[account.parentId] || !allAccountsMap[account.parentId]!.hidden)) || query.accountIds === account.id" />
<v-divider v-if="(!account.hidden && (!allAccountsMap[account.parentId] || !allAccountsMap[account.parentId]!.hidden)) || queryAllFilterAccountIds[account.id]" />
<v-list-item class="text-sm" density="compact"
:value="account.id"
:class="{ 'list-item-selected': query.accountIds === account.id, 'item-in-multiple-selection': queryAllFilterAccountIdsCount > 1 && queryAllFilterAccountIds[account.id] }"
:append-icon="(query.accountIds === account.id ? mdiCheck : undefined)"
v-if="(!account.hidden && (!allAccountsMap[account.parentId] || !allAccountsMap[account.parentId]!.hidden)) || query.accountIds === account.id">
v-if="(!account.hidden && (!allAccountsMap[account.parentId] || !allAccountsMap[account.parentId]!.hidden)) || queryAllFilterAccountIds[account.id]">
<v-list-item-title class="cursor-pointer"
@click="changeAccountFilter(account.id)">
<div class="d-flex align-center">
@@ -809,6 +809,7 @@ const {
transactionCalendarMinDate,
transactionCalendarMaxDate,
currentMonthTransactionData,
hasSubCategoryInQuery,
canAddTransaction,
getDisplayTime,
getDisplayLongDate,
+4 -3
View File
@@ -377,7 +377,7 @@
:class="getCategoryListItemCheckedClass(category, queryAllFilterCategoryIds)"
:key="category.id"
v-for="category in categories"
v-show="!category.hidden || query.categoryIds === category.id || (allCategories[query.categoryIds] && allCategories[query.categoryIds]?.parentId === category.id)"
v-show="!category.hidden || queryAllFilterCategoryIds[category.id] || allCategories[query.categoryIds]?.parentId === category.id || hasSubCategoryInQuery(category)"
>
<template #media>
<ItemIcon icon-type="category" :icon-id="category.icon" :color="category.color"></ItemIcon>
@@ -399,7 +399,7 @@
:title="subCategory.name"
:key="subCategory.id"
v-for="subCategory in category.subCategories"
v-show="!subCategory.hidden || query.categoryIds === subCategory.id"
v-show="!subCategory.hidden || queryAllFilterCategoryIds[subCategory.id]"
@click="changeCategoryFilter(subCategory.id)"
>
<template #media>
@@ -448,7 +448,7 @@
:title="account.name"
:key="account.id"
v-for="account in allAccounts"
v-show="(!account.hidden && (!allAccountsMap[account.parentId] || !allAccountsMap[account.parentId]!.hidden)) || query.accountIds === account.id"
v-show="(!account.hidden && (!allAccountsMap[account.parentId] || !allAccountsMap[account.parentId]!.hidden)) || queryAllFilterAccountIds[account.id]"
@click="changeAccountFilter(account.id)"
>
<template #media>
@@ -712,6 +712,7 @@ const {
transactionCalendarMinDate,
transactionCalendarMaxDate,
currentMonthTransactionData,
hasSubCategoryInQuery,
canAddTransaction,
getDisplayTime,
getDisplayLongYearMonth,