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

View File

@ -244,7 +244,7 @@ class Helper
*/
public function formRadio($name, $label, $value, $selected = false, $class = '')
{
return '<label><input type="radio" name="'.$name.'" class="'.$class.'" value="'.$this->e($value).'" '.($selected ? 'selected="selected"' : '').'>'.$this->e($label).'</label>';
return '<label><input type="radio" name="'.$name.'" class="'.$class.'" value="'.$this->e($value).'" '.($selected ? 'selected="selected"' : '').'> '.$this->e($label).'</label>';
}
/**
@ -648,4 +648,26 @@ class Helper
'Sat' => t('Sat'),
));
}
public function toggleSubtaskStatus(array $subtask, $redirect)
{
if ($subtask['status'] == 0 && isset($this->session['has_subtask_inprogress']) && $this->session['has_subtask_inprogress'] === true) {
return $this->a(
trim($this->render('subtask/icons', array('subtask' => $subtask))) . $this->e($subtask['status_name']),
'subtask',
'subtaskRestriction',
array('task_id' => $subtask['task_id'], 'subtask_id' => $subtask['id'], 'redirect' => $redirect),
false,
'popover-subtask-restriction'
);
}
return $this->a(
trim($this->render('subtask/icons', array('subtask' => $subtask))) . $this->e($subtask['status_name']),
'subtask',
'toggleStatus',
array('task_id' => $subtask['task_id'], 'subtask_id' => $subtask['id'], 'redirect' => $redirect)
);
}
}

View File

@ -701,4 +701,12 @@ return array(
// 'Moved to column %s' => '',
// 'Change description' => '',
// 'User dashboard' => '',
// 'Allow only one subtask in progress at the same time for a user' => '',
// 'Edit column "%s"' => '',
// 'Enable time tracking for subtasks' => '',
// 'Select the new status of the subtask: "%s"' => '',
// 'Subtask timesheet' => '',
// 'There is nothing to show.' => '',
// 'Time Tracking' => '',
// 'You already have one subtask in progress' => '',
);

View File

@ -701,4 +701,12 @@ return array(
// 'Moved to column %s' => '',
// 'Change description' => '',
// 'User dashboard' => '',
// 'Allow only one subtask in progress at the same time for a user' => '',
// 'Edit column "%s"' => '',
// 'Enable time tracking for subtasks' => '',
// 'Select the new status of the subtask: "%s"' => '',
// 'Subtask timesheet' => '',
// 'There is nothing to show.' => '',
// 'Time Tracking' => '',
// 'You already have one subtask in progress' => '',
);

View File

@ -701,4 +701,12 @@ return array(
'Moved to column %s' => 'Movido a columna %s',
// 'Change description' => '',
// 'User dashboard' => '',
// 'Allow only one subtask in progress at the same time for a user' => '',
// 'Edit column "%s"' => '',
// 'Enable time tracking for subtasks' => '',
// 'Select the new status of the subtask: "%s"' => '',
// 'Subtask timesheet' => '',
// 'There is nothing to show.' => '',
// 'Time Tracking' => '',
// 'You already have one subtask in progress' => '',
);

View File

@ -701,4 +701,12 @@ return array(
// 'Moved to column %s' => '',
// 'Change description' => '',
// 'User dashboard' => '',
// 'Allow only one subtask in progress at the same time for a user' => '',
// 'Edit column "%s"' => '',
// 'Enable time tracking for subtasks' => '',
// 'Select the new status of the subtask: "%s"' => '',
// 'Subtask timesheet' => '',
// 'There is nothing to show.' => '',
// 'Time Tracking' => '',
// 'You already have one subtask in progress' => '',
);

View File

@ -701,4 +701,12 @@ return array(
'Moved to column %s' => 'Tâche déplacée à la colonne %s',
'Change description' => 'Changer la description',
'User dashboard' => 'Tableau de bord de l\'utilisateur',
'Allow only one subtask in progress at the same time for a user' => 'Autoriser une seule sous-tâche en progrès en même temps pour un utilisateur',
'Edit column "%s"' => 'Modifier la colonne « %s »',
'Enable time tracking for subtasks' => 'Activer la feuille de temps pour les sous-tâches',
'Select the new status of the subtask: "%s"' => 'Selectionnez le nouveau statut de la sous-tâche : « %s »',
'Subtask timesheet' => 'Feuille de temps des sous-tâches',
'There is nothing to show.' => 'Il n\'y a rien à montrer',
'Time Tracking' => 'Feuille de temps',
'You already have one subtask in progress' => 'Vous avez déjà une sous-tâche en progrès',
);

View File

@ -701,4 +701,12 @@ return array(
// 'Moved to column %s' => '',
// 'Change description' => '',
// 'User dashboard' => '',
// 'Allow only one subtask in progress at the same time for a user' => '',
// 'Edit column "%s"' => '',
// 'Enable time tracking for subtasks' => '',
// 'Select the new status of the subtask: "%s"' => '',
// 'Subtask timesheet' => '',
// 'There is nothing to show.' => '',
// 'Time Tracking' => '',
// 'You already have one subtask in progress' => '',
);

View File

@ -701,4 +701,12 @@ return array(
// 'Moved to column %s' => '',
// 'Change description' => '',
// 'User dashboard' => '',
// 'Allow only one subtask in progress at the same time for a user' => '',
// 'Edit column "%s"' => '',
// 'Enable time tracking for subtasks' => '',
// 'Select the new status of the subtask: "%s"' => '',
// 'Subtask timesheet' => '',
// 'There is nothing to show.' => '',
// 'Time Tracking' => '',
// 'You already have one subtask in progress' => '',
);

View File

@ -701,4 +701,12 @@ return array(
// 'Moved to column %s' => '',
// 'Change description' => '',
// 'User dashboard' => '',
// 'Allow only one subtask in progress at the same time for a user' => '',
// 'Edit column "%s"' => '',
// 'Enable time tracking for subtasks' => '',
// 'Select the new status of the subtask: "%s"' => '',
// 'Subtask timesheet' => '',
// 'There is nothing to show.' => '',
// 'Time Tracking' => '',
// 'You already have one subtask in progress' => '',
);

View File

@ -701,4 +701,12 @@ return array(
'Moved to column %s' => 'Przeniosiono do kolumny %s',
// 'Change description' => '',
// 'User dashboard' => '',
// 'Allow only one subtask in progress at the same time for a user' => '',
// 'Edit column "%s"' => '',
// 'Enable time tracking for subtasks' => '',
// 'Select the new status of the subtask: "%s"' => '',
// 'Subtask timesheet' => '',
// 'There is nothing to show.' => '',
// 'Time Tracking' => '',
// 'You already have one subtask in progress' => '',
);

View File

@ -701,4 +701,12 @@ return array(
'Moved to column %s' => 'Mover para a coluna %s',
// 'Change description' => '',
// 'User dashboard' => '',
// 'Allow only one subtask in progress at the same time for a user' => '',
// 'Edit column "%s"' => '',
// 'Enable time tracking for subtasks' => '',
// 'Select the new status of the subtask: "%s"' => '',
// 'Subtask timesheet' => '',
// 'There is nothing to show.' => '',
// 'Time Tracking' => '',
// 'You already have one subtask in progress' => '',
);

View File

@ -701,4 +701,12 @@ return array(
// 'Moved to column %s' => '',
// 'Change description' => '',
// 'User dashboard' => '',
// 'Allow only one subtask in progress at the same time for a user' => '',
// 'Edit column "%s"' => '',
// 'Enable time tracking for subtasks' => '',
// 'Select the new status of the subtask: "%s"' => '',
// 'Subtask timesheet' => '',
// 'There is nothing to show.' => '',
// 'Time Tracking' => '',
// 'You already have one subtask in progress' => '',
);

View File

@ -701,4 +701,12 @@ return array(
// 'Moved to column %s' => '',
// 'Change description' => '',
// 'User dashboard' => '',
// 'Allow only one subtask in progress at the same time for a user' => '',
// 'Edit column "%s"' => '',
// 'Enable time tracking for subtasks' => '',
// 'Select the new status of the subtask: "%s"' => '',
// 'Subtask timesheet' => '',
// 'There is nothing to show.' => '',
// 'Time Tracking' => '',
// 'You already have one subtask in progress' => '',
);

View File

@ -701,4 +701,12 @@ return array(
// 'Moved to column %s' => '',
// 'Change description' => '',
// 'User dashboard' => '',
// 'Allow only one subtask in progress at the same time for a user' => '',
// 'Edit column "%s"' => '',
// 'Enable time tracking for subtasks' => '',
// 'Select the new status of the subtask: "%s"' => '',
// 'Subtask timesheet' => '',
// 'There is nothing to show.' => '',
// 'Time Tracking' => '',
// 'You already have one subtask in progress' => '',
);

View File

@ -701,4 +701,12 @@ return array(
// 'Moved to column %s' => '',
// 'Change description' => '',
// 'User dashboard' => '',
// 'Allow only one subtask in progress at the same time for a user' => '',
// 'Edit column "%s"' => '',
// 'Enable time tracking for subtasks' => '',
// 'Select the new status of the subtask: "%s"' => '',
// 'Subtask timesheet' => '',
// 'There is nothing to show.' => '',
// 'Time Tracking' => '',
// 'You already have one subtask in progress' => '',
);

View File

@ -223,12 +223,42 @@ class SubTask extends Base
$values = array(
'id' => $subtask['id'],
'status' => ($subtask['status'] + 1) % 3,
'task_id' => $subtask['task_id'],
);
return $this->update($values);
}
/**
* Get the subtask in progress for this user
*
* @access public
* @param integer $user_id
* @return array
*/
public function getSubtaskInProgress($user_id)
{
return $this->db->table(self::TABLE)
->eq('status', self::STATUS_INPROGRESS)
->eq('user_id', $user_id)
->findOne();
}
/**
* Return true if the user have a subtask in progress
*
* @access public
* @param integer $user_id
* @return boolean
*/
public function hasSubtaskInProgress($user_id)
{
return $this->config->get('subtask_restriction') == 1 &&
$this->db->table(self::TABLE)
->eq('status', self::STATUS_INPROGRESS)
->eq('user_id', $user_id)
->count() === 1;
}
/**
* Remove
*

View File

@ -0,0 +1,80 @@
<?php
namespace Model;
/**
* Subtask timesheet
*
* @package model
* @author Frederic Guillot
*/
class SubtaskTimeTracking extends Base
{
/**
* SQL table name
*
* @var string
*/
const TABLE = 'subtask_time_tracking';
/**
* Get query for user timesheet (pagination)
*
* @access public
* @param integer $user_id User id
* @return \PicoDb\Table
*/
public function getUserQuery($user_id)
{
return $this->db
->table(self::TABLE)
->columns(
self::TABLE.'.id',
self::TABLE.'.subtask_id',
self::TABLE.'.end',
self::TABLE.'.start',
SubTask::TABLE.'.task_id',
SubTask::TABLE.'.title AS subtask_title',
Task::TABLE.'.title AS task_title',
Task::TABLE.'.project_id'
)
->join(SubTask::TABLE, 'id', 'subtask_id')
->join(Task::TABLE, 'id', 'task_id', SubTask::TABLE)
->eq(self::TABLE.'.user_id', $user_id);
}
/**
* Log start time
*
* @access public
* @param integer $subtask_id
* @param integer $user_id
* @return boolean
*/
public function logStartTime($subtask_id, $user_id)
{
return $this->db
->table(self::TABLE)
->insert(array('subtask_id' => $subtask_id, 'user_id' => $user_id, 'start' => time()));
}
/**
* Log end time
*
* @access public
* @param integer $subtask_id
* @param integer $user_id
* @return boolean
*/
public function logEndTime($subtask_id, $user_id)
{
return $this->db
->table(self::TABLE)
->eq('subtask_id', $subtask_id)
->eq('user_id', $user_id)
->eq('end', 0)
->update(array(
'end' => time()
));
}
}

