summaryrefslogtreecommitdiff
path: root/resources/views/edit/reorder-media.phtml
blob: 282e174a1fad9214ddc5d77c1f39b04c7f73bb8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php

declare(strict_types=1);

use Fisharebest\Webtrees\Http\RequestHandlers\ReorderMediaAction;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\View;

/**
 * @var Individual $individual
 * @var string     $title
 */

?>

<h2 class="wt-page-title"><?= $title ?></h2>

<form method="post" action="<?= e(route(ReorderMediaAction::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref()])) ?>" class="wt-page-content">
    <div class="wt-sortable-list">
        <?php foreach ($individual->facts(['OBJE']) as $fact) : ?>
            <div class="card my-2 wt-sortable-item">
                <input type="hidden" name="order[]" value="<?= $fact->id() ?>">
                <div class="card-header">
                    <?= view('edit/reorder-card-header', ['title' => $fact->target()->fullName()]) ?>
                </div>

                <div class="card-body">
                    <?= $fact->target()->displayImage(100, 100, 'contain', []) ?>
                </div>
            </div>
        <?php endforeach ?>
    </div>

    <p>
        <button class="btn btn-primary" type="submit">
            <?= view('icons/save') ?>
            <?= /* I18N: A button label. */ I18N::translate('save') ?>
        </button>

        <a class="btn btn-secondary" href="<?= e($individual->url()) ?>">
            <?= view('icons/cancel') ?>
            <?= /* I18N: A button label. */ I18N::translate('cancel') ?>
        </a>
    </p>

    <?= csrf_field() ?>
</form>

<?php View::push('javascript') ?>
<script>
    new Sortable(document.querySelector(".wt-sortable-list"), {
        handle: ".card-header",
    });
</script>
<?php View::endpush() ?>