initial commit
This commit is contained in:
commit
3f64f4a49a
221 files changed
+26665
No files matched your search
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Форма заметки — одна на создание и на правку.
|
||||
*
|
||||
* @var \App\Models\Note $note
|
||||
*/
|
||||
|
||||
use Rsgrinko\Proton\View\View;
|
||||
|
||||
$isNew = !$note->existsInDatabase();
|
||||
$action = $isNew
|
||||
? View::route('notes.create')
|
||||
: View::route('notes.edit', ['id' => $note->id()]);
|
||||
?>
|
||||
<h1><?= $isNew ? 'Новая заметка' : 'Правка заметки' ?></h1>
|
||||
|
||||
<div class="card">
|
||||
<form method="post" action="<?= View::e($action) ?>" enctype="multipart/form-data">
|
||||
<?= View::csrf() ?>
|
||||
|
||||
<label>
|
||||
<span>Название</span>
|
||||
<input type="text" name="title" value="<?= View::e((string) $note->title) ?>" autofocus required>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span>Текст</span>
|
||||
<textarea name="body"><?= View::e((string) $note->body) ?></textarea>
|
||||
</label>
|
||||
|
||||
<label class="inline" style="margin-bottom: 12px;">
|
||||
<input type="checkbox" name="pinned" value="1" <?= $note->pinned ? 'checked' : '' ?>>
|
||||
<span>Закрепить наверху списка</span>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span>Файл<?= $note->hasFile() ? ' (сейчас: ' . View::e((string) $note->raw('file_name')) . ')' : '' ?></span>
|
||||
<input type="file" name="attachment">
|
||||
</label>
|
||||
|
||||
<div class="row">
|
||||
<button type="submit" class="primary">Сохранить</button>
|
||||
<a class="btn" href="<?= View::e(View::route('notes.index')) ?>">Отмена</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Список заметок.
|
||||
*
|
||||
* @var array{items: array<int, \App\Models\Note>, total: int, page: int, pages: int, per_page: int} $page
|
||||
* @var string $search
|
||||
*/
|
||||
|
||||
use Rsgrinko\Proton\View\View;
|
||||
?>
|
||||
<div class="row">
|
||||
<h1 style="margin: 0;">Заметки</h1>
|
||||
<span class="spacer"></span>
|
||||
|
||||
<?php if (View::can('notes.manage')) { ?>
|
||||
<a class="btn primary" href="<?= View::e(View::route('notes.create')) ?>">Новая заметка</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="card" style="margin-top: 16px;">
|
||||
<form method="get" action="<?= View::e(View::route('notes.index')) ?>">
|
||||
<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('notes.index')) ?>">Сбросить</a>
|
||||
<?php } ?>
|
||||
<span class="spacer"></span>
|
||||
<span class="muted small">Всего: <?= (int) $page['total'] ?></span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<?php if ($page['items'] === []) { ?>
|
||||
<p class="muted">Пока ничего нет.</p>
|
||||
<?php } else { ?>
|
||||
<div class="table-wrap">
|
||||
<table class="list">
|
||||
<tr class="head">
|
||||
<th>Название</th>
|
||||
<th class="hide-sm">Текст</th>
|
||||
<th class="hide-sm">Изменена</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<?php foreach ($page['items'] as $note) { ?>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="<?= View::e(View::route('notes.show', ['id' => $note->id()])) ?>"><?= View::e((string) $note->title) ?></a>
|
||||
<?php if ($note->pinned) { ?><span class="badge info">закреплена</span><?php } ?>
|
||||
<?php if ($note->hasFile()) { ?><span class="badge muted">файл</span><?php } ?>
|
||||
</td>
|
||||
<td class="hide-sm muted small"><?= View::e($note->excerpt(80)) ?></td>
|
||||
<td class="hide-sm muted small"><?= View::e(View::ago((string) $note->raw('updated_at'))) ?></td>
|
||||
<td class="right">
|
||||
<?php if (View::can('notes.manage')) { ?>
|
||||
<a class="btn small" href="<?= View::e(View::route('notes.edit', ['id' => $note->id()])) ?>">Править</a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<?= View::partial('pagination', [
|
||||
'route' => 'notes.index',
|
||||
'page' => $page['page'],
|
||||
'pages' => $page['pages'],
|
||||
'params' => ['q' => $search],
|
||||
]) ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Карточка заметки.
|
||||
*
|
||||
* @var \App\Models\Note $note
|
||||
* @var \Rsgrinko\Proton\Models\User|null $author
|
||||
*/
|
||||
|
||||
use Rsgrinko\Proton\View\View;
|
||||
?>
|
||||
<div class="row">
|
||||
<h1 style="margin: 0;"><?= View::e((string) $note->title) ?></h1>
|
||||
<span class="spacer"></span>
|
||||
|
||||
<?php if (View::can('notes.manage')) { ?>
|
||||
<a class="btn" href="<?= View::e(View::route('notes.edit', ['id' => $note->id()])) ?>">Править</a>
|
||||
|
||||
<form method="post" action="<?= View::e(View::route('notes.delete', ['id' => $note->id()])) ?>">
|
||||
<?= View::csrf() ?>
|
||||
<button type="submit" class="danger">Удалить</button>
|
||||
</form>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="grid cols-2" style="margin-top: 16px;">
|
||||
<div class="card">
|
||||
<h2>Текст</h2>
|
||||
<?php if (trim((string) $note->body) === '') { ?>
|
||||
<p class="muted">Пусто.</p>
|
||||
<?php } else { ?>
|
||||
<pre class="break"><?= View::e((string) $note->body) ?></pre>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>Свойства</h2>
|
||||
|
||||
<dl class="props">
|
||||
<dt>Автор</dt>
|
||||
<dd><?= View::e($author === null ? '—' : (string) $author->login) ?></dd>
|
||||
|
||||
<dt>Адресная часть</dt>
|
||||
<dd class="mono"><?= View::e((string) $note->raw('slug')) ?></dd>
|
||||
|
||||
<dt>Закреплена</dt>
|
||||
<dd><?= $note->pinned ? 'да' : 'нет' ?></dd>
|
||||
|
||||
<dt>Создана</dt>
|
||||
<dd><?= View::e(View::date((string) $note->raw('created_at'))) ?></dd>
|
||||
|
||||
<dt>Изменена</dt>
|
||||
<dd><?= View::e(View::date((string) $note->raw('updated_at'))) ?></dd>
|
||||
|
||||
<dt>Файл</dt>
|
||||
<dd>
|
||||
<?php if ($note->hasFile()) { ?>
|
||||
<a href="<?= View::e(View::route('notes.file', ['id' => $note->id()])) ?>"><?= View::e((string) $note->raw('file_name')) ?></a>
|
||||
<?php } else { ?>
|
||||
—
|
||||
<?php } ?>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p><a href="<?= View::e(View::route('notes.index')) ?>">← ко всем заметкам</a></p>
|
||||
Reference in new issue
Block a user