Improve subtask toggle
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user