View File

@ -5,7 +5,27 @@ namespace Schema;
use PDO;
use Core\Security;
const VERSION = 42;
const VERSION = 43;
function version_43($pdo)
{
$rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)');
$rq->execute(array('subtask_restriction', '0'));
$rq->execute(array('subtask_time_tracking', '0'));
$pdo->exec("
CREATE TABLE subtask_time_tracking (
id INT NOT NULL AUTO_INCREMENT,
user_id INT NOT NULL,
subtask_id INT NOT NULL,
start INT DEFAULT 0,
end INT DEFAULT 0,
PRIMARY KEY(id),
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY(subtask_id) REFERENCES task_has_subtasks(id) ON DELETE CASCADE
) ENGINE=InnoDB CHARSET=utf8
");
}
function version_42($pdo)
{

View File

@ -5,7 +5,26 @@ namespace Schema;
use PDO;
use Core\Security;
const VERSION = 23;
const VERSION = 24;
function version_24($pdo)
{
$rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)');
$rq->execute(array('subtask_restriction', '0'));
$rq->execute(array('subtask_time_tracking', '0'));
$pdo->exec("
CREATE TABLE subtask_time_tracking (
id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL,
subtask_id INTEGER NOT NULL,
start INTEGER DEFAULT 0,
end INTEGER DEFAULT 0,
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY(subtask_id) REFERENCES task_has_subtasks(id) ON DELETE CASCADE
)
");
}
function version_23($pdo)
{

View File

@ -5,7 +5,26 @@ namespace Schema;
use Core\Security;
use PDO;
const VERSION = 41;
const VERSION = 42;
function version_42($pdo)
{
$rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)');
$rq->execute(array('subtask_restriction', '0'));
$rq->execute(array('subtask_time_tracking', '0'));
$pdo->exec("
CREATE TABLE subtask_time_tracking (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL,
subtask_id INTEGER NOT NULL,
start INTEGER DEFAULT 0,
end INTEGER DEFAULT 0,
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY(subtask_id) REFERENCES task_has_subtasks(id) ON DELETE CASCADE
)
");
}
function version_41($pdo)
{

View File

@ -33,6 +33,7 @@ class ClassProvider implements ServiceProviderInterface
'ProjectPermission',
'SubTask',
'SubtaskExport',
'SubtaskTimeTracking',
'Swimlane',
'Task',
'TaskCreation',

View File

@ -12,6 +12,7 @@ use Subscriber\ProjectActivitySubscriber;
use Subscriber\ProjectDailySummarySubscriber;
use Subscriber\ProjectModificationDateSubscriber;
use Subscriber\WebhookSubscriber;
use Subscriber\SubtaskTimesheetSubscriber;
class EventDispatcherProvider implements ServiceProviderInterface
{
@ -25,6 +26,7 @@ class EventDispatcherProvider implements ServiceProviderInterface
$container['dispatcher']->addSubscriber(new ProjectModificationDateSubscriber($container));
$container['dispatcher']->addSubscriber(new WebhookSubscriber($container));
$container['dispatcher']->addSubscriber(new NotificationSubscriber($container));
$container['dispatcher']->addSubscriber(new SubtaskTimesheetSubscriber($container));
// Automatic actions
$container['action']->attachEvents();

View File

@ -0,0 +1,32 @@
<?php
namespace Subscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Model\SubTask;
use Event\SubtaskEvent;
class SubtaskTimesheetSubscriber extends Base implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return array(
SubTask::EVENT_UPDATE => array('log', 0),
);
}
public function log(SubtaskEvent $event)
{
if (isset($event['status'])) {
$subtask = $this->subTask->getById($event['id']);
if ($subtask['status'] == SubTask::STATUS_INPROGRESS) {
$this->subtaskTimeTracking->logStartTime($subtask['id'], $subtask['user_id']);
}
else {
$this->subtaskTimeTracking->logEndTime($subtask['id'], $subtask['user_id']);
}
}
}
}

View File

@ -18,7 +18,7 @@
<?= $this->a($this->e($subtask['project_name']), 'board', 'show', array('project_id' => $subtask['project_id'])) ?>
</td>
<td>
<?= $this->e($subtask['status_name']) ?>
<?= $this->toggleSubtaskStatus($subtask, 'dashboard') ?>
</td>
<td>
<?= $this->a($this->e($subtask['title']), 'task', 'show', array('task_id' => $subtask['task_id'], 'project_id' => $subtask['project_id'])) ?>

View File

@ -1,14 +1,7 @@
<section id="tooltip-subtasks">
<?php foreach ($subtasks as $subtask): ?>
<?= $this->a(
trim($this->render('subtask/icons', array('subtask' => $subtask))) . $this->e($subtask['title']),
'board',
'toggleSubtask',
array('task_id' => $subtask['task_id'], 'project_id' => $task['project_id'], 'subtask_id' => $subtask['id'])
) ?>
<?= $this->toggleSubtaskStatus($subtask, 'board') ?>
<?= $this->e(empty($subtask['username']) ? '' : ' ['.$this->getFullname($subtask).']') ?>
<br/>
<?php endforeach ?>
</section>

View File

@ -26,6 +26,9 @@
<?= $this->formText('project_categories', $values, $errors) ?><br/>
<p class="form-help"><?= t('Example: "Bug, Feature Request, Improvement"') ?></p>
<?= $this->formCheckbox('subtask_restriction', t('Allow only one subtask in progress at the same time for a user'), 1, $values['subtask_restriction'] == 1) ?>
<?= $this->formCheckbox('subtask_time_tracking', t('Enable time tracking for subtasks'), 1, $values['subtask_time_tracking'] == 1) ?>
<div class="form-actions">
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
</div>

View File

@ -12,9 +12,6 @@
<?= $this->formLabel(t('Title'), 'title') ?>
<?= $this->formText('title', $values, $errors, array('required', 'autofocus', 'maxlength="50"')) ?><br/>
<?= $this->formLabel(t('Status'), 'status') ?>
<?= $this->formSelect('status', $status_list, $values, $errors) ?><br/>
<?= $this->formLabel(t('Assignee'), 'user_id') ?>
<?= $this->formSelect('user_id', $users_list, $values, $errors) ?><br/>

View File

@ -0,0 +1,19 @@
<div class="page-header">
<h2><?= t('You already have one subtask in progress') ?></h2>
</div>
<form action="<?= $this->u('subtask', 'changeRestrictionStatus', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'subtask_id' => $subtask['id'])) ?>" method="post">
<?= $this->formCsrf() ?>
<?= $this->formHidden('redirect', array('redirect' => $redirect)) ?>
<p><?= t('Select the new status of the subtask: "%s"', $subtask_inprogress['title']) ?></p>
<?= $this->formRadios('status', $status_list) ?>
<?= $this->formHidden('id', $subtask_inprogress) ?>
<div class="form-actions">
<input type="submit" value="<?= t('Save') ?>" class="btn btn-red"/>
<?= t('or') ?>
<a href="#" class="close-popover"><?= t('cancel') ?></a>
</div>
</form>

View File

@ -20,15 +20,14 @@
<td><?= $this->e($subtask['title']) ?></td>
<td>
<?php if (! isset($not_editable)): ?>
<?= $this->a(trim($this->render('subtask/icons', array('subtask' => $subtask))) . $this->e($subtask['status_name']),
'subtask', 'toggleStatus', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'subtask_id' => $subtask['id'])) ?>
<?= $this->toggleSubtaskStatus($subtask, 'task') ?>
<?php else: ?>
<?= $this->render('subtask/icons', array('subtask' => $subtask)) . $this->e($subtask['status_name']) ?>
<?php endif ?>
</td>
<td>
<?php if (! empty($subtask['username'])): ?>
<?= $this->e($subtask['name'] ?: $subtask['username']) ?>
<?= $this->a($this->e($subtask['name'] ?: $subtask['username']), 'user', 'show', array('user_id' => $subtask['user_id'])) ?>
<?php endif ?>
</td>
<td>

View File

@ -28,6 +28,9 @@
<li>
<?= $this->a(t('Persistent connections'), 'user', 'sessions', array('user_id' => $user['id'])) ?>
</li>
<li>
<?= $this->a(t('Time tracking'), 'user', 'timesheet', array('user_id' => $user['id'])) ?>
</li>
<?php endif ?>
<?php if ($this->userSession->isAdmin()): ?>

View File

@ -0,0 +1,27 @@
<div class="page-header">
<h2><?= t('Time Tracking') ?></h2>
</div>
<h3><?= t('Subtask timesheet') ?></h3>
<?php if ($subtask_paginator->isEmpty()): ?>
<p class="alert"><?= t('There is nothing to show.') ?></p>
<?php else: ?>
<table class="table-fixed">
<tr>
<th class="column-20"><?= $subtask_paginator->order('Task', 'task_title') ?></th>
<th class="column-20"><?= $subtask_paginator->order('Subtask', 'subtask_title') ?></th>
<th><?= $subtask_paginator->order(t('Start'), 'start') ?></th>
<th><?= $subtask_paginator->order(t('End'), 'end') ?></th>
</tr>
<?php foreach ($subtask_paginator->getCollection() as $record): ?>
<tr>
<td><?= $this->a($this->e($record['task_title']), 'task', 'show', array('project_id' => $record['project_id'], 'task_id' => $record['task_id'])) ?></td>
<td><?= $this->a($this->e($record['subtask_title']), 'task', 'show', array('project_id' => $record['project_id'], 'task_id' => $record['task_id'])) ?></td>
<td><?= dt('%B %e, %Y at %k:%M %p', $record['start']) ?></td>
<td><?= dt('%B %e, %Y at %k:%M %p', $record['end']) ?></td>
</tr>
<?php endforeach ?>
</table>
<?= $subtask_paginator ?>
<?php endif ?>

View File

@ -135,16 +135,16 @@ var Kanboard=function(){return{Exists:function(a){return document.getElementById
$(".close-popover").click(function(a){a.preventDefault();$("#popover-container").remove()});Mousetrap.bind("esc",function(){$("#popover-container").remove()});d&&d()})},IsVisible:function(){var a="";"undefined"!==typeof document.hidden?a="visibilityState":"undefined"!==typeof document.mozHidden?a="mozVisibilityState":"undefined"!==typeof document.msHidden?a="msVisibilityState":"undefined"!==typeof document.webkitHidden&&(a="webkitVisibilityState");return""!=a?"visible"==document[a]:!0},SetStorageItem:function(a,
d){"undefined"!==typeof Storage&&localStorage.setItem(a,d)},GetStorageItem:function(a){return"undefined"!==typeof Storage?localStorage.getItem(a):""},MarkdownPreview:function(a){a.preventDefault();var d=$(this),c=$(this).closest("ul"),f=$(".write-area"),e=$(".preview-area"),b=$("textarea");$.ajax({url:"?controller=app&action=preview",contentType:"application/json",type:"POST",processData:!1,dataType:"html",data:JSON.stringify({text:b.val()})}).done(function(a){c.find("li").removeClass("form-tab-selected");
d.parent().addClass("form-tab-selected");e.find(".markdown").html(a);e.css("height",b.css("height"));e.css("width",b.css("width"));f.hide();e.show()})},MarkdownWriter:function(a){a.preventDefault();$(this).closest("ul").find("li").removeClass("form-tab-selected");$(this).parent().addClass("form-tab-selected");$(".write-area").show();$(".preview-area").hide()},CheckSession:function(){$(".form-login").length||$.ajax({cache:!1,url:$("body").data("status-url"),statusCode:{401:function(a){window.location=
$("body").data("login-url")}}})},Init:function(){$("#board-selector").chosen({width:180});$("#board-selector").change(function(){window.location=$(this).attr("data-board-url").replace(/PROJECT_ID/g,$(this).val())});window.setInterval(Kanboard.CheckSession,6E4);Mousetrap.bind("ctrl+enter",function(){$("form").submit()});Kanboard.InitAfterAjax()},InitAfterAjax:function(){$(".form-date").datepicker({showOtherMonths:!0,selectOtherMonths:!0,dateFormat:"yy-mm-dd",constrainInput:!1});$("#markdown-preview").click(Kanboard.MarkdownPreview);
$("#markdown-write").click(Kanboard.MarkdownWriter);$(".auto-select").focus(function(){$(this).select()});$(".dropit-submenu").hide();$(".dropdown").not(".dropit").dropit()}}}();
$("body").data("login-url")}}})},Init:function(){$("#board-selector").chosen({width:180});$("#board-selector").change(function(){window.location=$(this).attr("data-board-url").replace(/PROJECT_ID/g,$(this).val())});window.setInterval(Kanboard.CheckSession,6E4);Mousetrap.bind("ctrl+enter",function(){$("form").submit()});$(".popover-subtask-restriction").click(Kanboard.Popover);Kanboard.InitAfterAjax()},InitAfterAjax:function(){$(".form-date").datepicker({showOtherMonths:!0,selectOtherMonths:!0,dateFormat:"yy-mm-dd",
constrainInput:!1});$("#markdown-preview").click(Kanboard.MarkdownPreview);$("#markdown-write").click(Kanboard.MarkdownWriter);$(".auto-select").focus(function(){$(this).select()});$(".dropit-submenu").hide();$(".dropdown").not(".dropit").dropit()}}}();
Kanboard.Board=function(){function a(a){Kanboard.Popover(a,Kanboard.InitAfterAjax)}function d(){Mousetrap.bind("n",function(){Kanboard.OpenPopover($(".task-creation-popover").attr("href"),Kanboard.InitAfterAjax)})}function c(){$(".column").sortable({delay:300,distance:5,connectWith:".column",placeholder:"draggable-placeholder",stop:function(a,b){e(b.item.attr("data-task-id"),b.item.parent().attr("data-column-id"),b.item.index()+1,b.item.parent().attr("data-swimlane-id"))}});$(".assignee-popover").click(a);
$(".category-popover").click(a);$(".task-edit-popover").click(a);$(".task-creation-popover").click(a);$(".task-description-popover").click(a);$(".column-tooltip").tooltip({content:function(a){return $(this).attr("title")}});$(".task-board-tooltip").tooltip({track:!1,position:{my:"left-20 top",at:"center bottom+9",using:function(a,b){$(this).css(a);var c=b.target.left+b.target.width/2-b.element.left-20;$("<div>").addClass("tooltip-arrow").addClass(b.vertical).addClass(0==c?"align-left":"align-right").appendTo(this)}},
content:function(a){if(a=$(this).attr("data-href")){var b=this;$.get(a,function k(a){$(".ui-tooltip-content:visible").html(a);a=$(".ui-tooltip:visible");a.css({top:"",left:""});a.children(".tooltip-arrow").remove();var c=$(b).tooltip("option","position");c.of=$(b);a.position(c);$("#tooltip-subtasks a").click(function(a){a.preventDefault();a.stopPropagation();$.get($(this).attr("href"),k)})});return'<i class="fa fa-refresh fa-spin fa-2x"></i>'}}}).on("mouseenter",function(){var a=this;$(this).tooltip("open");
$(".ui-tooltip").on("mouseleave",function(){$(a).tooltip("close")})}).on("mouseleave focusout",function(a){a.stopImmediatePropagation();var b=this;setTimeout(function(){$(".ui-tooltip:hover").length||$(b).tooltip("close")},100)});$("[data-task-url]").each(function(){$(this).click(function(){window.location=$(this).attr("data-task-url")})});var c=parseInt($("#board").attr("data-check-interval"));0<c&&(h=window.setInterval(b,1E3*c))}function f(){$("[data-task-url]").off();clearInterval(h)}function e(a,
b,e,d){f();$.ajax({cache:!1,url:$("#board").attr("data-save-url"),contentType:"application/json",type:"POST",processData:!1,data:JSON.stringify({task_id:a,column_id:b,swimlane_id:d,position:e}),success:function(a){$("#board").remove();$("#main").append(a);Kanboard.InitAfterAjax();c();g()}})}function b(){Kanboard.IsVisible()&&$.ajax({cache:!1,url:$("#board").attr("data-check-url"),statusCode:{200:function(a){$("#board").remove();$("#main").append(a);Kanboard.InitAfterAjax();f();c();g()}}})}function g(){var a=
$("#form-user_id").val(),b=$("#form-category_id").val(),c=$("#filter-due-date").hasClass("filter-on"),e=$("#board").data("project-id");$("[data-task-id]").each(function(e,d){var f=d.getAttribute("data-owner-id"),g=d.getAttribute("data-due-date"),h=d.getAttribute("data-category-id");d.style.opacity=f!=a&&-1!=a?"0.2":"1.0";!c||""!=g&&"0"!=g||(d.style.opacity="0.2");h!=b&&-1!=b&&(d.style.opacity="0.2")});Kanboard.SetStorageItem("board_filter_"+e+"_form-user_id",a);Kanboard.SetStorageItem("board_filter_"+
e+"_form-category_id",b);Kanboard.SetStorageItem("board_filter_"+e+"_filter-due-date",~~c)}function l(){var a=$("#board").data("project-id");$("#form-user_id").change(g);$("#form-category_id").change(g);$("#filter-due-date").click(function(a){$(this).toggleClass("filter-on");g();a.preventDefault()});$("#form-user_id").val(Kanboard.GetStorageItem("board_filter_"+a+"_form-user_id")||-1);$("#form-category_id").val(Kanboard.GetStorageItem("board_filter_"+a+"_form-category_id")||-1);+Kanboard.GetStorageItem("board_filter_"+
a+"_filter-due-date")?$("#filter-due-date").addClass("filter-on"):$("#filter-due-date").removeClass("filter-on");g()}var h=null;return{Init:function(){c();l();d()}}}();
content:function(a){if(a=$(this).attr("data-href")){var b=this;$.get(a,function k(a){$(".ui-tooltip-content:visible").html(a);a=$(".ui-tooltip:visible");a.css({top:"",left:""});a.children(".tooltip-arrow").remove();var c=$(b).tooltip("option","position");c.of=$(b);a.position(c);$("#tooltip-subtasks a").click(function(a){a.preventDefault();a.stopPropagation();$(this).hasClass("popover-subtask-restriction")?(Kanboard.OpenPopover($(this).attr("href")),$(b).tooltip("close")):$.get($(this).attr("href"),
k)})});return'<i class="fa fa-refresh fa-spin fa-2x"></i>'}}}).on("mouseenter",function(){var a=this;$(this).tooltip("open");$(".ui-tooltip").on("mouseleave",function(){$(a).tooltip("close")})}).on("mouseleave focusout",function(a){a.stopImmediatePropagation();var b=this;setTimeout(function(){$(".ui-tooltip:hover").length||$(b).tooltip("close")},100)});$("[data-task-url]").each(function(){$(this).click(function(){window.location=$(this).attr("data-task-url")})});var c=parseInt($("#board").attr("data-check-interval"));
0<c&&(h=window.setInterval(b,1E3*c))}function f(){$("[data-task-url]").off();clearInterval(h)}function e(a,b,e,d){f();$.ajax({cache:!1,url:$("#board").attr("data-save-url"),contentType:"application/json",type:"POST",processData:!1,data:JSON.stringify({task_id:a,column_id:b,swimlane_id:d,position:e}),success:function(a){$("#board").remove();$("#main").append(a);Kanboard.InitAfterAjax();c();g()}})}function b(){Kanboard.IsVisible()&&$.ajax({cache:!1,url:$("#board").attr("data-check-url"),statusCode:{200:function(a){$("#board").remove();
$("#main").append(a);Kanboard.InitAfterAjax();f();c();g()}}})}function g(){var a=$("#form-user_id").val(),b=$("#form-category_id").val(),c=$("#filter-due-date").hasClass("filter-on"),e=$("#board").data("project-id");$("[data-task-id]").each(function(e,d){var f=d.getAttribute("data-owner-id"),g=d.getAttribute("data-due-date"),h=d.getAttribute("data-category-id");d.style.opacity=f!=a&&-1!=a?"0.2":"1.0";!c||""!=g&&"0"!=g||(d.style.opacity="0.2");h!=b&&-1!=b&&(d.style.opacity="0.2")});Kanboard.SetStorageItem("board_filter_"+
e+"_form-user_id",a);Kanboard.SetStorageItem("board_filter_"+e+"_form-category_id",b);Kanboard.SetStorageItem("board_filter_"+e+"_filter-due-date",~~c)}function l(){var a=$("#board").data("project-id");$("#form-user_id").change(g);$("#form-category_id").change(g);$("#filter-due-date").click(function(a){$(this).toggleClass("filter-on");g();a.preventDefault()});$("#form-user_id").val(Kanboard.GetStorageItem("board_filter_"+a+"_form-user_id")||-1);$("#form-category_id").val(Kanboard.GetStorageItem("board_filter_"+
a+"_form-category_id")||-1);+Kanboard.GetStorageItem("board_filter_"+a+"_filter-due-date")?$("#filter-due-date").addClass("filter-on"):$("#filter-due-date").removeClass("filter-on");g()}var h=null;return{Init:function(){c();l();d()}}}();
Kanboard.Calendar=function(){function a(a){$.ajax({cache:!1,url:$("#calendar").data("save-url"),contentType:"application/json",type:"POST",processData:!1,data:JSON.stringify({task_id:a.id,date_due:a.start.format()})})}function d(a){var b=$("#calendar"),c=b.data("check-url"),d={start:b.fullCalendar("getView").start.format(),end:b.fullCalendar("getView").end.format()};jQuery.extend(d,a);for(var f in d)c+="&"+f+"="+d[f];$.getJSON(c,function(a){b.fullCalendar("removeEvents");b.fullCalendar("addEventSource",
a);b.fullCalendar("rerenderEvents")})}function c(){var a={};$(".calendar-filter").each(function(b,c){a[$(this).attr("name")]=$(this).val()});Kanboard.SetStorageItem(f,JSON.stringify(a));d(a)}var f="";return{Init:function(){f="calendar_filters_"+$("#calendar").data("project-id");var e=$("#calendar"),b=e.data("translations");e.fullCalendar({editable:!0,eventLimit:!0,header:{left:"prev,next today",center:"title",right:""},eventDrop:a,monthNames:[b.January,b.February,b.March,b.April,b.May,b.June,b.July,
b.August,b.September,b.October,b.November,b.December],monthNamesShort:[b.Jan,b.Feb,b.Mar,b.Apr,b.May,b.Jun,b.Jul,b.Aug,b.Sep,b.Oct,b.Nov,b.Dec],buttonText:{today:b.Today},dayNames:[b.Sunday,b.Monday,b.Tuesday,b.Wednesday,b.Thursday,b.Friday,b.Saturday],dayNamesShort:[b.Sun,b.Mon,b.Tue,b.Wed,b.Thu,b.Fri,b.Sat]});e=Kanboard.GetStorageItem(f);if("undefined"!==e&&""!==e){var e=JSON.parse(e),g;for(g in e)$("select[name="+g+"]").val(e[g])}d(e||{});$(".calendar-filter").change(c)}}}();Kanboard.Task=function(){return{Init:function(){$(".file-popover").click(Kanboard.Popover)}}}();

View File

@ -178,6 +178,8 @@ var Kanboard = (function() {
$("form").submit();
});
$(".popover-subtask-restriction").click(Kanboard.Popover);
Kanboard.InitAfterAjax();
},

View File

@ -107,7 +107,13 @@ Kanboard.Board = (function() {
e.preventDefault();
e.stopPropagation();
$.get($(this).attr('href'), setTooltipContent);
if ($(this).hasClass("popover-subtask-restriction")) {
Kanboard.OpenPopover($(this).attr('href'));
$(_this).tooltip('close');
}
else {
$.get($(this).attr('href'), setTooltipContent);
}
});
});