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;