mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 15:37:33 +08:00
auto choose the secondary category of selected primary category when create transaction in transaction list page
This commit is contained in:
+21
-1
@@ -116,7 +116,7 @@ export function allVisibleTransactionCategories(allTransactionCategories) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
export function isCategoryIdAvailable(categories, categoryId) {
|
||||
export function isSubCategoryIdAvailable(categories, categoryId) {
|
||||
if (!categories || !categories.length) {
|
||||
return false;
|
||||
}
|
||||
@@ -144,6 +144,26 @@ export function getFirstAvailableCategoryId(categories) {
|
||||
}
|
||||
}
|
||||
|
||||
export function getFirstAvaiableSubCategoryId(categories, categoryId) {
|
||||
if (!categories || !categories.length) {
|
||||
return '';
|
||||
}
|
||||
|
||||
for (let i = 0; i < categories.length; i++) {
|
||||
if (categories[i].id !== categoryId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (categories[i].subCategories.length <= 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return categories[i].subCategories[0].id;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
export function hasAnyAvailableCategory(allVisibleTransactionCategories) {
|
||||
for (let type in allVisibleTransactionCategories) {
|
||||
if (!Object.prototype.hasOwnProperty.call(allVisibleTransactionCategories, type)) {
|
||||
|
||||
Reference in New Issue
Block a user