73 lines
2.5 KiB
Twig
73 lines
2.5 KiB
Twig
{% extends "layout.twig" %}
|
||
|
||
{% block title %}Tableau de bord – Catégories{% endblock %}
|
||
|
||
{% block content %}
|
||
<h2>Gestion des catégories</h2>
|
||
|
||
{% include 'partials/_admin_nav.twig' %}
|
||
|
||
{% if error %}
|
||
<div class="alert alert--danger">{{ error }}</div>
|
||
{% endif %}
|
||
|
||
{% if success %}
|
||
<div class="alert alert--success">{{ success }}</div>
|
||
{% endif %}
|
||
|
||
<div class="category-create">
|
||
<h3 class="category-create__title">Ajouter une catégorie</h3>
|
||
|
||
<form method="post" action="/admin/categories/create" class="category-create__form">
|
||
<input type="hidden" name="{{ csrf.keys.name }}" value="{{ csrf.name }}">
|
||
<input type="hidden" name="{{ csrf.keys.value }}" value="{{ csrf.value }}">
|
||
|
||
<label for="name" class="category-create__label">
|
||
Nom
|
||
<input type="text" id="name" name="name" required maxlength="100"
|
||
class="form-container__input category-create__input" placeholder="ex : Développement Web">
|
||
</label>
|
||
|
||
<button type="submit" class="btn btn--primary">Créer</button>
|
||
</form>
|
||
|
||
<p class="category-create__hint">Le slug URL est généré automatiquement depuis le nom.</p>
|
||
</div>
|
||
|
||
{% if categories is not empty %}
|
||
<table class="admin-table">
|
||
<thead>
|
||
<tr>
|
||
<th>Nom</th>
|
||
<th>Slug</th>
|
||
<th>Actions</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{% for category in categories %}
|
||
<tr>
|
||
<td data-label="Nom"><strong>{{ category.name }}</strong></td>
|
||
<td data-label="Slug"><code>{{ category.slug }}</code></td>
|
||
<td data-label="Actions">
|
||
<div class="u-inline-actions">
|
||
<form method="post" action="/admin/categories/delete/{{ category.id }}" class="u-inline-form">
|
||
<input type="hidden" name="{{ csrf.keys.name }}" value="{{ csrf.name }}">
|
||
<input type="hidden" name="{{ csrf.keys.value }}" value="{{ csrf.value }}">
|
||
<button type="submit" class="btn btn--sm btn--danger"
|
||
onclick="return confirm('Supprimer la catégorie « {{ category.name }} » ?\n\nCette action est impossible si des articles lui sont rattachés.')">
|
||
Supprimer
|
||
</button>
|
||
</form>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
{% endfor %}
|
||
</tbody>
|
||
</table>
|
||
|
||
{% include 'partials/_pagination.twig' with { pagination: pagination } %}
|
||
{% else %}
|
||
<p><em>Aucune catégorie créée.</em></p>
|
||
{% endif %}
|
||
{% endblock %}
|