add list pagination

This commit is contained in:
Dennis Eichhorn 2020-04-05 17:07:05 +02:00
parent 9cf818f765
commit eb1a7e2979
4 changed files with 35 additions and 18 deletions

View File

@ -36,16 +36,16 @@ use phpOMS\Utils\Parser\Markdown\Markdown;
* @link https://orange-management.org * @link https://orange-management.org
* @since 1.0.0 * @since 1.0.0
* *
* @todo Orange-Management/Modules#6 * @todo Orange-Management/oms-Tasks#9
* Create task/calendar reference * Create task/calendar reference
* Show tasks in calendars not just in user calendars but also in event calendars and project calendars?! * Show tasks in calendars not just in user calendars but also in event calendars and project calendars?!
* *
* @todo Orange-Management/Modules#33 * @todo Orange-Management/Modules#33
* Repeating tasks should be implemented. * Repeating tasks should be implemented.
* At the same time this mans a fix to the due date needs to be implemented. * At the same time this means a fix to the due date needs to be implemented.
* Maybe simple calculate the time difference between first start and first due? * Maybe simple calculate the time difference between first start and first due?
* *
* @todo Orange-Management/Modules#147 * @todo Orange-Management/oms-Tasks#6
* Add tags * Add tags
* The user should be able to add a tag to a task and also decide on the color of the tag. * The user should be able to add a tag to a task and also decide on the color of the tag.
* User means the creator of the task. * User means the creator of the task.
@ -244,7 +244,7 @@ final class ApiController extends Controller
} }
/** /**
* @todo Orange-Management/Moudles#201 * @todo Orange-Management/oms-Tasks#3
* Validate that the user is allowed to create a task element for a specific task * Validate that the user is allowed to create a task element for a specific task
*/ */
@ -338,7 +338,7 @@ final class ApiController extends Controller
$this->updateModel($request->getHeader()->getAccount(), $old, $new, TaskElementMapper::class, 'taskelement'); $this->updateModel($request->getHeader()->getAccount(), $old, $new, TaskElementMapper::class, 'taskelement');
/** /**
* @todo Orange-Management/Modules#205 * @todo Orange-Management/oms-Tasks#2
* Update task status depending on the new task element or updated task element * Update task status depending on the new task element or updated task element
* The task status is not normalized and relates to the last task element. * The task status is not normalized and relates to the last task element.
* Depending on the task status of the last task element also the task status should change. * Depending on the task status of the last task element also the task status should change.

View File

@ -36,7 +36,7 @@ use phpOMS\Views\View;
* @link https://orange-management.org * @link https://orange-management.org
* @since 1.0.0 * @since 1.0.0
* *
* @todo Orange-Management/Modules#148 * @todo Orange-Management/oms-Tasks#5
* Add a calender like task view * Add a calender like task view
* If you define tasks far into the future it can become very difficult to read and organize them. * If you define tasks far into the future it can become very difficult to read and organize them.
* For this purpose there should be a calendar view for them. * For this purpose there should be a calendar view for them.
@ -52,7 +52,7 @@ final class BackendController extends Controller implements DashboardElementInte
* *
* @return RenderableInterface Returns a renderable object * @return RenderableInterface Returns a renderable object
* *
* @todo Orange-Management/Modules#54 * @todo Orange-Management/oms-Tasks#6
* Implement dashboard statistics * Implement dashboard statistics
* Currently on the dashboard there is only a placeholder for some stats. * Currently on the dashboard there is only a placeholder for some stats.
* These stats need to be implemented. * These stats need to be implemented.
@ -71,9 +71,17 @@ final class BackendController extends Controller implements DashboardElementInte
$view->setTemplate('/Modules/Tasks/Theme/Backend/task-dashboard'); $view->setTemplate('/Modules/Tasks/Theme/Backend/task-dashboard');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1001101001, $request, $response)); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1001101001, $request, $response));
$tasks = TaskMapper::getAny($request->getHeader()->getAccount()); if ($request->getData('ptype') === '-') {
$view->setData('tasks',
$view->addData('tasks', $tasks); TaskMapper::withConditional('language', $response->getHeader()->getL11n()->getLanguage())
::getBeforePivot((int) ($request->getData('id') ?? 0), null, 25)
);
} else {
$view->setData('tasks',
TaskMapper::withConditional('language', $response->getHeader()->getL11n()->getLanguage())
::getAfterPivot((int) ($request->getData('id') ?? 0), null, 25)
);
}
return $view; return $view;
} }
@ -200,7 +208,7 @@ final class BackendController extends Controller implements DashboardElementInte
* *
* @return int Returns the amount of unread tasks * @return int Returns the amount of unread tasks
* *
* @todo Orange-Management/Modules#206 * @todo Orange-Management/oms-Tasks#1
* Implement has seen feature * Implement has seen feature
* In order to allow a "user has seen task x" feature every task should have a user/account status for the different users (creator, cc, receiver). * In order to allow a "user has seen task x" feature every task should have a user/account status for the different users (creator, cc, receiver).
* *

View File

@ -13,9 +13,10 @@
declare(strict_types=1); declare(strict_types=1);
use Modules\Tasks\Models\TaskPriority; use Modules\Tasks\Models\TaskPriority;
use phpOMS\Uri\UriFactory;
/** /**
* @todo Orange-Management/Modules#176 * @todo Orange-Management/oms-Tasks#4
* Batch handle tasks in the dashboard list * Batch handle tasks in the dashboard list
* In the dashboard/list it should be possible to change the status of a task without going into it (changing it to done is the most important). * In the dashboard/list it should be possible to change the status of a task without going into it (changing it to done is the most important).
* This could be done with a button but also touch sliding/swiping should be possible for mobile. * This could be done with a button but also touch sliding/swiping should be possible for mobile.
@ -26,25 +27,29 @@ use Modules\Tasks\Models\TaskPriority;
* @var \phpOMS\Views\View $this * @var \phpOMS\Views\View $this
* @var \Modules\Tasks\Models\Task[] $tasks * @var \Modules\Tasks\Models\Task[] $tasks
*/ */
$tasks = $this->getData('tasks'); $tasks = $this->getData('tasks') ?? [];
$previous = empty($tasks) ? '{/prefix}task/dashboard' : '{/prefix}task/dashboard?{?}&id=' . \reset($tasks)->getId() . '&ptype=-';
$next = empty($tasks) ? '{/prefix}task/dashboard' : '{/prefix}task/dashboard?{?}&id=' . \end($tasks)->getId() . '&ptype=+';
echo $this->getData('nav')->render(); ?> echo $this->getData('nav')->render(); ?>
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col-xs-12">
<div class="box wf-100 x-overflow"> <div class="portlet">
<div class="portlet-head"><?= $this->getHtml('Tasks') ?><i class="fa fa-download floatRight download btn"></i></div>
<table id="taskList" class="default"> <table id="taskList" class="default">
<caption><?= $this->getHtml('Tasks') ?><i class="fa fa-download floatRight download btn"></i></caption>
<thead> <thead>
<td><?= $this->getHtml('Status') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i> <td><?= $this->getHtml('Status') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Due/Priority') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i> <td><?= $this->getHtml('Due/Priority') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td class="full"><?= $this->getHtml('Title') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i> <td class="wf-100"><?= $this->getHtml('Title') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Creator') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i> <td><?= $this->getHtml('Creator') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Created') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i> <td><?= $this->getHtml('Created') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<tfoot> <tfoot>
<tbody> <tbody>
<?php <?php
$c = 0; foreach ($tasks as $key => $task) : ++$c; $c = 0; foreach ($tasks as $key => $task) : ++$c;
$url = \phpOMS\Uri\UriFactory::build('{/prefix}task/single?{?}&id=' . $task->getId()); $url = UriFactory::build('{/prefix}task/single?{?}&id=' . $task->getId());
?> ?>
<tr data-href="<?= $url; ?>"> <tr data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('Status') ?>"> <td data-label="<?= $this->getHtml('Status') ?>">
@ -71,6 +76,10 @@ echo $this->getData('nav')->render(); ?>
<tr><td colspan="6" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?> <tr><td colspan="6" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?> <?php endif; ?>
</table> </table>
<div class="portlet-foot">
<a class="button" href="<?= UriFactory::build($previous); ?>"><?= $this->getHtml('Previous', '0', '0'); ?></a>
<a class="button" href="<?= UriFactory::build($next); ?>"><?= $this->getHtml('Next', '0', '0'); ?></a>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -81,7 +81,7 @@ class BackendControllerTest extends \PHPUnit\Framework\TestCase
self::assertEquals(0, $this->module->openNav(999)); self::assertEquals(0, $this->module->openNav(999));
/** /**
* @todo Orange-Management/Modules#206 * @todo Orange-Management/oms-Tasks#1
* Implement has seen feature * Implement has seen feature
* In order to allow a "user has seen task x" feature every task should have a user/account status for the different users (creator, cc, receiver). * In order to allow a "user has seen task x" feature every task should have a user/account status for the different users (creator, cc, receiver).
*/ */