diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | app/Controller/TaskModificationController.php | 51 | ||||
-rw-r--r-- | app/Controller/TaskPopoverController.php | 74 | ||||
-rw-r--r-- | app/Template/task/dropdown.php | 12 | ||||
-rw-r--r-- | app/Template/task/sidebar.php | 4 | ||||
-rw-r--r-- | app/Template/task_modification/edit_description.php | 27 | ||||
-rw-r--r-- | app/Template/task_modification/show.php (renamed from app/Template/task_modification/edit_task.php) | 0 | ||||
-rw-r--r-- | app/Template/task_popover/change_assignee.php | 20 | ||||
-rw-r--r-- | app/Template/task_popover/change_category.php | 20 | ||||
-rw-r--r-- | app/Validator/TaskValidator.php | 47 | ||||
-rw-r--r-- | tests/units/Model/TaskCreationTest.php | 17 |
11 files changed, 2 insertions, 271 deletions
@@ -4,6 +4,7 @@ Version 1.0.31 (unreleased) Improvements: * Use the same task form layout everywhere +* Remove some tasks dropdown menus that are now available with task edit form * Make embedded documentation available in multiple languages Bug fixes: diff --git a/app/Controller/TaskModificationController.php b/app/Controller/TaskModificationController.php index 3c526b3b..b064123a 100644 --- a/app/Controller/TaskModificationController.php +++ b/app/Controller/TaskModificationController.php @@ -23,55 +23,6 @@ class TaskModificationController extends BaseController } /** - * Edit description form - * - * @access public - * @param array $values - * @param array $errors - * @throws \Kanboard\Core\Controller\AccessForbiddenException - * @throws \Kanboard\Core\Controller\PageNotFoundException - */ - public function description(array $values = array(), array $errors = array()) - { - $task = $this->getTask(); - - if (empty($values)) { - $values = array('id' => $task['id'], 'description' => $task['description']); - } - - $this->response->html($this->template->render('task_modification/edit_description', array( - 'values' => $values, - 'errors' => $errors, - 'task' => $task, - ))); - } - - /** - * Update description - * - * @access public - */ - public function updateDescription() - { - $task = $this->getTask(); - $values = $this->request->getValues(); - - list($valid, $errors) = $this->taskValidator->validateDescriptionCreation($values); - - if ($valid) { - if ($this->taskModificationModel->update($values)) { - $this->flash->success(t('Task updated successfully.')); - } else { - $this->flash->failure(t('Unable to update your task.')); - } - - return $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); - } - - return $this->description($values, $errors); - } - - /** * Display a form to edit a task * * @access public @@ -93,7 +44,7 @@ class TaskModificationController extends BaseController $values = $this->dateParser->format($values, array('date_started'), $this->dateParser->getUserDateTimeFormat()); } - $this->response->html($this->template->render('task_modification/edit_task', array( + $this->response->html($this->template->render('task_modification/show', array( 'project' => $project, 'values' => $values, 'errors' => $errors, diff --git a/app/Controller/TaskPopoverController.php b/app/Controller/TaskPopoverController.php index bf4e23d5..4e3c11a3 100644 --- a/app/Controller/TaskPopoverController.php +++ b/app/Controller/TaskPopoverController.php @@ -11,80 +11,6 @@ namespace Kanboard\Controller; class TaskPopoverController extends BaseController { /** - * Change a task assignee directly from the board - * - * @access public - */ - public function changeAssignee() - { - $task = $this->getTask(); - $project = $this->projectModel->getById($task['project_id']); - - $this->response->html($this->template->render('task_popover/change_assignee', array( - 'values' => $task, - 'users_list' => $this->projectUserRoleModel->getAssignableUsersList($project['id']), - 'project' => $project, - ))); - } - - /** - * Validate an assignee modification - * - * @access public - */ - public function updateAssignee() - { - $values = $this->request->getValues(); - - list($valid,) = $this->taskValidator->validateAssigneeModification($values); - - if ($valid && $this->taskModificationModel->update($values)) { - $this->flash->success(t('Task updated successfully.')); - } else { - $this->flash->failure(t('Unable to update your task.')); - } - - $this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $values['project_id'])), true); - } - - /** - * Change a task category directly from the board - * - * @access public - */ - public function changeCategory() - { - $task = $this->getTask(); - $project = $this->projectModel->getById($task['project_id']); - - $this->response->html($this->template->render('task_popover/change_category', array( - 'values' => $task, - 'categories_list' => $this->categoryModel->getList($project['id']), - 'project' => $project, - ))); - } - - /** - * Validate a category modification - * - * @access public - */ - public function updateCategory() - { - $values = $this->request->getValues(); - - list($valid,) = $this->taskValidator->validateCategoryModification($values); - - if ($valid && $this->taskModificationModel->update($values)) { - $this->flash->success(t('Task updated successfully.')); - } else { - $this->flash->failure(t('Unable to update your task.')); - } - - $this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $values['project_id'])), true); - } - - /** * Screenshot popover * * @access public diff --git a/app/Template/task/dropdown.php b/app/Template/task/dropdown.php index b6b9c789..95c7a88c 100644 --- a/app/Template/task/dropdown.php +++ b/app/Template/task/dropdown.php @@ -8,22 +8,10 @@ </li> <?php endif ?> <li> - <i class="fa fa-user fa-fw"></i> - <?= $this->url->link(t('Change assignee'), 'TaskPopoverController', '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'), 'TaskPopoverController', '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'), 'TaskModificationController', 'edit', 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('Edit the description'), 'TaskModificationController', 'description', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?> - </li> - <li> <i class="fa fa-plus fa-fw"></i> <?= $this->url->link(t('Add a sub-task'), 'SubtaskController', 'create', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?> </li> diff --git a/app/Template/task/sidebar.php b/app/Template/task/sidebar.php index e77ec18a..b44e6f0b 100644 --- a/app/Template/task/sidebar.php +++ b/app/Template/task/sidebar.php @@ -35,10 +35,6 @@ <?= $this->url->link(t('Edit the task'), 'TaskModificationController', 'edit', 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('Edit the description'), 'TaskModificationController', 'description', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?> - </li> - <li> <i class="fa fa-refresh fa-rotate-90 fa-fw"></i> <?= $this->url->link(t('Edit recurrence'), 'TaskRecurrenceController', 'edit', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?> </li> diff --git a/app/Template/task_modification/edit_description.php b/app/Template/task_modification/edit_description.php deleted file mode 100644 index 339ed036..00000000 --- a/app/Template/task_modification/edit_description.php +++ /dev/null @@ -1,27 +0,0 @@ -<div class="page-header"> - <h2><?= t('Edit the description') ?></h2> -</div> - -<form class="popover-form" method="post" action="<?= $this->url->href('TaskModificationController', 'updateDescription', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" autocomplete="off"> - - <?= $this->form->csrf() ?> - <?= $this->form->hidden('id', $values) ?> - - <?= $this->form->textarea( - 'description', - $values, - $errors, - array( - 'autofocus', - 'placeholder="'.t('Leave a description').'"', - 'data-mention-search-url="'.$this->url->href('UserAjaxController', 'mention', array('project_id' => $task['project_id'])).'"' - ), - 'markdown-editor' - ) ?> - - <div class="form-actions"> - <button type="submit" class="btn btn-blue"><?= t('Save') ?></button> - <?= t('or') ?> - <?= $this->url->link(t('cancel'), 'TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?> - </div> -</form> diff --git a/app/Template/task_modification/edit_task.php b/app/Template/task_modification/show.php index d747407e..d747407e 100644 --- a/app/Template/task_modification/edit_task.php +++ b/app/Template/task_modification/show.php diff --git a/app/Template/task_popover/change_assignee.php b/app/Template/task_popover/change_assignee.php deleted file mode 100644 index 02f3e198..00000000 --- a/app/Template/task_popover/change_assignee.php +++ /dev/null @@ -1,20 +0,0 @@ -<section id="main"> - <div class="page-header"> - <h2><?= t('Change assignee for the task "%s"', $values['title']) ?></h2> - </div> - <form class="popover-form" method="post" action="<?= $this->url->href('TaskPopoverController', 'updateAssignee', array('task_id' => $values['id'], 'project_id' => $project['id'])) ?>"> - - <?= $this->form->csrf() ?> - - <?= $this->form->hidden('id', $values) ?> - <?= $this->form->hidden('project_id', $values) ?> - - <?= $this->task->selectAssignee($users_list, $values, array(), array('autofocus')) ?> - - <div class="form-actions"> - <button type="submit" class="btn btn-blue"><?= t('Save') ?></button> - <?= t('or') ?> - <?= $this->url->link(t('cancel'), 'BoardViewController', 'show', array('project_id' => $project['id']), false, 'close-popover') ?> - </div> - </form> -</section> diff --git a/app/Template/task_popover/change_category.php b/app/Template/task_popover/change_category.php deleted file mode 100644 index eb6a373d..00000000 --- a/app/Template/task_popover/change_category.php +++ /dev/null @@ -1,20 +0,0 @@ -<section id="main"> - <div class="page-header"> - <h2><?= t('Change category for the task "%s"', $values['title']) ?></h2> - </div> - <form class="popover-form" method="post" action="<?= $this->url->href('TaskPopoverController', 'updateCategory', array('task_id' => $values['id'], 'project_id' => $project['id'])) ?>"> - - <?= $this->form->csrf() ?> - - <?= $this->form->hidden('id', $values) ?> - <?= $this->form->hidden('project_id', $values) ?> - - <?= $this->task->selectCategory($categories_list, $values, array(), array('autofocus'), true) ?> - - <div class="form-actions"> - <button type="submit" class="btn btn-blue"><?= t('Save') ?></button> - <?= t('or') ?> - <?= $this->url->link(t('cancel'), 'BoardViewController', 'show', array('project_id' => $project['id']), false, 'close-popover') ?> - </div> - </form> -</section> diff --git a/app/Validator/TaskValidator.php b/app/Validator/TaskValidator.php index 90bda6f3..8aa5c440 100644 --- a/app/Validator/TaskValidator.php +++ b/app/Validator/TaskValidator.php @@ -182,53 +182,6 @@ class TaskValidator extends BaseValidator } /** - * Validate assignee change - * - * @access public - * @param array $values Form values - * @return array $valid, $errors [0] = Success or not, [1] = List of errors - */ - public function validateAssigneeModification(array $values) - { - $rules = array( - new Validators\Required('id', t('The id is required')), - new Validators\Required('project_id', t('The project is required')), - new Validators\Required('owner_id', t('This value is required')), - ); - - $v = new Validator($values, array_merge($rules, $this->commonValidationRules())); - - return array( - $v->execute(), - $v->getErrors() - ); - } - - /** - * Validate category change - * - * @access public - * @param array $values Form values - * @return array $valid, $errors [0] = Success or not, [1] = List of errors - */ - public function validateCategoryModification(array $values) - { - $rules = array( - new Validators\Required('id', t('The id is required')), - new Validators\Required('project_id', t('The project is required')), - new Validators\Required('category_id', t('This value is required')), - - ); - - $v = new Validator($values, array_merge($rules, $this->commonValidationRules())); - - return array( - $v->execute(), - $v->getErrors() - ); - } - - /** * Validate project modification * * @access public diff --git a/tests/units/Model/TaskCreationTest.php b/tests/units/Model/TaskCreationTest.php index b249bc0b..7f2f6f5f 100644 --- a/tests/units/Model/TaskCreationTest.php +++ b/tests/units/Model/TaskCreationTest.php @@ -20,23 +20,6 @@ class TaskCreationTest extends Base $this->assertEquals('test', $event_data['title']); } - public function testNoProjectId() - { - $p = new ProjectModel($this->container); - $tc = new TaskCreationModel($this->container); - $tf = new TaskFinderModel($this->container); - - $this->container['dispatcher']->addListener(TaskModel::EVENT_CREATE_UPDATE, function () {}); - $this->container['dispatcher']->addListener(TaskModel::EVENT_CREATE, function () {}); - - $this->assertEquals(1, $p->create(array('name' => 'test'))); - $this->assertEquals(0, $tc->create(array('title' => 'test', 'project_id' => 0))); - - $called = $this->container['dispatcher']->getCalledListeners(); - $this->assertArrayNotHasKey(TaskModel::EVENT_CREATE_UPDATE.'.closure', $called); - $this->assertArrayNotHasKey(TaskModel::EVENT_CREATE.'.closure', $called); - } - public function testNoTitle() { $p = new ProjectModel($this->container); |