Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 230982dd4c |
37
Controller/ConfigController.php
Normal file
37
Controller/ConfigController.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Kanboard\Plugin\OrganonTweaks\Controller;
|
||||||
|
|
||||||
|
use Kanboard\Controller\BaseController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Settings page for the OrganonTweaks plugin: one toggle per tweak.
|
||||||
|
*/
|
||||||
|
class ConfigController extends BaseController
|
||||||
|
{
|
||||||
|
public function show()
|
||||||
|
{
|
||||||
|
$this->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')));
|
||||||
|
}
|
||||||
|
}
|
||||||
14
Plugin.php
14
Plugin.php
@@ -16,6 +16,16 @@ class Plugin extends Base
|
|||||||
$this->hook->on('template:layout:js', array(
|
$this->hook->on('template:layout:js', array(
|
||||||
'template' => 'plugins/OrganonTweaks/Asset/js/relocate.js',
|
'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()
|
public function getHelpers()
|
||||||
@@ -32,7 +42,7 @@ class Plugin extends Base
|
|||||||
|
|
||||||
public function getPluginDescription()
|
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()
|
public function getPluginAuthor()
|
||||||
@@ -42,7 +52,7 @@ class Plugin extends Base
|
|||||||
|
|
||||||
public function getPluginVersion()
|
public function getPluginVersion()
|
||||||
{
|
{
|
||||||
return '0.2.0';
|
return '0.3.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginHomepage()
|
public function getPluginHomepage()
|
||||||
|
|||||||
19
README.md
19
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
|
- Only users allowed to manage columns see it, and the controller re-checks both the
|
||||||
permission and the emptiness before deleting.
|
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
|
## Requirements
|
||||||
|
|
||||||
- Kanboard >= 1.2.0
|
- Kanboard >= 1.2.0
|
||||||
|
|||||||
14
Template/board/task_comment_icon.php
Normal file
14
Template/board/task_comment_icon.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php /*
|
||||||
|
* Rendered by the template:board:task:icons hook, inside the card icons row. When a card
|
||||||
|
* has no comments yet, Kanboard shows no comment icon at all -- so adding the first comment
|
||||||
|
* means opening the card and finding the sidebar link. This adds a comment bubble with a
|
||||||
|
* "+" that opens the same comment modal (CommentListController::show) the native count icon
|
||||||
|
* uses, so the first comment can be added straight from the board. Cards that already have
|
||||||
|
* comments render nothing here (the native count icon already shows).
|
||||||
|
*
|
||||||
|
* Only shown to users who may create a comment (CommentController::save is PROJECT_MEMBER),
|
||||||
|
* so it does not appear for read-only viewers.
|
||||||
|
*/ ?>
|
||||||
|
<?php if (empty($task['nb_comments']) && $this->user->hasProjectAccess('CommentController', 'save', $task['project_id'])): ?>
|
||||||
|
<?= $this->modal->medium('comments-o', '+', 'CommentListController', 'show', array('task_id' => $task['id']), t('Add a comment')) ?>
|
||||||
|
<?php endif ?>
|
||||||
18
Template/config/show.php
Normal file
18
Template/config/show.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<div class="page-header">
|
||||||
|
<h2><?= t('Organon Tweaks') ?></h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form method="post" action="<?= $this->url->href('ConfigController', 'save', array('plugin' => 'OrganonTweaks')) ?>" autocomplete="off">
|
||||||
|
<?= $this->form->csrf() ?>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<?= $this->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) ?>
|
||||||
|
<p class="form-help">
|
||||||
|
<?= t('Show a comment bubble with a "+" on cards that have no comments yet, so you can add the first comment straight from the board. Cards that already have comments keep showing the count as usual.') ?>
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<div class="form-actions">
|
||||||
|
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
3
Template/config/sidebar.php
Normal file
3
Template/config/sidebar.php
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<li <?= $this->app->checkMenuSelection('ConfigController', 'show', 'OrganonTweaks') ?>>
|
||||||
|
<?= $this->url->link(t('Organon Tweaks'), 'ConfigController', 'show', array('plugin' => 'OrganonTweaks')) ?>
|
||||||
|
</li>
|
||||||
Reference in New Issue
Block a user