From f63984af1a1098f9d3925b5d5f1d0b98fdcf05e2 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Tue, 7 Oct 2014 19:21:26 -0400 Subject: Allow quickly creating and changing state of subtask (pull-request #312) --- app/Controller/Subtask.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'app/Controller/Subtask.php') diff --git a/app/Controller/Subtask.php b/app/Controller/Subtask.php index 63ca6303..da9acbab 100644 --- a/app/Controller/Subtask.php +++ b/app/Controller/Subtask.php @@ -184,4 +184,26 @@ class Subtask extends Base $this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'#subtasks'); } + + /** + * Change status to the next status: Toto -> In Progress -> Done + * + * @access public + */ + public function toggleStatus() + { + $task = $this->getTask(); + $subtask = $this->getSubtask(); + + $value = array( + 'id' => $subtask['id'], + 'status' => ($subtask['status'] + 1) % 3 + ); + + if (! $this->subTask->update($value)) { + $this->session->flashError(t('Unable to update your sub-task.')); + } + + $this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'#subtasks'); + } } -- cgit v1.2.3