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