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