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