mirror of
https://github.com/itflow-org/itflow
synced 2026-11-11 07:01:16 +00:00
- Add confirm-link to 14 one-click delete/disable links (asset, contact, files, templates, logo, MFA, calendar event, disable user, cancel schedule) - confirm_modal.js treats btn-danger / btn-outline-danger as destructive - Replace per-editor window.onbeforeunload with one guard over all editors - New js/autosubmit.js replaces inline onchange in the portal; CSP back on recurring_invoices.php - Fix blank user name in disable_user audit log
28 lines
1004 B
JavaScript
28 lines
1004 B
JavaScript
/*
|
|
* ITFlow - submit a form as soon as one of its controls changes.
|
|
*
|
|
* Markup contract:
|
|
* <select name="status" data-autosubmit> ... </select>
|
|
*
|
|
* Replaces inline onchange="this.form.submit()". The client portal sends
|
|
* Content-Security-Policy: default-src 'self', which blocks inline event
|
|
* handlers outright, so any page using that pattern had to run without the
|
|
* policy. A bound listener in a same-origin file is allowed.
|
|
*
|
|
* Delegated on document, so it needs no init call and also covers markup added
|
|
* after load. requestSubmit() rather than submit(): it runs the form's own
|
|
* validation and fires the submit event, the same as pressing a submit button.
|
|
*/
|
|
document.addEventListener('change', function (e) {
|
|
const control = e.target.closest('[data-autosubmit]');
|
|
if (!control || !control.form) {
|
|
return;
|
|
}
|
|
|
|
if (typeof control.form.requestSubmit === 'function') {
|
|
control.form.requestSubmit();
|
|
} else {
|
|
control.form.submit();
|
|
}
|
|
});
|