support hiding/unhiding/deleting sub-account in account list page

This commit is contained in:
MaysWind
2025-04-13 20:46:06 +08:00
parent 68b08c1e8a
commit df31be61e8
15 changed files with 329 additions and 32 deletions
+64
View File
@@ -240,6 +240,30 @@ export class Account implements AccountInfoResponse {
}
}
public isAccountOrSubAccountHidden(subAccountId: string): boolean {
if (this.type === AccountType.SingleAccount.type) {
return this.hidden;
} else if (this.type === AccountType.MultiSubAccounts.type && !subAccountId) {
return this.hidden;
} else if (this.type === AccountType.MultiSubAccounts.type && subAccountId) {
if (!this.subAccounts || !this.subAccounts.length) {
return false;
}
for (let i = 0; i < this.subAccounts.length; i++) {
const subAccount = this.subAccounts[i];
if (subAccountId && subAccountId === subAccount.id) {
return subAccount.hidden;
}
}
return false;
} else {
return false;
}
}
public getAccountOrSubAccountComment(subAccountId: string): string | null {
if (this.type === AccountType.SingleAccount.type) {
return this.comment;
@@ -264,6 +288,46 @@ export class Account implements AccountInfoResponse {
}
}
public getAccountOrSubAccount(subAccountId: string): Account | null {
if (this.type === AccountType.SingleAccount.type) {
return this;
} else if (this.type === AccountType.MultiSubAccounts.type && !subAccountId) {
return this;
} else if (this.type === AccountType.MultiSubAccounts.type && subAccountId) {
if (!this.subAccounts || !this.subAccounts.length) {
return null;
}
for (let i = 0; i < this.subAccounts.length; i++) {
const subAccount = this.subAccounts[i];
if (subAccountId && subAccountId === subAccount.id) {
return subAccount;
}
}
return null;
} else {
return null;
}
}
public getSubAccount(subAccountId: string): Account | null {
if (!this.subAccounts || !this.subAccounts.length) {
return null;
}
for (let i = 0; i < this.subAccounts.length; i++) {
const subAccount = this.subAccounts[i];
if (subAccountId && subAccountId === subAccount.id) {
return subAccount;
}
}
return null;
}
public getSubAccountCurrencies(showHidden: boolean, subAccountId: string): string[] {
if (!this.subAccounts || !this.subAccounts.length) {
return [];