Phase 114 complete (v3.7 Invoices): - /settings/accounting jako hub-rozdroze (Paragony / Faktury) - /settings/accounting/receipts + /invoices osobne podstrony list i edycji - InvoiceConfigRepository + Controller (CRUD z walidacja delegacji) - Seed Domyslny VAT (NOT EXISTS idempotent) - invoice-config-form.js (toggle is_delegated -> integration_id) - confirm-delete.js (globalny modul OrderProAlerts.confirm) - Legacy aliasy starych endpointow /settings/accounting/save|toggle|delete Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
function bind(btn) {
|
|
if (btn.dataset.confirmBound === '1') return;
|
|
btn.dataset.confirmBound = '1';
|
|
|
|
btn.addEventListener('click', function () {
|
|
var form = btn.closest('form');
|
|
if (!form) return;
|
|
|
|
var title = form.getAttribute('data-confirm-title') || 'Usun pozycje';
|
|
var message = form.getAttribute('data-confirm-message') || 'Czy na pewno chcesz usunac ten wpis?';
|
|
|
|
if (window.OrderProAlerts && typeof window.OrderProAlerts.confirm === 'function') {
|
|
var submitted = false;
|
|
var doSubmit = function () {
|
|
if (submitted) return;
|
|
submitted = true;
|
|
form.submit();
|
|
};
|
|
var result = window.OrderProAlerts.confirm({
|
|
title: title,
|
|
message: message,
|
|
danger: true,
|
|
confirmLabel: 'Usun',
|
|
onConfirm: doSubmit
|
|
});
|
|
if (result && typeof result.then === 'function') {
|
|
result.then(function (ok) { if (ok) doSubmit(); });
|
|
}
|
|
} else if (window.confirm(message)) {
|
|
form.submit();
|
|
}
|
|
});
|
|
}
|
|
|
|
function init() {
|
|
document.querySelectorAll('.js-delete-btn').forEach(bind);
|
|
}
|
|
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', init);
|
|
} else {
|
|
init();
|
|
}
|
|
})();
|