Skip to content

Commit

Permalink
Clearer feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
droberts-ctrlo committed Dec 6, 2024
1 parent 041ba36 commit 73fd8a5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/frontend/components/form-group/autosave/lib/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class AutosaveModal extends AutosaveBase {
$modal.find('.btn-js-restore-values').on('click', async (e) => {
e.preventDefault();

let errored = false;

let $list = $("<ul></ul>");
const $body = $modal.find(".modal-body");
$body.html("<p>Restoring values...</p>").append($list);
Expand All @@ -32,9 +34,10 @@ class AutosaveModal extends AutosaveBase {
const $li = $(`<li class="li-error">Failed to restore ${name}<ul><li class="warning">${e.message}</li></ul></li>`);
console.error(e);
$list.append($li);
errored = true;
});
})).then(() => {
$body.append("<p>All values restored.</p>");
$body.append(`<p>${errored ? "Values restored with errors." : "All values restored."} Please check that all field values are as expected.</p>`);
}).catch(e => {
$body.append(`<div class="alert alert-danger"><h4>Critical error restoring values</h4><p>${e}</p></div>`);
}).finally(() => {
Expand Down

0 comments on commit 73fd8a5

Please sign in to comment.