Added task creation menu for all projects views

This commit is contained in:
Frederic Guillot
2016-05-15 20:09:43 -04:00
parent 67b8361649
commit 8a6f02735b
14 changed files with 53 additions and 42 deletions

View File

@@ -3,12 +3,14 @@ Version 1.0.29 (unreleased)
New features: New features:
* Added menu entry to add tasks from all project views
* Add tasks in bulk from the board * Add tasks in bulk from the board
* Add dropdown for projects * Add dropdown for projects
Improvements: Improvements:
* Use Gulp and Bower to manage assets * Use Gulp and Bower to manage assets
* Controller and Middleware refactoring
Version 1.0.28 Version 1.0.28
-------------- --------------

View File

@@ -81,9 +81,9 @@ class DashboardController extends BaseController
$this->response->html($this->helper->layout->dashboard('dashboard/show', array( $this->response->html($this->helper->layout->dashboard('dashboard/show', array(
'title' => t('Dashboard'), 'title' => t('Dashboard'),
'project_paginator' => $this->getProjectPaginator($user['id'], 'index', 10), 'project_paginator' => $this->getProjectPaginator($user['id'], 'show', 10),
'task_paginator' => $this->getTaskPaginator($user['id'], 'index', 10), 'task_paginator' => $this->getTaskPaginator($user['id'], 'show', 10),
'subtask_paginator' => $this->getSubtaskPaginator($user['id'], 'index', 10), 'subtask_paginator' => $this->getSubtaskPaginator($user['id'], 'show', 10),
'user' => $user, 'user' => $user,
))); )));
} }

View File

