-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Manuel Raposo
committed
Sep 21, 2016
0 parents
commit 1fc0d90
Showing
14 changed files
with
328 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Kanboard\Plugin\TaskBoardDate\Controller; | ||
|
||
use Kanboard\Controller\BaseController; | ||
use Kanboard\Plugin\TaskBoardDate\Pagination\FutureTaskPagination; | ||
|
||
class DashboardController extends BaseController | ||
{ | ||
public function future() | ||
{ | ||
$user = $this->getUser(); | ||
|
||
$this->response->html($this->helper->layout->dashboard('TaskBoardDate:dashboard/show', array( | ||
'title' => t('Future tasks for %s', $this->helper->user->getFullname($user)), | ||
'paginator' => FutureTaskPagination::getInstance($this->container)->getDashboardPaginator($user['id'], false), | ||
'user' => $user, | ||
))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Kanboard\Plugin\TaskBoardDate\Filter; | ||
|
||
use Kanboard\Core\Filter\FilterInterface; | ||
use Kanboard\Filter\BaseDateFilter; | ||
use Kanboard\Model\TaskModel; | ||
use PicoDb\Table; | ||
|
||
/** | ||
* Filter tasks by board date | ||
* | ||
* @package filter | ||
* @author Frederic Guillot | ||
*/ | ||
class TaskBoardDateFilter extends BaseDateFilter implements FilterInterface | ||
{ | ||
/** | ||
* Get search attribute | ||
* | ||
* @access public | ||
* @return string[] | ||
*/ | ||
public function getAttributes() | ||
{ | ||
return array('board_date'); | ||
} | ||
|
||
/** | ||
* Apply filter | ||
* | ||
* @access public | ||
* @return FilterInterface | ||
*/ | ||
public function apply() | ||
{ | ||
$this->applyDateFilter(TaskModel::TABLE . '.date_board'); | ||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
plugin=TaskBoardDate | ||
|
||
all: | ||
@ echo "Build archive for plugin ${plugin} version=${version}" | ||
@ git archive HEAD --prefix=${plugin}/ --format=zip -o ${plugin}-${version}.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Kanboard\Plugin\TaskBoardDate\Pagination; | ||
|
||
use Kanboard\Core\Base; | ||
use Kanboard\Model\TaskModel; | ||
|
||
class FutureTaskPagination extends Base | ||
{ | ||
public function getDashboardPaginator($userId, $isMainPage) | ||
{ | ||
$query = $this->taskFinderModel->getUserQuery($userId) | ||
->gt(TaskModel::TABLE.'.date_board', time()); | ||
|
||
$paginator = $this->paginator | ||
->setMax(50) | ||
->setOrder(TaskModel::TABLE.'.id') | ||
->setQuery($query) | ||
->calculateOnlyIf($this->request->getStringParam('pagination') === 'future'); | ||
|
||
if ($isMainPage) { | ||
$paginator->setUrl( | ||
'DashboardController', 'show', array( | ||
'pagination' => 'future', | ||
'user_id' => $userId, | ||
) | ||
); | ||
} else { | ||
$paginator->setUrl( | ||
'DashboardController', 'future', array( | ||
'plugin' => 'TaskBoardDate', | ||
'pagination' => 'future', | ||
'user_id' => $userId, | ||
) | ||
); | ||
} | ||
|
||
return $paginator; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
namespace Kanboard\Plugin\TaskBoardDate; | ||
|
||
use Kanboard\Core\Plugin\Base; | ||
use Kanboard\Core\Translator; | ||
use Kanboard\Model\TaskModel; | ||
use Kanboard\Plugin\TaskBoardDate\Filter\TaskBoardDateFilter; | ||
use Kanboard\Plugin\TaskBoardDate\Pagination\FutureTaskPagination; | ||
use PicoDb\Table; | ||
|
||
class Plugin extends Base | ||
{ | ||
public function initialize() | ||
{ | ||
$this->hook->on('formatter:board:query', array($this, 'applyDateFilter')); | ||
$this->hook->on('pagination:dashboard:task:query', array($this, 'applyDateFilter')); | ||
$this->hook->on('pagination:dashboard:subtask:query', array($this, 'applyDateFilter')); | ||
$this->hook->on('model:task:creation:prepare', array($this, 'beforeSave')); | ||
$this->hook->on('model:task:modification:prepare', array($this, 'beforeSave')); | ||
|
||
$this->template->hook->attach('template:task:form:third-column', 'TaskBoardDate:task_creation/form'); | ||
$this->template->hook->attach('template:dashboard:sidebar', 'TaskBoardDate:dashboard/sidebar'); | ||
$this->template->hook->attachCallable('template:dashboard:show', 'TaskBoardDate:dashboard/show', function(array $user) { | ||
return array( | ||
'paginator' => FutureTaskPagination::getInstance($this->container)->getDashboardPaginator($user['id'], true) | ||
); | ||
}); | ||
|
||
$this->container->extend('taskLexer', function($taskLexer, $c) { | ||
$taskLexer->withFilter(TaskBoardDateFilter::getInstance($c)->setDateParser($c['dateParser'])); | ||
return $taskLexer; | ||
}); | ||
} | ||
|
||
public function onStartup() | ||
{ | ||
Translator::load($this->languageModel->getCurrentLanguage(), __DIR__.'/Locale'); | ||
} | ||
|
||
public function beforeSave(array &$values) | ||
{ | ||
$values = $this->dateParser->convert($values, array('date_board')); | ||
$this->helper->model->resetFields($values, array('date_board')); | ||
} | ||
|
||
public function applyDateFilter(Table $query) | ||
{ | ||
$query->lte(TaskModel::TABLE.'.date_board', time()); | ||
} | ||
|
||
public function getPluginName() | ||
{ | ||
return 'TaskBoardDate'; | ||
} | ||
|
||
public function getPluginDescription() | ||
{ | ||
return t('Add a new date field for tasks to define the visibility on the board and dashboard'); | ||
} | ||
|
||
public function getPluginAuthor() | ||
{ | ||
return 'Frédéric Guillot'; | ||
} | ||
|
||
public function getPluginVersion() | ||
{ | ||
return '1.0.0'; | ||
} | ||
|
||
public function getPluginHomepage() | ||
{ | ||
return 'https://github.com/kanboard/plugin-task-board-date'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Task Board Date | ||
=============== | ||
|
||
[](https://travis-ci.org/kanboard/plugin-task-board-date) | ||
|
||
- Add a new date field for tasks to define the visibility on the board and dashboard. | ||
- Add a new section on the dashboard for future tasks. | ||
- Add a new search filter: `board_date`. | ||
|
||
To make visible a task on the board, you have to define a board date lower or equals than today. | ||
|
||
Author | ||
------ | ||
|
||
- Frédéric Guillot | ||
- License MIT | ||
|
||
Requirements | ||
------------ | ||
|
||
- Kanboard >= 1.0.33 | ||
- PHP >= 5.3.3 | ||
|
||
Installation | ||
------------ | ||
|
||
You have the choice between 3 methods: | ||
|
||
1. Install the plugin from the Kanboard plugin manager in one click | ||
2. Download the zip file and decompress everything under the directory `plugins/TaskBoardDate` | ||
3. Clone this repository into the folder `plugins/TaskBoardDate` | ||
|
||
Note: Plugin folder is case-sensitive. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Kanboard\Plugin\TaskBoardDate\Schema; | ||
|
||
use PDO; | ||
|
||
const VERSION = 1; | ||
|
||
function version_1(PDO $pdo) | ||
{ | ||
$pdo->exec("ALTER TABLE `tasks` ADD COLUMN `date_board` INT DEFAULT '0'"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Kanboard\Plugin\TaskBoardDate\Schema; | ||
|
||
use PDO; | ||
|
||
const VERSION = 1; | ||
|
||
function version_1(PDO $pdo) | ||
{ | ||
$pdo->exec("ALTER TABLE tasks ADD COLUMN date_board INT DEFAULT '0'"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Kanboard\Plugin\TaskBoardDate\Schema; | ||
|
||
use PDO; | ||
|
||
const VERSION = 1; | ||
|
||
function version_1(PDO $pdo) | ||
{ | ||
$pdo->exec("ALTER TABLE tasks ADD COLUMN date_board INTEGER DEFAULT '0'"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<div class="page-header"> | ||
<h2><?= $this->url->link(t('My future tasks'), 'DashboardController', 'future', array('plugin' => 'TaskBoardDate', 'user_id' => $user['id'])) ?> (<?= $paginator->getTotal() ?>)</h2> | ||
</div> | ||
<?php if ($paginator->isEmpty()): ?> | ||
<p class="alert"><?= t('There is no future task.') ?></p> | ||
<?php else: ?> | ||
<table class="table-small table-scrolling"> | ||
<tr> | ||
<th class="column-5"><?= $paginator->order('Id', \Kanboard\Model\TaskModel::TABLE.'.id') ?></th> | ||
<th class="column-20"><?= $paginator->order(t('Project'), 'project_name') ?></th> | ||
<th><?= $paginator->order(t('Task'), \Kanboard\Model\TaskModel::TABLE.'.title') ?></th> | ||
<th class="column-8"><?= $paginator->order(t('Priority'), \Kanboard\Model\TaskModel::TABLE.'.priority') ?></th> | ||
<th class="column-20"><?= t('Time tracking') ?></th> | ||
<th class="column-10"><?= $paginator->order(t('Due date'), \Kanboard\Model\TaskModel::TABLE.'.date_due') ?></th> | ||
<th class="column-10"><?= $paginator->order(t('Column'), 'column_title') ?></th> | ||
</tr> | ||
<?php foreach ($paginator->getCollection() as $task): ?> | ||
<tr> | ||
<td class="task-table color-<?= $task['color_id'] ?>"> | ||
<?= $this->render('task/dropdown', array('task' => $task)) ?> | ||
</td> | ||
<td> | ||
<?= $this->url->link($this->text->e($task['project_name']), 'BoardViewController', 'show', array('project_id' => $task['project_id'])) ?> | ||
</td> | ||
<td> | ||
<?= $this->url->link($this->text->e($task['title']), 'TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?> | ||
</td> | ||
<td> | ||
<?php if ($task['priority'] >= 0): ?> | ||
P<?= $this->text->e($task['priority'])?> | ||
<?php endif?> | ||
</td> | ||
<td> | ||
<?php if (! empty($task['time_spent'])): ?> | ||
<strong><?= $this->text->e($task['time_spent']).'h' ?></strong> <?= t('spent') ?> | ||
<?php endif ?> | ||
|
||
<?php if (! empty($task['time_estimated'])): ?> | ||
<strong><?= $this->text->e($task['time_estimated']).'h' ?></strong> <?= t('estimated') ?> | ||
<?php endif ?> | ||
</td> | ||
<td> | ||
<?= $this->dt->date($task['date_due']) ?> | ||
</td> | ||
<td> | ||
<?= $this->text->e($task['column_title']) ?> | ||
</td> | ||
</tr> | ||
<?php endforeach ?> | ||
</table> | ||
|
||
<?= $paginator ?> | ||
<?php endif ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<li <?= $this->app->checkMenuSelection('DashboardController', 'future', 'TaskBoardDate') ?>> | ||
<?= $this->url->link(t('My future tasks'), 'DashboardController', 'future', array('plugin' => 'TaskBoardDate', 'user_id' => $user['id'])) ?> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?= $this->form->date(t('Board Date'), 'date_board', $values + array('date_board' => time()), $errors); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
require_once 'tests/units/Base.php'; | ||
|
||
use Kanboard\Plugin\TaskBoardDate\Plugin; | ||
|
||
class PluginTest extends Base | ||
{ | ||
public function testPlugin() | ||
{ | ||
$plugin = new Plugin($this->container); | ||
$this->assertSame(null, $plugin->initialize()); | ||
$this->assertSame(null, $plugin->onStartup()); | ||
$this->assertNotEmpty($plugin->getPluginName()); | ||
$this->assertNotEmpty($plugin->getPluginDescription()); | ||
$this->assertNotEmpty($plugin->getPluginAuthor()); | ||
$this->assertNotEmpty($plugin->getPluginVersion()); | ||
$this->assertNotEmpty($plugin->getPluginHomepage()); | ||
} | ||
} |
Submodule plugin-task-board-date
added at
cbeaee