summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2018-05-09 11:21:57 -0700
committerFrédéric Guillot <fred@kanboard.net>2018-05-09 11:21:57 -0700
commit6ae97d399dc96bd9a0e854bea6d09fa68e078ab5 (patch)
tree63592644f6f1802c62ec2c2f9bc62e2573950049
parentcc17cb32071c8fbf3bfa781b98d415638ebb966e (diff)
Improve dashboard pagination
-rw-r--r--app/Core/Paginator.php22
-rw-r--r--app/Pagination/DashboardPagination.php6
-rw-r--r--app/Template/dashboard/overview.php2
3 files changed, 23 insertions, 7 deletions
diff --git a/app/Core/Paginator.php b/app/Core/Paginator.php
index 7b0a9c1b..9776a03d 100644
--- a/app/Core/Paginator.php
+++ b/app/Core/Paginator.php
@@ -103,6 +103,14 @@ class Paginator
private $action = '';
/**
+ * URL anchor
+ *
+ * @access private
+ * @var string
+ */
+ private $anchor = '';
+
+ /**
* Url params
*
* @access private
@@ -183,13 +191,15 @@ class Paginator
* @param string $controller
* @param string $action
* @param array $params
+ * @param string $anchor
* @return $this
*/
- public function setUrl($controller, $action, array $params = array())
+ public function setUrl($controller, $action, array $params = array(), $anchor = '')
{
$this->controller = $controller;
$this->action = $action;
$this->params = $params;
+ $this->anchor = $anchor;
return $this;
}
@@ -399,7 +409,10 @@ class Paginator
$this->action,
$this->getUrlParams($this->page - 1, $this->order, $this->direction),
false,
- 'js-modal-replace'
+ 'js-modal-replace',
+ t('Previous'),
+ false,
+ $this->anchor
);
} else {
$html .= '&larr; '.t('Previous');
@@ -427,7 +440,10 @@ class Paginator
$this->action,
$this->getUrlParams($this->page + 1, $this->order, $this->direction),
false,
- 'js-modal-replace'
+ 'js-modal-replace',
+ t('Next'),
+ false,
+ $this->anchor
);
} else {
$html .= t('Next').' &rarr;';
diff --git a/app/Pagination/DashboardPagination.php b/app/Pagination/DashboardPagination.php
index 0149a42b..9669cb9d 100644
--- a/app/Pagination/DashboardPagination.php
+++ b/app/Pagination/DashboardPagination.php
@@ -32,13 +32,13 @@ class DashboardPagination extends Base
$this->hook->reference('pagination:dashboard:task:query', $query);
$paginator = $this->paginator
- ->setUrl('DashboardController', 'show', array('user_id' => $userId))
- ->setMax(50)
+ ->setUrl('DashboardController', 'show', array('user_id' => $userId, 'pagination' => 'tasks-'.$projectId), 'project-tasks-'.$projectId)
+ ->setMax(15)
->setOrder(TaskModel::TABLE.'.priority')
->setDirection('DESC')
->setFormatter($this->taskListSubtaskAssigneeFormatter->withUserId($userId))
->setQuery($query)
- ->calculate();
+ ->calculateOnlyIf($this->request->getStringParam('pagination') === 'tasks-'.$projectId);
if ($paginator->getTotal() > 0) {
$paginators[] = array(
diff --git a/app/Template/dashboard/overview.php b/app/Template/dashboard/overview.php
index e732a387..c0cde10b 100644
--- a/app/Template/dashboard/overview.php
+++ b/app/Template/dashboard/overview.php
@@ -51,7 +51,7 @@
<?php foreach ($overview_paginator as $result): ?>
<?php if (! $result['paginator']->isEmpty()): ?>
<div class="page-header">
- <h2><?= $this->url->link($this->text->e($result['project_name']), 'BoardViewController', 'show', array('project_id' => $result['project_id'])) ?></h2>
+ <h2 id="project-tasks-<?= $result['project_id'] ?>"><?= $this->url->link($this->text->e($result['project_name']), 'BoardViewController', 'show', array('project_id' => $result['project_id'])) ?></h2>
</div>
<div class="table-list">