fix: the last browser confirm() in the resources library uses the app's confirm modal
Deleting a generated image asked with the browser's own confirm(), a bare dialog that looks nothing like the rest of the app. It now goes through showConfirm like every other confirmation, with the danger styling and a Delete button. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015j4L7Eu5Jp8gVMPsXdPaZ2
This commit is contained in:
parent
5d28ebad9c
commit
055c8d121b
1 changed files with 23 additions and 19 deletions
|
|
@ -590,26 +590,30 @@
|
||||||
function deleteImage(image, tile, button) {
|
function deleteImage(image, tile, button) {
|
||||||
// Asked, because it removes the picture from every deck that used it. The
|
// Asked, because it removes the picture from every deck that used it. The
|
||||||
// deck keeps working; the figure is simply no longer there.
|
// deck keeps working; the figure is simply no longer there.
|
||||||
if (!window.confirm('Delete this image? Any resource that used it will render without it.')) return;
|
var message = 'Delete this image? Any resource that used it will render without it.';
|
||||||
button.disabled = true;
|
if (!window.showConfirm) { if (window.confirm(message)) doDelete(); return; }
|
||||||
fetch('/api/generated-images/' + encodeURIComponent(image.id), {
|
window.showConfirm(message, doDelete, { danger: true, confirmText: 'Delete' });
|
||||||
method: 'DELETE', headers: getAuthHeaders()
|
function doDelete() {
|
||||||
})
|
button.disabled = true;
|
||||||
.then(function (r) { return r.json(); })
|
fetch('/api/generated-images/' + encodeURIComponent(image.id), {
|
||||||
.then(function (data) {
|
method: 'DELETE', headers: getAuthHeaders()
|
||||||
if (!data.success) throw new Error(data.error || 'Could not delete that image');
|
|
||||||
tile.remove();
|
|
||||||
var grid = document.getElementById('mr-images-grid');
|
|
||||||
var empty = document.getElementById('mr-images-empty');
|
|
||||||
if (grid && !grid.children.length && empty) {
|
|
||||||
empty.hidden = false;
|
|
||||||
empty.textContent = 'No images yet.';
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.then(function (r) { return r.json(); })
|
||||||
button.disabled = false;
|
.then(function (data) {
|
||||||
if (typeof showToast === 'function') showToast(err.message, 'error');
|
if (!data.success) throw new Error(data.error || 'Could not delete that image');
|
||||||
});
|
tile.remove();
|
||||||
|
var grid = document.getElementById('mr-images-grid');
|
||||||
|
var empty = document.getElementById('mr-images-empty');
|
||||||
|
if (grid && !grid.children.length && empty) {
|
||||||
|
empty.hidden = false;
|
||||||
|
empty.textContent = 'No images yet.';
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
button.disabled = false;
|
||||||
|
if (typeof showToast === 'function') showToast(err.message, 'error');
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The library as last fetched. Held so searching and the Modify picker both
|
// The library as last fetched. Held so searching and the Modify picker both
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue