Simplify "Discard changes?" dialog
This commit is contained in:
parent
bc0f8b8046
commit
a6e329faf0
2 changed files with 5 additions and 7 deletions
|
@ -52,10 +52,8 @@ function alertAsync(message) {
|
||||||
return popup(dialog);
|
return popup(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
function confirmAsync(message) {
|
function confirmDiscard() {
|
||||||
const dialog = instantiate("confirm");
|
return popup(instantiate("confirm-discard"));
|
||||||
dialog.querySelector(".message").textContent = message;
|
|
||||||
return popup(dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let hasBeenOpen = false;
|
let hasBeenOpen = false;
|
||||||
|
@ -161,7 +159,7 @@ function openEditor() {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
|
|
||||||
Promise.resolve(!isEdited(form) || confirmAsync("Discard changes?"))
|
Promise.resolve(!isEdited(form) || confirmDiscard())
|
||||||
.then(doReset => {
|
.then(doReset => {
|
||||||
if (doReset) {
|
if (doReset) {
|
||||||
container.classList.remove('edit');
|
container.classList.remove('edit');
|
||||||
|
|
|
@ -22,10 +22,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class=prototype id=confirm>
|
<div class=prototype id=confirm-discard>
|
||||||
<div class=modal-block>
|
<div class=modal-block>
|
||||||
<div class=popup>
|
<div class=popup>
|
||||||
<div class=message></div>
|
<div class=message>Discard changes?</div>
|
||||||
<div class=btn-row>
|
<div class=btn-row>
|
||||||
<button class=primary>No</button>
|
<button class=primary>No</button>
|
||||||
<button data-value=true>Yes</button>
|
<button data-value=true>Yes</button>
|
||||||
|
|
Loading…
Reference in a new issue