diff options
author | Dzial Techniczny WMW Projekt s.c <techniczna@wmwprojekt.pl> | 2020-04-08 14:01:28 +0200 |
---|---|---|
committer | Dzial Techniczny WMW Projekt s.c <techniczna@wmwprojekt.pl> | 2020-04-08 14:01:28 +0200 |
commit | 0dfe48b7fa475aade00a8ccf42e3dba99dfa3702 (patch) | |
tree | 92d34a659a841c4d0036fa5ef23b2f2b425c4b4e | |
parent | eca069dbd1318274b4170eb78629b0128dd0543c (diff) |
"My tasks" view grops tasks by project - fixes #107
-rw-r--r-- | app/Controller/DashboardController.php | 4 | ||||
-rw-r--r-- | app/Core/Base.php | 1 | ||||
-rw-r--r-- | app/Formatter/TaskListProjectFormatter.php | 30 | ||||
-rw-r--r-- | app/Pagination/TaskPagination.php | 15 | ||||
-rw-r--r-- | app/ServiceProvider/FormatterProvider.php | 1 | ||||
-rw-r--r-- | app/Template/dashboard/project_tasks.php | 45 | ||||
-rw-r--r-- | app/Template/task_list/task_details.php | 2 | ||||
-rw-r--r-- | app/Template/task_list/task_project_name.php | 5 |
8 files changed, 101 insertions, 2 deletions
diff --git a/app/Controller/DashboardController.php b/app/Controller/DashboardController.php index 6758381e..320ee4dd 100644 --- a/app/Controller/DashboardController.php +++ b/app/Controller/DashboardController.php @@ -36,9 +36,9 @@ class DashboardController extends BaseController { $user = $this->getUser(); - $this->response->html($this->helper->layout->dashboard('dashboard/tasks', array( + $this->response->html($this->helper->layout->dashboard('dashboard/project_tasks', array( 'title' => t('Tasks overview for %s', $this->helper->user->getFullname($user)), - 'paginator' => $this->taskPagination->getDashboardPaginator($user['id'], 'tasks', 50), + 'paginator' => $this->taskPagination->getDashboardPerProjectPaginator($user['id'], 'tasks', 50), 'user' => $user, ))); } diff --git a/app/Core/Base.php b/app/Core/Base.php index 3535a339..697566da 100644 --- a/app/Core/Base.php +++ b/app/Core/Base.php @@ -77,6 +77,7 @@ use Pimple\Container; * @property \Kanboard\Formatter\TaskAutoCompleteFormatter $taskAutoCompleteFormatter * @property \Kanboard\Formatter\TaskICalFormatter $taskICalFormatter * @property \Kanboard\Formatter\TaskListFormatter $taskListFormatter + * @property \Kanboard\Formatter\TaskListProjectFormatter $taskListProjectFormatter * @property \Kanboard\Formatter\TaskListSubtaskFormatter $taskListSubtaskFormatter * @property \Kanboard\Formatter\TaskListSubtaskAssigneeFormatter $taskListSubtaskAssigneeFormatter * @property \Kanboard\Formatter\TaskSuggestMenuFormatter $taskSuggestMenuFormatter diff --git a/app/Formatter/TaskListProjectFormatter.php b/app/Formatter/TaskListProjectFormatter.php new file mode 100644 index 00000000..109e9a2d --- /dev/null +++ b/app/Formatter/TaskListProjectFormatter.php @@ -0,0 +1,30 @@ +<?php + +namespace Kanboard\Formatter; + +use Kanboard\Formatter\TaskListFormatter; + +/** + * Class TaskListProjectFormatter + * + * @package Kanboard\Formatter + */ +class TaskListProjectFormatter extends TaskListFormatter +{ + /** + * Apply formatter + * + * @access public + * @return array + */ + public function format() + { + $tasks = parent::format(); + $prev = NULL; + foreach ($tasks as &$task) { + $task['render_project_name'] = (!$prev || $prev['project_name'] != $task['project_name']); + $prev = $task; + } + return $tasks; + } +} diff --git a/app/Pagination/TaskPagination.php b/app/Pagination/TaskPagination.php index 53e05c13..29706cd5 100644 --- a/app/Pagination/TaskPagination.php +++ b/app/Pagination/TaskPagination.php @@ -36,4 +36,19 @@ class TaskPagination extends Base ->setFormatter($this->taskListFormatter) ->calculateOnlyIf($this->request->getStringParam('pagination') === 'tasks'); } + + public function getDashboardPerProjectPaginator($userId, $method, $max) + { + $query = $this->taskFinderModel->getUserQuery($userId); + $this->hook->reference('pagination:dashboard:task:query', $query); + + return $this->paginator + ->setUrl('DashboardController', $method, array('pagination' => 'tasks', 'user_id' => $userId)) + ->setMax($max) + ->setOrder(TaskModel::TABLE.'.project_id, '.TaskModel::TABLE.'.id') + ->setQuery($query) + ->setFormatter($this->taskListProjectFormatter) + ->calculateOnlyIf($this->request->getStringParam('pagination') === 'tasks'); + } + } diff --git a/app/ServiceProvider/FormatterProvider.php b/app/ServiceProvider/FormatterProvider.php index efc85d06..b43d1ae4 100644 --- a/app/ServiceProvider/FormatterProvider.php +++ b/app/ServiceProvider/FormatterProvider.php @@ -31,6 +31,7 @@ class FormatterProvider implements ServiceProviderInterface 'TaskAutoCompleteFormatter', 'TaskICalFormatter', 'TaskListFormatter', + 'TaskListProjectFormatter', 'TaskListSubtaskFormatter', 'TaskListSubtaskAssigneeFormatter', 'TaskSuggestMenuFormatter', diff --git a/app/Template/dashboard/project_tasks.php b/app/Template/dashboard/project_tasks.php new file mode 100644 index 00000000..1577f814 --- /dev/null +++ b/app/Template/dashboard/project_tasks.php @@ -0,0 +1,45 @@ +<div class="page-header"> + <h2><?= $this->url->link(t('My tasks'), 'DashboardController', 'tasks', array('user_id' => $user['id'])) ?> (<?= $paginator->getTotal() ?>)</h2> +</div> +<?php if ($paginator->isEmpty()): ?> + <p class="alert"><?= t('There is nothing assigned to you.') ?></p> +<?php else: ?> + <div class="table-list"> + <?= $this->render('task_list/header', array( + 'paginator' => $paginator, + )) ?> + + <?php foreach ($paginator->getCollection() as $task): ?> + <?= $this->render('task_list/task_project_name', array( + 'task' => $task + )) ?> + <div class="table-list-row color-<?= $task['color_id'] ?>"> + <?= $this->render('task_list/task_title', array( + 'task' => $task, + 'redirect' => 'dashboard-tasks', + 'is_subtask' => FALSE + )) ?> + + <?= $this->render('task_list/task_details', array( + 'task' => $task, + )) ?> + + <?= $this->render('task_list/task_avatars', array( + 'task' => $task, + )) ?> + + <?= $this->render('task_list/task_icons', array( + 'task' => $task, + )) ?> + + <?= $this->render('task_list/task_subtasks', array( + 'task' => $task, + )) ?> + + <?= $this->hook->render('template:dashboard:task:footer', array('task' => $task)) ?> + </div> + <?php endforeach ?> + </div> + + <?= $paginator ?> +<?php endif ?> diff --git a/app/Template/task_list/task_details.php b/app/Template/task_list/task_details.php index 03e1d3eb..5230a8b5 100644 --- a/app/Template/task_list/task_details.php +++ b/app/Template/task_list/task_details.php @@ -1,5 +1,7 @@ <div class="table-list-details"> +<?php if (!isset($task['render_project_name'])): ?> <?= $this->text->e($task['project_name']) ?> > +<?php endif ?> <?= $this->text->e($task['swimlane_name']) ?> > <?= $this->text->e($task['column_name']) ?> diff --git a/app/Template/task_list/task_project_name.php b/app/Template/task_list/task_project_name.php new file mode 100644 index 00000000..c4a6095a --- /dev/null +++ b/app/Template/task_list/task_project_name.php @@ -0,0 +1,5 @@ +<?php if (isset($task['render_project_name']) && $task['render_project_name']): ?> +<h2> + <?= $task['project_name'] ?> +</h2> +<?php endif ?> |