diff --git a/Controller/DashboardController.php b/Controller/DashboardController.php new file mode 100644 index 0000000..9d1cbe7 --- /dev/null +++ b/Controller/DashboardController.php @@ -0,0 +1,20 @@ +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, + ))); + } +} diff --git a/Filter/TaskBoardDateFilter.php b/Filter/TaskBoardDateFilter.php new file mode 100644 index 0000000..9dd4dd3 --- /dev/null +++ b/Filter/TaskBoardDateFilter.php @@ -0,0 +1,40 @@ +applyDateFilter(TaskModel::TABLE . '.date_board'); + return $this; + } +} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e89f19e --- /dev/null +++ b/Makefile @@ -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 diff --git a/Pagination/FutureTaskPagination.php b/Pagination/FutureTaskPagination.php new file mode 100644 index 0000000..4aff49b --- /dev/null +++ b/Pagination/FutureTaskPagination.php @@ -0,0 +1,40 @@ +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; + } +} diff --git a/Plugin.php b/Plugin.php new file mode 100644 index 0000000..322a32a --- /dev/null +++ b/Plugin.php @@ -0,0 +1,76 @@ +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'; + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..d5db319 --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +Task Board Date +=============== + +[![Build Status](https://travis-ci.org/kanboard/plugin-task-board-date.svg?branch=master)](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. diff --git a/Schema/Mysql.php b/Schema/Mysql.php new file mode 100644 index 0000000..e5b9b4a --- /dev/null +++ b/Schema/Mysql.php @@ -0,0 +1,12 @@ +exec("ALTER TABLE `tasks` ADD COLUMN `date_board` INT DEFAULT '0'"); +} diff --git a/Schema/Postgres.php b/Schema/Postgres.php new file mode 100644 index 0000000..90ce0ec --- /dev/null +++ b/Schema/Postgres.php @@ -0,0 +1,12 @@ +exec("ALTER TABLE tasks ADD COLUMN date_board INT DEFAULT '0'"); +} diff --git a/Schema/Sqlite.php b/Schema/Sqlite.php new file mode 100644 index 0000000..c842e23 --- /dev/null +++ b/Schema/Sqlite.php @@ -0,0 +1,12 @@ +exec("ALTER TABLE tasks ADD COLUMN date_board INTEGER DEFAULT '0'"); +} diff --git a/Template/dashboard/show.php b/Template/dashboard/show.php new file mode 100644 index 0000000..733ee81 --- /dev/null +++ b/Template/dashboard/show.php @@ -0,0 +1,53 @@ + +isEmpty()): ?> +

+ + + + + + + + + + + + getCollection() as $task): ?> + + + + + + + + + + +
order('Id', \Kanboard\Model\TaskModel::TABLE.'.id') ?>order(t('Project'), 'project_name') ?>order(t('Task'), \Kanboard\Model\TaskModel::TABLE.'.title') ?>order(t('Priority'), \Kanboard\Model\TaskModel::TABLE.'.priority') ?>order(t('Due date'), \Kanboard\Model\TaskModel::TABLE.'.date_due') ?>order(t('Column'), 'column_title') ?>
+ render('task/dropdown', array('task' => $task)) ?> + + url->link($this->text->e($task['project_name']), 'BoardViewController', 'show', array('project_id' => $task['project_id'])) ?> + + url->link($this->text->e($task['title']), 'TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?> + + = 0): ?> + Ptext->e($task['priority'])?> + + + + text->e($task['time_spent']).'h' ?> + + + + text->e($task['time_estimated']).'h' ?> + + + dt->date($task['date_due']) ?> + + text->e($task['column_title']) ?> +
+ + + diff --git a/Template/dashboard/sidebar.php b/Template/dashboard/sidebar.php new file mode 100644 index 0000000..9b34e12 --- /dev/null +++ b/Template/dashboard/sidebar.php @@ -0,0 +1,3 @@ +
  • app->checkMenuSelection('DashboardController', 'future', 'TaskBoardDate') ?>> + url->link(t('My future tasks'), 'DashboardController', 'future', array('plugin' => 'TaskBoardDate', 'user_id' => $user['id'])) ?> +
  • diff --git a/Template/task_creation/form.php b/Template/task_creation/form.php new file mode 100644 index 0000000..bae0c86 --- /dev/null +++ b/Template/task_creation/form.php @@ -0,0 +1 @@ +form->date(t('Board Date'), 'date_board', $values + array('date_board' => time()), $errors); ?> diff --git a/Test/PluginTest.php b/Test/PluginTest.php new file mode 100644 index 0000000..1d9a0e3 --- /dev/null +++ b/Test/PluginTest.php @@ -0,0 +1,20 @@ +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()); + } +} diff --git a/plugin-task-board-date b/plugin-task-board-date new file mode 160000 index 0000000..cbeaee5 --- /dev/null +++ b/plugin-task-board-date @@ -0,0 +1 @@ +Subproject commit cbeaee59c2fbbcc4572daaf6732e3faf6752ecb6