mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 23:47:33 +08:00
only show categories with specified type in category filter dialog / page
This commit is contained in:
@@ -130,7 +130,7 @@ import { useTransactionsStore } from '@/stores/transaction.js';
|
||||
import { useStatisticsStore } from '@/stores/statistics.js';
|
||||
|
||||
import categoryConstants from '@/consts/category.js';
|
||||
import { copyObjectTo } from '@/lib/common.js';
|
||||
import { copyObjectTo, arrayItemToObjectField } from '@/lib/common.js';
|
||||
import {
|
||||
allVisibleTransactionCategories,
|
||||
hasAnyAvailableCategory,
|
||||
@@ -156,6 +156,7 @@ export default {
|
||||
loading: true,
|
||||
loadingError: null,
|
||||
type: null,
|
||||
allowCategoryTypes: null,
|
||||
filterCategoryIds: {},
|
||||
collapseStates: self.getCollapseStates(),
|
||||
showMoreActionSheet: false
|
||||
@@ -178,7 +179,7 @@ export default {
|
||||
}
|
||||
},
|
||||
allVisibleTransactionCategories() {
|
||||
return allVisibleTransactionCategories(this.transactionCategoriesStore.allTransactionCategories);
|
||||
return allVisibleTransactionCategories(this.transactionCategoriesStore.allTransactionCategories, this.allowCategoryTypes);
|
||||
},
|
||||
hasAnyAvailableCategory() {
|
||||
return hasAnyAvailableCategory(this.allVisibleTransactionCategories);
|
||||
@@ -192,6 +193,7 @@ export default {
|
||||
const query = self.f7route.query;
|
||||
|
||||
self.type = query.type;
|
||||
self.allowCategoryTypes = query.allowCategoryTypes ? arrayItemToObjectField(query.allowCategoryTypes.split(','), true) : null;
|
||||
|
||||
self.transactionCategoriesStore.loadAllCategories({
|
||||
force: false
|
||||
@@ -207,6 +209,10 @@ export default {
|
||||
|
||||
const category = self.transactionCategoriesStore.allTransactionCategoriesMap[categoryId];
|
||||
|
||||
if (self.allowCategoryTypes && !self.allowCategoryTypes[category.type]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.type === 'transactionListCurrent' && self.transactionsStore.allFilterCategoryIdsCount > 0) {
|
||||
allCategoryIds[category.id] = true;
|
||||
} else {
|
||||
|
||||
@@ -906,7 +906,13 @@ export default {
|
||||
}
|
||||
},
|
||||
filterMultipleCategories() {
|
||||
this.f7router.navigate('/settings/filter/category?type=transactionListCurrent');
|
||||
let navigateUrl = '/settings/filter/category?type=transactionListCurrent';
|
||||
|
||||
if (this.allTransactionTypes.Income <= this.query.type && this.query.type <= this.allTransactionTypes.Transfer) {
|
||||
navigateUrl += '&allowCategoryTypes=' + transactionTypeToCategoryType(this.query.type);
|
||||
}
|
||||
|
||||
this.f7router.navigate(navigateUrl);
|
||||
},
|
||||
filterMultipleAccounts() {
|
||||
this.f7router.navigate('/settings/filter/account?type=transactionListCurrent');
|
||||
|
||||
Reference in New Issue
Block a user