summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Controller/Taskcreation.php36
-rw-r--r--app/Controller/Taskmodification.php28
-rw-r--r--app/Core/Response.php8
-rw-r--r--app/Helper/App.php2
-rw-r--r--app/Template/task_creation/form.php6
-rw-r--r--app/Template/task_modification/edit_task.php6
6 files changed, 46 insertions, 40 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'])));
+ }
}
}
diff --git a/app/Controller/Taskmodification.php b/app/Controller/Taskmodification.php
index 56d2b9f9..638af594 100644
--- a/app/Controller/Taskmodification.php
+++ b/app/Controller/Taskmodification.php
@@ -126,11 +126,13 @@ class Taskmodification extends Base
);
if ($ajax) {
- $this->response->html($this->template->render('task_modification/edit_task', $params));
+ $html = $this->template->render('task_modification/edit_task', $params);
}
else {
- $this->response->html($this->taskLayout('task_modification/edit_task', $params));
+ $html = $this->taskLayout('task_modification/edit_task', $params);
}
+
+ $this->response->html($html);
}
/**
@@ -145,24 +147,20 @@ class Taskmodification extends Base
list($valid, $errors) = $this->taskValidator->validateModification($values);
- if ($valid) {
-
- if ($this->taskModification->update($values)) {
- $this->session->flash(t('Task updated successfully.'));
+ if ($valid && $this->taskModification->update($values)) {
+ $this->session->flash(t('Task updated successfully.'));
- if ($this->request->getIntegerParam('ajax')) {
- $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
- }
- else {
- $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])));
- }
+ if ($this->request->isAjax()) {
+ $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
}
else {
- $this->session->flashError(t('Unable to update your task.'));
+ $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])));
}
}
-
- $this->edit($values, $errors);
+ else {
+ $this->session->flashError(t('Unable to update your task.'));
+ $this->edit($values, $errors);
+ }
}
/**
diff --git a/app/Core/Response.php b/app/Core/Response.php
index d42a8f1e..f8ca015c 100644
--- a/app/Core/Response.php
+++ b/app/Core/Response.php
@@ -66,7 +66,13 @@ class Response
*/
public function redirect($url)
{
- header('Location: '.$url);
+ if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest') {
+ header('X-Ajax-Redirect: '.$url);
+ }
+ else {
+ header('Location: '.$url);
+ }
+
exit;
}
diff --git a/app/Helper/App.php b/app/Helper/App.php
index e5ebefcb..5fb89afe 100644
--- a/app/Helper/App.php
+++ b/app/Helper/App.php
@@ -67,9 +67,11 @@ class App extends \Core\Base
if (isset($this->session['flash_message'])) {
$html = '<div class="alert alert-success alert-fade-out">'.$this->helper->e($this->session['flash_message']).'</div>';
unset($this->session['flash_message']);
+ unset($this->session['flash_error_message']);
}
else if (isset($this->session['flash_error_message'])) {
$html = '<div class="alert alert-error">'.$this->helper->e($this->session['flash_error_message']).'</div>';
+ unset($this->session['flash_message']);
unset($this->session['flash_error_message']);
}
diff --git a/app/Template/task_creation/form.php b/app/Template/task_creation/form.php
index 8a29896e..747c843d 100644
--- a/app/Template/task_creation/form.php
+++ b/app/Template/task_creation/form.php
@@ -10,8 +10,7 @@
</div>
<?php endif ?>
-<section id="task-section">
-<form method="post" action="<?= $this->url->href('taskcreation', 'save', array('project_id' => $values['project_id'])) ?>" autocomplete="off">
+<form id="task-form" method="post" action="<?= $this->url->href('taskcreation', 'save', array('project_id' => $values['project_id'])) ?>" autocomplete="off">
<?= $this->form->csrf() ?>
@@ -80,5 +79,4 @@
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue" tabindex="11"/>
<?= t('or') ?> <?= $this->url->link(t('cancel'), 'board', 'show', array('project_id' => $values['project_id']), false, 'close-popover') ?>
</div>
-</form>
-</section>
+</form> \ No newline at end of file
diff --git a/app/Template/task_modification/edit_task.php b/app/Template/task_modification/edit_task.php
index fe4696d6..0cabc6e8 100644
--- a/app/Template/task_modification/edit_task.php
+++ b/app/Template/task_modification/edit_task.php
@@ -1,8 +1,7 @@
<div class="page-header">
<h2><?= t('Edit a task') ?></h2>
</div>
-<section id="task-section">
-<form method="post" action="<?= $this->url->href('taskmodification', 'update', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'ajax' => $ajax)) ?>" autocomplete="off">
+<form id="task-form" method="post" action="<?= $this->url->href('taskmodification', 'update', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" autocomplete="off">
<?= $this->form->csrf() ?>
@@ -62,5 +61,4 @@
<?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
<?php endif ?>
</div>
-</form>
-</section>
+</form> \ No newline at end of file