feat(photos): modern confirm dialog + correct lightbox favorite state
- Add Modal.confirmDialog() (Promise<boolean>, built on openPanel so it inherits the overlay, animation, focus-trap and Escape handling) and use it to replace native confirm() in the photos batch-delete and lightbox single-delete flows. - The lightbox now reflects the real favorite state when an item opens (previously the star always started empty) and toggles favorites through the favorites module so its cache stays in sync. - Add photos.delete_* i18n keys (English; other locales fall back to en). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JW6ghFMDtnRYuYNzZhb47M
This commit is contained in:
@@ -436,6 +436,47 @@ const Modal = {
|
||||
requestAnimationFrame(() => {
|
||||
this.overlay.classList.add('active');
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Confirmation dialog (replacement for window.confirm()).
|
||||
* Built on openPanel, so it inherits the overlay, animation, focus-trap,
|
||||
* Escape and click-outside handling.
|
||||
* @param {Object} options
|
||||
* @param {string} options.title
|
||||
* @param {string} options.message
|
||||
* @param {string} [options.confirmText]
|
||||
* @param {string} [options.cancelText]
|
||||
* @param {string} [options.icon] - Font Awesome class, default 'fa-circle-question'
|
||||
* @returns {Promise<boolean>} true if confirmed, false otherwise
|
||||
*/
|
||||
confirmDialog({ title, message, confirmText = null, cancelText = null, icon = 'fa-circle-question' }) {
|
||||
return new Promise((resolve) => {
|
||||
if (!this.overlay) {
|
||||
resolve(false);
|
||||
return;
|
||||
}
|
||||
const content = document.createElement('p');
|
||||
content.className = 'modal-confirm-message';
|
||||
content.textContent = message;
|
||||
|
||||
let settled = false;
|
||||
const done = (/** @type {boolean} */ value) => {
|
||||
if (settled) return;
|
||||
settled = true;
|
||||
resolve(value);
|
||||
};
|
||||
|
||||
this.openPanel({
|
||||
title,
|
||||
icon,
|
||||
content,
|
||||
confirmText: confirmText ?? i18n.t('actions.confirm'),
|
||||
cancelText: cancelText ?? i18n.t('actions.cancel'),
|
||||
onConfirm: () => done(true),
|
||||
onCancel: () => done(false)
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user