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