Plugin feature 1: remove column

This commit is contained in:
2026-07-04 10:09:21 -03:00
parent 8b7b6478fd
commit 6cca6ce562
2 changed files with 39 additions and 65 deletions

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace Kanboard\Plugin\Skeleton; namespace Kanboard\Plugin\OrganonTweaks;
use Kanboard\Core\Plugin\Base; use Kanboard\Core\Plugin\Base;
@@ -8,28 +8,31 @@ class Plugin extends Base
{ {
public function initialize() public function initialize()
{ {
// 1. Render a visible word at the top of every page (the demo output). // "Remove this Column" entry in the board column header dropdown. The only
$this->template->hook->attach('template:layout:top', 'skeleton:layout/header'); // column hook renders outside the native menu <ul>, so the item is rendered
// hidden and relocate.js moves it into the menu (like BulkMoveTasks).
$this->template->hook->attach('template:board:column:dropdown', 'organonTweaks:board/column_dropdown');
// 2. Load the plugin stylesheet (currently empty -- proves the CSS hook fires).
$this->hook->on('template:layout:css', array(
'template' => 'plugins/Skeleton/Asset/css/skeleton.css',
));
// 3. Load the plugin script (currently empty -- proves the JS hook fires).
$this->hook->on('template:layout:js', array( $this->hook->on('template:layout:js', array(
'template' => 'plugins/Skeleton/Asset/js/skeleton.js', 'template' => 'plugins/OrganonTweaks/Asset/js/relocate.js',
)); ));
} }
public function getHelpers()
{
return array(
'Plugin\OrganonTweaks\Helper' => array('OrganonColumnHelper'),
);
}
public function getPluginName() public function getPluginName()
{ {
return 'Skeleton'; return 'OrganonTweaks';
} }
public function getPluginDescription() public function getPluginDescription()
{ {
return t('Reusable skeleton/template for building Kanboard plugins.'); return t('Umbrella plugin for small Kanboard tweaks. First tweak: remove an empty board column from its header menu.');
} }
public function getPluginAuthor() public function getPluginAuthor()
@@ -44,7 +47,7 @@ class Plugin extends Base
public function getPluginHomepage() public function getPluginHomepage()
{ {
return 'https://code.beco.cc/beco/kanboard-plugin-skeleton'; return 'https://code.beco.cc/beco/OrganonTweaks';
} }
public function getCompatibleVersion() public function getCompatibleVersion()

View File

@@ -1,19 +1,26 @@
# Skeleton -- a Kanboard plugin template # OrganonTweaks -- umbrella plugin for small Kanboard tweaks
A minimal, working Kanboard plugin that you copy and rename as the starting point for a A home for small, unrelated Kanboard adjustments that are not big enough to deserve their
real plugin. By itself it does only one trivial thing: it renders the word "Skeleton" at own plugin. Each tweak is self-contained; more will be added over time. If a tweak grows
the top of every page. It changes no data and runs no database migration. into a real subsystem it graduates into its own plugin (see PLAN-organon-tweaks-plugin.md).
## What it demonstrates ## Tweaks
- A complete `Plugin.php` registration class with all the metadata Kanboard shows in ### Remove an empty column
Settings -> Plugins (name, description, author, version, homepage, compatible version).
- A template hook (`template:layout:top`) that injects a template into the page. Adds a **Remove this Column** entry (trash icon) to a board column's header dropdown, next
- Asset hooks (`template:layout:css` and `template:layout:js`) that load a stylesheet and to the other column actions. It appears only when the column is completely empty -- no
a script. They are empty for now but prove the injection path works -- handy when a real tasks, open or closed -- because Kanboard's column removal is a plain delete and a non-empty
plugin needs custom CSS or JS. column would orphan its tasks. Clicking it asks for confirmation, then removes the column
- The standard plugin directory layout, with stub folders (`Controller/`, `Model/`, and returns to the board.
`Schema/`, `Locale/`, `Test/`) ready to grow into.
- The menu entry is rendered by the `template:board:column:dropdown` hook (which sits
outside the native menu list), then moved into the menu by `Asset/js/relocate.js`.
- The empty check counts open and closed tasks via a helper
(`Helper/OrganonColumnHelper.php`, `taskFinderModel->countByColumnId(...)`), since the
board's own count is open-only.
- Only users allowed to manage columns see it, and the controller re-checks both the
permission and the emptiness before deleting.
## Requirements ## Requirements
@@ -21,45 +28,9 @@ the top of every page. It changes no data and runs no database migration.
## Installation ## Installation
No build step and no dependencies. Copy this folder into your Kanboard installation as `plugins/OrganonTweaks/`. The directory
name must be exactly `OrganonTweaks` (Kanboard derives the plugin namespace from the folder
1. Copy this folder into your Kanboard installation as `plugins/Skeleton/`. name). No build step and no database migration.
2. Reload any page. The word "Skeleton" appears at the top.
3. Confirm it under Settings -> Plugins.
To uninstall, delete `plugins/Skeleton/`. Nothing else is left behind.
## Directory layout
```
Skeleton/
Plugin.php Registration and hook wiring (the only required file).
README.md
LICENSE AGPL-3.0.
Template/
layout/header.php The visible "Skeleton" word.
Asset/
css/skeleton.css Loaded via template:layout:css.
js/skeleton.js Loaded via template:layout:js.
Controller/ Stub for future request handlers.
Model/ Stub for future business logic / DB access.
Schema/ Stub for future database migrations.
Locale/ Stub for future translations (e.g. pt_BR/, fr_FR/).
Test/ Stub for future unit tests.
```
## How to fork this into a new plugin
1. Copy the folder and rename it, e.g. `plugins/MyPlugin/`. The folder name must match the
namespace and start with a capital letter.
2. In `Plugin.php`, change the namespace from `Kanboard\Plugin\Skeleton` to
`Kanboard\Plugin\MyPlugin`.
3. Update the metadata methods (`getPluginName`, `getPluginDescription`, `getPluginAuthor`,
`getPluginVersion`, `getPluginHomepage`, `getCompatibleVersion`).
4. Update the hook target paths: the lowercase prefix in `'skeleton:layout/header'` and the
`plugins/Skeleton/Asset/...` asset paths must match the new plugin name.
5. Replace `Template/layout/header.php` with your real template, or attach to a different
hook. See the Kanboard plugin hooks documentation for the full list of hook points.
## License ## License