diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-09-05 17:06:01 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-09-05 17:06:01 -0400 |
commit | 70d3340cd0c9d7a009c186b14ca436e9c4e61aa5 (patch) | |
tree | 2fd898d99e73d79607beb72f57cbd706f238f976 /app/Controller/Taskcreation.php | |
parent | ccaf78b3484134336212780587835befa8759096 (diff) |
Creating another task stay in the popover
Diffstat (limited to 'app/Controller/Taskcreation.php')
-rw-r--r-- | app/Controller/Taskcreation.php | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/app/Controller/Taskcreation.php b/app/Controller/Taskcreation.php index ff25c5da..b9e9a33c 100644 --- a/app/Controller/Taskcreation.php +++ b/app/Controller/Taskcreation.php @@ -59,25 +59,29 @@ class Taskcreation extends Base list($valid, $errors) = $this->taskValidator->validateCreation($values); - if ($valid) { + if ($valid && $this->taskCreation->create($values)) { + $this->session->flash(t('Task created successfully.')); + $this->afterSave($project, $values); + } + else { + $this->session->flashError(t('Unable to create your task.')); + } - if ($this->taskCreation->create($values)) { - $this->session->flash(t('Task created successfully.')); + $this->create($values, $errors); + } - if (isset($values['another_task']) && $values['another_task'] == 1) { - unset($values['title']); - unset($values['description']); - $this->response->redirect($this->helper->url->to('taskcreation', 'create', $values)); - } - else { - $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $project['id']))); - } - } - else { - $this->session->flashError(t('Unable to create your task.')); + private function afterSave(array $project, array &$values) + { + if (isset($values['another_task']) && $values['another_task'] == 1) { + unset($values['title']); + unset($values['description']); + + if (! $this->request->isAjax()) { + $this->response->redirect($this->helper->url->to('taskcreation', 'create', $values)); } } - - $this->create($values, $errors); + else { + $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $project['id']))); + } } } |