/**
* A confirm dialog box.
* <p>Part of the XUI module which, for now, has an undocumented API.
*/
export class Confirm extends Alert {
static showConfirm(question, reference=null) {
return new Promise((resolve, reject) => {
let dialog = new Confirm(question, resolve);
dialog.open("center", reference);
});
}
constructor(question, resolve) {
super("confirm", question,
{ buttons: [ { label: "Cancel", action: "cancelAction" },
{ label: "OK", action: "okAction" } ] });
this._resolve = resolve;
}
dialogClosed(result) {
if (result === null) { // Close button clicked.
result = false;
}
this._resolve(result);
}
cancelAction() {
this.close(false);
}
okAction() {
this.close(true);
}
}