diff options
author | Frederic Guillot <fred@kanboard.net> | 2017-03-19 16:45:32 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2017-03-19 16:45:32 -0400 |
commit | d915c2a96b0cbb54b9949cc04495d156e1f89332 (patch) | |
tree | 93f31d3de295c0f6cfc7c3a3bdf20cb8d7e7922a /app/Controller/SubtaskStatusController.php | |
parent | 5b7ed28ba1a47a5c4312017a86fb811e14c0285a (diff) |
Improve subtask toggle
Diffstat (limited to 'app/Controller/SubtaskStatusController.php')
-rw-r--r-- | app/Controller/SubtaskStatusController.php | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/app/Controller/SubtaskStatusController.php b/app/Controller/SubtaskStatusController.php index 72feb685..ef16fce0 100644 --- a/app/Controller/SubtaskStatusController.php +++ b/app/Controller/SubtaskStatusController.php @@ -19,11 +19,20 @@ class SubtaskStatusController extends BaseController { $task = $this->getTask(); $subtask = $this->getSubtask(); + $fragment = $this->request->getStringParam('fragment'); $status = $this->subtaskStatusModel->toggleStatus($subtask['id']); $subtask['status'] = $status; - $this->response->html($this->helper->subtask->renderToggleStatus($task, $subtask)); + if ($fragment === 'table') { + $html = $this->renderTable($task); + } elseif ($fragment === 'rows') { + $html = $this->renderRows($task); + } else { + $html = $this->helper->subtask->renderToggleStatus($task, $subtask); + } + + $this->response->html($html); } /** @@ -49,4 +58,43 @@ class SubtaskStatusController extends BaseController 'subtask' => $this->subtaskModel->getByIdWithDetails($subtaskId), ))); } + + /** + * Render table + * + * @access protected + * @param array $task + * @return string + */ + protected function renderTable(array $task) + { + return $this->template->render('subtask/table', array( + 'task' => $task, + 'subtasks' => $this->subtaskModel->getAll($task['id']), + 'editable' => true, + )); + } + + /** + * Render task list rows + * + * @access protected + * @param array $task + * @return string + */ + protected function renderRows(array $task) + { + $userId = $this->request->getIntegerParam('user_id'); + + if ($userId > 0) { + $task['subtasks'] = $this->subtaskModel->getAllByTaskIdsAndAssignee(array($task['id']), $userId); + } else { + $task['subtasks'] = $this->subtaskModel->getAll($task['id']); + } + + return $this->template->render('task_list/task_subtasks', array( + 'task' => $task, + 'user_id' => $userId, + )); + } } |