From b6e92cb64a5ba6c8eb5222a7732fba50e6079622 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Fri, 24 Jun 2016 18:09:01 -0400 Subject: Remove dropdown menus that are now available with task edit form --- ChangeLog | 1 + app/Controller/TaskModificationController.php | 51 +-------------- app/Controller/TaskPopoverController.php | 74 ---------------------- app/Template/task/dropdown.php | 12 ---- app/Template/task/sidebar.php | 4 -- .../task_modification/edit_description.php | 27 -------- app/Template/task_modification/edit_task.php | 43 ------------- app/Template/task_modification/show.php | 43 +++++++++++++ app/Template/task_popover/change_assignee.php | 20 ------ app/Template/task_popover/change_category.php | 20 ------ app/Validator/TaskValidator.php | 47 -------------- tests/units/Model/TaskCreationTest.php | 17 ----- 12 files changed, 45 insertions(+), 314 deletions(-) delete mode 100644 app/Template/task_modification/edit_description.php delete mode 100644 app/Template/task_modification/edit_task.php create mode 100644 app/Template/task_modification/show.php delete mode 100644 app/Template/task_popover/change_assignee.php delete mode 100644 app/Template/task_popover/change_category.php diff --git a/ChangeLog b/ChangeLog index f46c72aa..7a6f4edf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 @@ -22,55 +22,6 @@ class TaskModificationController extends BaseController $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']))); } - /** - * 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 * @@ -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 @@ -10,80 +10,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 * 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 @@ -7,22 +7,10 @@ url->link(t('Set automatically the start date'), 'TaskModificationController', 'start', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?> -
  • - - url->link(t('Change assignee'), 'TaskPopoverController', 'changeAssignee', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?> -
  • -
  • - - url->link(t('Change category'), 'TaskPopoverController', 'changeCategory', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?> -
  • url->link(t('Edit the task'), 'TaskModificationController', 'edit', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
  • -
  • - - url->link(t('Edit the description'), 'TaskModificationController', 'description', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?> -
  • url->link(t('Add a sub-task'), 'SubtaskController', 'create', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?> 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 @@ -34,10 +34,6 @@ url->link(t('Edit the task'), 'TaskModificationController', 'edit', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
  • -
  • - - url->link(t('Edit the description'), 'TaskModificationController', 'description', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?> -
  • url->link(t('Edit recurrence'), 'TaskRecurrenceController', 'edit', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?> 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 @@ - - -
    - - form->csrf() ?> - form->hidden('id', $values) ?> - - 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' - ) ?> - -
    - - - url->link(t('cancel'), 'TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?> -
    -
    diff --git a/app/Template/task_modification/edit_task.php b/app/Template/task_modification/edit_task.php deleted file mode 100644 index d747407e..00000000 --- a/app/Template/task_modification/edit_task.php +++ /dev/null @@ -1,43 +0,0 @@ - -
    - form->csrf() ?> - form->hidden('id', $values) ?> - form->hidden('project_id', $values) ?> - -
    -
    - task->selectTitle($values, $errors) ?> - task->selectDescription($values, $errors) ?> - task->selectTags($project, $tags) ?> - - hook->render('template:task:form:first-column', array('values' => $values, 'errors' => $errors)) ?> -
    - -
    - task->selectColor($values) ?> - task->selectAssignee($users_list, $values, $errors) ?> - task->selectCategory($categories_list, $values, $errors) ?> - task->selectPriority($project, $values) ?> - task->selectScore($values, $errors) ?> - - hook->render('template:task:form:second-column', array('values' => $values, 'errors' => $errors)) ?> -
    - -
    - task->selectTimeEstimated($values, $errors) ?> - task->selectTimeSpent($values, $errors) ?> - task->selectStartDate($values, $errors) ?> - task->selectDueDate($values, $errors) ?> - - hook->render('template:task:form:third-column', array('values' => $values, 'errors' => $errors)) ?> -
    -
    - -
    - - - url->link(t('cancel'), 'TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?> -
    -
    diff --git a/app/Template/task_modification/show.php b/app/Template/task_modification/show.php new file mode 100644 index 00000000..d747407e --- /dev/null +++ b/app/Template/task_modification/show.php @@ -0,0 +1,43 @@ + +
    + form->csrf() ?> + form->hidden('id', $values) ?> + form->hidden('project_id', $values) ?> + +
    +
    + task->selectTitle($values, $errors) ?> + task->selectDescription($values, $errors) ?> + task->selectTags($project, $tags) ?> + + hook->render('template:task:form:first-column', array('values' => $values, 'errors' => $errors)) ?> +
    + +
    + task->selectColor($values) ?> + task->selectAssignee($users_list, $values, $errors) ?> + task->selectCategory($categories_list, $values, $errors) ?> + task->selectPriority($project, $values) ?> + task->selectScore($values, $errors) ?> + + hook->render('template:task:form:second-column', array('values' => $values, 'errors' => $errors)) ?> +
    + +
    + task->selectTimeEstimated($values, $errors) ?> + task->selectTimeSpent($values, $errors) ?> + task->selectStartDate($values, $errors) ?> + task->selectDueDate($values, $errors) ?> + + hook->render('template:task:form:third-column', array('values' => $values, 'errors' => $errors)) ?> +
    +
    + +
    + + + url->link(t('cancel'), 'TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?> +
    +
    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 @@ -
    - -
    - - form->csrf() ?> - - form->hidden('id', $values) ?> - form->hidden('project_id', $values) ?> - - task->selectAssignee($users_list, $values, array(), array('autofocus')) ?> - -
    - - - url->link(t('cancel'), 'BoardViewController', 'show', array('project_id' => $project['id']), false, 'close-popover') ?> -
    -
    -
    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 @@ -
    - -
    - - form->csrf() ?> - - form->hidden('id', $values) ?> - form->hidden('project_id', $values) ?> - - task->selectCategory($categories_list, $values, array(), array('autofocus'), true) ?> - -
    - - - url->link(t('cancel'), 'BoardViewController', 'show', array('project_id' => $project['id']), false, 'close-popover') ?> -
    -
    -
    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 @@ -181,53 +181,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 * 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); -- cgit v1.2.3