Refactoring to implement new layout with filters: board/calendar/list views (work in progress)
This commit is contained in:
29
app/Controller/Activity.php
Normal file
29
app/Controller/Activity.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Controller;
|
||||
|
||||
/**
|
||||
* Activity stream
|
||||
*
|
||||
* @package controller
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class Activity extends Base
|
||||
{
|
||||
/**
|
||||
* Activity page for a project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function project()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
|
||||
$this->response->html($this->template->layout('activity/project', array(
|
||||
'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()),
|
||||
'events' => $this->projectActivity->getProject($project['id']),
|
||||
'project' => $project,
|
||||
'title' => t('%s\'s activity', $project['name'])
|
||||
)));
|
||||
}
|
||||
}
|
||||
@@ -327,4 +327,33 @@ abstract class Base extends \Core\Base
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Common method to get project filters
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function getProjectFilters($controller, $action)
|
||||
{
|
||||
$project = $this->getProject();
|
||||
$search = $this->request->getStringParam('search', $this->userSession->getFilters($project['id']));
|
||||
$board_selector = $this->projectPermission->getAllowedProjects($this->userSession->getId());
|
||||
unset($board_selector[$project['id']]);
|
||||
|
||||
$filters = array(
|
||||
'controller' => $controller,
|
||||
'action' => $action,
|
||||
'project_id' => $project['id'],
|
||||
'search' => $search,
|
||||
);
|
||||
|
||||
$this->userSession->setFilters($project['id'], $search);
|
||||
|
||||
return array(
|
||||
'project' => $project,
|
||||
'board_selector' => $board_selector,
|
||||
'filters' => $filters,
|
||||
'title' => $project['name'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class Board extends Base
|
||||
}
|
||||
|
||||
// Display the board with a specific layout
|
||||
$this->response->html($this->template->layout('board/public', array(
|
||||
$this->response->html($this->template->layout('board/public_view', array(
|
||||
'project' => $project,
|
||||
'swimlanes' => $this->board->getBoard($project['id']),
|
||||
'title' => $project['name'],
|
||||
@@ -44,28 +44,17 @@ class Board extends Base
|
||||
* Show a board for a given project
|
||||
*
|
||||
* @access public
|
||||
* @param integer $project_id Default project id
|
||||
*/
|
||||
public function show($project_id = 0)
|
||||
public function show()
|
||||
{
|
||||
$project = $this->getProject($project_id);
|
||||
$projects = $this->projectPermission->getAllowedProjects($this->userSession->getId());
|
||||
$params = $this->getProjectFilters('board', 'show');
|
||||
|
||||
$board_selector = $projects;
|
||||
unset($board_selector[$project['id']]);
|
||||
|
||||
$this->response->html($this->template->layout('board/index', array(
|
||||
'users' => $this->projectPermission->getMemberList($project['id'], true, true),
|
||||
'projects' => $projects,
|
||||
'project' => $project,
|
||||
'swimlanes' => $this->board->getBoard($project['id']),
|
||||
'categories_listing' => $this->category->getList($project['id'], true, true),
|
||||
'title' => $project['name'],
|
||||
'description' => $project['description'],
|
||||
'board_selector' => $board_selector,
|
||||
$this->response->html($this->template->layout('board/private_view', array(
|
||||
'swimlanes' => $this->taskFilter->search($params['filters']['search'])->getBoard($params['project']['id']),
|
||||
'description' => $params['project']['description'],
|
||||
'board_private_refresh_interval' => $this->config->get('board_private_refresh_interval'),
|
||||
'board_highlight_period' => $this->config->get('board_highlight_period'),
|
||||
)));
|
||||
) + $params));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,9 +89,9 @@ class Board extends Base
|
||||
}
|
||||
|
||||
$this->response->html(
|
||||
$this->template->render('board/show', array(
|
||||
$this->template->render('board/table_container', array(
|
||||
'project' => $this->project->getById($project_id),
|
||||
'swimlanes' => $this->board->getBoard($project_id),
|
||||
'swimlanes' => $this->taskFilter->search($this->userSession->getFilters($project_id))->getBoard($project_id),
|
||||
'board_private_refresh_interval' => $this->config->get('board_private_refresh_interval'),
|
||||
'board_highlight_period' => $this->config->get('board_highlight_period'),
|
||||
)),
|
||||
@@ -133,9 +122,9 @@ class Board extends Base
|
||||
}
|
||||
|
||||
$this->response->html(
|
||||
$this->template->render('board/show', array(
|
||||
$this->template->render('board/table_container', array(
|
||||
'project' => $this->project->getById($project_id),
|
||||
'swimlanes' => $this->board->getBoard($project_id),
|
||||
'swimlanes' => $this->taskFilter->search($this->userSession->getFilters($project_id))->getBoard($project_id),
|
||||
'board_private_refresh_interval' => $this->config->get('board_private_refresh_interval'),
|
||||
'board_highlight_period' => $this->config->get('board_highlight_period'),
|
||||
))
|
||||
@@ -150,7 +139,7 @@ class Board extends Base
|
||||
public function tasklinks()
|
||||
{
|
||||
$task = $this->getTask();
|
||||
$this->response->html($this->template->render('board/tasklinks', array(
|
||||
$this->response->html($this->template->render('board/tooltip_tasklinks', array(
|
||||
'links' => $this->taskLink->getAll($task['id']),
|
||||
'task' => $task,
|
||||
)));
|
||||
@@ -164,7 +153,7 @@ class Board extends Base
|
||||
public function subtasks()
|
||||
{
|
||||
$task = $this->getTask();
|
||||
$this->response->html($this->template->render('board/subtasks', array(
|
||||
$this->response->html($this->template->render('board/tooltip_subtasks', array(
|
||||
'subtasks' => $this->subtask->getAll($task['id']),
|
||||
'task' => $task,
|
||||
)));
|
||||
@@ -179,7 +168,7 @@ class Board extends Base
|
||||
{
|
||||
$task = $this->getTask();
|
||||
|
||||
$this->response->html($this->template->render('board/files', array(
|
||||
$this->response->html($this->template->render('board/tooltip_files', array(
|
||||
'files' => $this->file->getAllDocuments($task['id']),
|
||||
'images' => $this->file->getAllImages($task['id']),
|
||||
'task' => $task,
|
||||
@@ -195,7 +184,7 @@ class Board extends Base
|
||||
{
|
||||
$task = $this->getTask();
|
||||
|
||||
$this->response->html($this->template->render('board/comments', array(
|
||||
$this->response->html($this->template->render('board/tooltip_comments', array(
|
||||
'comments' => $this->comment->getAll($task['id'])
|
||||
)));
|
||||
}
|
||||
@@ -209,7 +198,7 @@ class Board extends Base
|
||||
{
|
||||
$task = $this->getTask();
|
||||
|
||||
$this->response->html($this->template->render('board/description', array(
|
||||
$this->response->html($this->template->render('board/tooltip_description', array(
|
||||
'task' => $task
|
||||
)));
|
||||
}
|
||||
@@ -224,7 +213,7 @@ class Board extends Base
|
||||
$task = $this->getTask();
|
||||
$project = $this->project->getById($task['project_id']);
|
||||
|
||||
$this->response->html($this->template->render('board/assignee', array(
|
||||
$this->response->html($this->template->render('board/popover_assignee', array(
|
||||
'values' => $task,
|
||||
'users_list' => $this->projectPermission->getMemberList($project['id']),
|
||||
'project' => $project,
|
||||
@@ -262,7 +251,7 @@ class Board extends Base
|
||||
$task = $this->getTask();
|
||||
$project = $this->project->getById($task['project_id']);
|
||||
|
||||
$this->response->html($this->template->render('board/category', array(
|
||||
$this->response->html($this->template->render('board/popover_category', array(
|
||||
'values' => $task,
|
||||
'categories_list' => $this->category->getList($project['id']),
|
||||
'project' => $project,
|
||||
|
||||
@@ -20,20 +20,9 @@ class Calendar extends Base
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
|
||||
$this->response->html($this->template->layout('calendar/show', array(
|
||||
'check_interval' => $this->config->get('board_private_refresh_interval'),
|
||||
'users_list' => $this->projectPermission->getMemberList($project['id'], true, true),
|
||||
'categories_list' => $this->category->getList($project['id'], true, true),
|
||||
'columns_list' => $this->board->getColumnsList($project['id'], true),
|
||||
'swimlanes_list' => $this->swimlane->getList($project['id'], true),
|
||||
'colors_list' => $this->color->getList(true),
|
||||
'status_list' => $this->taskStatus->getList(true),
|
||||
'project' => $project,
|
||||
'title' => t('Calendar for "%s"', $project['name']),
|
||||
'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()),
|
||||
)));
|
||||
) + $this->getProjectFilters('calendar', 'show')));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,14 +38,8 @@ class Calendar extends Base
|
||||
|
||||
// Common filter
|
||||
$filter = $this->taskFilter
|
||||
->create()
|
||||
->filterByProject($project_id)
|
||||
->filterByCategory($this->request->getIntegerParam('category_id', -1))
|
||||
->filterByOwner($this->request->getIntegerParam('owner_id', -1))
|
||||
->filterByColumn($this->request->getIntegerParam('column_id', -1))
|
||||
->filterBySwimlane($this->request->getIntegerParam('swimlane_id', -1))
|
||||
->filterByColor($this->request->getStringParam('color_id'))
|
||||
->filterByStatus($this->request->getIntegerParam('is_active', -1));
|
||||
->search($this->userSession->getFilters($project_id))
|
||||
->filterByProject($project_id);
|
||||
|
||||
// Tasks
|
||||
if ($this->config->get('calendar_project_tasks', 'date_started') === 'date_creation') {
|
||||
|
||||
37
app/Controller/Listing.php
Normal file
37
app/Controller/Listing.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Controller;
|
||||
|
||||
use Model\Task as TaskModel;
|
||||
|
||||
/**
|
||||
* List view controller
|
||||
*
|
||||
* @package controller
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class Listing extends Base
|
||||
{
|
||||
/**
|
||||
* Show list view for projects
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
$params = $this->getProjectFilters('listing', 'show');
|
||||
$query = $this->taskFilter->search($params['filters']['search'])->filterByProject($params['project']['id'])->getQuery();
|
||||
|
||||
$paginator = $this->paginator
|
||||
->setUrl('listing', 'show', array('project_id' => $params['project']['id']))
|
||||
->setMax(30)
|
||||
->setOrder(TaskModel::TABLE.'.id')
|
||||
->setDirection('DESC')
|
||||
->setQuery($query)
|
||||
->calculate();
|
||||
|
||||
$this->response->html($this->template->layout('listing/show', $params + array(
|
||||
'paginator' => $paginator,
|
||||
)));
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Controller;
|
||||
|
||||
/**
|
||||
* Project Info controller (ActivityStream + completed tasks)
|
||||
*
|
||||
* @package controller
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class Projectinfo extends Base
|
||||
{
|
||||
/**
|
||||
* Activity page for a project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function activity()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
|
||||
$this->response->html($this->template->layout('projectinfo/activity', array(
|
||||
'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()),
|
||||
'events' => $this->projectActivity->getProject($project['id']),
|
||||
'project' => $project,
|
||||
'title' => t('%s\'s activity', $project['name'])
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Task search for a given project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function search()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
$search = $this->request->getStringParam('search');
|
||||
$nb_tasks = 0;
|
||||
|
||||
$paginator = $this->paginator
|
||||
->setUrl('projectinfo', 'search', array('search' => $search, 'project_id' => $project['id']))
|
||||
->setMax(30)
|
||||
->setOrder('tasks.id')
|
||||
->setDirection('DESC');
|
||||
|
||||
if ($search !== '') {
|
||||
$paginator->setQuery($this->taskFilter->search($search)->filterByProject($project['id'])->getQuery())
|
||||
->calculate();
|
||||
|
||||
$nb_tasks = $paginator->getTotal();
|
||||
}
|
||||
|
||||
$this->response->html($this->template->layout('projectinfo/search', array(
|
||||
'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()),
|
||||
'values' => array(
|
||||
'search' => $search,
|
||||
'controller' => 'projectinfo',
|
||||
'action' => 'search',
|
||||
'project_id' => $project['id'],
|
||||
),
|
||||
'paginator' => $paginator,
|
||||
'project' => $project,
|
||||
'columns' => $this->board->getColumnsList($project['id']),
|
||||
'categories' => $this->category->getList($project['id'], false),
|
||||
'title' => t('Search in the project "%s"', $project['name']).($nb_tasks > 0 ? ' ('.$nb_tasks.')' : '')
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* List of completed tasks for a given project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function tasks()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
$paginator = $this->paginator
|
||||
->setUrl('projectinfo', 'tasks', array('project_id' => $project['id']))
|
||||
->setMax(30)
|
||||
->setOrder('tasks.id')
|
||||
->setDirection('DESC')
|
||||
->setQuery($this->taskFinder->getClosedTaskQuery($project['id']))
|
||||
->calculate();
|
||||
|
||||
$this->response->html($this->template->layout('projectinfo/tasks', array(
|
||||
'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()),
|
||||
'project' => $project,
|
||||
'columns' => $this->board->getColumnsList($project['id']),
|
||||
'categories' => $this->category->getList($project['id'], false),
|
||||
'paginator' => $paginator,
|
||||
'title' => t('Completed tasks for "%s"', $project['name']).' ('.$paginator->getTotal().')'
|
||||
)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user