diff --git a/ChangeLog b/ChangeLog index 1dda9ed06..4c32804ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,7 @@ Core functionalities moved to plugins: Improvements: +* Show "Open this task" in dropdown menu for closed tasks * Show assignee on card only when someone is assigned (hide nobody text) * Highlight selected item in dropdown menus * Gantt chart: change bar color according to task progress diff --git a/app/Controller/Taskstatus.php b/app/Controller/Taskstatus.php index a47d9da34..9260b6581 100644 --- a/app/Controller/Taskstatus.php +++ b/app/Controller/Taskstatus.php @@ -18,36 +18,8 @@ class Taskstatus extends Base public function close() { $task = $this->getTask(); - $redirect = $this->request->getStringParam('redirect'); - - if ($this->request->getStringParam('confirmation') === 'yes') { - - $this->checkCSRFParam(); - - if ($this->taskStatus->close($task['id'])) { - $this->session->flash(t('Task closed successfully.')); - } else { - $this->session->flashError(t('Unable to close this task.')); - } - - if ($redirect === 'board') { - $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id']))); - } - - $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); - } - - if ($this->request->isAjax()) { - $this->response->html($this->template->render('task_status/close', array( - 'task' => $task, - 'redirect' => $redirect, - ))); - } - - $this->response->html($this->taskLayout('task_status/close', array( - 'task' => $task, - 'redirect' => $redirect, - ))); + $this->changeStatus($task, 'close', t('Task closed successfully.'), t('Unable to close this task.')); + $this->renderTemplate($task, 'task_status/close'); } /** @@ -58,22 +30,46 @@ class Taskstatus extends Base public function open() { $task = $this->getTask(); + $redirect = $this->request->getStringParam('redirect'); + $this->changeStatus($task, 'open', t('Task opened successfully.'), t('Unable to open this task.')); + $this->renderTemplate($task, 'task_status/open'); + } + + private function changeStatus(array $task, $method, $success_message, $failure_message) + { if ($this->request->getStringParam('confirmation') === 'yes') { $this->checkCSRFParam(); - if ($this->taskStatus->open($task['id'])) { - $this->session->flash(t('Task opened successfully.')); + if ($this->taskStatus->$method($task['id'])) { + $this->session->flash($success_message); } else { - $this->session->flashError(t('Unable to open this task.')); + $this->session->flashError($failure_message); } - $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']))); + if ($this->request->getStringParam('redirect') === 'board') { + $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id']))); + } + + $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); + } + } + + private function renderTemplate(array $task, $template) + { + $redirect = $this->request->getStringParam('redirect'); + + if ($this->request->isAjax()) { + $this->response->html($this->template->render($template, array( + 'task' => $task, + 'redirect' => $redirect, + ))); } - $this->response->html($this->taskLayout('task_status/open', array( + $this->response->html($this->taskLayout($template, array( 'task' => $task, + 'redirect' => $redirect, ))); } } diff --git a/app/Template/board/task_menu.php b/app/Template/board/task_menu.php index 1434a1a0d..3eb357058 100644 --- a/app/Template/board/task_menu.php +++ b/app/Template/board/task_menu.php @@ -8,6 +8,10 @@
- = t('Do you really want to close the task "%s" as well as all subtasks?', $this->e($task['title'])) ?> + = t('Do you really want to close the task "%s" as well as all subtasks?', $task['title']) ?>
- = t('Do you really want to open this task: "%s"?', $this->e($task['title'])) ?> + = t('Do you really want to open this task: "%s"?', $task['title']) ?>