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 +=============== + +[](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 @@ +
= t('There is no future task.') ?>
+ += $paginator->order('Id', \Kanboard\Model\TaskModel::TABLE.'.id') ?> | += $paginator->order(t('Project'), 'project_name') ?> | += $paginator->order(t('Task'), \Kanboard\Model\TaskModel::TABLE.'.title') ?> | += $paginator->order(t('Priority'), \Kanboard\Model\TaskModel::TABLE.'.priority') ?> | += t('Time tracking') ?> | += $paginator->order(t('Due date'), \Kanboard\Model\TaskModel::TABLE.'.date_due') ?> | += $paginator->order(t('Column'), 'column_title') ?> | +
---|---|---|---|---|---|---|
+ = $this->render('task/dropdown', array('task' => $task)) ?> + | ++ = $this->url->link($this->text->e($task['project_name']), 'BoardViewController', 'show', array('project_id' => $task['project_id'])) ?> + | ++ = $this->url->link($this->text->e($task['title']), 'TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?> + | ++ = 0): ?> + P= $this->text->e($task['priority'])?> + + | ++ + = $this->text->e($task['time_spent']).'h' ?> = t('spent') ?> + + + + = $this->text->e($task['time_estimated']).'h' ?> = t('estimated') ?> + + | ++ = $this->dt->date($task['date_due']) ?> + | ++ = $this->text->e($task['column_title']) ?> + | +