diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-02-04 22:19:32 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-02-04 22:19:32 -0500 |
commit | b24b1e7e4e5ee0551ee56aa0f21c4425b479db2e (patch) | |
tree | 5fffaeb461707dada9f2909101d51c9da3c77a50 /app/Controller | |
parent | 2d070627d751bf5728ec98a5efaf163532594cd9 (diff) |
Add subtasks restrictions and time tracking
Diffstat (limited to 'app/Controller')
-rw-r--r-- | app/Controller/Base.php | 2 | ||||
-rw-r--r-- | app/Controller/Board.php | 16 | ||||
-rw-r--r-- | app/Controller/Subtask.php | 84 | ||||
-rw-r--r-- | app/Controller/User.php | 27 |
4 files changed, 107 insertions, 22 deletions
diff --git a/app/Controller/Base.php b/app/Controller/Base.php index d0d5e848..d36e02c0 100644 --- a/app/Controller/Base.php +++ b/app/Controller/Base.php @@ -167,6 +167,8 @@ abstract class Base if (! $this->acl->isPublicAction($controller, $action)) { $this->handleAuthentication(); $this->handleAuthorization($controller, $action); + + $this->session['has_subtask_inprogress'] = $this->subTask->hasSubtaskInProgress($this->userSession->getId()); } } diff --git a/app/Controller/Board.php b/app/Controller/Board.php index f4d17f92..3671b5fc 100644 --- a/app/Controller/Board.php +++ b/app/Controller/Board.php @@ -416,22 +416,6 @@ class Board extends Base } /** - * Change the status of a subtask from the mouseover - * - * @access public - */ - public function toggleSubtask() - { - $task = $this->getTask(); - $this->subTask->toggleStatus($this->request->getIntegerParam('subtask_id')); - - $this->response->html($this->template->render('board/subtasks', array( - 'subtasks' => $this->subTask->getAll($task['id']), - 'task' => $task, - ))); - } - - /** * Display all attachments during the task mouseover * * @access public diff --git a/app/Controller/Subtask.php b/app/Controller/Subtask.php index 0521b893..a6cec435 100644 --- a/app/Controller/Subtask.php +++ b/app/Controller/Subtask.php @@ -2,6 +2,8 @@ namespace Controller; +use Model\SubTask as SubtaskModel; + /** * SubTask controller * @@ -175,12 +177,86 @@ class Subtask extends Base public function toggleStatus() { $task = $this->getTask(); - $subtask_id = $this->request->getIntegerParam('subtask_id'); + $subtask = $this->getSubtask(); + $redirect = $this->request->getStringParam('redirect', 'task'); + + $this->subTask->toggleStatus($subtask['id']); - if (! $this->subTask->toggleStatus($subtask_id)) { - $this->session->flashError(t('Unable to update your sub-task.')); + if ($redirect === 'board') { + + $this->session['has_subtask_inprogress'] = $this->subTask->hasSubtaskInProgress($this->userSession->getId()); + + $this->response->html($this->template->render('board/subtasks', array( + 'subtasks' => $this->subTask->getAll($task['id']), + 'task' => $task, + ))); } - $this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'&project_id='.$task['project_id'].'#subtasks'); + $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('board', 'show', array('project_id' => $task['project_id']))); + case 'dashboard': + $this->response->redirect($this->helper->url('app', 'index')); + default: + $this->response->redirect($this->helper->url('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); + } } } diff --git a/app/Controller/User.php b/app/Controller/User.php index a02da7a9..3d44f226 100644 --- a/app/Controller/User.php +++ b/app/Controller/User.php @@ -190,6 +190,29 @@ class User extends Base } /** + * Display timesheet + * + * @access public + */ + public function timesheet() + { + $user = $this->getUser(); + + $subtask_paginator = $this->paginator + ->setUrl('user', 'timesheet', array('user_id' => $user['id'], 'pagination' => 'subtasks')) + ->setMax(20) + ->setOrder('start') + ->setDirection('DESC') + ->setQuery($this->subtaskTimeTracking->getUserQuery($user['id'])) + ->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks'); + + $this->response->html($this->layout('user/timesheet', array( + 'subtask_paginator' => $subtask_paginator, + 'user' => $user, + ))); + } + + /** * Display last connections * * @access public @@ -450,7 +473,7 @@ class User extends Base * * @access public */ - public function gitHub() + public function github() { $code = $this->request->getStringParam('code'); @@ -494,7 +517,7 @@ class User extends Base * * @access public */ - public function unlinkGitHub() + public function unlinkGithub() { $this->checkCSRFParam(); |