xref: /webtrees/resources/views/edit/reorder-names.phtml (revision 090a06287954f43677f06ea778b3f67c029de8fe)
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    <?= csrf_field() ?>
22
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</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