From e032d5d2b4b6c2d88cf85dcc8755c9defb09e47c Mon Sep 17 00:00:00 2001 From: Ruben Carlo Benante Date: Fri, 10 Jul 2026 17:56:55 -0300 Subject: [PATCH] show existing keyboard-shortcut hints on the task Actions menu --- Asset/js/shortcut-labels.js | 42 +++++++++++++++++++++++++++++++++ Controller/ConfigController.php | 3 +++ Plugin.php | 8 +++++++ Template/config/show.php | 7 ++++++ 4 files changed, 60 insertions(+) create mode 100644 Asset/js/shortcut-labels.js diff --git a/Asset/js/shortcut-labels.js b/Asset/js/shortcut-labels.js new file mode 100644 index 0000000..81504ed --- /dev/null +++ b/Asset/js/shortcut-labels.js @@ -0,0 +1,42 @@ +/* + * OrganonTweaks -- show the keyboard shortcuts Kanboard already binds, next to the task Actions + * menu items. Display only: this adds NO key bindings, it just surfaces the existing ones (listed + * in Kanboard's own "Keyboard shortcuts" help). Items are matched by their FontAwesome icon class, + * so it is independent of the URL format (pretty vs query-string) and the interface language. + */ +(function () { + "use strict"; + + var HINTS = [ + { icon: "fa-edit", key: "e" }, // Edit the task + { icon: "fa-plus", key: "s" }, // Add a sub-task + { icon: "fa-comment-o", key: "c" }, // Add a comment + { icon: "fa-code-fork", key: "l" } // Add internal link + ]; + + function annotate() { + var sidebar = document.querySelector(".sidebar"); + if (!sidebar) { return; } + + HINTS.forEach(function (hint) { + var icon = sidebar.querySelector("li a i." + hint.icon); + if (!icon) { return; } + + var link = icon.closest("a"); + if (!link || link.querySelector(".organon-kbd")) { return; } + + var kbd = document.createElement("span"); + kbd.className = "organon-kbd"; + kbd.textContent = hint.key; + kbd.style.cssText = "margin-left:8px;padding:0 5px;border:1px solid #ccc;" + + "border-radius:3px;font-family:monospace;font-size:0.85em;color:#777;background:#f7f7f7;"; + link.appendChild(kbd); + }); + } + + if (document.readyState !== "loading") { + annotate(); + } else { + document.addEventListener("DOMContentLoaded", annotate); + } +})(); diff --git a/Controller/ConfigController.php b/Controller/ConfigController.php index 084f535..1039497 100644 --- a/Controller/ConfigController.php +++ b/Controller/ConfigController.php @@ -22,6 +22,7 @@ class ConfigController extends BaseController 'organon_tweaks_show_all_filter' => (int) $this->configModel->get('organon_tweaks_show_all_filter', 1), '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), ), 'errors' => array(), ))); @@ -39,6 +40,7 @@ class ConfigController extends BaseController $showAllFilter = isset($values['organon_tweaks_show_all_filter']) ? 1 : 0; $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; if ($this->configModel->save(array( 'organon_tweaks_always_comment_icon' => $alwaysCommentIcon, @@ -49,6 +51,7 @@ class ConfigController extends BaseController 'organon_tweaks_show_all_filter' => $showAllFilter, 'organon_tweaks_month_filters' => $monthFilters, 'organon_tweaks_recurring_filters' => $recurringFilters, + 'organon_tweaks_shortcut_labels' => $shortcutLabels, ))) { $this->flash->success(t('Settings saved successfully.')); } else { diff --git a/Plugin.php b/Plugin.php index c2547ca..78cbde1 100644 --- a/Plugin.php +++ b/Plugin.php @@ -58,6 +58,14 @@ class Plugin extends Base )); } + // Tweak: show the keyboard shortcuts Kanboard already binds next to the task Actions menu + // items (display only -- no new bindings). Done in JS since those menu
  • have no hook. + if ((int) $this->configModel->get('organon_tweaks_shortcut_labels', 1) === 1) { + $this->hook->on('template:layout:js', array( + 'template' => 'plugins/OrganonTweaks/Asset/js/shortcut-labels.js', + )); + } + // 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/config/show.php b/Template/config/show.php index 13201b7..e0d11e5 100644 --- a/Template/config/show.php +++ b/Template/config/show.php @@ -49,6 +49,13 @@

    +
    + + + 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) ?> +

    +
    +