Permet de supprimer une news

This commit is contained in:
2022-12-14 11:33:09 +01:00
parent 2ab457aa8f
commit ca78aca8cb
5 changed files with 28 additions and 1 deletions

View File

@@ -16,6 +16,9 @@
<header class="card-header">
<p class="card-header-title">
<?= $news->getPublicationDate()->format('Y-m-d') . " : " . $news->getTitle() ?>
<?php if ($security->getCurrentUser() !== null && $security->getCurrentUser()->isAdmin()): ?>
<button class="button is-danger ml-4" onclick="deleteReq(<?= $news->getId() ?>); return false;">Delete</button>
<?php endif; ?>
</p>
</header>
<div class="card-content">
@@ -68,4 +71,15 @@
</li>
<?php endif; ?>
</ul>
</nav>
</nav>
<?php if ($security->getCurrentUser() !== null && $security->getCurrentUser()->isAdmin()): ?>
<script>
function deleteReq(i) {
fetch(`<?= $router->url('admin/delete/') ?>${i}`, {
method: 'DELETE'
}).then(() => location.reload());
return false;
}
</script>
<?php endif; ?>