diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/Controller/SubtaskRestrictionController.php | 2 | ||||
-rw-r--r-- | app/Controller/SubtaskStatusController.php | 50 | ||||
-rw-r--r-- | app/Helper/SubtaskHelper.php | 16 | ||||
-rw-r--r-- | app/Model/SubtaskModel.php | 5 | ||||
-rw-r--r-- | app/Template/dashboard/show.php | 3 | ||||
-rw-r--r-- | app/Template/subtask/table.php | 2 | ||||
-rw-r--r-- | app/Template/task_list/task_subtasks.php | 2 |
7 files changed, 66 insertions, 14 deletions
diff --git a/app/Controller/SubtaskRestrictionController.php b/app/Controller/SubtaskRestrictionController.php index 0e207674..99315931 100644 --- a/app/Controller/SubtaskRestrictionController.php +++ b/app/Controller/SubtaskRestrictionController.php @@ -48,14 +48,12 @@ class SubtaskRestrictionController extends BaseController $this->subtaskModel->update(array( 'id' => $values['id'], 'status' => $values['status'], - 'task_id' => $task['id'], )); // Set the current subtask to "in progress" $this->subtaskModel->update(array( 'id' => $subtask['id'], 'status' => SubtaskModel::STATUS_INPROGRESS, - 'task_id' => $task['id'], )); $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); 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, + )); + } } diff --git a/app/Helper/SubtaskHelper.php b/app/Helper/SubtaskHelper.php index eea1ed63..3a853238 100644 --- a/app/Helper/SubtaskHelper.php +++ b/app/Helper/SubtaskHelper.php @@ -45,20 +45,24 @@ class SubtaskHelper extends Base * Get the link to toggle subtask status * * @access public - * @param array $task - * @param array $subtask + * @param array $task + * @param array $subtask + * @param string $fragment + * @param int $userId * @return string */ - public function renderToggleStatus(array $task, array $subtask) + public function renderToggleStatus(array $task, array $subtask, $fragment = '', $userId = 0) { if (! $this->helper->user->hasProjectAccess('SubtaskController', 'edit', $task['project_id'])) { $html = $this->renderTitle($subtask); } else { $title = $this->renderTitle($subtask); $params = array( - 'project_id' => $task['project_id'], - 'task_id' => $subtask['task_id'], - 'subtask_id' => $subtask['id'], + 'project_id' => $task['project_id'], + 'task_id' => $subtask['task_id'], + 'subtask_id' => $subtask['id'], + 'user_id' => $userId, + 'fragment' => $fragment, ); if ($subtask['status'] == 0 && $this->hasSubtaskInProgress()) { diff --git a/app/Model/SubtaskModel.php b/app/Model/SubtaskModel.php index 9d047d90..40cb517d 100644 --- a/app/Model/SubtaskModel.php +++ b/app/Model/SubtaskModel.php @@ -218,10 +218,11 @@ class SubtaskModel extends Base $result = $this->db->table(self::TABLE)->eq('id', $values['id'])->save($values); if ($result) { - $this->subtaskTimeTrackingModel->updateTaskTimeTracking($values['task_id']); + $subtask = $this->getById($values['id']); + $this->subtaskTimeTrackingModel->updateTaskTimeTracking($subtask['task_id']); if ($fireEvent) { - $this->queueManager->push($this->subtaskEventJob->withParams($values['id'], self::EVENT_UPDATE, $values)); + $this->queueManager->push($this->subtaskEventJob->withParams($subtask['id'], self::EVENT_UPDATE, $values)); } } diff --git a/app/Template/dashboard/show.php b/app/Template/dashboard/show.php index df5b03e0..2cc78e3f 100644 --- a/app/Template/dashboard/show.php +++ b/app/Template/dashboard/show.php @@ -69,7 +69,8 @@ )) ?> <?= $this->render('task_list/task_subtasks', array( - 'task' => $task, + 'task' => $task, + 'user_id' => $user['id'], )) ?> </div> <?php endforeach ?> diff --git a/app/Template/subtask/table.php b/app/Template/subtask/table.php index 5488796d..e1bca500 100644 --- a/app/Template/subtask/table.php +++ b/app/Template/subtask/table.php @@ -21,7 +21,7 @@ 'task' => $task, 'subtask' => $subtask, )) ?> - <?= $this->subtask->renderToggleStatus($task, $subtask, true) ?> + <?= $this->subtask->renderToggleStatus($task, $subtask, 'table') ?> <?php else: ?> <?= $this->subtask->renderTitle($subtask) ?> <?php endif ?> diff --git a/app/Template/task_list/task_subtasks.php b/app/Template/task_list/task_subtasks.php index 716d6df2..9110b171 100644 --- a/app/Template/task_list/task_subtasks.php +++ b/app/Template/task_list/task_subtasks.php @@ -3,7 +3,7 @@ <?php foreach ($task['subtasks'] as $subtask): ?> <div class="task-list-subtask"> <span class="subtask-cell column-50"> - <?= $this->subtask->renderToggleStatus($task, $subtask) ?> + <?= $this->subtask->renderToggleStatus($task, $subtask, 'rows', isset($user_id) ? $user_id : 0) ?> </span> <span class="subtask-cell column-20 subtask-assignee"> <?php if (! empty($subtask['username'])): ?> |