add Save & Close button on the task edit form v1.8 t2
This commit is contained in:
39
Asset/js/save-close.js
Normal file
39
Asset/js/save-close.js
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* OrganonTweaks -- the "Save & Close" button on the task edit form. It is a plain type=button (so it
|
||||
* never becomes the Enter default -- Enter still triggers the core Save), and on click it repoints
|
||||
* the form to the plugin's TaskSaveCloseController and lets Kanboard's own modal submit it. Kanboard
|
||||
* keeps ownership of the POST, CSRF, error re-render, and the X-Ajax-Redirect navigation; we only
|
||||
* change the destination, so the controller redirects to the board instead of the card view.
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
document.addEventListener("click", function (e) {
|
||||
if (!e.target || !e.target.closest) {
|
||||
return;
|
||||
}
|
||||
|
||||
var btn = e.target.closest("[data-organon-save-close]");
|
||||
if (!btn) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
var form = btn.closest("form");
|
||||
var url = btn.getAttribute("data-url");
|
||||
if (!form || !url) {
|
||||
return;
|
||||
}
|
||||
|
||||
form.setAttribute("action", url);
|
||||
|
||||
if (window.KB && KB.modal && KB.modal.isOpen && KB.modal.isOpen() && KB.modal.submitForm) {
|
||||
KB.modal.submitForm();
|
||||
} else if (form.requestSubmit) {
|
||||
form.requestSubmit();
|
||||
} else {
|
||||
form.submit();
|
||||
}
|
||||
}, false);
|
||||
})();
|
||||
Reference in New Issue
Block a user