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