Корзина, массовые действия в списках и история записи в карточке

This commit is contained in:
rsgrinko committed 2026-09-15 22:47:55 +03:00
1 parent 20f3d79552
commit 00bba5abfa
23 files changed
+936

No files matched your search

+4
View File
@@ -72,3 +72,7 @@ $granted = $role->permissions();
</form>
</div>
<?php } ?>
<?php if ($role->id() > 0) { ?>
<?= View::partial('history', ['entity' => 'role', 'id' => $role->id()]) ?>
<?php } ?>
+85
View File
@@ -0,0 +1,85 @@
<?php
declare(strict_types=1);
/**
* Корзина: удалённые записи, которые ещё можно вернуть.
*
* @var array<string, array{model: string, label: string, title: callable, permission: string}> $kinds
* @var array<string, int> $counts
* @var string $kind выбранный раздел
* @var string $label его подпись
* @var callable $title как назвать запись
* @var array{items: array<int, \Rsgrinko\Proton\Database\Model\Model>, total: int, page: int, pages: int, per_page: int} $page
*/
use Rsgrinko\Proton\Database\Model\Model;
use Rsgrinko\Proton\View\View;
?>
<h1>Корзина</h1>
<div class="card">
<div class="row">
<?php foreach ($kinds as $key => $item) { ?>
<?php if ($key === $kind) { ?>
<span class="badge info"><?= View::e($item['label']) ?>: <?= (int) ($counts[$key] ?? 0) ?></span>
<?php } else { ?>
<a class="btn small" href="<?= View::e(View::route('admin.trash', ['kind' => $key])) ?>">
<?= View::e($item['label']) ?> (<?= (int) ($counts[$key] ?? 0) ?>)
</a>
<?php } ?>
<?php } ?>
<span class="spacer"></span>
<span class="muted small">Корзина не архив: слишком старое воркер добивает сам</span>
</div>
</div>
<div class="card">
<h2><?= View::e($label) ?></h2>
<?php if ($page['items'] === []) { ?>
<p class="muted">Здесь пусто — ничего не удаляли или всё уже вернули.</p>
<?php } else { ?>
<div class="table-wrap">
<table class="list">
<tr class="head">
<th>Запись</th>
<th>Удалена</th>
<th></th>
</tr>
<?php foreach ($page['items'] as $record) { ?>
<tr>
<td><?= View::e(($title)($record)) ?></td>
<td class="muted small nowrap"><?= View::e(View::ago((string) $record->raw(Model::DELETED_AT))) ?></td>
<td class="right">
<div class="row end">
<form method="post" action="<?= View::e(View::route('admin.trash.restore')) ?>">
<?= View::csrf() ?>
<input type="hidden" name="kind" value="<?= View::e($kind) ?>">
<input type="hidden" name="id" value="<?= $record->id() ?>">
<button type="submit" class="primary">Вернуть</button>
</form>
<form method="post" action="<?= View::e(View::route('admin.trash.destroy')) ?>">
<?= View::csrf() ?>
<input type="hidden" name="kind" value="<?= View::e($kind) ?>">
<input type="hidden" name="id" value="<?= $record->id() ?>">
<button type="submit" class="danger">Удалить совсем</button>
</form>
</div>
</td>
</tr>
<?php } ?>
</table>
</div>
<?= View::partial('pagination', [
'route' => 'admin.trash',
'page' => $page['page'],
'pages' => $page['pages'],
'params' => ['kind' => $kind],
]) ?>
<?php } ?>
</div>
+4
View File
@@ -108,3 +108,7 @@ $hint = $isNew ? 'пусто — придумаем сами' : 'пусто
</form>
</div>
<?php } ?>
<?php if ($user->id() > 0) { ?>
<?= View::partial('history', ['entity' => 'user', 'id' => $user->id()]) ?>
<?php } ?>
+16
View File
@@ -26,9 +26,22 @@ use Rsgrinko\Proton\View\View;
<?php if ($page['items'] === []) { ?>
<p class="muted">Ничего не нашлось.</p>
<?php } else { ?>
<form method="post" action="<?= View::e(View::route('admin.users.bulk')) ?>">
<?= View::csrf() ?>
<?= View::partial('bulk', [
'actions' => [
'enable' => 'включить',
'disable' => 'выключить',
'delete' => 'удалить (в корзину)',
],
'confirm' => 'Выполнить действие над отмеченными пользователями?',
]) ?>
<div class="table-wrap">
<table class="list">
<tr class="head">
<th></th>
<th><?= View::partial('sort', ['filters' => $filters, 'route' => 'admin.users', 'column' => 'login', 'label' => 'Логин']) ?></th>
<th class="hide-sm">Имя</th>
<th class="hide-sm">Почта</th>
@@ -39,6 +52,7 @@ use Rsgrinko\Proton\View\View;
<?php foreach ($page['items'] as $user) { ?>
<tr>
<td><input type="checkbox" name="ids[]" value="<?= $user->id() ?>" data-check-item></td>
<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>
@@ -56,6 +70,8 @@ use Rsgrinko\Proton\View\View;
</table>
</div>
</form>
<?= View::partial('pagination', [
'route' => 'admin.users',
'page' => $page['page'],
+4
View File
@@ -197,3 +197,7 @@ $all = in_array(Webhook::ALL_EVENTS, $selected, true);
<?php } ?>
</div>
<?php } ?>
<?php if ($webhook->id() > 0) { ?>
<?= View::partial('history', ['entity' => 'webhook', 'id' => $webhook->id()]) ?>
<?php } ?>