Skip to content

Commit

Permalink
Merge pull request #111 from DDMAL/validation-fix
Browse files Browse the repository at this point in the history
Make validation status global
  • Loading branch information
yinanazhou authored Jul 11, 2024
2 parents 204cfbe + 7734680 commit 2d2001a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Editor/CressTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class CressTable {
.then(([isValid, errorMsg]) => {
this.meiTools.updateMeiData(mei.row, mei.mei, isValid, errorMsg);
this.table.render();
this.meiTools.setResultStatus(isValid);
this.meiTools.setResultStatus();
});
});
} else {
Expand All @@ -181,7 +181,7 @@ export class CressTable {
.then(([isValid, errorMsg]) => {
this.meiTools.updateMeiData(row, undefined, isValid, errorMsg);
this.table.render();
this.meiTools.setResultStatus(isValid);
this.meiTools.setResultStatus();
});
}
});
Expand Down
10 changes: 5 additions & 5 deletions src/Editor/MeiTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export class MeiTools {
private meiData: MeiData;
public validationInProgress = false;
public pendingValidations = 0;
public hasInvalid = false;

constructor() {
this.meiData = [];
Expand Down Expand Up @@ -70,13 +69,14 @@ export class MeiTools {
if (value) this.pendingValidations++;
}

public setResultStatus(isValid: boolean) {
if (!isValid) this.hasInvalid = true;
public setResultStatus() {
this.pendingValidations--;
if (this.pendingValidations === 0) {
this.validationInProgress = false;
updateStatus('done', this.hasInvalid);
this.hasInvalid = false;
const hasInvalid = this.meiData.some(
(element) => element.isValid === false,
);
updateStatus('done', hasInvalid);
}
}

Expand Down

0 comments on commit 2d2001a

Please sign in to comment.