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