summaryrefslogtreecommitdiff
path: root/resources/views/admin/fix-level-0-media.phtml
blob: 3f9d3f30d73981d3c0db91fd61947611312db543 (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
57
58
59
60
61
62
63
64
65
<?php

use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
use Fisharebest\Webtrees\Http\RequestHandlers\FixLevel0MediaAction;
use Fisharebest\Webtrees\Http\RequestHandlers\FixLevel0MediaData;
use Fisharebest\Webtrees\I18N;

?>
<?php use Fisharebest\Webtrees\View; ?>

<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), $title]]) ?>

<h1><?= $title ?></h1>

<p>
    <?= 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.') ?>
</p>

<table
    class="table table-bordered table-sm table-hover wt-fix-table datatables d-none"
    <?= view('lists/datatables-attributes') ?>
    data-ajax="<?= e(json_encode(['url' => route(FixLevel0MediaData::class)])) ?>"
    data-server-side="true"
>
    <caption class="sr-only">
        <?= I18N::translate('Media objects') ?>
    </caption>
    <thead class="thead-dark">
        <tr>
            <th data-sortable="false"><?= I18N::translate('Family tree') ?></th>
            <th data-sortable="false"><?= I18N::translate('Media object') ?></th>
            <th data-sortable="false"><?= I18N::translate('Title') ?></th>
            <th data-sortable="false"><?= I18N::translate('Individual') ?></th>
            <th data-sortable="false"><?= I18N::translate('Facts and events') ?></th>
        </tr>
    </thead>
</table>

<?php View::push('javascript') ?>
<script>
  'use strict';

  // If we click on a button, post the request and reload the table
  document.querySelector(".wt-fix-table").onclick = function (event) {
    let element = event.target;
    if (element.classList.contains("wt-fix-button")) {
      event.stopPropagation();
      if (confirm(element.dataset.confirm)) {
        $.ajax({
          data: {
            "fact_id":   element.dataset.factId,
            "indi_xref": element.dataset.individualXref,
            "obje_xref": element.dataset.mediaXref,
            "tree_id":   element.dataset.treeId
          },
          method: "POST",
          url: <?= json_encode(route(FixLevel0MediaAction::class)) ?>
        }).done(function () {
          $(".wt-fix-table").DataTable().ajax.reload(null, false);
        });
      }
    }
  };
</script>
<?php View::endpush() ?>