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:
+9
-1
@@ -62,8 +62,12 @@ export function getTransactionSecondaryCategoryName(categoryId, allCategories) {
|
||||
return '';
|
||||
}
|
||||
|
||||
export function allVisibleTransactionCategories(allTransactionCategories) {
|
||||
export function allVisibleTransactionCategories(allTransactionCategories, allowCategoryTypes) {
|
||||
const ret = {};
|
||||
const hasAllowCategoryTypes = allowCategoryTypes
|
||||
&& (allowCategoryTypes[categoryConstants.allCategoryTypes.Income.toString()]
|
||||
|| allowCategoryTypes[categoryConstants.allCategoryTypes.Expense.toString()]
|
||||
|| allowCategoryTypes[categoryConstants.allCategoryTypes.Transfer.toString()]);
|
||||
|
||||
for (let key in categoryConstants.allCategoryTypes) {
|
||||
if (!Object.prototype.hasOwnProperty.call(categoryConstants.allCategoryTypes, key)) {
|
||||
@@ -76,6 +80,10 @@ export function allVisibleTransactionCategories(allTransactionCategories) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hasAllowCategoryTypes && !allowCategoryTypes[categoryType]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const allCategories = allTransactionCategories[categoryType];
|
||||
const visibleCategories = [];
|
||||
const allVisibleSubCategories = {};
|
||||
|
||||
@@ -373,6 +373,16 @@ export function objectToArray(object) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
export function arrayItemToObjectField(array, value) {
|
||||
const ret = {};
|
||||
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
ret[array[i]] = value;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
export function categorizedArrayToPlainArray(object) {
|
||||
const ret = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user