Add subtasks restrictions and time tracking

This commit is contained in:
Frederic Guillot
2015-02-04 22:19:32 -05:00
parent 2d070627d7
commit b24b1e7e4e
38 changed files with 522 additions and 51 deletions

View File

@@ -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());
}
}

View File

@@ -415,22 +415,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
*

View File

@@ -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');
if (! $this->subTask->toggleStatus($subtask_id)) {
$this->session->flashError(t('Unable to update your sub-task.'));
$this->subTask->toggleStatus($subtask['id']);
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'])));
}
}
}

View File

@@ -189,6 +189,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
*
@@ -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();