xref: /webtrees/resources/views/edit/reorder-names.phtml (revision b8c8582ab2a169215e9010c84703b6f7f9c8027d)
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(), 'xref' => $individual->xref()])) ?>" class="wt-page-content">
14    <?= csrf_field() ?>
15
16    <div class="wt-sortable-list">
17        <?php foreach ($individual->facts(['NAME'], false, null, true) 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