xref: /webtrees/resources/views/admin/fix-level-0-media.phtml (revision fcfa5390e0212e053854eb4fa4c263c9f6fb1e21)
1<?php use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
2use Fisharebest\Webtrees\I18N; ?>
3<?php use Fisharebest\Webtrees\View; ?>
4
5<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), $title]]) ?>
6
7<h1><?= $title ?></h1>
8
9<p>
10    <?= I18N::translate('If a media object is linked to an individual, when it should be linked to a fact or event, then you can move it to the correct location.') ?>
11</p>
12
13<table
14    class="table table-bordered table-sm table-hover datatables wt-fix-table"
15    <?= view('lists/datatables-attributes') ?>
16    data-ajax="<?= e(json_encode(['url' => route('admin-fix-level-0-media-data')])) ?>"
17    data-server-side="true"
18>
19    <caption class="sr-only">
20        <?= I18N::translate('Media objects') ?>
21    </caption>
22    <thead class="thead-dark">
23        <tr>
24            <th data-sortable="false"><?= I18N::translate('Family tree') ?></th>
25            <th data-sortable="false"><?= I18N::translate('Media object') ?></th>
26            <th data-sortable="false"><?= I18N::translate('Title') ?></th>
27            <th data-sortable="false"><?= I18N::translate('Individual') ?></th>
28            <th data-sortable="false"><?= I18N::translate('Facts and events') ?></th>
29        </tr>
30    </thead>
31</table>
32
33<?php View::push('javascript') ?>
34<script>
35  'use strict';
36
37  // If we click on a button, post the request and reload the table
38  document.querySelector(".wt-fix-table").onclick = function (event) {
39    let element = event.target;
40    if (element.classList.contains("wt-fix-button")) {
41      event.stopPropagation();
42      if (confirm(element.dataset.confirm)) {
43        $.ajax({
44          data: {
45            "fact_id":   element.dataset.factId,
46            "indi_xref": element.dataset.individualXref,
47            "obje_xref": element.dataset.mediaXref,
48            "tree_id":   element.dataset.treeId
49          },
50          method: "POST",
51          url: <?= json_encode(route('admin-fix-level-0-media-action')) ?>
52        }).done(function () {
53          $(".wt-fix-table").DataTable().ajax.reload(null, false);
54        });
55      }
56    }
57  };
58</script>
59<?php View::endpush() ?>
60