xref: /webtrees/resources/views/edit/reorder-media-files.phtml (revision d178350f1d754b60945fcca3e61a19f04dadd861)
1*d178350fSGreg Roach<?php
2*d178350fSGreg Roach
3*d178350fSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ReorderMediaFilesAction;
4*d178350fSGreg Roachuse Fisharebest\Webtrees\I18N;
5*d178350fSGreg Roachuse Fisharebest\Webtrees\Media;
6*d178350fSGreg Roachuse Fisharebest\Webtrees\View;
7*d178350fSGreg Roach
8*d178350fSGreg Roach/**
9*d178350fSGreg Roach * @var Media  $media
10*d178350fSGreg Roach * @var string $title
11*d178350fSGreg Roach */
12*d178350fSGreg Roach
13*d178350fSGreg Roach?>
14*d178350fSGreg Roach
15*d178350fSGreg Roach<h2 class="wt-page-title"><?= $title ?></h2>
16*d178350fSGreg Roach
17*d178350fSGreg Roach<form method="post" action="<?= e(route(ReorderMediaFilesAction::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref()])) ?>" class="wt-page-content">
18*d178350fSGreg Roach    <?= csrf_field() ?>
19*d178350fSGreg Roach
20*d178350fSGreg Roach    <div class="wt-sortable-list">
21*d178350fSGreg Roach        <?php foreach ($media->mediaFiles() as $media_file) : ?>
22*d178350fSGreg Roach            <div class="card my-2 wt-sortable-item">
23*d178350fSGreg Roach                <input type="hidden" name="order[]" value="<?= $media_file->factId() ?>">
24*d178350fSGreg Roach                <div class="card-header">
25*d178350fSGreg Roach                    <?= view('edit/reorder-card-header', ['title' => e($media_file->filename())]) ?>
26*d178350fSGreg Roach                </div>
27*d178350fSGreg Roach
28*d178350fSGreg Roach                <div class="card-body d-flex">
29*d178350fSGreg Roach                    <?= $media_file->displayImage(100, 100, 'contain') ?>
30*d178350fSGreg Roach                    <?= e($media_file->title()) ?>
31*d178350fSGreg Roach                </div>
32*d178350fSGreg Roach            </div>
33*d178350fSGreg Roach        <?php endforeach ?>
34*d178350fSGreg Roach    </div>
35*d178350fSGreg Roach
36*d178350fSGreg Roach    <p>
37*d178350fSGreg Roach        <button class="btn btn-primary" type="submit">
38*d178350fSGreg Roach            <?= view('icons/save') ?>
39*d178350fSGreg Roach            <?= /* I18N: A button label. */ I18N::translate('save') ?>
40*d178350fSGreg Roach        </button>
41*d178350fSGreg Roach
42*d178350fSGreg Roach        <a class="btn btn-secondary" href="<?= e($media->url()) ?>">
43*d178350fSGreg Roach            <?= view('icons/cancel') ?>
44*d178350fSGreg Roach            <?= /* I18N: A button label. */ I18N::translate('cancel') ?>
45*d178350fSGreg Roach        </a>
46*d178350fSGreg Roach    </p>
47*d178350fSGreg Roach</form>
48*d178350fSGreg Roach
49*d178350fSGreg Roach<?php View::push('javascript') ?>
50*d178350fSGreg Roach<script>
51*d178350fSGreg Roach    new Sortable(document.querySelector(".wt-sortable-list"), {
52*d178350fSGreg Roach        handle: ".card-header",
53*d178350fSGreg Roach    });
54*d178350fSGreg Roach</script>
55*d178350fSGreg Roach<?php View::endpush() ?>
56