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