xref: /webtrees/resources/views/edit/reorder-names.phtml (revision f4c767fd89cdb62ee54edec032285924cd767af7)
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 my-2 wt-sortable-item">
19                <input type="hidden" name="order[]" value="<?= $fact->id() ?>">
20                <div class="card-header">
21                    <?= view('edit/reorder-card-header', ['title' => e($fact->value())]) ?>
22                </div>
23
24                <div class="card-body">
25                    <?= GedcomTag::getLabelValue('TYPE', GedcomCodeName::getValue($fact->attribute('TYPE'), $fact->record())) ?>
26                </div>
27            </div>
28        <?php endforeach ?>
29    </div>
30
31    <p>
32        <button class="btn btn-primary" type="submit">
33            <?= view('icons/save') ?>
34            <?= /* I18N: A button label. */ I18N::translate('save') ?>
35        </button>
36
37        <a class="btn btn-secondary" href="<?= e($individual->url()) ?>">
38            <?= view('icons/cancel') ?>
39            <?= /* I18N: A button label. */ I18N::translate('cancel') ?>
40        </a>
41    </p>
42</form>
43
44<?php View::push('javascript') ?>
45<script>
46    new Sortable(document.querySelector(".wt-sortable-list"), {
47        handle: ".card-header",
48    });
49</script>
50<?php View::endpush() ?>
51