Display tags in task list view
This commit is contained in:
@@ -28,6 +28,7 @@ class TaskListController extends BaseController
|
||||
->setMax(30)
|
||||
->setOrder(TaskModel::TABLE.'.id')
|
||||
->setDirection('DESC')
|
||||
->setFormatter($this->taskListFormatter)
|
||||
->setQuery($this->taskLexer
|
||||
->build($search)
|
||||
->withFilter(new TaskProjectFilter($project['id']))
|
||||
@@ -36,10 +37,10 @@ class TaskListController extends BaseController
|
||||
->calculate();
|
||||
|
||||
$this->response->html($this->helper->layout->app('task_list/listing', array(
|
||||
'project' => $project,
|
||||
'title' => $project['name'],
|
||||
'project' => $project,
|
||||
'title' => $project['name'],
|
||||
'description' => $this->helper->projectHeader->getDescription($project),
|
||||
'paginator' => $paginator,
|
||||
'paginator' => $paginator,
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ use Pimple\Container;
|
||||
* @property \Kanboard\Formatter\TaskCalendarFormatter $taskCalendarFormatter
|
||||
* @property \Kanboard\Formatter\TaskGanttFormatter $taskGanttFormatter
|
||||
* @property \Kanboard\Formatter\TaskICalFormatter $taskICalFormatter
|
||||
* @property \Kanboard\Formatter\TaskListFormatter $taskListFormatter
|
||||
* @property \Kanboard\Formatter\TaskSuggestMenuFormatter $taskSuggestMenuFormatter
|
||||
* @property \Kanboard\Formatter\UserAutoCompleteFormatter $userAutoCompleteFormatter
|
||||
* @property \Kanboard\Formatter\UserMentionFormatter $userMentionFormatter
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
namespace Kanboard\Core;
|
||||
|
||||
use Kanboard\Core\Filter\FormatterInterface;
|
||||
use Pimple\Container;
|
||||
use PicoDb\Table;
|
||||
|
||||
/**
|
||||
* Paginator helper
|
||||
* Paginator Helper
|
||||
*
|
||||
* @package core
|
||||
* @package Kanboard\Core
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class Paginator
|
||||
@@ -109,6 +110,11 @@ class Paginator
|
||||
*/
|
||||
private $params = array();
|
||||
|
||||
/**
|
||||
* @var FormatterInterface
|
||||
*/
|
||||
protected $formatter = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -125,7 +131,7 @@ class Paginator
|
||||
*
|
||||
* @access public
|
||||
* @param \PicoDb\Table
|
||||
* @return Paginator
|
||||
* @return $this
|
||||
*/
|
||||
public function setQuery(Table $query)
|
||||
{
|
||||
@@ -134,6 +140,18 @@ class Paginator
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Formatter
|
||||
*
|
||||
* @param FormatterInterface $formatter
|
||||
* @return $this
|
||||
*/
|
||||
public function setFormatter(FormatterInterface $formatter)
|
||||
{
|
||||
$this->formatter = $formatter;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a PicoDb query
|
||||
*
|
||||
@@ -143,11 +161,16 @@ class Paginator
|
||||
public function executeQuery()
|
||||
{
|
||||
if ($this->query !== null) {
|
||||
return $this->query
|
||||
->offset($this->offset)
|
||||
->limit($this->limit)
|
||||
->orderBy($this->order, $this->direction)
|
||||
->findAll();
|
||||
$this->query
|
||||
->offset($this->offset)
|
||||
->limit($this->limit)
|
||||
->orderBy($this->order, $this->direction);
|
||||
|
||||
if ($this->formatter !== null) {
|
||||
return $this->formatter->withQuery($this->query)->format();
|
||||
} else {
|
||||
return $this->query->findAll();
|
||||
}
|
||||
}
|
||||
|
||||
return array();
|
||||
@@ -160,7 +183,7 @@ class Paginator
|
||||
* @param string $controller
|
||||
* @param string $action
|
||||
* @param array $params
|
||||
* @return Paginator
|
||||
* @return $this
|
||||
*/
|
||||
public function setUrl($controller, $action, array $params = array())
|
||||
{
|
||||
@@ -175,7 +198,7 @@ class Paginator
|
||||
*
|
||||
* @access public
|
||||
* @param array $items
|
||||
* @return Paginator
|
||||
* @return $this
|
||||
*/
|
||||
public function setCollection(array $items)
|
||||
{
|
||||
@@ -199,7 +222,7 @@ class Paginator
|
||||
*
|
||||
* @access public
|
||||
* @param integer $total
|
||||
* @return Paginator
|
||||
* @return $this
|
||||
*/
|
||||
public function setTotal($total)
|
||||
{
|
||||
@@ -223,7 +246,7 @@ class Paginator
|
||||
*
|
||||
* @access public
|
||||
* @param integer $page
|
||||
* @return Paginator
|
||||
* @return $this
|
||||
*/
|
||||
public function setPage($page)
|
||||
{
|
||||
@@ -247,7 +270,7 @@ class Paginator
|
||||
*
|
||||
* @access public
|
||||
* @param string $order
|
||||
* @return Paginator
|
||||
* @return $this
|
||||
*/
|
||||
public function setOrder($order)
|
||||
{
|
||||
@@ -260,7 +283,7 @@ class Paginator
|
||||
*
|
||||
* @access public
|
||||
* @param string $direction
|
||||
* @return Paginator
|
||||
* @return $this
|
||||
*/
|
||||
public function setDirection($direction)
|
||||
{
|
||||
@@ -273,7 +296,7 @@ class Paginator
|
||||
*
|
||||
* @access public
|
||||
* @param integer $limit
|
||||
* @return Paginator
|
||||
* @return $this
|
||||
*/
|
||||
public function setMax($limit)
|
||||
{
|
||||
@@ -307,7 +330,7 @@ class Paginator
|
||||
*
|
||||
* @access public
|
||||
* @param boolean $condition
|
||||
* @return Paginator
|
||||
* @return $this
|
||||
*/
|
||||
public function calculateOnlyIf($condition)
|
||||
{
|
||||
@@ -322,7 +345,7 @@ class Paginator
|
||||
* Calculate the offset value accoring to url params and the page number
|
||||
*
|
||||
* @access public
|
||||
* @return Paginator
|
||||
* @return $this
|
||||
*/
|
||||
public function calculate()
|
||||
{
|
||||
@@ -421,7 +444,7 @@ class Paginator
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function generatPageShowing()
|
||||
public function generatePageShowing()
|
||||
{
|
||||
return '<span class="pagination-showing">'.t('Showing %d-%d of %d', (($this->getPage() - 1) * $this->getMax() + 1), min($this->getTotal(), $this->getPage() * $this->getMax()), $this->getTotal()).'</span>';
|
||||
}
|
||||
@@ -432,7 +455,7 @@ class Paginator
|
||||
* @access public
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasNothingtoShow()
|
||||
public function hasNothingToShow()
|
||||
{
|
||||
return $this->offset === 0 && ($this->total - $this->offset) <= $this->limit;
|
||||
}
|
||||
@@ -447,9 +470,9 @@ class Paginator
|
||||
{
|
||||
$html = '';
|
||||
|
||||
if (! $this->hasNothingtoShow()) {
|
||||
if (! $this->hasNothingToShow()) {
|
||||
$html .= '<div class="pagination">';
|
||||
$html .= $this->generatPageShowing();
|
||||
$html .= $this->generatePageShowing();
|
||||
$html .= $this->generatePreviousLink();
|
||||
$html .= $this->generateNextLink();
|
||||
$html .= '</div>';
|
||||
|
||||
30
app/Formatter/TaskListFormatter.php
Normal file
30
app/Formatter/TaskListFormatter.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Formatter;
|
||||
|
||||
use Kanboard\Core\Filter\FormatterInterface;
|
||||
|
||||
/**
|
||||
* Class TaskListFormatter
|
||||
*
|
||||
* @package Kanboard\Formatter
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskListFormatter extends BaseFormatter implements FormatterInterface
|
||||
{
|
||||
/**
|
||||
* Apply formatter
|
||||
*
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function format()
|
||||
{
|
||||
$tasks = $this->query->findAll();
|
||||
$taskIds = array_column($tasks, 'id');
|
||||
$tags = $this->taskTagModel->getTagsByTasks($taskIds);
|
||||
array_merge_relation($tasks, $tags, 'tags', 'id');
|
||||
|
||||
return $tasks;
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ class FormatterProvider implements ServiceProviderInterface
|
||||
'TaskCalendarFormatter',
|
||||
'TaskGanttFormatter',
|
||||
'TaskICalFormatter',
|
||||
'TaskListFormatter',
|
||||
'TaskSuggestMenuFormatter',
|
||||
'UserAutoCompleteFormatter',
|
||||
'UserMentionFormatter',
|
||||
|
||||
@@ -20,4 +20,10 @@
|
||||
<?php endif ?>
|
||||
</span>
|
||||
<?php endif ?>
|
||||
|
||||
<?php foreach ($task['tags'] as $tag): ?>
|
||||
<span class="table-list-category task-list-tag">
|
||||
<?= $this->text->e($tag['name']) ?>
|
||||
</span>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user