add search box in filter account page / dialog

This commit is contained in:
MaysWind
2025-12-14 17:41:50 +08:00
parent aebd65449b
commit e825323bb0
22 changed files with 180 additions and 218 deletions
@@ -7,10 +7,10 @@ import { useStatisticsStore } from '@/stores/statistics.ts';
import { useOverviewStore } from '@/stores/overview.ts';
import { keys, keysIfValueEquals, values } from '@/core/base.ts';
import type { Account, AccountCategoriesWithVisibleCount } from '@/models/account.ts';
import type {Account, CategorizedAccount} from '@/models/account.ts';
import {
getCategorizedAccountsWithVisibleCount,
filterCategorizedAccounts,
selectAccountOrSubAccounts,
isAccountOrSubAccountsAllChecked
} from '@/lib/account.ts';
@@ -26,6 +26,7 @@ export function useAccountFilterSettingPageBase(type?: AccountFilterType) {
const loading = ref<boolean>(true);
const showHidden = ref<boolean>(false);
const filterContent = ref<string>('');
const filterAccountIds = ref<Record<string, boolean>>({});
const title = computed<string>(() => {
@@ -48,15 +49,33 @@ export function useAccountFilterSettingPageBase(type?: AccountFilterType) {
return type === 'statisticsDefault' || type === 'statisticsCurrent' || type === 'homePageOverview' || type === 'transactionListCurrent';
});
const allCategorizedAccounts = computed<AccountCategoriesWithVisibleCount[]>(() => getCategorizedAccountsWithVisibleCount(accountsStore.allCategorizedAccountsMap));
const hasAnyAvailableAccount = computed<boolean>(() => accountsStore.allAvailableAccountsCount > 0);
const allCategorizedAccounts = computed<Record<number, CategorizedAccount>>(() => filterCategorizedAccounts(accountsStore.allCategorizedAccountsMap, filterContent.value, showHidden.value));
const allVisibleAccountMap = computed<Record<string, Account>>(() => {
const accountMap: Record<string, Account> = {};
const hasAnyVisibleAccount = computed<boolean>(() => {
if (showHidden.value) {
return accountsStore.allAvailableAccountsCount > 0;
} else {
return accountsStore.allVisibleAccountsCount > 0;
for (const accountCategory of values(allCategorizedAccounts.value)) {
for (const account of accountCategory.accounts) {
accountMap[account.id] = account;
if (account.subAccounts) {
for (const subAccount of account.subAccounts) {
accountMap[subAccount.id] = subAccount;
}
}
}
}
return accountMap;
});
const hasAnyAvailableAccount = computed<boolean>(() => accountsStore.allAvailableAccountsCount > 0);
const hasAnyVisibleAccount = computed<boolean>(() => {
for (const accountCategory of values(allCategorizedAccounts.value)) {
if (accountCategory.accounts.length > 0) {
return true;
}
}
return false;
});
function isAccountChecked(account: Account, filterAccountIds: Record<string, boolean>): boolean {
@@ -162,12 +181,14 @@ export function useAccountFilterSettingPageBase(type?: AccountFilterType) {
// states
loading,
showHidden,
filterContent,
filterAccountIds,
// computed states
title,
applyText,
allowHiddenAccount,
allCategorizedAccounts,
allVisibleAccountMap,
hasAnyAvailableAccount,
hasAnyVisibleAccount,
// functions