Списки: фильтры, сортировка, выгрузка и загрузка CSV
This commit is contained in:
1 parent
9075c817dc
commit
c4e9f6fc37
31 files changed
+1734
-184
No files matched your search
@@ -7,7 +7,7 @@ declare(strict_types=1);
|
||||
*
|
||||
* @var array{items: array<int, \Rsgrinko\Proton\Models\User>, total: int, page: int, pages: int, per_page: int} $page
|
||||
* @var array<int, string> $roles
|
||||
* @var string $search
|
||||
* @var \Rsgrinko\Proton\Support\Filters $filters
|
||||
*/
|
||||
|
||||
use Rsgrinko\Proton\View\View;
|
||||
@@ -18,61 +18,49 @@ use Rsgrinko\Proton\View\View;
|
||||
<a class="btn primary" href="<?= View::e(View::route('admin.users.create')) ?>">Новый пользователь</a>
|
||||
</div>
|
||||
|
||||
<div class="card" style="margin-top: 16px;">
|
||||
<form method="get" action="<?= View::e(View::route('admin.users')) ?>">
|
||||
<div class="filters">
|
||||
<label>
|
||||
<span>Поиск по логину или почте</span>
|
||||
<input type="search" name="q" value="<?= View::e($search) ?>">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="filter-actions row">
|
||||
<button type="submit" class="primary">Искать</button>
|
||||
<?php if ($search !== '') { ?>
|
||||
<a class="btn" href="<?= View::e(View::route('admin.users')) ?>">Сбросить</a>
|
||||
<?php } ?>
|
||||
<span class="spacer"></span>
|
||||
<span class="muted small">Всего: <?= (int) $page['total'] ?></span>
|
||||
</div>
|
||||
</form>
|
||||
<div style="margin-top: 16px;">
|
||||
<?= View::partial('filters', ['filters' => $filters, 'route' => 'admin.users', 'total' => $page['total'], 'submit' => 'Искать', 'export' => 'admin.users.export']) ?>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="table-wrap">
|
||||
<table class="list">
|
||||
<tr class="head">
|
||||
<th>Логин</th>
|
||||
<th class="hide-sm">Имя</th>
|
||||
<th class="hide-sm">Почта</th>
|
||||
<th>Роль</th>
|
||||
<th>Активен</th>
|
||||
<th class="hide-sm">Последний вход</th>
|
||||
</tr>
|
||||
|
||||
<?php foreach ($page['items'] as $user) { ?>
|
||||
<tr>
|
||||
<td><a href="<?= View::e(View::route('admin.users.show', ['id' => $user->id()])) ?>"><?= View::e((string) $user->login) ?></a></td>
|
||||
<td class="hide-sm"><?= View::e((string) $user->name) ?></td>
|
||||
<td class="hide-sm muted small"><?= View::e((string) $user->email) ?></td>
|
||||
<td><?= View::e($roles[(int) $user->raw('role_id')] ?? '—') ?></td>
|
||||
<td>
|
||||
<?php if ($user->isActive()) { ?>
|
||||
<span class="badge ok">да</span>
|
||||
<?php } else { ?>
|
||||
<span class="badge muted">нет</span>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td class="hide-sm muted small"><?= View::e(View::ago((string) $user->raw('last_login_at'))) ?></td>
|
||||
<?php if ($page['items'] === []) { ?>
|
||||
<p class="muted">Ничего не нашлось.</p>
|
||||
<?php } else { ?>
|
||||
<div class="table-wrap">
|
||||
<table class="list">
|
||||
<tr class="head">
|
||||
<th><?= View::partial('sort', ['filters' => $filters, 'route' => 'admin.users', 'column' => 'login', 'label' => 'Логин']) ?></th>
|
||||
<th class="hide-sm">Имя</th>
|
||||
<th class="hide-sm">Почта</th>
|
||||
<th>Роль</th>
|
||||
<th>Активен</th>
|
||||
<th class="hide-sm"><?= View::partial('sort', ['filters' => $filters, 'route' => 'admin.users', 'column' => 'last_login_at', 'label' => 'Последний вход']) ?></th>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<?= View::partial('pagination', [
|
||||
'route' => 'admin.users',
|
||||
'page' => $page['page'],
|
||||
'pages' => $page['pages'],
|
||||
'params' => ['q' => $search],
|
||||
]) ?>
|
||||
<?php foreach ($page['items'] as $user) { ?>
|
||||
<tr>
|
||||
<td><a href="<?= View::e(View::route('admin.users.show', ['id' => $user->id()])) ?>"><?= View::e((string) $user->login) ?></a></td>
|
||||
<td class="hide-sm"><?= View::e((string) $user->name) ?></td>
|
||||
<td class="hide-sm muted small"><?= View::e((string) $user->email) ?></td>
|
||||
<td><?= View::e($roles[(int) $user->raw('role_id')] ?? '—') ?></td>
|
||||
<td>
|
||||
<?php if ($user->isActive()) { ?>
|
||||
<span class="badge ok">да</span>
|
||||
<?php } else { ?>
|
||||
<span class="badge muted">нет</span>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td class="hide-sm muted small"><?= View::e(View::ago((string) $user->raw('last_login_at'))) ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<?= View::partial('pagination', [
|
||||
'route' => 'admin.users',
|
||||
'page' => $page['page'],
|
||||
'pages' => $page['pages'],
|
||||
'params' => $filters->params(),
|
||||
]) ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
Reference in new issue
Block a user