mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-16 07:57:33 +08:00
add search box in filter account page / dialog
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user