Журнал действий: бейджи по цвету действия, рамка у развёрнутых изменений
This commit is contained in:
1 parent
3cf96b5b07
commit
29fef30be7
4 files changed
+25
-5
No files matched your search
@@ -43,6 +43,21 @@ final class AuditEntry extends Model
|
||||
self::LOGOUT => 'выход',
|
||||
];
|
||||
|
||||
/**
|
||||
* Цвет бейджа под действие — по строке в общем списке проще отличить
|
||||
* удаление от входа, чем читать подпись у каждой.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public const BADGES = [
|
||||
self::CREATED => 'ok',
|
||||
self::UPDATED => 'info',
|
||||
self::DELETED => 'error',
|
||||
self::ACTION => 'muted',
|
||||
self::LOGIN => 'ok',
|
||||
self::LOGOUT => 'muted',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param array<string, array{0: mixed, 1: mixed}> $changes поле => [было, стало]
|
||||
*/
|
||||
@@ -76,6 +91,11 @@ final class AuditEntry extends Model
|
||||
return self::LABELS[$action] ?? $action;
|
||||
}
|
||||
|
||||
public static function badge(string $action): string
|
||||
{
|
||||
return self::BADGES[$action] ?? 'muted';
|
||||
}
|
||||
|
||||
/**
|
||||
* Чистка по сроку — зовётся воркером.
|
||||
*/
|
||||
|
||||
@@ -46,13 +46,13 @@ $entries = AuditEntry::query()
|
||||
<td class="muted small nowrap"><?= View::e(View::date((string) $entry->raw('created_at'))) ?></td>
|
||||
<td class="small"><?= View::e((string) $entry->raw('user_login') ?: 'система') ?></td>
|
||||
<td>
|
||||
<span class="badge muted"><?= View::e(AuditEntry::label((string) $entry->raw('action'))) ?></span>
|
||||
<span class="badge <?= View::e(AuditEntry::badge((string) $entry->raw('action'))) ?>"><?= View::e(AuditEntry::label((string) $entry->raw('action'))) ?></span>
|
||||
<?= View::e((string) $entry->raw('description')) ?>
|
||||
|
||||
<?php if ($changes !== []) { ?>
|
||||
<details>
|
||||
<summary class="small">что изменилось</summary>
|
||||
<table>
|
||||
<table class="diff">
|
||||
<?php foreach ($changes as $field => $pair) { ?>
|
||||
<tr>
|
||||
<td class="muted small"><?= View::e((string) $field) ?></td>
|
||||
|
||||
@@ -35,7 +35,7 @@ use Rsgrinko\Proton\View\View;
|
||||
<tr>
|
||||
<td class="muted small nowrap"><?= View::e(View::date((string) $entry->raw('created_at'))) ?></td>
|
||||
<td><?= View::e((string) $entry->raw('user_login') ?: 'система') ?></td>
|
||||
<td><span class="badge muted"><?= View::e(AuditEntry::label((string) $entry->raw('action'))) ?></span></td>
|
||||
<td><span class="badge <?= View::e(AuditEntry::badge((string) $entry->raw('action'))) ?>"><?= View::e(AuditEntry::label((string) $entry->raw('action'))) ?></span></td>
|
||||
<td>
|
||||
<?= View::e((string) $entry->raw('description')) ?>
|
||||
<div class="muted small"><?= View::e((string) $entry->raw('entity')) ?> <?= View::e((string) $entry->raw('entity_id')) ?></div>
|
||||
@@ -43,7 +43,7 @@ use Rsgrinko\Proton\View\View;
|
||||
<?php if ($changes !== []) { ?>
|
||||
<details>
|
||||
<summary class="small">что изменилось</summary>
|
||||
<table>
|
||||
<table class="diff">
|
||||
<?php foreach ($changes as $field => $pair) { ?>
|
||||
<tr>
|
||||
<td class="muted small"><?= View::e((string) $field) ?></td>
|
||||
|
||||
@@ -71,7 +71,7 @@ $inner = static function (array $widget): string {
|
||||
<td class="muted small nowrap"><?= View::e(View::date((string) $event->raw('created_at'))) ?></td>
|
||||
<td><?= View::e((string) $event->raw('user_login')) ?></td>
|
||||
<td>
|
||||
<span class="badge muted"><?= View::e(AuditEntry::label((string) $event->raw('action'))) ?></span>
|
||||
<span class="badge <?= View::e(AuditEntry::badge((string) $event->raw('action'))) ?>"><?= View::e(AuditEntry::label((string) $event->raw('action'))) ?></span>
|
||||
<?= View::e((string) $event->raw('description')) ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
Reference in new issue
Block a user