Add user dashboard view

This commit is contained in:
Frederic Guillot
2015-02-04 22:05:41 -05:00
parent 24300f828a
commit 2d070627d7
17 changed files with 36 additions and 5 deletions

View File

@@ -22,34 +22,44 @@ class App extends Base
$this->response->text('OK'); $this->response->text('OK');
} }
/**
* User dashboard view for admins
*
* @access public
*/
public function dashboard()
{
$this->index($this->request->getIntegerParam('user_id'), 'dashboard');
}
/** /**
* Dashboard for the current user * Dashboard for the current user
* *
* @access public * @access public
*/ */
public function index() public function index($user_id = 0, $action = 'index')
{ {
$status = array(SubTaskModel::STATUS_TODO, SubTaskModel::STATUS_INPROGRESS); $status = array(SubTaskModel::STATUS_TODO, SubTaskModel::STATUS_INPROGRESS);
$user_id = $this->userSession->getId(); $user_id = $user_id ?: $this->userSession->getId();
$projects = $this->projectPermission->getActiveMemberProjects($user_id); $projects = $this->projectPermission->getActiveMemberProjects($user_id);
$project_ids = array_keys($projects); $project_ids = array_keys($projects);
$task_paginator = $this->paginator $task_paginator = $this->paginator
->setUrl('app', 'index', array('pagination' => 'tasks')) ->setUrl('app', $action, array('pagination' => 'tasks'))
->setMax(10) ->setMax(10)
->setOrder('tasks.id') ->setOrder('tasks.id')
->setQuery($this->taskFinder->getUserQuery($user_id)) ->setQuery($this->taskFinder->getUserQuery($user_id))
->calculateOnlyIf($this->request->getStringParam('pagination') === 'tasks'); ->calculateOnlyIf($this->request->getStringParam('pagination') === 'tasks');
$subtask_paginator = $this->paginator $subtask_paginator = $this->paginator
->setUrl('app', 'index', array('pagination' => 'subtasks')) ->setUrl('app', $action, array('pagination' => 'subtasks'))
->setMax(10) ->setMax(10)
->setOrder('tasks.id') ->setOrder('tasks.id')
->setQuery($this->subTask->getUserQuery($user_id, $status)) ->setQuery($this->subTask->getUserQuery($user_id, $status))
->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks'); ->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks');
$project_paginator = $this->paginator $project_paginator = $this->paginator
->setUrl('app', 'index', array('pagination' => 'projects')) ->setUrl('app', $action, array('pagination' => 'projects'))
->setMax(10) ->setMax(10)
->setOrder('name') ->setOrder('name')
->setQuery($this->project->getQueryColumnStats($project_ids)) ->setQuery($this->project->getQueryColumnStats($project_ids))

View File

@@ -700,4 +700,5 @@ return array(
// 'Add a comment logging moving the task between columns' => '', // 'Add a comment logging moving the task between columns' => '',
// 'Moved to column %s' => '', // 'Moved to column %s' => '',
// 'Change description' => '', // 'Change description' => '',
// 'User dashboard' => '',
); );

View File

@@ -700,4 +700,5 @@ return array(
// 'Add a comment logging moving the task between columns' => '', // 'Add a comment logging moving the task between columns' => '',
// 'Moved to column %s' => '', // 'Moved to column %s' => '',
// 'Change description' => '', // 'Change description' => '',
// 'User dashboard' => '',
); );

View File

@@ -700,4 +700,5 @@ return array(
// 'Add a comment logging moving the task between columns' => '', // 'Add a comment logging moving the task between columns' => '',
'Moved to column %s' => 'Movido a columna %s', 'Moved to column %s' => 'Movido a columna %s',
// 'Change description' => '', // 'Change description' => '',
// 'User dashboard' => '',
); );

View File

@@ -700,4 +700,5 @@ return array(
// 'Add a comment logging moving the task between columns' => '', // 'Add a comment logging moving the task between columns' => '',
// 'Moved to column %s' => '', // 'Moved to column %s' => '',
// 'Change description' => '', // 'Change description' => '',
// 'User dashboard' => '',
); );

View File

@@ -700,4 +700,5 @@ return array(
'Add a comment logging moving the task between columns' => 'Ajouter un commentaire de log lorsqu\'une tâche est déplacée dans une autre colonne', 'Add a comment logging moving the task between columns' => 'Ajouter un commentaire de log lorsqu\'une tâche est déplacée dans une autre colonne',
'Moved to column %s' => 'Tâche déplacée à la colonne %s', 'Moved to column %s' => 'Tâche déplacée à la colonne %s',
'Change description' => 'Changer la description', 'Change description' => 'Changer la description',
'User dashboard' => 'Tableau de bord de l\'utilisateur',
); );

