diff options
| author | Frederic Guillot <fred@kanboard.net> | 2017-02-26 19:30:02 -0500 |
|---|---|---|
| committer | Frederic Guillot <fred@kanboard.net> | 2017-02-26 19:30:02 -0500 |
| commit | f3deb6492a74f1ffa9e3391274e0ab7947a04016 (patch) | |
| tree | cbf7a3563cf1543bd131dd114f8dc89afdf5328f /app/Formatter/TaskListSubtaskFormatter.php | |
| parent | 4f325193be4f16a9658258fecd525e71917156a0 (diff) | |
Add toggle button to show/hide subtasks in task list view
Diffstat (limited to 'app/Formatter/TaskListSubtaskFormatter.php')
| -rw-r--r-- | app/Formatter/TaskListSubtaskFormatter.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/app/Formatter/TaskListSubtaskFormatter.php b/app/Formatter/TaskListSubtaskFormatter.php new file mode 100644 index 00000000..4f889674 --- /dev/null +++ b/app/Formatter/TaskListSubtaskFormatter.php @@ -0,0 +1,29 @@ +<?php + +namespace Kanboard\Formatter; + +/** + * Class TaskListSubtaskFormatter + * + * @package Kanboard\Formatter + * @author Frederic Guillot + */ +class TaskListSubtaskFormatter extends TaskListFormatter +{ + /** + * Apply formatter + * + * @access public + * @return array + */ + public function format() + { + $tasks = parent::format(); + $taskIds = array_column($tasks, 'id'); + $subtasks = $this->subtaskModel->getAllByTaskIds($taskIds); + $subtasks = array_column_index($subtasks, 'task_id'); + array_merge_relation($tasks, $subtasks, 'subtasks', 'id'); + + return $tasks; + } +} |
