xref: /webtrees/resources/views/edit/reorder-media-files.phtml (revision b9a4a6c608ac9f9f3bf6c12fbe1fbe871f30fedb)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Http\RequestHandlers\ReorderMediaFilesAction;
6use Fisharebest\Webtrees\I18N;
7use Fisharebest\Webtrees\Media;
8use Fisharebest\Webtrees\View;
9
10/**
11 * @var Media  $media
12 * @var string $title
13 */
14
15?>
16
17<h2 class="wt-page-title"><?= $title ?></h2>
18
19<form method="post" action="<?= e(route(ReorderMediaFilesAction::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref()])) ?>" class="wt-page-content">
20    <div class="wt-sortable-list">
21        <?php foreach ($media->mediaFiles() as $media_file) : ?>
22            <div class="card my-2 wt-sortable-item">
23                <input type="hidden" name="order[]" value="<?= $media_file->factId() ?>">
24                <div class="card-header">
25                    <?= view('edit/reorder-card-header', ['title' => e($media_file->filename())]) ?>
26                </div>
27
28                <div class="card-body d-flex">
29                    <?= $media_file->displayImage(100, 100, 'contain') ?>
30                    <?= e($media_file->title()) ?>
31                </div>
32            </div>
33        <?php endforeach ?>
34    </div>
35
36    <p>
37        <button class="btn btn-primary" type="submit">
38            <?= view('icons/save') ?>
39            <?= /* I18N: A button label. */ I18N::translate('save') ?>
40        </button>
41
42        <a class="btn btn-secondary" href="<?= e($media->url()) ?>">
43            <?= view('icons/cancel') ?>
44            <?= /* I18N: A button label. */ I18N::translate('cancel') ?>
45        </a>
46    </p>
47
48    <?= csrf_field() ?>
49</form>
50
51<?php View::push('javascript') ?>
52<script>
53    new Sortable(document.querySelector(".wt-sortable-list"), {
54        handle: ".card-header",
55    });
56</script>
57<?php View::endpush() ?>
58