View File

@@ -700,4 +700,5 @@ return array(
// 'Add a comment logging moving the task between columns' => '', // 'Add a comment logging moving the task between columns' => '',
// 'Moved to column %s' => '', // 'Moved to column %s' => '',
// 'Change description' => '', // 'Change description' => '',
// 'User dashboard' => '',
); );

View File

@@ -700,4 +700,5 @@ return array(
// 'Add a comment logging moving the task between columns' => '', // 'Add a comment logging moving the task between columns' => '',
// 'Moved to column %s' => '', // 'Moved to column %s' => '',
// 'Change description' => '', // 'Change description' => '',
// 'User dashboard' => '',
); );

View File

@@ -700,4 +700,5 @@ return array(
// 'Add a comment logging moving the task between columns' => '', // 'Add a comment logging moving the task between columns' => '',
// 'Moved to column %s' => '', // 'Moved to column %s' => '',
// 'Change description' => '', // 'Change description' => '',
// 'User dashboard' => '',
); );

View File

@@ -700,4 +700,5 @@ return array(
'Add a comment logging moving the task between columns' => 'Dodaj komentarz dokumentujący przeniesienie zadania pomiędzy kolumnami', 'Add a comment logging moving the task between columns' => 'Dodaj komentarz dokumentujący przeniesienie zadania pomiędzy kolumnami',
'Moved to column %s' => 'Przeniosiono do kolumny %s', 'Moved to column %s' => 'Przeniosiono do kolumny %s',
// 'Change description' => '', // 'Change description' => '',
// 'User dashboard' => '',
); );

View File

@@ -700,4 +700,5 @@ return array(
'Add a comment logging moving the task between columns' => 'Adicionar un comentário de log ao mover uma tarefa em outra coluna', 'Add a comment logging moving the task between columns' => 'Adicionar un comentário de log ao mover uma tarefa em outra coluna',
'Moved to column %s' => 'Mover para a coluna %s', 'Moved to column %s' => 'Mover para a coluna %s',
// 'Change description' => '', // 'Change description' => '',
// 'User dashboard' => '',
); );

View File

@@ -700,4 +700,5 @@ return array(
// 'Add a comment logging moving the task between columns' => '', // 'Add a comment logging moving the task between columns' => '',
// 'Moved to column %s' => '', // 'Moved to column %s' => '',
// 'Change description' => '', // 'Change description' => '',
// 'User dashboard' => '',
); );

View File

@@ -700,4 +700,5 @@ return array(
// 'Add a comment logging moving the task between columns' => '', // 'Add a comment logging moving the task between columns' => '',
// 'Moved to column %s' => '', // 'Moved to column %s' => '',
// 'Change description' => '', // 'Change description' => '',
// 'User dashboard' => '',
); );

View File

@@ -700,4 +700,5 @@ return array(
// 'Add a comment logging moving the task between columns' => '', // 'Add a comment logging moving the task between columns' => '',
// 'Moved to column %s' => '', // 'Moved to column %s' => '',
// 'Change description' => '', // 'Change description' => '',
// 'User dashboard' => '',
); );

View File

@@ -700,4 +700,5 @@ return array(
// 'Add a comment logging moving the task between columns' => '', // 'Add a comment logging moving the task between columns' => '',
// 'Moved to column %s' => '', // 'Moved to column %s' => '',
// 'Change description' => '', // 'Change description' => '',
// 'User dashboard' => '',
); );

View File

@@ -64,6 +64,7 @@ class Acl extends Base
* @var array * @var array
*/ */
private $admin_acl = array( private $admin_acl = array(
'app' => array('dashboard'),
'user' => array('index', 'create', 'save', 'remove'), 'user' => array('index', 'create', 'save', 'remove'),
'config' => '*', 'config' => '*',
'project' => array('remove'), 'project' => array('remove'),

View File

@@ -30,6 +30,12 @@
</li> </li>
<?php endif ?> <?php endif ?>
<?php if ($this->userSession->isAdmin()): ?>
<li>
<?= $this->a(t('User dashboard'), 'app', 'dashboard', array('user_id' => $user['id'])) ?>
</li>
<?php endif ?>
<?php if ($this->userSession->isAdmin() && ! $this->userSession->isCurrentUser($user['id'])): ?> <?php if ($this->userSession->isAdmin() && ! $this->userSession->isCurrentUser($user['id'])): ?>
<li> <li>
<?= $this->a(t('Remove'), 'user', 'remove', array('user_id' => $user['id'])) ?> <?= $this->a(t('Remove'), 'user', 'remove', array('user_id' => $user['id'])) ?>