xref: /webtrees/resources/views/edit/reorder-media-files.phtml (revision 3f0247b283a74c64ac885446380ea81de9cf779e)
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    <div class="wt-sortable-list">
19        <?php foreach ($media->mediaFiles() as $media_file) : ?>
20            <div class="card my-2 wt-sortable-item">
21                <input type="hidden" name="order[]" value="<?= $media_file->factId() ?>">
22                <div class="card-header">
23                    <?= view('edit/reorder-card-header', ['title' => e($media_file->filename())]) ?>
24                </div>
25
26                <div class="card-body d-flex">
27                    <?= $media_file->displayImage(100, 100, 'contain') ?>
28                    <?= e($media_file->title()) ?>
29                </div>
30            </div>
31        <?php endforeach ?>
32    </div>
33
34    <p>
35        <button class="btn btn-primary" type="submit">
36            <?= view('icons/save') ?>
37            <?= /* I18N: A button label. */ I18N::translate('save') ?>
38        </button>
39
40        <a class="btn btn-secondary" href="<?= e($media->url()) ?>">
41            <?= view('icons/cancel') ?>
42            <?= /* I18N: A button label. */ I18N::translate('cancel') ?>
43        </a>
44    </p>
45
46    <?= csrf_field() ?>
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