Unify task drop-down menu between different views
This commit is contained in:
@@ -44,7 +44,7 @@ class BoardPopover extends Base
|
||||
$this->flash->failure(t('Unable to update your task.'));
|
||||
}
|
||||
|
||||
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $values['project_id'])));
|
||||
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $values['project_id'])), true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ class BoardPopover extends Base
|
||||
$this->flash->failure(t('Unable to update your task.'));
|
||||
}
|
||||
|
||||
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $values['project_id'])));
|
||||
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $values['project_id'])), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -151,7 +151,7 @@ class Task extends Base
|
||||
{
|
||||
$task = $this->getTask();
|
||||
|
||||
if (! $this->taskPermission->canRemoveTask($task)) {
|
||||
if (! $this->helper->user->canRemoveTask($task)) {
|
||||
$this->forbidden();
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ class Task extends Base
|
||||
$this->flash->failure(t('Unable to remove this task.'));
|
||||
}
|
||||
|
||||
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
|
||||
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])), true);
|
||||
}
|
||||
|
||||
$this->response->html($this->template->render('task/remove', array(
|
||||
|
||||
@@ -92,7 +92,6 @@ use Pimple\Container;
|
||||
* @property \Kanboard\Model\TaskFinder $taskFinder
|
||||
* @property \Kanboard\Model\TaskLink $taskLink
|
||||
* @property \Kanboard\Model\TaskModification $taskModification
|
||||
* @property \Kanboard\Model\TaskPermission $taskPermission
|
||||
* @property \Kanboard\Model\TaskPosition $taskPosition
|
||||
* @property \Kanboard\Model\TaskStatus $taskStatus
|
||||
* @property \Kanboard\Model\TaskMetadata $taskMetadata
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Kanboard\Helper;
|
||||
|
||||
use Kanboard\Core\Base;
|
||||
use Kanboard\Core\Security\Role;
|
||||
|
||||
/**
|
||||
* User helpers
|
||||
@@ -41,6 +42,17 @@ class UserHelper extends Base
|
||||
return mb_strtoupper($initials);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the user full name
|
||||
*
|
||||
* @param array $user User properties
|
||||
* @return string
|
||||
*/
|
||||
public function getFullname(array $user = array())
|
||||
{
|
||||
return $this->user->getFullname(empty($user) ? $this->userSession->getAll() : $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user id
|
||||
*
|
||||
@@ -149,13 +161,24 @@ class UserHelper extends Base
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the user full name
|
||||
* Return true if the user can remove a task
|
||||
*
|
||||
* @param array $user User properties
|
||||
* @return string
|
||||
* Regular users can't remove tasks from other people
|
||||
*
|
||||
* @public
|
||||
* @param array $task
|
||||
* @return bool
|
||||
*/
|
||||
public function getFullname(array $user = array())
|
||||
public function canRemoveTask(array $task)
|
||||
{
|
||||
return $this->user->getFullname(empty($user) ? $this->userSession->getAll() : $user);
|
||||
if (isset($task['creator_id']) && $task['creator_id'] == $this->userSession->getId()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->userSession->isAdmin() || $this->getProjectUserRole($task['project_id']) === Role::PROJECT_MANAGER) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,8 @@ class TaskFinder extends Base
|
||||
'tasks.priority',
|
||||
'tasks.time_spent',
|
||||
'tasks.time_estimated',
|
||||
'tasks.is_active',
|
||||
'tasks.creator_id',
|
||||
'projects.name AS project_name'
|
||||
)
|
||||
->join(Project::TABLE, 'id', 'project_id')
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Model;
|
||||
|
||||
use Kanboard\Core\Security\Role;
|
||||
|
||||
/**
|
||||
* Task permission model
|
||||
*
|
||||
* @package model
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskPermission extends Base
|
||||
{
|
||||
/**
|
||||
* Return true if the user can remove a task
|
||||
*
|
||||
* Regular users can't remove tasks from other people
|
||||
*
|
||||
* @public
|
||||
* @param array $task
|
||||
* @return bool
|
||||
*/
|
||||
public function canRemoveTask(array $task)
|
||||
{
|
||||
if ($this->userSession->isAdmin() || $this->projectUserRole->getUserRole($task['project_id'], $this->userSession->getId()) === Role::PROJECT_MANAGER) {
|
||||
return true;
|
||||
} elseif (isset($task['creator_id']) && $task['creator_id'] == $this->userSession->getId()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,6 @@ class ClassProvider implements ServiceProviderInterface
|
||||
'TaskFile',
|
||||
'TaskLink',
|
||||
'TaskModification',
|
||||
'TaskPermission',
|
||||
'TaskPosition',
|
||||
'TaskStatus',
|
||||
'TaskMetadata',
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<span class="dropdown">
|
||||
<a href="#" class="dropdown-menu"><?= '#'.$task['id'] ?> <i class="fa fa-caret-down"></i></a>
|
||||
<ul>
|
||||
<li><i class="fa fa-user fa-fw"></i> <?= $this->url->link(t('Change assignee'), 'BoardPopover', 'changeAssignee', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li>
|
||||
<li><i class="fa fa-tag fa-fw"></i> <?= $this->url->link(t('Change category'), 'BoardPopover', 'changeCategory', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li>
|
||||
<li><i class="fa fa-align-left fa-fw"></i> <?= $this->url->link(t('Change description'), 'taskmodification', 'description', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li>
|
||||
<li><i class="fa fa-pencil-square-o fa-fw"></i> <?= $this->url->link(t('Edit this task'), 'taskmodification', 'edit', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li>
|
||||
<li><i class="fa fa-comment-o fa-fw"></i> <?= $this->url->link(t('Add a comment'), 'comment', 'create', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li>
|
||||
<li><i class="fa fa-code-fork fa-fw"></i> <?= $this->url->link(t('Add internal link'), 'TaskInternalLink', 'create', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li>
|
||||
<li><i class="fa fa-external-link fa-fw"></i> <?= $this->url->link(t('Add external link'), 'TaskExternalLink', 'find', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li>
|
||||
<li><i class="fa fa-camera fa-fw"></i> <?= $this->url->link(t('Add a screenshot'), 'BoardPopover', 'screenshot', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li>
|
||||
<?php if ($task['is_active'] == 1): ?>
|
||||
<li><i class="fa fa-close fa-fw"></i> <?= $this->url->link(t('Close this task'), 'taskstatus', 'close', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li>
|
||||
<?php else: ?>
|
||||
<li><i class="fa fa-check-square-o fa-fw"></i> <?= $this->url->link(t('Open this task'), 'taskstatus', 'open', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li>
|
||||
<?php endif ?>
|
||||
</ul>
|
||||
</span>
|
||||
@@ -17,7 +17,7 @@
|
||||
<div class="task-board-collapsed">
|
||||
<div class="task-board-saving-icon" style="display: none;"><i class="fa fa-spinner fa-pulse"></i></div>
|
||||
<?php if ($this->user->hasProjectAccess('taskmodification', 'edit', $task['project_id'])): ?>
|
||||
<?= $this->render('board/task_menu', array('task' => $task)) ?>
|
||||
<?= $this->render('task/dropdown', array('task' => $task)) ?>
|
||||
<?php else: ?>
|
||||
<strong><?= '#'.$task['id'] ?></strong>
|
||||
<?php endif ?>
|
||||
@@ -33,7 +33,7 @@
|
||||
<div class="task-board-expanded">
|
||||
<div class="task-board-saving-icon" style="display: none;"><i class="fa fa-spinner fa-pulse fa-2x"></i></div>
|
||||
<?php if ($this->user->hasProjectAccess('taskmodification', 'edit', $task['project_id'])): ?>
|
||||
<?= $this->render('board/task_menu', array('task' => $task)) ?>
|
||||
<?= $this->render('task/dropdown', array('task' => $task)) ?>
|
||||
<?php else: ?>
|
||||
<strong><?= '#'.$task['id'] ?></strong>
|
||||
<?php endif ?>
|
||||
|
||||
@@ -7,6 +7,14 @@
|
||||
<?= $this->url->link(t('Set automatically the start date'), 'taskmodification', 'start', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
|
||||
</li>
|
||||
<?php endif ?>
|
||||
<li>
|
||||
<i class="fa fa-user fa-fw"></i>
|
||||
<?= $this->url->link(t('Change assignee'), 'BoardPopover', 'changeAssignee', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-tag fa-fw"></i>
|
||||
<?= $this->url->link(t('Change category'), 'BoardPopover', 'changeCategory', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-pencil-square-o fa-fw"></i>
|
||||
<?= $this->url->link(t('Edit the task'), 'taskmodification', 'edit', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
|
||||
@@ -31,6 +39,10 @@
|
||||
<i class="fa fa-comment-o fa-fw"></i>
|
||||
<?= $this->url->link(t('Add a comment'), 'comment', 'create', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-camera fa-fw"></i>
|
||||
<?= $this->url->link(t('Add a screenshot'), 'BoardPopover', 'screenshot', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
|
||||
</li>
|
||||
<li>
|
||||
<i class="fa fa-files-o fa-fw"></i>
|
||||
<?= $this->url->link(t('Duplicate'), 'taskduplication', 'duplicate', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
|
||||
@@ -43,6 +55,12 @@
|
||||
<i class="fa fa-clone fa-fw"></i>
|
||||
<?= $this->url->link(t('Move to another project'), 'taskduplication', 'move', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
|
||||
</li>
|
||||
<?php if ($this->user->canRemoveTask($task)): ?>
|
||||
<li>
|
||||
<i class="fa fa-trash-o fa-fw"></i>
|
||||
<?= $this->url->link(t('Remove'), 'task', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
|
||||
</li>
|
||||
<?php endif ?>
|
||||
<?php if (isset($task['is_active'])): ?>
|
||||
<li>
|
||||
<?php if ($task['is_active'] == 1): ?>
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
</p>
|
||||
|
||||
<div class="form-actions">
|
||||
<?= $this->url->link(t('Yes'), 'task', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'confirmation' => 'yes'), true, 'btn btn-red') ?>
|
||||
<?= $this->url->link(t('Yes'), 'task', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'confirmation' => 'yes'), true, 'btn btn-red popover-link') ?>
|
||||
<?= t('or') ?>
|
||||
<?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
<?= $this->url->link(t('Open this task'), 'taskstatus', 'open', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
|
||||
<?php endif ?>
|
||||
</li>
|
||||
<?php if ($this->task->canRemove($task)): ?>
|
||||
<?php if ($this->user->canRemoveTask($task)): ?>
|
||||
<li>
|
||||
<i class="fa fa-trash-o fa-fw"></i>
|
||||
<?= $this->url->link(t('Remove'), 'task', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
|
||||
|
||||
Reference in New Issue
Block a user