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