xref: /webtrees/resources/views/edit/reorder-media-files.phtml (revision 4e9f79fb8504acad5511a54ba739c9bf95a4503d)
1<?php
2
3use Fisharebest\Webtrees\Http\RequestHandlers\ReorderMediaFilesAction;
4use Fisharebest\Webtrees\I18N;
5use Fisharebest\Webtrees\Media;
6use Fisharebest\Webtrees\View;
7
8/**
9 * @var Media  $media
10 * @var string $title
11 */
12
13?>
14
15<h2 class="wt-page-title"><?= $title ?></h2>
16
17<form method="post" action="<?= e(route(ReorderMediaFilesAction::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref()])) ?>" class="wt-page-content">
18    <?= csrf_field() ?>
19
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</form>
48
49<?php View::push('javascript') ?>
50<script>
51    new Sortable(document.querySelector(".wt-sortable-list"), {
52        handle: ".card-header",
53    });
54</script>
55<?php View::endpush() ?>
56