xref: /webtrees/resources/views/edit/reorder-names.phtml (revision 58c781b3c055e42036269e115fb5a3c4643b0df4)
1<?php
2
3use Fisharebest\Webtrees\Http\RequestHandlers\ReorderNamesAction;
4use Fisharebest\Webtrees\I18N;
5use Fisharebest\Webtrees\Individual;
6use Fisharebest\Webtrees\Registry;
7use Fisharebest\Webtrees\Tree;
8use Fisharebest\Webtrees\View;
9
10/**
11 * @var Individual $individual
12 * @var string     $title
13 * @var Tree       $tree
14 */
15
16?>
17
18<h2 class="wt-page-title"><?= $title ?></h2>
19
20<form method="post" action="<?= e(route(ReorderNamesAction::class, ['tree' => $tree->name(), 'xref' => $individual->xref()])) ?>" class="wt-page-content">
21    <div class="wt-sortable-list">
22        <?php foreach ($individual->facts(['NAME'], false, null, true) as $fact) : ?>
23            <div class="card my-2 wt-sortable-item">
24                <input type="hidden" name="order[]" value="<?= $fact->id() ?>">
25                <div class="card-header">
26                    <?= view('edit/reorder-card-header', ['title' => e($fact->value())]) ?>
27                </div>
28
29                <div class="card-body">
30                    <?= Registry::elementFactory()->make('INDI:NAME:TYPE')->value($fact->attribute('TYPE'), $tree) ?>
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($individual->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