From a905079abcbe08d8e92233f4d88e7d451ba18c6a Mon Sep 17 00:00:00 2001 From: Ruben Carlo Benante Date: Fri, 10 Jul 2026 18:06:24 -0300 Subject: [PATCH] board card title click opens the edit modal --- Asset/js/title-click-edit.js | 36 +++++++++++++++++++++++++++++++++ Controller/ConfigController.php | 3 +++ Plugin.php | 11 ++++++++++ Template/board/title_edit.php | 3 +++ Template/config/show.php | 3 +++ 5 files changed, 56 insertions(+) create mode 100644 Asset/js/title-click-edit.js create mode 100644 Template/board/title_edit.php diff --git a/Asset/js/title-click-edit.js b/Asset/js/title-click-edit.js new file mode 100644 index 0000000..2ac8e5c --- /dev/null +++ b/Asset/js/title-click-edit.js @@ -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); +})(); diff --git a/Controller/ConfigController.php b/Controller/ConfigController.php index 1039497..7ca854e 100644 --- a/Controller/ConfigController.php +++ b/Controller/ConfigController.php @@ -23,6 +23,7 @@ class ConfigController extends BaseController 'organon_tweaks_month_filters' => (int) $this->configModel->get('organon_tweaks_month_filters', 1), 'organon_tweaks_recurring_filters' => (int) $this->configModel->get('organon_tweaks_recurring_filters', 1), 'organon_tweaks_shortcut_labels' => (int) $this->configModel->get('organon_tweaks_shortcut_labels', 1), + 'organon_tweaks_title_click_edit' => (int) $this->configModel->get('organon_tweaks_title_click_edit', 1), ), 'errors' => array(), ))); @@ -41,6 +42,7 @@ class ConfigController extends BaseController $monthFilters = isset($values['organon_tweaks_month_filters']) ? 1 : 0; $recurringFilters = isset($values['organon_tweaks_recurring_filters']) ? 1 : 0; $shortcutLabels = isset($values['organon_tweaks_shortcut_labels']) ? 1 : 0; + $titleClickEdit = isset($values['organon_tweaks_title_click_edit']) ? 1 : 0; if ($this->configModel->save(array( 'organon_tweaks_always_comment_icon' => $alwaysCommentIcon, @@ -52,6 +54,7 @@ class ConfigController extends BaseController 'organon_tweaks_month_filters' => $monthFilters, 'organon_tweaks_recurring_filters' => $recurringFilters, 'organon_tweaks_shortcut_labels' => $shortcutLabels, + 'organon_tweaks_title_click_edit' => $titleClickEdit, ))) { $this->flash->success(t('Settings saved successfully.')); } else { diff --git a/Plugin.php b/Plugin.php index 78cbde1..c5e752b 100644 --- a/Plugin.php +++ b/Plugin.php @@ -66,6 +66,17 @@ class Plugin extends Base )); } + // Tweak: clicking a task title opens the edit modal (instead of the read-only card view). + // JS reuses Kanboard's own modal opener. On the board the title is a link, so a hidden marker + // (rendered by the hook below, only when the user may edit) carries the server-generated edit + // URL for the JS to open; on the card view the JS reads #task-view's data-edit-url. + if ((int) $this->configModel->get('organon_tweaks_title_click_edit', 1) === 1) { + $this->hook->on('template:layout:js', array( + 'template' => 'plugins/OrganonTweaks/Asset/js/title-click-edit.js', + )); + $this->template->hook->attach('template:board:private:task:before-title', 'organonTweaks:board/title_edit'); + } + // Auto-managed shared custom filters (v1.5 "Show all tasks", v1.6 month filters, v1.7 // recurring filters). Ensured lazily whenever a project header renders (covers old + new // boards); each group is gated by its own config toggle inside diff --git a/Template/board/title_edit.php b/Template/board/title_edit.php new file mode 100644 index 0000000..14ed091 --- /dev/null +++ b/Template/board/title_edit.php @@ -0,0 +1,3 @@ +user->hasProjectAccess('TaskModificationController', 'edit', $task['project_id'])): ?> + + diff --git a/Template/config/show.php b/Template/config/show.php index e0d11e5..0dd89d6 100644 --- a/Template/config/show.php +++ b/Template/config/show.php @@ -54,6 +54,9 @@ form->checkbox('organon_tweaks_shortcut_labels', t('Show keyboard shortcuts on the task menu'), 1, isset($values['organon_tweaks_shortcut_labels']) && $values['organon_tweaks_shortcut_labels'] == 1) ?>

+ + form->checkbox('organon_tweaks_title_click_edit', t('Clicking a task title opens the edit form'), 1, isset($values['organon_tweaks_title_click_edit']) && $values['organon_tweaks_title_click_edit'] == 1) ?> +