allow pressing ESC or clicking outside to close add dialog when nothing is modified

This commit is contained in:
MaysWind
2025-03-31 00:00:16 +08:00
parent 433a225b9d
commit 0a5f8862ad
12 changed files with 106 additions and 17 deletions
+37
View File
@@ -81,6 +81,43 @@ export class Account implements AccountInfoResponse {
return !this.visible;
}
public equals(other: Account): boolean {
const isEqual = this.id === other.id &&
this.name === other.name &&
this.parentId === other.parentId &&
this.category === other.category &&
this.type === other.type &&
this.icon === other.icon &&
this.color === other.color &&
this.currency === other.currency &&
this.balance === other.balance &&
this.balanceTime === other.balanceTime &&
this.comment === other.comment &&
this.displayOrder === other.displayOrder &&
this.visible === other.visible &&
this.creditCardStatementDate === other.creditCardStatementDate;
if (!isEqual) {
return false;
}
if (this.subAccounts && other.subAccounts) {
if (this.subAccounts.length !== other.subAccounts.length) {
return false;
}
for (let i = 0; i < this.subAccounts.length; i++) {
if (!this.subAccounts[i].equals(other.subAccounts[i])) {
return false;
}
}
} else if ((this.subAccounts && this.subAccounts.length) || (other.subAccounts && other.subAccounts.length)) {
return false;
}
return true;
}
public fillFrom(other: Account): void {
this.id = other.id;
this.category = other.category;
+32
View File
@@ -37,6 +37,38 @@ export class TransactionCategory implements TransactionCategoryInfoResponse {
return !this.visible;
}
public equals(other: TransactionCategory): boolean {
const isEqual = this.id === other.id &&
this.name === other.name &&
this.parentId === other.parentId &&
this.type === other.type &&
this.icon === other.icon &&
this.color === other.color &&
this.comment === other.comment &&
this.displayOrder === other.displayOrder &&
this.visible === other.visible;
if (!isEqual) {
return false;
}
if (this.subCategories && other.subCategories) {
if (this.subCategories.length !== other.subCategories.length) {
return false;
}
for (let i = 0; i < this.subCategories.length; i++) {
if (!this.subCategories[i].equals(other.subCategories[i])) {
return false;
}
}
} else if ((this.subCategories && this.subCategories.length) || (other.subCategories && other.subCategories.length)) {
return false;
}
return true;
}
public fillFrom(other: TransactionCategory): void {
this.id = other.id;
this.name = other.name;