TODO/DONE auto-mark done when all subtasks done
This commit is contained in:
25
Plugin.php
25
Plugin.php
@@ -3,6 +3,7 @@
|
||||
namespace Kanboard\Plugin\OrganonTweaks;
|
||||
|
||||
use Kanboard\Core\Plugin\Base;
|
||||
use Kanboard\Model\SubtaskModel;
|
||||
use Kanboard\Model\TaskModel;
|
||||
|
||||
class Plugin extends Base
|
||||
@@ -122,6 +123,28 @@ class Plugin extends Base
|
||||
// Bulk "Mark all as Done/Todo" entry in the column header dropdown (moved into the native
|
||||
// menu by relocate.js). Opens a two-button modal that confirms + picks the direction.
|
||||
$this->template->hook->attach('template:board:column:dropdown', 'organonTweaks:board/mark_all_item');
|
||||
|
||||
// Sub-tweak (opt-in): auto-mark a card Done when its LAST subtask is completed. On every
|
||||
// subtask change, recompute all-done and mark Done only on the up-transition
|
||||
// (state-comparison in the helper), so a manual unmark is honored -- nothing re-fires.
|
||||
// Dispatcher direct (the plugin on() wrapper drops the event). DELETE fires before the row
|
||||
// is removed, so its id is excluded from the recount.
|
||||
if ((int) $this->configModel->get('organon_tweaks_done_autosubtasks', 0) === 1) {
|
||||
$container = $this->container;
|
||||
$sync = function ($task_id, $exclude_id = 0) use ($container) {
|
||||
$helper = new \Kanboard\Plugin\OrganonTweaks\Helper\OrganonDoneHelper($container);
|
||||
$helper->syncSubtasksDone((int) $task_id, (int) $exclude_id);
|
||||
};
|
||||
$this->dispatcher->addListener(SubtaskModel::EVENT_UPDATE, function ($event) use ($sync) {
|
||||
$sync($event['subtask']['task_id']);
|
||||
});
|
||||
$this->dispatcher->addListener(SubtaskModel::EVENT_CREATE, function ($event) use ($sync) {
|
||||
$sync($event['subtask']['task_id']);
|
||||
});
|
||||
$this->dispatcher->addListener(SubtaskModel::EVENT_DELETE, function ($event) use ($sync) {
|
||||
$sync($event['subtask']['task_id'], $event['subtask']['id']);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Auto-managed shared custom filters (v1.5 "Show all tasks", v1.6 month filters, v1.7
|
||||
@@ -175,7 +198,7 @@ class Plugin extends Base
|
||||
|
||||
public function getPluginVersion()
|
||||
{
|
||||
return '2.1.3';
|
||||
return '2.2.0';
|
||||
}
|
||||
|
||||
public function getPluginHomepage()
|
||||
|
||||
Reference in New Issue
Block a user