diff --git a/Controller/ConfigController.php b/Controller/ConfigController.php new file mode 100644 index 0000000..85841f1 --- /dev/null +++ b/Controller/ConfigController.php @@ -0,0 +1,37 @@ +response->html($this->helper->layout->config('organonTweaks:config/show', array( + 'title' => t('Settings').' > '.t('Organon Tweaks'), + 'values' => array( + 'organon_tweaks_always_comment_icon' => (int) $this->configModel->get('organon_tweaks_always_comment_icon', 1), + ), + 'errors' => array(), + ))); + } + + public function save() + { + $values = $this->request->getValues(); + + $alwaysCommentIcon = isset($values['organon_tweaks_always_comment_icon']) ? 1 : 0; + + if ($this->configModel->save(array('organon_tweaks_always_comment_icon' => $alwaysCommentIcon))) { + $this->flash->success(t('Settings saved successfully.')); + } else { + $this->flash->failure(t('Unable to save your settings.')); + } + + $this->response->redirect($this->helper->url->to('ConfigController', 'show', array('plugin' => 'OrganonTweaks'))); + } +} diff --git a/Plugin.php b/Plugin.php index cf3d7cc..32a9122 100644 --- a/Plugin.php +++ b/Plugin.php @@ -16,6 +16,16 @@ class Plugin extends Base $this->hook->on('template:layout:js', array( 'template' => 'plugins/OrganonTweaks/Asset/js/relocate.js', )); + + // Settings page for the plugin's tweaks. + $this->template->hook->attach('template:config:sidebar', 'organonTweaks:config/sidebar'); + + // Tweak: always show a comment icon on board cards. When a card has no comments + // yet, add a bubble "+" that opens the same comment modal (add the first comment + // straight from the board). Cards with comments already show the native count. + if ((int) $this->configModel->get('organon_tweaks_always_comment_icon', 1) === 1) { + $this->template->hook->attach('template:board:task:icons', 'organonTweaks:board/task_comment_icon'); + } } public function getHelpers() @@ -32,7 +42,7 @@ class Plugin extends Base public function getPluginDescription() { - return t('Umbrella plugin for small Kanboard tweaks. First tweak: remove an empty board column from its header menu.'); + return t('Umbrella plugin for small Kanboard tweaks: remove an empty board column, always show the card comment icon, and more.'); } public function getPluginAuthor() @@ -42,7 +52,7 @@ class Plugin extends Base public function getPluginVersion() { - return '0.2.0'; + return '0.3.0'; } public function getPluginHomepage() diff --git a/README.md b/README.md index f813648..a904b38 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,25 @@ and returns to the board. - Only users allowed to manage columns see it, and the controller re-checks both the permission and the emptiness before deleting. +### Always show the comment icon + +Kanboard shows the comment icon on a board card only once it has at least one comment, so +adding the *first* comment means opening the card and finding the sidebar link. With this +tweak on, a card with no comments shows a comment bubble with a **"+"** that opens the same +comment modal, letting you add the first comment straight from the board. Cards that already +have comments keep showing the count as before. + +- Rendered by the `template:board:task:icons` hook (`Template/board/task_comment_icon.php`), + only when the card has no comments and the user may create one (so it does not show for + read-only viewers). +- **On by default.** Toggle it under "Settings -> Organon Tweaks". + +## Settings + +Global (per Kanboard instance) and admin-only, under "Settings -> Organon Tweaks": + +- **Always show the comment icon on board cards** -- default on. + ## Requirements - Kanboard >= 1.2.0 diff --git a/Template/board/task_comment_icon.php b/Template/board/task_comment_icon.php new file mode 100644 index 0000000..2ec0603 --- /dev/null +++ b/Template/board/task_comment_icon.php @@ -0,0 +1,14 @@ + +user->hasProjectAccess('CommentController', 'save', $task['project_id'])): ?> + modal->medium('comments-o', '+', 'CommentListController', 'show', array('task_id' => $task['id']), t('Add a comment')) ?> + diff --git a/Template/config/show.php b/Template/config/show.php new file mode 100644 index 0000000..84f995a --- /dev/null +++ b/Template/config/show.php @@ -0,0 +1,18 @@ + + +
+ form->csrf() ?> + +
+ form->checkbox('organon_tweaks_always_comment_icon', t('Always show the comment icon on board cards'), 1, isset($values['organon_tweaks_always_comment_icon']) && $values['organon_tweaks_always_comment_icon'] == 1) ?> +

+ +

+
+ +
+ +
+
diff --git a/Template/config/sidebar.php b/Template/config/sidebar.php new file mode 100644 index 0000000..f6ebcad --- /dev/null +++ b/Template/config/sidebar.php @@ -0,0 +1,3 @@ +
  • app->checkMenuSelection('ConfigController', 'show', 'OrganonTweaks') ?>> + url->link(t('Organon Tweaks'), 'ConfigController', 'show', array('plugin' => 'OrganonTweaks')) ?> +
  • diff --git a/VERSION b/VERSION index 94d14f6..ed666ee 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -OrganonTweaks v0.2 +OrganonTweaks v0.3