Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8648b67061 |
31
Plugin.php
31
Plugin.php
@@ -3,6 +3,7 @@
|
|||||||
namespace Kanboard\Plugin\QualKard;
|
namespace Kanboard\Plugin\QualKard;
|
||||||
|
|
||||||
use Kanboard\Core\Plugin\Base;
|
use Kanboard\Core\Plugin\Base;
|
||||||
|
use Kanboard\Model\TaskModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* QualKard -- flashcard spaced repetition on Kanboard cards.
|
* QualKard -- flashcard spaced repetition on Kanboard cards.
|
||||||
@@ -17,10 +18,36 @@ class Plugin extends Base
|
|||||||
{
|
{
|
||||||
public function initialize()
|
public function initialize()
|
||||||
{
|
{
|
||||||
|
$container = $this->container;
|
||||||
|
|
||||||
// Per-board setup/reset/disable on Settings -> Integrations.
|
// Per-board setup/reset/disable on Settings -> Integrations.
|
||||||
$this->template->hook->attach('template:project:integrations', 'qualKard:project/integration');
|
$this->template->hook->attach('template:project:integrations', 'qualKard:project/integration');
|
||||||
|
|
||||||
// (The grade handler and the badge are wired in later versions.)
|
// New card on a QualKard board -> reset it (unread, armed inert, moved to Drafts).
|
||||||
|
$this->hook->on('model:task:creation:aftersave', function ($task_id) use ($container) {
|
||||||
|
$helper = new \Kanboard\Plugin\QualKard\Helper\QualKardHelper($container);
|
||||||
|
$task = $container['taskFinderModel']->getById($task_id);
|
||||||
|
if (! empty($task) && $helper->isEnabled($task['project_id'])) {
|
||||||
|
$helper->resetCard($task_id, (int) $task['project_id']);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Card dragged INTO a grade column -> grade it (RecoReco then handles the movement). The
|
||||||
|
// plugin on() wrapper drops the event, so we subscribe on the dispatcher to get the TaskEvent.
|
||||||
|
$this->dispatcher->addListener(TaskModel::EVENT_MOVE_COLUMN, function ($event) use ($container) {
|
||||||
|
$task = $event['task'];
|
||||||
|
$helper = new \Kanboard\Plugin\QualKard\Helper\QualKardHelper($container);
|
||||||
|
if (! $helper->isEnabled($task['project_id'])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$dst = (int) $event['dst_column_id'];
|
||||||
|
foreach (array('hairy', 'hard', 'medium', 'easy') as $role) {
|
||||||
|
if ($dst === $helper->col($task['project_id'], $role)) {
|
||||||
|
$helper->grade($task['id'], \Kanboard\Plugin\QualKard\Helper\QualKardHelper::SCORE[$role]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHelpers()
|
public function getHelpers()
|
||||||
@@ -47,7 +74,7 @@ class Plugin extends Base
|
|||||||
|
|
||||||
public function getPluginVersion()
|
public function getPluginVersion()
|
||||||
{
|
{
|
||||||
return '0.3.0';
|
return '0.4.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginHomepage()
|
public function getPluginHomepage()
|
||||||
|
|||||||
@@ -26,3 +26,4 @@
|
|||||||
|
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
|
<hr>
|
||||||
|
|||||||
Reference in New Issue
Block a user