summaryrefslogtreecommitdiff
path: root/app/Formatter
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2017-02-26 19:30:02 -0500
committerFrederic Guillot <fred@kanboard.net>2017-02-26 19:30:02 -0500
commitf3deb6492a74f1ffa9e3391274e0ab7947a04016 (patch)
treecbf7a3563cf1543bd131dd114f8dc89afdf5328f /app/Formatter
parent4f325193be4f16a9658258fecd525e71917156a0 (diff)
Add toggle button to show/hide subtasks in task list view
Diffstat (limited to 'app/Formatter')
-rw-r--r--app/Formatter/BoardFormatter.php2
-rw-r--r--app/Formatter/SubtaskListFormatter.php2
-rw-r--r--app/Formatter/TaskListFormatter.php4
-rw-r--r--app/Formatter/TaskListSubtaskFormatter.php29
4 files changed, 33 insertions, 4 deletions
diff --git a/app/Formatter/BoardFormatter.php b/app/Formatter/BoardFormatter.php
index 59a8fb18..a43790b0 100644
--- a/app/Formatter/BoardFormatter.php
+++ b/app/Formatter/BoardFormatter.php
@@ -58,7 +58,7 @@ class BoardFormatter extends BaseFormatter implements FormatterInterface
->findAll();
$task_ids = array_column($tasks, 'id');
- $tags = $this->taskTagModel->getTagsByTasks($task_ids);
+ $tags = $this->taskTagModel->getTagsByTaskIds($task_ids);
return $this->boardSwimlaneFormatter
->withSwimlanes($swimlanes)
diff --git a/app/Formatter/SubtaskListFormatter.php b/app/Formatter/SubtaskListFormatter.php
index 5b20111d..8af5b1f5 100644
--- a/app/Formatter/SubtaskListFormatter.php
+++ b/app/Formatter/SubtaskListFormatter.php
@@ -16,7 +16,7 @@ class SubtaskListFormatter extends BaseFormatter implements FormatterInterface
* Apply formatter
*
* @access public
- * @return mixed
+ * @return array
*/
public function format()
{
diff --git a/app/Formatter/TaskListFormatter.php b/app/Formatter/TaskListFormatter.php
index 01fbbae0..2f83469d 100644
--- a/app/Formatter/TaskListFormatter.php
+++ b/app/Formatter/TaskListFormatter.php
@@ -16,13 +16,13 @@ class TaskListFormatter extends BaseFormatter implements FormatterInterface
* Apply formatter
*
* @access public
- * @return mixed
+ * @return array
*/
public function format()
{
$tasks = $this->query->findAll();
$taskIds = array_column($tasks, 'id');
- $tags = $this->taskTagModel->getTagsByTasks($taskIds);
+ $tags = $this->taskTagModel->getTagsByTaskIds($taskIds);
array_merge_relation($tasks, $tags, 'tags', 'id');
return $tasks;
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;
+ }
+}