add list pagination

This commit is contained in:
Dennis Eichhorn 2020-04-05 17:05:59 +02:00
parent a68fcb8639
commit 04982f300f
4 changed files with 24 additions and 9 deletions

View File

@ -194,7 +194,12 @@ final class BackendController extends Controller
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Admin/Theme/Backend/groups-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000103001, $request, $response));
$view->setData('list:elements', GroupMapper::getAll(RelationType::NONE));
if ($request->getData('ptype') === '-') {
$view->setData('groups', GroupMapper::getBeforePivot((int) ($request->getData('id') ?? 0), null, 25));
} else {
$view->setData('groups', GroupMapper::getAfterPivot((int) ($request->getData('id') ?? 0), null, 25));
}
return $view;
}

View File

@ -60,8 +60,8 @@ echo $this->getData('nav')->render(); ?>
<?php endif; ?>
</table>
<div class="portlet-foot">
<a class="button" href="<?= UriFactory::build($previous); ?>">Previous</a>
<a class="button" href="<?= UriFactory::build($next); ?>">Next</a>
<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>

View File

@ -12,10 +12,17 @@
*/
declare(strict_types=1);
use phpOMS\Uri\UriFactory;
/**
* @var \phpOMS\Views\View $this
* @var \phpOMS\Views\View $this
* @var \Modules\Admin\Models\Group[] $groups
*/
$groups = $this->getData('groups') ?? [];
$previous = empty($groups) ? '{/prefix}admin/group/list' : '{/prefix}admin/group/list?{?}&id=' . \reset($groups)->getId() . '&ptype=-';
$next = empty($groups) ? '{/prefix}admin/group/list' : '{/prefix}admin/group/list?{?}&id=' . \end($groups)->getId() . '&ptype=+';
echo $this->getData('nav')->render(); ?>
<div class="row">
@ -30,7 +37,7 @@ echo $this->getData('nav')->render(); ?>
<td class="wf-100"><?= $this->getHtml('Name') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Members') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<tbody>
<?php $c = 0; foreach ($this->getData('list:elements') as $key => $value) : ++$c;
<?php $c = 0; foreach ($groups as $key => $value) : ++$c;
$url = \phpOMS\Uri\UriFactory::build('{/prefix}admin/group/settings?{?}&id=' . $value->getId());
$color = 'darkred';
if ($value->getStatus() === \phpOMS\Account\GroupStatus::ACTIVE) { $color = 'green'; }
@ -46,7 +53,10 @@ echo $this->getData('nav')->render(); ?>
<tr><td colspan="5" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
<div class="portlet-foot"></div>
<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>

View File

@ -100,10 +100,10 @@ echo $this->getData('nav')->render(); ?>
<td><?= $this->getHtml('ID', '0', '0'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td class="wf-100"><?= $this->getHtml('Name'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<tbody>
<?php $c = 0; foreach ($accounts as $key => $value) : ++$c; ?>
<tr>
<?php $c = 0; foreach ($accounts as $key => $value) : ++$c; $url = UriFactory::build('{/prefix}admin/account/settings?{?}&id=' . $value->getId()); ?>
<tr data-href="<?= $url; ?>">
<td><a href="#"><i class="fa fa-times"></i></a>
<td><a href="<?= UriFactory::build('{/prefix}admin/account/settings?{?}&id=' . $value->getId()) ?>"><?= $value->getName1(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->getName1(); ?></a>
<?php endforeach; ?>
<?php if ($c === 0) : ?>
<tr><td colspan="2" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>