From 91200ddcdebb9e592cc264714c4a14921416868f Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Wed, 3 Feb 2016 18:27:45 -0500 Subject: Change sidebar style --- assets/js/src/App.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'assets/js/src/App.js') diff --git a/assets/js/src/App.js b/assets/js/src/App.js index 976b4554..0ae437c0 100644 --- a/assets/js/src/App.js +++ b/assets/js/src/App.js @@ -1,7 +1,6 @@ function App() { this.board = new Board(this); this.markdown = new Markdown(); - this.sidebar = new Sidebar(); this.search = new Search(this); this.swimlane = new Swimlane(); this.dropdown = new Dropdown(); @@ -33,7 +32,6 @@ App.prototype.listen = function() { this.project.listen(); this.popover.listen(); this.markdown.listen(); - this.sidebar.listen(); this.tooltip.listen(); this.dropdown.listen(); this.search.listen(); -- cgit v1.2.3 From 0f2b46dd6a9a1dc17768de2c415f382df95142e8 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Thu, 4 Feb 2016 21:38:53 -0500 Subject: Do not refresh the whole page when changing subtask status (work in progress) --- ChangeLog | 1 + app/Controller/Base.php | 20 +++- app/Controller/Comment.php | 2 +- app/Controller/Subtask.php | 111 --------------------- app/Controller/SubtaskRestriction.php | 61 +++++++++++ app/Controller/SubtaskStatus.php | 28 ++++++ app/Helper/Subtask.php | 38 +++---- app/Model/Subtask.php | 7 +- app/ServiceProvider/AuthenticationProvider.php | 2 + app/Template/app/subtasks.php | 2 +- app/Template/board/tooltip_subtasks.php | 15 ++- app/Template/subtask/icons.php | 7 -- app/Template/subtask/menu.php | 4 +- app/Template/subtask/restriction_change_status.php | 19 ---- app/Template/subtask/show.php | 77 +------------- app/Template/subtask/table.php | 69 +++++++++++++ app/Template/subtask_restriction/popover.php | 17 ++++ app/Template/task/show.php | 5 +- assets/js/app.js | 2 +- assets/js/src/App.js | 13 +++ assets/js/src/Tooltip.js | 15 --- tests/units/Model/SubtaskTest.php | 12 +-- 22 files changed, 258 insertions(+), 269 deletions(-) create mode 100644 app/Controller/SubtaskRestriction.php create mode 100644 app/Controller/SubtaskStatus.php delete mode 100644 app/Template/subtask/icons.php delete mode 100644 app/Template/subtask/restriction_change_status.php create mode 100644 app/Template/subtask/table.php create mode 100644 app/Template/subtask_restriction/popover.php (limited to 'assets/js/src/App.js') diff --git a/ChangeLog b/ChangeLog index 7e4bdad6..7a95ae1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,7 @@ New features: Improvements: +* Do not refresh the whole page when changing subtask status (work in progress) * Add dropdown menu with inline popup for all task actions * Change sidebar style * Change task summary layout diff --git a/app/Controller/Base.php b/app/Controller/Base.php index a80b3528..c55ad9ad 100644 --- a/app/Controller/Base.php +++ b/app/Controller/Base.php @@ -214,8 +214,7 @@ abstract class Base extends \Kanboard\Core\Base $project = $this->project->getByIdWithOwner($project_id); if (empty($project)) { - $this->flash->failure(t('Project not found.')); - $this->response->redirect($this->helper->url->to('project', 'index')); + $this->notfound(); } return $project; @@ -242,6 +241,23 @@ abstract class Base extends \Kanboard\Core\Base return $user; } + /** + * Get the current subtask + * + * @access protected + * @return array + */ + protected function getSubtask() + { + $subtask = $this->subtask->getById($this->request->getIntegerParam('subtask_id')); + + if (empty($subtask)) { + $this->notfound(); + } + + return $subtask; + } + /** * Common method to get project filters * diff --git a/app/Controller/Comment.php b/app/Controller/Comment.php index 2ad3f379..da3213e0 100644 --- a/app/Controller/Comment.php +++ b/app/Controller/Comment.php @@ -107,7 +107,7 @@ class Comment extends Base public function update() { $task = $this->getTask(); - $comment = $this->getComment(); + $this->getComment(); $values = $this->request->getValues(); list($valid, $errors) = $this->commentValidator->validateModification($values); diff --git a/app/Controller/Subtask.php b/app/Controller/Subtask.php index 9fe15c9d..f8798906 100644 --- a/app/Controller/Subtask.php +++ b/app/Controller/Subtask.php @@ -2,8 +2,6 @@ namespace Kanboard\Controller; -use Kanboard\Model\Subtask as SubtaskModel; - /** * Subtask controller * @@ -12,23 +10,6 @@ use Kanboard\Model\Subtask as SubtaskModel; */ class Subtask extends Base { - /** - * Get the current subtask - * - * @access private - * @return array - */ - private function getSubtask() - { - $subtask = $this->subtask->getById($this->request->getIntegerParam('subtask_id')); - - if (empty($subtask)) { - $this->notfound(); - } - - return $subtask; - } - /** * Show list of subtasks */ @@ -181,98 +162,6 @@ class Subtask extends Base $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); } - /** - * Change status to the next status: Toto -> In Progress -> Done - * - * @access public - */ - public function toggleStatus() - { - $task = $this->getTask(); - $subtask = $this->getSubtask(); - $redirect = $this->request->getStringParam('redirect', 'task'); - - $this->subtask->toggleStatus($subtask['id']); - - if ($redirect === 'board') { - $this->sessionStorage->hasSubtaskInProgress = $this->subtask->hasSubtaskInProgress($this->userSession->getId()); - - $this->response->html($this->template->render('board/tooltip_subtasks', array( - 'subtasks' => $this->subtask->getAll($task['id']), - 'task' => $task, - ))); - } - - $this->toggleRedirect($task, $redirect); - } - - /** - * Handle subtask restriction (popover) - * - * @access public - */ - public function subtaskRestriction() - { - $task = $this->getTask(); - $subtask = $this->getSubtask(); - - $this->response->html($this->template->render('subtask/restriction_change_status', array( - 'status_list' => array( - SubtaskModel::STATUS_TODO => t('Todo'), - SubtaskModel::STATUS_DONE => t('Done'), - ), - 'subtask_inprogress' => $this->subtask->getSubtaskInProgress($this->userSession->getId()), - 'subtask' => $subtask, - 'task' => $task, - 'redirect' => $this->request->getStringParam('redirect'), - ))); - } - - /** - * Change status of the in progress subtask and the other subtask - * - * @access public - */ - public function changeRestrictionStatus() - { - $task = $this->getTask(); - $subtask = $this->getSubtask(); - $values = $this->request->getValues(); - - // Change status of the previous in progress subtask - $this->subtask->update(array( - 'id' => $values['id'], - 'status' => $values['status'], - )); - - // Set the current subtask to in pogress - $this->subtask->update(array( - 'id' => $subtask['id'], - 'status' => SubtaskModel::STATUS_INPROGRESS, - )); - - $this->toggleRedirect($task, $values['redirect']); - } - - /** - * Redirect to the right page - * - * @access private - */ - private function toggleRedirect(array $task, $redirect) - { - switch ($redirect) { - case 'board': - $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id']))); - case 'dashboard': - $this->response->redirect($this->helper->url->to('app', 'index')); - case 'subtask': - $this->response->redirect($this->helper->url->to('subtask', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); - default: - $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'subtasks')); - } - } - /** * Move subtask position * diff --git a/app/Controller/SubtaskRestriction.php b/app/Controller/SubtaskRestriction.php new file mode 100644 index 00000000..56024867 --- /dev/null +++ b/app/Controller/SubtaskRestriction.php @@ -0,0 +1,61 @@ +getTask(); + $subtask = $this->getSubtask(); + + $this->response->html($this->template->render('subtask_restriction/popover', array( + 'status_list' => array( + SubtaskModel::STATUS_TODO => t('Todo'), + SubtaskModel::STATUS_DONE => t('Done'), + ), + 'subtask_inprogress' => $this->subtask->getSubtaskInProgress($this->userSession->getId()), + 'subtask' => $subtask, + 'task' => $task, + ))); + } + + /** + * Change status of the in progress subtask and the other subtask + * + * @access public + */ + public function update() + { + $task = $this->getTask(); + $subtask = $this->getSubtask(); + $values = $this->request->getValues(); + + // Change status of the previous "in progress" subtask + $this->subtask->update(array( + 'id' => $values['id'], + 'status' => $values['status'], + )); + + // Set the current subtask to "in progress" + $this->subtask->update(array( + 'id' => $subtask['id'], + 'status' => SubtaskModel::STATUS_INPROGRESS, + )); + + $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); + } +} diff --git a/app/Controller/SubtaskStatus.php b/app/Controller/SubtaskStatus.php new file mode 100644 index 00000000..efe8a974 --- /dev/null +++ b/app/Controller/SubtaskStatus.php @@ -0,0 +1,28 @@ + In Progress -> Done + * + * @access public + */ + public function change() + { + $task = $this->getTask(); + $subtask = $this->getSubtask(); + + $status = $this->subtask->toggleStatus($subtask['id']); + $subtask['status'] = $status; + + $this->response->html($this->helper->subtask->toggleStatus($subtask, $task['project_id'])); + } +} diff --git a/app/Helper/Subtask.php b/app/Helper/Subtask.php index 5b8d7d90..38074b78 100644 --- a/app/Helper/Subtask.php +++ b/app/Helper/Subtask.php @@ -10,38 +10,40 @@ namespace Kanboard\Helper; */ class Subtask extends \Kanboard\Core\Base { + public function getTitle(array $subtask) + { + if ($subtask['status'] == 0) { + $html = ''; + } elseif ($subtask['status'] == 1) { + $html = ''; + } else { + $html = ''; + } + + return $html.$this->helper->e($subtask['title']); + } + /** * Get the link to toggle subtask status * * @access public * @param array $subtask - * @param string $redirect * @param integer $project_id * @return string */ - public function toggleStatus(array $subtask, $redirect, $project_id = 0) + public function toggleStatus(array $subtask, $project_id) { - if ($project_id > 0 && ! $this->helper->user->hasProjectAccess('subtask', 'edit', $project_id)) { - return trim($this->template->render('subtask/icons', array('subtask' => $subtask))) . $this->helper->e($subtask['title']); + if (! $this->helper->user->hasProjectAccess('subtask', 'edit', $project_id)) { + return $this->getTitle($subtask); } + $params = array('task_id' => $subtask['task_id'], 'subtask_id' => $subtask['id']); + if ($subtask['status'] == 0 && isset($this->sessionStorage->hasSubtaskInProgress) && $this->sessionStorage->hasSubtaskInProgress) { - return $this->helper->url->link( - trim($this->template->render('subtask/icons', array('subtask' => $subtask))) . $this->helper->e($subtask['title']), - 'subtask', - 'subtaskRestriction', - array('task_id' => $subtask['task_id'], 'subtask_id' => $subtask['id'], 'redirect' => $redirect), - false, - 'popover task-board-popover' - ); + return $this->helper->url->link($this->getTitle($subtask), 'SubtaskRestriction', 'popover', $params, false, 'popover'); } - return $this->helper->url->link( - trim($this->template->render('subtask/icons', array('subtask' => $subtask))) . $this->helper->e($subtask['title']), - 'subtask', - 'toggleStatus', - array('task_id' => $subtask['task_id'], 'subtask_id' => $subtask['id'], 'redirect' => $redirect) - ); + return $this->helper->url->link($this->getTitle($subtask), 'SubtaskStatus', 'change', $params, false, 'ajax-replace'); } public function selectTitle(array $values, array $errors = array(), array $attributes = array()) diff --git a/app/Model/Subtask.php b/app/Model/Subtask.php index 1e989ad5..14853941 100644 --- a/app/Model/Subtask.php +++ b/app/Model/Subtask.php @@ -353,15 +353,16 @@ class Subtask extends Base * * @access public * @param integer $subtask_id - * @return bool + * @return boolean|integer */ public function toggleStatus($subtask_id) { $subtask = $this->getById($subtask_id); + $status = ($subtask['status'] + 1) % 3; $values = array( 'id' => $subtask['id'], - 'status' => ($subtask['status'] + 1) % 3, + 'status' => $status, 'task_id' => $subtask['task_id'], ); @@ -369,7 +370,7 @@ class Subtask extends Base $values['user_id'] = $this->userSession->getId(); } - return $this->update($values); + return $this->update($values) ? $status : false; } /** diff --git a/app/ServiceProvider/AuthenticationProvider.php b/app/ServiceProvider/AuthenticationProvider.php index dac73160..4196a470 100644 --- a/app/ServiceProvider/AuthenticationProvider.php +++ b/app/ServiceProvider/AuthenticationProvider.php @@ -83,6 +83,8 @@ class AuthenticationProvider implements ServiceProviderInterface $acl->add('ProjectEdit', '*', Role::PROJECT_MANAGER); $acl->add('Projectuser', '*', Role::PROJECT_MANAGER); $acl->add('Subtask', '*', Role::PROJECT_MEMBER); + $acl->add('SubtaskRestriction', '*', Role::PROJECT_MEMBER); + $acl->add('SubtaskStatus', '*', Role::PROJECT_MEMBER); $acl->add('Swimlane', '*', Role::PROJECT_MANAGER); $acl->add('Task', 'remove', Role::PROJECT_MEMBER); $acl->add('Taskcreation', '*', Role::PROJECT_MEMBER); diff --git a/app/Template/app/subtasks.php b/app/Template/app/subtasks.php index b4c87bab..f72f21fb 100644 --- a/app/Template/app/subtasks.php +++ b/app/Template/app/subtasks.php @@ -24,7 +24,7 @@ url->link($this->e($subtask['task_name']), 'task', 'show', array('task_id' => $subtask['task_id'], 'project_id' => $subtask['project_id'])) ?> - subtask->toggleStatus($subtask, 'dashboard') ?> + subtask->toggleStatus($subtask, $subtask['project_id']) ?> diff --git a/app/Template/board/tooltip_subtasks.php b/app/Template/board/tooltip_subtasks.php index 5e48fcf4..65b7ce4d 100644 --- a/app/Template/board/tooltip_subtasks.php +++ b/app/Template/board/tooltip_subtasks.php @@ -1,7 +1,12 @@ -
+ - subtask->toggleStatus($subtask, 'board', $task['project_id']) ?> - e(empty($subtask['username']) ? '' : ' ['.$this->user->getFullname($subtask).']') ?> -
+ + + + - +
+ subtask->toggleStatus($subtask, $task['project_id']) ?> + + e($subtask['username'] ?: $this->user->getFullname($subtask)) ?> +
diff --git a/app/Template/subtask/icons.php b/app/Template/subtask/icons.php deleted file mode 100644 index 1f31d51f..00000000 --- a/app/Template/subtask/icons.php +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/Template/subtask/menu.php b/app/Template/subtask/menu.php index f14b09b2..878ad68c 100644 --- a/app/Template/subtask/menu.php +++ b/app/Template/subtask/menu.php @@ -3,12 +3,12 @@