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