mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-18 00:34:28 +08:00
add insights & explore page
This commit is contained in:
@@ -15,9 +15,9 @@ import {
|
||||
isAccountOrSubAccountsAllChecked
|
||||
} from '@/lib/account.ts';
|
||||
|
||||
export type AccountFilterType = 'statisticsDefault' | 'statisticsCurrent' | 'homePageOverview' | 'transactionListCurrent' | 'accountListTotalAmount';
|
||||
export type AccountFilterType = 'statisticsDefault' | 'statisticsCurrent' | 'homePageOverview' | 'transactionListCurrent' | 'accountListTotalAmount' | 'custom';
|
||||
|
||||
export function useAccountFilterSettingPageBase(type?: AccountFilterType) {
|
||||
export function useAccountFilterSettingPageBase(type?: AccountFilterType, selectedAccountIds?: string[]) {
|
||||
const settingsStore = useSettingsStore();
|
||||
const accountsStore = useAccountsStore();
|
||||
const transactionsStore = useTransactionsStore();
|
||||
@@ -46,7 +46,7 @@ export function useAccountFilterSettingPageBase(type?: AccountFilterType) {
|
||||
});
|
||||
|
||||
const allowHiddenAccount = computed<boolean>(() => {
|
||||
return type === 'statisticsDefault' || type === 'statisticsCurrent' || type === 'homePageOverview' || type === 'transactionListCurrent';
|
||||
return type === 'statisticsDefault' || type === 'statisticsCurrent' || type === 'homePageOverview' || type === 'transactionListCurrent' || type === 'custom';
|
||||
});
|
||||
|
||||
const allCategorizedAccounts = computed<Record<number, CategorizedAccount>>(() => filterCategorizedAccounts(accountsStore.allCategorizedAccountsMap, filterContent.value, showHidden.value));
|
||||
@@ -92,6 +92,8 @@ export function useAccountFilterSettingPageBase(type?: AccountFilterType) {
|
||||
|
||||
if (type === 'transactionListCurrent' && transactionsStore.allFilterAccountIdsCount > 0) {
|
||||
allAccountIds[account.id] = true;
|
||||
} else if (type === 'custom') {
|
||||
allAccountIds[account.id] = true;
|
||||
} else {
|
||||
allAccountIds[account.id] = false;
|
||||
}
|
||||
@@ -119,12 +121,26 @@ export function useAccountFilterSettingPageBase(type?: AccountFilterType) {
|
||||
} else if (type === 'accountListTotalAmount') {
|
||||
filterAccountIds.value = Object.assign(allAccountIds, settingsStore.appSettings.totalAmountExcludeAccountIds);
|
||||
return true;
|
||||
} else if (type === 'custom') {
|
||||
if (selectedAccountIds) {
|
||||
for (const accountId of selectedAccountIds) {
|
||||
const account = accountsStore.allAccountsMap[accountId];
|
||||
|
||||
if (account) {
|
||||
selectAccountOrSubAccounts(allAccountIds, account, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
filterAccountIds.value = allAccountIds;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function saveFilterAccountIds(): boolean {
|
||||
function saveFilterAccountIds(): [boolean, string[]] {
|
||||
const selectedAccountIds: string[] = [];
|
||||
const filteredAccountIds: Record<string, boolean> = {};
|
||||
let isAllSelected = true;
|
||||
let finalAccountIds = '';
|
||||
@@ -150,6 +166,7 @@ export function useAccountFilterSettingPageBase(type?: AccountFilterType) {
|
||||
}
|
||||
|
||||
finalAccountIds += accountId;
|
||||
selectedAccountIds.push(accountId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +191,7 @@ export function useAccountFilterSettingPageBase(type?: AccountFilterType) {
|
||||
settingsStore.setTotalAmountExcludeAccountIds(filteredAccountIds);
|
||||
}
|
||||
|
||||
return changed;
|
||||
return [changed, selectedAccountIds];
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -50,6 +50,13 @@ export const ALL_APPLICATION_CLOUD_SETTINGS: CategorizedApplicationCloudSettingI
|
||||
{ settingKey: 'alwaysShowTransactionPicturesInMobileTransactionEditPage', settingName: 'Always Show Transaction Pictures', mobile: true, desktop: false }
|
||||
]
|
||||
},
|
||||
{
|
||||
categoryName: 'Insights & Explore Page',
|
||||
items: [
|
||||
{ settingKey: 'insightsExploreDefaultDateRangeType', settingName: 'Default Date Range', mobile: false, desktop: true },
|
||||
{ settingKey: 'timezoneUsedForInsightsExplorePage', settingName: 'Timezone Used for Date Range', mobile: false, desktop: true },
|
||||
]
|
||||
},
|
||||
{
|
||||
categoryName: 'Account List Page',
|
||||
items: [
|
||||
|
||||
@@ -21,9 +21,9 @@ import {
|
||||
isCategoryOrSubCategoriesAllChecked
|
||||
} from '@/lib/category.ts';
|
||||
|
||||
export type CategoryFilterType = 'statisticsDefault' | 'statisticsCurrent' | 'homePageOverview' | 'transactionListCurrent';
|
||||
export type CategoryFilterType = 'statisticsDefault' | 'statisticsCurrent' | 'homePageOverview' | 'transactionListCurrent' | 'custom';
|
||||
|
||||
export function useCategoryFilterSettingPageBase(type?: CategoryFilterType, allowCategoryTypesStr?: string) {
|
||||
export function useCategoryFilterSettingPageBase(type?: CategoryFilterType, allowCategoryTypesStr?: string, selectedCategoryIds?: string[]) {
|
||||
const { tt } = useI18n();
|
||||
|
||||
const settingsStore = useSettingsStore();
|
||||
@@ -111,6 +111,8 @@ export function useCategoryFilterSettingPageBase(type?: CategoryFilterType, allo
|
||||
|
||||
if (type === 'transactionListCurrent' && transactionsStore.allFilterCategoryIdsCount > 0) {
|
||||
allCategoryIds[category.id] = true;
|
||||
} else if (type === 'custom') {
|
||||
allCategoryIds[category.id] = true;
|
||||
} else {
|
||||
allCategoryIds[category.id] = false;
|
||||
}
|
||||
@@ -136,6 +138,21 @@ export function useCategoryFilterSettingPageBase(type?: CategoryFilterType, allo
|
||||
}
|
||||
}
|
||||
|
||||
filterCategoryIds.value = allCategoryIds;
|
||||
return true;
|
||||
} else if (type === 'custom') {
|
||||
if (selectedCategoryIds) {
|
||||
for (const categoryId of selectedCategoryIds) {
|
||||
const category = transactionCategoriesStore.allTransactionCategoriesMap[categoryId];
|
||||
|
||||
if (category && (!category.subCategories || !category.subCategories.length)) {
|
||||
allCategoryIds[category.id] = false;
|
||||
} else if (category) {
|
||||
selectAllSubCategories(allCategoryIds, false, category);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
filterCategoryIds.value = allCategoryIds;
|
||||
return true;
|
||||
} else {
|
||||
@@ -143,7 +160,8 @@ export function useCategoryFilterSettingPageBase(type?: CategoryFilterType, allo
|
||||
}
|
||||
}
|
||||
|
||||
function saveFilterCategoryIds(): boolean {
|
||||
function saveFilterCategoryIds(): [boolean, string[]] {
|
||||
const selectedCategoryIds: string[] = [];
|
||||
const filteredCategoryIds: Record<string, boolean> = {};
|
||||
let isAllSelected = true;
|
||||
let finalCategoryIds = '';
|
||||
@@ -165,6 +183,7 @@ export function useCategoryFilterSettingPageBase(type?: CategoryFilterType, allo
|
||||
}
|
||||
|
||||
finalCategoryIds += categoryId;
|
||||
selectedCategoryIds.push(categoryId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +206,7 @@ export function useCategoryFilterSettingPageBase(type?: CategoryFilterType, allo
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
return [changed, selectedCategoryIds];
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user