Fix wrong redirect after removing a task from the task view page

This commit is contained in:
Frederic Guillot 2016-05-28 17:26:33 -04:00
parent 9e218032c4
commit 88ee691bb9
7 changed files with 58 additions and 34 deletions

View File

@ -22,6 +22,7 @@ Improvements:
Bug fixes:
* Do not send notifications to disabled users
* Fix wrong redirect when removing a task from the task view page
Breaking changes:

View File

@ -0,0 +1,53 @@
<?php
namespace Kanboard\Controller;
use Kanboard\Core\Controller\AccessForbiddenException;
/**
* Class TaskSuppressionController
*
* @package Kanboard\Controller
* @author Frederic Guillot
*/
class TaskSuppressionController extends BaseController
{
/**
* Confirmation dialog box before to remove the task
*/
public function confirm()
{
$task = $this->getTask();
if (! $this->helper->user->canRemoveTask($task)) {
throw new AccessForbiddenException();
}
$this->response->html($this->template->render('task_suppression/remove', array(
'task' => $task,
'redirect' => $this->request->getStringParam('redirect'),
)));
}
/**
* Remove a task
*/
public function remove()
{
$task = $this->getTask();
$this->checkCSRFParam();
if (! $this->helper->user->canRemoveTask($task)) {
throw new AccessForbiddenException();
}
if ($this->task->remove($task['id'])) {
$this->flash->success(t('Task removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this task.'));
}
$redirect = $this->request->getStringParam('redirect') === '';
$this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $task['project_id'])), $redirect);
}
}

View File

@ -143,34 +143,4 @@ class TaskViewController extends BaseController
'transitions' => $this->transition->getAllByTask($task['id']),
)));
}
/**
* Remove a task
*
* @access public
*/
public function remove()
{
$task = $this->getTask();
if (! $this->helper->user->canRemoveTask($task)) {
throw new AccessForbiddenException();
}
if ($this->request->getStringParam('confirmation') === 'yes') {
$this->checkCSRFParam();
if ($this->task->remove($task['id'])) {
$this->flash->success(t('Task removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this task.'));
}
return $this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $task['project_id'])), true);
}
return $this->response->html($this->template->render('task/remove', array(
'task' => $task,
)));
}
}

View File

@ -92,7 +92,7 @@ class AuthenticationProvider implements ServiceProviderInterface
$acl->add('SubtaskRestrictionController', '*', Role::PROJECT_MEMBER);
$acl->add('SubtaskStatusController', '*', Role::PROJECT_MEMBER);
$acl->add('SwimlaneController', '*', Role::PROJECT_MANAGER);
$acl->add('TaskViewController', 'remove', Role::PROJECT_MEMBER);
$acl->add('TaskSuppressionController', '*', Role::PROJECT_MEMBER);
$acl->add('TaskCreationController', '*', Role::PROJECT_MEMBER);
$acl->add('TaskBulkController', '*', Role::PROJECT_MEMBER);
$acl->add('TaskDuplicationController', '*', Role::PROJECT_MEMBER);

View File

@ -58,7 +58,7 @@
<?php if ($this->user->canRemoveTask($task)): ?>
<li>
<i class="fa fa-trash-o fa-fw"></i>
<?= $this->url->link(t('Remove'), 'TaskViewController', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
<?= $this->url->link(t('Remove'), 'TaskSuppressionController', 'confirm', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
</li>
<?php endif ?>
<?php if (isset($task['is_active'])): ?>

View File

@ -90,7 +90,7 @@
<?php if ($this->user->canRemoveTask($task)): ?>
<li>
<i class="fa fa-trash-o fa-fw"></i>
<?= $this->url->link(t('Remove'), 'TaskViewController', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
<?= $this->url->link(t('Remove'), 'TaskSuppressionController', 'confirm', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'redirect' => 'board'), false, 'popover') ?>
</li>
<?php endif ?>

View File

@ -8,7 +8,7 @@
</p>
<div class="form-actions">
<?= $this->url->link(t('Yes'), 'TaskViewController', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'confirmation' => 'yes'), true, 'btn btn-red popover-link') ?>
<?= $this->url->link(t('Yes'), 'TaskSuppressionController', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'redirect' => $redirect), true, 'btn btn-red popover-link') ?>
<?= t('or') ?>
<?= $this->url->link(t('cancel'), 'TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?>
</div>