board card title click opens the edit modal
This commit is contained in:
36
Asset/js/title-click-edit.js
Normal file
36
Asset/js/title-click-edit.js
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* OrganonTweaks -- clicking a task title opens the edit modal instead of the read-only card view,
|
||||
* reusing Kanboard's own modal opener (KB.modal.open). Board part: the title is a link, and a hidden
|
||||
* marker rendered next to it (only when the user may edit) carries the server-generated edit URL.
|
||||
*
|
||||
* A capture-phase delegated click is used so it (a) runs before Kanboard's own bubble-phase handlers,
|
||||
* (b) survives the board's AJAX re-renders without re-binding, and (c) stops both the link navigation
|
||||
* and the card's own click.
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function openEdit(url) {
|
||||
if (url && window.KB && KB.modal) {
|
||||
KB.modal.open(url, "large", false);
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("click", function (e) {
|
||||
if (!e.target || !e.target.closest) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Board card title -> open the edit modal via the per-card marker URL.
|
||||
var link = e.target.closest(".task-board-title a");
|
||||
if (link) {
|
||||
var card = link.closest(".task-board");
|
||||
var marker = card ? card.querySelector(".organon-edit-url") : null;
|
||||
if (marker) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
openEdit(marker.getAttribute("data-url"));
|
||||
}
|
||||
}
|
||||
}, true);
|
||||
})();
|
||||
Reference in New Issue
Block a user