mirror of
https://github.com/Karaka-Management/oms-Profile.git
synced 2026-02-06 11:08:40 +00:00
add profile pagination
This commit is contained in:
parent
0df5bc76a3
commit
c2dc838249
|
|
@ -5,7 +5,7 @@
|
|||
"type": 2,
|
||||
"subtype": 1,
|
||||
"name": "Profiles",
|
||||
"uri": "{/prefix}profile/list?{?}",
|
||||
"uri": "{/prefix}profile/list",
|
||||
"target": "self",
|
||||
"icon": null,
|
||||
"order": 10,
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
"type": 3,
|
||||
"subtype": 1,
|
||||
"name": "List",
|
||||
"uri": "{/prefix}profile/list?{?}",
|
||||
"uri": "{/prefix}profile/list",
|
||||
"target": "self",
|
||||
"icon": null,
|
||||
"order": 1,
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Profile\Controller;
|
||||
|
||||
use Modules\Profile\Models\Profile;
|
||||
use Modules\Profile\Models\ProfileMapper;
|
||||
|
||||
use phpOMS\Asset\AssetType;
|
||||
use phpOMS\Contract\RenderableInterface;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\Views\PaginationView;
|
||||
use phpOMS\Views\View;
|
||||
|
||||
/**
|
||||
|
|
@ -74,7 +74,12 @@ final class BackendController extends Controller
|
|||
$view = new View($this->app->l11nManager, $request, $response);
|
||||
|
||||
$view->setTemplate('/Modules/Profile/Theme/Backend/profile-list');
|
||||
$view->setData('accounts', ProfileMapper::getNewest(25));
|
||||
|
||||
if ($request->getData('ptype') === '-') {
|
||||
$view->setData('accounts', ProfileMapper::getBeforePivot((int) ($request->getData('id') ?? 0), null, 25));
|
||||
} else {
|
||||
$view->setData('accounts', ProfileMapper::getAfterPivot((int) ($request->getData('id') ?? 0), null, 25));
|
||||
}
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,13 +12,17 @@
|
|||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use phpOMS\Uri\UriFactory;
|
||||
|
||||
/**
|
||||
* @var \phpOMS\Views\View $this
|
||||
* @var \Modules\Profile\Models\Profile[] $accounts
|
||||
*/
|
||||
$accounts = $this->getData('accounts');
|
||||
?>
|
||||
$accounts = $this->getData('accounts') ?? [];
|
||||
|
||||
$previous = empty($accounts) ? '{/prefix}profile/list' : '{/prefix}profile/list?{?}&id=' . \reset($accounts)->getId() . '&ptype=-';
|
||||
$next = empty($accounts) ? '{/prefix}profile/list' : '{/prefix}profile/list?{?}&id=' . \end($accounts)->getId() . '&ptype=+';
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="box wf-100">
|
||||
|
|
@ -32,9 +36,11 @@ declare(strict_types=1);
|
|||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<a class="button" href="<?= UriFactory::build($previous); ?>">Previous</a>
|
||||
<a class="button" href="<?= UriFactory::build($next); ?>">Next</a>
|
||||
<tbody>
|
||||
<?php $count = 0; foreach ($accounts as $key => $account) : ++$count;
|
||||
$url = \phpOMS\Uri\UriFactory::build('{/prefix}profile/single?{?}&id=' . $account->getId()); ?>
|
||||
$url = UriFactory::build('{/prefix}profile/single?{?}&id=' . $account->getId()); ?>
|
||||
<tr data-href="<?= $url; ?>">
|
||||
<td data-label="<?= $this->getHtml('ID', '0', '0') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($account->getId()); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Name') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($account->getAccount()->getName3() . ' ' . $account->getAccount()->getName2() . ' ' . $account->getAccount()->getName1()); ?></a>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user