fix(ux): extend nordaConfirm to support callback mode for AJAX actions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
nordaConfirm now accepts both (form, message, options) for form submission and (message, callback, options) for AJAX-based confirmations like guest deletion. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
4f07acb051
commit
e0fbd8ce9a
@ -2670,12 +2670,30 @@
|
||||
var overlay = document.getElementById('nordaConfirmOverlay');
|
||||
var pendingForm = null;
|
||||
|
||||
window.nordaConfirm = function(form, message, options) {
|
||||
options = options || {};
|
||||
pendingForm = form;
|
||||
var pendingCallback = null;
|
||||
|
||||
window.nordaConfirm = function(formOrMessage, messageOrOptions, options) {
|
||||
// Support two signatures:
|
||||
// nordaConfirm(form, message, options) — form submission
|
||||
// nordaConfirm(message, callback, options) — callback-based
|
||||
if (typeof formOrMessage === 'string') {
|
||||
// Callback mode: nordaConfirm('message', callback, options)
|
||||
pendingForm = null;
|
||||
pendingCallback = typeof messageOrOptions === 'function' ? messageOrOptions : null;
|
||||
options = options || {};
|
||||
document.getElementById('nordaConfirmMessage').innerHTML = formOrMessage;
|
||||
} else {
|
||||
// Form mode: nordaConfirm(form, message, options)
|
||||
pendingForm = formOrMessage;
|
||||
pendingCallback = null;
|
||||
options = messageOrOptions || {};
|
||||
document.getElementById('nordaConfirmMessage').innerHTML = messageOrOptions;
|
||||
// Fix: options is third arg in form mode
|
||||
options = arguments[2] || {};
|
||||
document.getElementById('nordaConfirmMessage').innerHTML = arguments[1];
|
||||
}
|
||||
document.getElementById('nordaConfirmIcon').textContent = options.icon || '⚠️';
|
||||
document.getElementById('nordaConfirmTitle').textContent = options.title || 'Potwierdzenie';
|
||||
document.getElementById('nordaConfirmMessage').innerHTML = message;
|
||||
var okBtn = document.getElementById('nordaConfirmOk');
|
||||
okBtn.textContent = options.okText || 'Potwierdź';
|
||||
okBtn.style.background = options.danger !== false ? '#dc2626' : 'var(--primary, #2E4872)';
|
||||
@ -2685,14 +2703,16 @@
|
||||
|
||||
document.getElementById('nordaConfirmOk').addEventListener('click', function() {
|
||||
overlay.style.display = 'none';
|
||||
if (pendingForm) { pendingForm.submit(); pendingForm = null; }
|
||||
if (pendingCallback) { pendingCallback(); pendingCallback = null; }
|
||||
else if (pendingForm) { pendingForm.submit(); pendingForm = null; }
|
||||
});
|
||||
document.getElementById('nordaConfirmCancel').addEventListener('click', function() {
|
||||
overlay.style.display = 'none';
|
||||
pendingForm = null;
|
||||
pendingCallback = null;
|
||||
});
|
||||
overlay.addEventListener('click', function(e) {
|
||||
if (e.target === overlay) { overlay.style.display = 'none'; pendingForm = null; }
|
||||
if (e.target === overlay) { overlay.style.display = 'none'; pendingForm = null; pendingCallback = null; }
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
@ -847,8 +847,9 @@ async function submitGuest() {
|
||||
}
|
||||
|
||||
async function deleteGuest(guestId) {
|
||||
if (!confirm('Czy na pewno chcesz usunąć tę osobę towarzyszącą?')) return;
|
||||
await doDeleteGuest(guestId);
|
||||
nordaConfirm('Czy na pewno chcesz usunąć tę osobę towarzyszącą?', function() {
|
||||
doDeleteGuest(guestId);
|
||||
});
|
||||
}
|
||||
|
||||
async function doDeleteGuest(guestId) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user