@@ -3,11 +3,11 @@
namespace Kanboard\Controller; namespace Kanboard\Controller;
/** /**
* Class TaskBulk * Class TaskBulkController
* *
* @package Kanboard\Controller * @package Kanboard\Controller
*/ */
class TaskBulk extends BaseController class TaskBulkController extends BaseController
{ {
/** /**
* Show the form * Show the form

View File

@@ -3,12 +3,12 @@
namespace Kanboard\Controller; namespace Kanboard\Controller;
/** /**
* Task Creation controller * Task Creation Controller
* *
* @package controller * @package Kanboard\Controller
* @author Frederic Guillot * @author Frederic Guillot
*/ */
class Taskcreation extends BaseController class TaskCreationController extends BaseController
{ {
/** /**
* Display a form to create a new task * Display a form to create a new task
@@ -18,7 +18,7 @@ class Taskcreation extends BaseController
* @param array $errors * @param array $errors
* @throws \Kanboard\Core\Controller\PageNotFoundException * @throws \Kanboard\Core\Controller\PageNotFoundException
*/ */
public function create(array $values = array(), array $errors = array()) public function show(array $values = array(), array $errors = array())
{ {
$project = $this->getProject(); $project = $this->getProject();
$swimlanes_list = $this->swimlane->getList($project['id'], false, true); $swimlanes_list = $this->swimlane->getList($project['id'], false, true);
@@ -35,7 +35,7 @@ class Taskcreation extends BaseController
$values = $this->hook->merge('controller:task-creation:form:default', $values, array('default_values' => $values)); $values = $this->hook->merge('controller:task-creation:form:default', $values, array('default_values' => $values));
} }
$this->response->html($this->template->render('task_creation/form', array( $this->response->html($this->template->render('task_creation/show', array(
'project' => $project, 'project' => $project,
'errors' => $errors, 'errors' => $errors,
'values' => $values + array('project_id' => $project['id']), 'values' => $values + array('project_id' => $project['id']),
@@ -66,13 +66,13 @@ class Taskcreation extends BaseController
} }
$this->flash->failure(t('Unable to create your task.')); $this->flash->failure(t('Unable to create your task.'));
return $this->create($values, $errors); return $this->show($values, $errors);
} }
private function afterSave(array $project, array &$values) private function afterSave(array $project, array &$values)
{ {
if (isset($values['another_task']) && $values['another_task'] == 1) { if (isset($values['another_task']) && $values['another_task'] == 1) {
return $this->create(array( return $this->show(array(
'owner_id' => $values['owner_id'], 'owner_id' => $values['owner_id'],
'color_id' => $values['color_id'], 'color_id' => $values['color_id'],
'category_id' => isset($values['category_id']) ? $values['category_id'] : 0, 'category_id' => isset($values['category_id']) ? $values['category_id'] : 0,

View File

@@ -25,10 +25,10 @@ abstract class BaseMiddleware extends Base
/** /**
* Set next middleware * Set next middleware
* *
* @param BaseMiddleware $nextMiddleware * @param BaseMiddleware|null $nextMiddleware
* @return BaseMiddleware * @return BaseMiddleware
*/ */
public function setNextMiddleware($nextMiddleware) public function setNextMiddleware(BaseMiddleware $nextMiddleware)
{ {
$this->nextMiddleware = $nextMiddleware; $this->nextMiddleware = $nextMiddleware;
return $this; return $this;

View File

@@ -91,7 +91,8 @@ class AuthenticationProvider implements ServiceProviderInterface
$acl->add('SubtaskStatus', '*', Role::PROJECT_MEMBER); $acl->add('SubtaskStatus', '*', Role::PROJECT_MEMBER);
$acl->add('Swimlane', '*', Role::PROJECT_MANAGER); $acl->add('Swimlane', '*', Role::PROJECT_MANAGER);
$acl->add('Task', 'remove', Role::PROJECT_MEMBER); $acl->add('Task', 'remove', Role::PROJECT_MEMBER);
$acl->add('Taskcreation', '*', Role::PROJECT_MEMBER); $acl->add('TaskCreationController', '*', Role::PROJECT_MEMBER);
$acl->add('TaskBulkController', '*', Role::PROJECT_MEMBER);
$acl->add('Taskduplication', '*', Role::PROJECT_MEMBER); $acl->add('Taskduplication', '*', Role::PROJECT_MEMBER);
$acl->add('TaskRecurrence', '*', Role::PROJECT_MEMBER); $acl->add('TaskRecurrence', '*', Role::PROJECT_MEMBER);
$acl->add('TaskImport', '*', Role::PROJECT_MANAGER); $acl->add('TaskImport', '*', Role::PROJECT_MANAGER);

View File

@@ -32,10 +32,10 @@ class BootstrapSubscriber extends BaseSubscriber implements EventSubscriberInter
$this->logger->debug('SQL: ' . $message); $this->logger->debug('SQL: ' . $message);
} }
$this->logger->debug('nb_queries={nb}', array('nb' => $this->db->getStatementHandler()->getNbQueries())); $this->logger->debug('APP: nb_queries={nb}', array('nb' => $this->db->getStatementHandler()->getNbQueries()));
$this->logger->debug('rendering_time={time}', array('time' => microtime(true) - $this->request->getStartTime())); $this->logger->debug('APP: rendering_time={time}', array('time' => microtime(true) - $this->request->getStartTime()));
$this->logger->debug('memory_usage='.$this->helper->text->bytes(memory_get_usage())); $this->logger->debug('APP: memory_usage='.$this->helper->text->bytes(memory_get_usage()));
$this->logger->debug('uri='.$this->request->getUri()); $this->logger->debug('APP: uri='.$this->request->getUri());
$this->logger->debug('###############################################'); $this->logger->debug('###############################################');
} }
} }

View File

@@ -12,9 +12,9 @@
<!-- column in expanded mode --> <!-- column in expanded mode -->
<div class="board-column-expanded"> <div class="board-column-expanded">
<?php if (! $not_editable && $this->user->hasProjectAccess('taskcreation', 'create', $column['project_id'])): ?> <?php if (! $not_editable && $this->user->hasProjectAccess('TaskCreationController', 'show', $column['project_id'])): ?>
<div class="board-add-icon"> <div class="board-add-icon">
<?= $this->url->link('+', 'taskcreation', 'create', array('project_id' => $column['project_id'], 'column_id' => $column['id'], 'swimlane_id' => $swimlane['id']), false, 'popover', t('Add a new task')) ?> <?= $this->url->link('+', 'TaskCreationController', 'show', array('project_id' => $column['project_id'], 'column_id' => $column['id'], 'swimlane_id' => $swimlane['id']), false, 'popover', t('Add a new task')) ?>
</div> </div>
<?php endif ?> <?php endif ?>
@@ -35,10 +35,10 @@
<i class="fa fa-minus-square fa-fw"></i> <i class="fa fa-minus-square fa-fw"></i>
<a href="#" class="board-toggle-column-view" data-column-id="<?= $column['id'] ?>"><?= t('Hide this column') ?></a> <a href="#" class="board-toggle-column-view" data-column-id="<?= $column['id'] ?>"><?= t('Hide this column') ?></a>
</li> </li>
<?php if ($this->user->hasProjectAccess('Taskcreation', 'create', $column['project_id'])): ?> <?php if ($this->user->hasProjectAccess('TaskCreationController', 'show', $column['project_id'])): ?>
<li> <li>
<i class="fa fa-align-justify" aria-hidden="true"></i> <i class="fa fa-align-justify" aria-hidden="true"></i>
<?= $this->url->link(t('Create tasks in bulk'), 'TaskBulk', 'show', array('project_id' => $column['project_id'], 'column_id' => $column['id'], 'swimlane_id' => $swimlane['id']), false, 'popover') ?> <?= $this->url->link(t('Create tasks in bulk'), 'TaskBulkController', 'show', array('project_id' => $column['project_id'], 'column_id' => $column['id'], 'swimlane_id' => $swimlane['id']), false, 'popover') ?>
</li> </li>
<?php if ($column['nb_tasks'] > 0): ?> <?php if ($column['nb_tasks'] > 0): ?>
<li> <li>

View File

@@ -13,7 +13,7 @@
data-save-url="<?= $this->url->href('board', 'save', array('project_id' => $project['id'])) ?>" data-save-url="<?= $this->url->href('board', 'save', array('project_id' => $project['id'])) ?>"
data-reload-url="<?= $this->url->href('board', 'reload', array('project_id' => $project['id'])) ?>" data-reload-url="<?= $this->url->href('board', 'reload', array('project_id' => $project['id'])) ?>"
data-check-url="<?= $this->url->href('board', 'check', array('project_id' => $project['id'], 'timestamp' => time())) ?>" data-check-url="<?= $this->url->href('board', 'check', array('project_id' => $project['id'], 'timestamp' => time())) ?>"
data-task-creation-url="<?= $this->url->href('taskcreation', 'create', array('project_id' => $project['id'])) ?>" data-task-creation-url="<?= $this->url->href('TaskCreationController', 'show', array('project_id' => $project['id'])) ?>"
> >
<?php endif ?> <?php endif ?>
@@ -55,4 +55,4 @@
</table> </table>
<?php endif ?> <?php endif ?>
</div> </div>

View File

@@ -59,4 +59,4 @@
<?= $paginator ?> <?= $paginator ?>
<?php endif ?> <?php endif ?>
</section> </section>

View File

@@ -30,21 +30,29 @@
</li> </li>
<?php endif ?> <?php endif ?>
<?php if ($this->user->hasProjectAccess('TaskCreationController', 'show', $project['id'])): ?>
<li>
<i class="fa fa-plus fa-fw"></i>
<?= $this->url->link(t('Add a new task'), 'TaskCreationController', 'show', array('project_id' => $project['id']), false, 'popover') ?>
</li>
<?php endif ?>
<li> <li>
<i class="fa fa-dashboard fa-fw"></i>&nbsp; <i class="fa fa-dashboard fa-fw"></i>
<?= $this->url->link(t('Activity'), 'activity', 'project', array('project_id' => $project['id'])) ?> <?= $this->url->link(t('Activity'), 'activity', 'project', array('project_id' => $project['id'])) ?>
</li> </li>
<?php if ($this->user->hasProjectAccess('customfilter', 'index', $project['id'])): ?> <?php if ($this->user->hasProjectAccess('customfilter', 'index', $project['id'])): ?>
<li> <li>
<i class="fa fa-filter fa-fw"></i>&nbsp; <i class="fa fa-filter fa-fw"></i>
<?= $this->url->link(t('Custom filters'), 'customfilter', 'index', array('project_id' => $project['id'])) ?> <?= $this->url->link(t('Custom filters'), 'customfilter', 'index', array('project_id' => $project['id'])) ?>
</li> </li>
<?php endif ?> <?php endif ?>
<?php if ($project['is_public']): ?> <?php if ($project['is_public']): ?>
<li> <li>
<i class="fa fa-share-alt fa-fw"></i>&nbsp;<?= $this->url->link(t('Public link'), 'board', 'readonly', array('token' => $project['token']), false, '', '', true) ?> <i class="fa fa-share-alt fa-fw"></i>
<?= $this->url->link(t('Public link'), 'board', 'readonly', array('token' => $project['token']), false, '', '', true) ?>
</li> </li>
<?php endif ?> <?php endif ?>
@@ -52,21 +60,21 @@
<?php if ($this->user->hasProjectAccess('analytic', 'tasks', $project['id'])): ?> <?php if ($this->user->hasProjectAccess('analytic', 'tasks', $project['id'])): ?>
<li> <li>
<i class="fa fa-line-chart fa-fw"></i>&nbsp; <i class="fa fa-line-chart fa-fw"></i>
<?= $this->url->link(t('Analytics'), 'analytic', 'tasks', array('project_id' => $project['id'])) ?> <?= $this->url->link(t('Analytics'), 'analytic', 'tasks', array('project_id' => $project['id'])) ?>
</li> </li>
<?php endif ?> <?php endif ?>
<?php if ($this->user->hasProjectAccess('export', 'tasks', $project['id'])): ?> <?php if ($this->user->hasProjectAccess('export', 'tasks', $project['id'])): ?>
<li> <li>
<i class="fa fa-download fa-fw"></i>&nbsp; <i class="fa fa-download fa-fw"></i>
<?= $this->url->link(t('Exports'), 'export', 'tasks', array('project_id' => $project['id'])) ?> <?= $this->url->link(t('Exports'), 'export', 'tasks', array('project_id' => $project['id'])) ?>
</li> </li>
<?php endif ?> <?php endif ?>
<?php if ($this->user->hasProjectAccess('ProjectEdit', 'edit', $project['id'])): ?> <?php if ($this->user->hasProjectAccess('ProjectEdit', 'edit', $project['id'])): ?>
<li> <li>
<i class="fa fa-cog fa-fw"></i>&nbsp; <i class="fa fa-cog fa-fw"></i>
<?= $this->url->link(t('Settings'), 'project', 'show', array('project_id' => $project['id'])) ?> <?= $this->url->link(t('Settings'), 'project', 'show', array('project_id' => $project['id'])) ?>
</li> </li>
<?php endif ?> <?php endif ?>

View File

@@ -2,7 +2,7 @@
<h2><?= t('Create tasks in bulk') ?></h2> <h2><?= t('Create tasks in bulk') ?></h2>
</div> </div>
<form class="popover-form" method="post" action="<?= $this->url->href('TaskBulk', 'save', array('project_id' => $project['id'])) ?>" autocomplete="off"> <form class="popover-form" method="post" action="<?= $this->url->href('TaskBulkController', 'save', array('project_id' => $project['id'])) ?>" autocomplete="off">
<?= $this->form->csrf() ?> <?= $this->form->csrf() ?>
<?= $this->form->hidden('column_id', $values) ?> <?= $this->form->hidden('column_id', $values) ?>
<?= $this->form->hidden('swimlane_id', $values) ?> <?= $this->form->hidden('swimlane_id', $values) ?>

View File

@@ -2,7 +2,7 @@
<h2><?= t('New task') ?></h2> <h2><?= t('New task') ?></h2>
</div> </div>
<form class="popover-form" method="post" action="<?= $this->url->href('taskcreation', 'save', array('project_id' => $values['project_id'])) ?>" autocomplete="off"> <form class="popover-form" method="post" action="<?= $this->url->href('TaskCreationController', 'save', array('project_id' => $values['project_id'])) ?>" autocomplete="off">
<?= $this->form->csrf() ?> <?= $this->form->csrf() ?>

View File

@@ -141,12 +141,12 @@ class UserHelperTest extends Base
$this->assertTrue($helper->hasProjectAccess('ProjectEdit', 'edit', 1)); $this->assertTrue($helper->hasProjectAccess('ProjectEdit', 'edit', 1));
$this->assertTrue($helper->hasProjectAccess('board', 'show', 1)); $this->assertTrue($helper->hasProjectAccess('board', 'show', 1));
$this->assertTrue($helper->hasProjectAccess('task', 'show', 1)); $this->assertTrue($helper->hasProjectAccess('task', 'show', 1));
$this->assertTrue($helper->hasProjectAccess('taskcreation', 'save', 1)); $this->assertTrue($helper->hasProjectAccess('taskcreationcontroller', 'save', 1));
$this->assertFalse($helper->hasProjectAccess('ProjectEdit', 'edit', 2)); $this->assertFalse($helper->hasProjectAccess('ProjectEdit', 'edit', 2));
$this->assertFalse($helper->hasProjectAccess('board', 'show', 2)); $this->assertFalse($helper->hasProjectAccess('board', 'show', 2));
$this->assertFalse($helper->hasProjectAccess('task', 'show', 2)); $this->assertFalse($helper->hasProjectAccess('task', 'show', 2));
$this->assertFalse($helper->hasProjectAccess('taskcreation', 'save', 2)); $this->assertFalse($helper->hasProjectAccess('TaskCreationController', 'save', 2));
} }
public function testHasProjectAccessForProjectManagers() public function testHasProjectAccessForProjectManagers()
@@ -169,12 +169,12 @@ class UserHelperTest extends Base
$this->assertTrue($helper->hasProjectAccess('ProjectEdit', 'edit', 1)); $this->assertTrue($helper->hasProjectAccess('ProjectEdit', 'edit', 1));
$this->assertTrue($helper->hasProjectAccess('board', 'show', 1)); $this->assertTrue($helper->hasProjectAccess('board', 'show', 1));
$this->assertTrue($helper->hasProjectAccess('task', 'show', 1)); $this->assertTrue($helper->hasProjectAccess('task', 'show', 1));
$this->assertTrue($helper->hasProjectAccess('taskcreation', 'save', 1)); $this->assertTrue($helper->hasProjectAccess('TaskCreationController', 'save', 1));
$this->assertFalse($helper->hasProjectAccess('ProjectEdit', 'edit', 2)); $this->assertFalse($helper->hasProjectAccess('ProjectEdit', 'edit', 2));
$this->assertFalse($helper->hasProjectAccess('board', 'show', 2)); $this->assertFalse($helper->hasProjectAccess('board', 'show', 2));
$this->assertFalse($helper->hasProjectAccess('task', 'show', 2)); $this->assertFalse($helper->hasProjectAccess('task', 'show', 2));
$this->assertFalse($helper->hasProjectAccess('taskcreation', 'save', 2)); $this->assertFalse($helper->hasProjectAccess('TaskCreationController', 'save', 2));
} }
public function testHasProjectAccessForProjectMembers() public function testHasProjectAccessForProjectMembers()
@@ -197,12 +197,12 @@ class UserHelperTest extends Base
$this->assertFalse($helper->hasProjectAccess('ProjectEdit', 'edit', 1)); $this->assertFalse($helper->hasProjectAccess('ProjectEdit', 'edit', 1));
$this->assertTrue($helper->hasProjectAccess('board', 'show', 1)); $this->assertTrue($helper->hasProjectAccess('board', 'show', 1));
$this->assertTrue($helper->hasProjectAccess('task', 'show', 1)); $this->assertTrue($helper->hasProjectAccess('task', 'show', 1));
$this->assertTrue($helper->hasProjectAccess('taskcreation', 'save', 1)); $this->assertTrue($helper->hasProjectAccess('TaskCreationController', 'save', 1));
$this->assertFalse($helper->hasProjectAccess('ProjectEdit', 'edit', 2)); $this->assertFalse($helper->hasProjectAccess('ProjectEdit', 'edit', 2));
$this->assertFalse($helper->hasProjectAccess('board', 'show', 2)); $this->assertFalse($helper->hasProjectAccess('board', 'show', 2));
$this->assertFalse($helper->hasProjectAccess('task', 'show', 2)); $this->assertFalse($helper->hasProjectAccess('task', 'show', 2));
$this->assertFalse($helper->hasProjectAccess('taskcreation', 'save', 2)); $this->assertFalse($helper->hasProjectAccess('TaskCreationController', 'save', 2));
} }
public function testHasProjectAccessForProjectViewers() public function testHasProjectAccessForProjectViewers()
@@ -225,12 +225,12 @@ class UserHelperTest extends Base
$this->assertFalse($helper->hasProjectAccess('ProjectEdit', 'edit', 1)); $this->assertFalse($helper->hasProjectAccess('ProjectEdit', 'edit', 1));
$this->assertTrue($helper->hasProjectAccess('board', 'show', 1)); $this->assertTrue($helper->hasProjectAccess('board', 'show', 1));
$this->assertTrue($helper->hasProjectAccess('task', 'show', 1)); $this->assertTrue($helper->hasProjectAccess('task', 'show', 1));
$this->assertFalse($helper->hasProjectAccess('taskcreation', 'save', 1)); $this->assertFalse($helper->hasProjectAccess('TaskCreationController', 'save', 1));
$this->assertFalse($helper->hasProjectAccess('ProjectEdit', 'edit', 2)); $this->assertFalse($helper->hasProjectAccess('ProjectEdit', 'edit', 2));
$this->assertFalse($helper->hasProjectAccess('board', 'show', 2)); $this->assertFalse($helper->hasProjectAccess('board', 'show', 2));
$this->assertFalse($helper->hasProjectAccess('task', 'show', 2)); $this->assertFalse($helper->hasProjectAccess('task', 'show', 2));
$this->assertFalse($helper->hasProjectAccess('taskcreation', 'save', 2)); $this->assertFalse($helper->hasProjectAccess('TaskCreationController', 'save', 2));
} }
public function testCanRemoveTask() public function testCanRemoveTask()