refonte arborescence + correction des chemins
This commit is contained in:
@@ -1,57 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Ajouter une catégorie</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
|
||||
|
||||
<style>
|
||||
body{
|
||||
background: #f4f6f981;
|
||||
|
||||
}
|
||||
.container{
|
||||
max-width: 600px;
|
||||
margin-top: 50px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<h2 class="mb-5 text-center">Ajouter une catégorie</h2>
|
||||
|
||||
<!--Erreur champ vide -->
|
||||
<div id="errorEmpty" class="alert alert-danger d-none">Le nom de catégorie est obligatoire.</div>
|
||||
|
||||
<!--Erreur nom deja existant -->
|
||||
<div id="errorExists" class="alert alert-danger d-none">Cette catégorie existe déjà. Veuillez en choisir une autre.</div>
|
||||
|
||||
<!--Succès ajout catégorie -->
|
||||
<div id="successMessage" class="alert alert-success d-none">Catégorie ajoutée avec succès !</div>
|
||||
|
||||
<form id="addCategoryForm">
|
||||
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="form-label fw-bold">Nom de la catégorie (obligatoire)</label>
|
||||
<input type="text" id="categoryName" class="form-control" placeholder="Actualité, chien, chat .." required></div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-bold">Description</label>
|
||||
<textarea id="categoryDescription" class="form-control" rows="4" placeholder="Entrez une description (optionnel)"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="d-flex gap-3 mt-4">
|
||||
<a href="../../../blog/categories/liste_categorie/liste_categorie.html" class="btn btn-secondary w-50">Annuler</a>
|
||||
<button type="submit" class="btn btn-primary w-50">Ajouter</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script src="ajouter.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,43 +0,0 @@
|
||||
|
||||
const form = document.getElementById("addCategoryForm");
|
||||
const nameField = document.getElementById("categoryName");
|
||||
const descField = document.getElementById("categoryDescription");
|
||||
|
||||
const errorEmpty = document.getElementById("errorEmpty");
|
||||
const errorExists = document.getElementById("errorExists");
|
||||
const successMessage = document.getElementById("successMessage");
|
||||
|
||||
// Catégories existantes ( à remplacer en BD si besoin)
|
||||
const existingCategories = ["Actualités", "Chien", "Chat", "Boutique"];
|
||||
|
||||
form.addEventListener("submit", function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
const nom = nameField.value.trim();
|
||||
|
||||
//Remettre tout a zero
|
||||
errorEmpty.classList.add("d-none");
|
||||
errorExists.classList.add("d-none");
|
||||
successMessage.classList.add("d-none");
|
||||
|
||||
//Erreur champs vide
|
||||
if (nom === "") {
|
||||
errorEmpty.classList.remove("d-none");
|
||||
return;
|
||||
}
|
||||
|
||||
//Erreur catégorie existante
|
||||
if (existingCategories.includes(nom)) {
|
||||
errorExists.classList.remove("d-none");
|
||||
return;
|
||||
}
|
||||
|
||||
//Succès
|
||||
successMessage.classList.remove("d-none");
|
||||
|
||||
|
||||
//Ajout d'une nouvelle catégorie en BDD
|
||||
existingCategories.push(nom);
|
||||
|
||||
|
||||
});
|
||||
@@ -1,56 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Liste des catégories</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
|
||||
|
||||
<style>
|
||||
body {
|
||||
background: #f4f6f9;
|
||||
padding: 30px;
|
||||
}
|
||||
.container {
|
||||
max-width: 800px;
|
||||
margin-top: 40px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<h2 class="text-center mb-4">Liste des catégories</h2>
|
||||
|
||||
<!-- Message succès -->
|
||||
<div id="successMsg" class="alert alert-success d-none"></div>
|
||||
|
||||
<!-- Bouton ajouter -->
|
||||
<div class="d-flex justify-content-end mb-4">
|
||||
<a href="../ajouter_categorie/ajouter_categorie.html" class="btn btn-primary">
|
||||
Ajouter une catégorie
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Tableau -->
|
||||
<table class="table table-striped table-hover">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>Nom</th>
|
||||
<th>Description</th>
|
||||
<th class="text-center">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="categoriesTableBody">
|
||||
<!-- rempli en JS -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script src="liste_categorie.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
// Simulation BDD
|
||||
let categories = [
|
||||
{ id: 1, nom: "Actualités", description: "Infos et nouveautés" },
|
||||
{ id: 2, nom: "Chien", description: "Articles liés aux chiens" },
|
||||
{ id: 3, nom: "Chat", description: "Conseils pour chats" },
|
||||
{ id: 4, nom: "Boutique", description: "Produits et accessoires" }
|
||||
];
|
||||
|
||||
const tableBody = document.getElementById("categoriesTableBody");
|
||||
const successMsg = document.getElementById("successMsg");
|
||||
|
||||
// Fonction d'affichage
|
||||
function afficherCategories() {
|
||||
tableBody.innerHTML = "";
|
||||
|
||||
categories.forEach((cat, index) => {
|
||||
const row = `
|
||||
<tr>
|
||||
<td>${cat.nom}</td>
|
||||
<td>${cat.description || "-"}</td>
|
||||
|
||||
<td class="text-center">
|
||||
<a href="../modifier_categorie/modifier_categorie.html?id=${cat.id}" class="btn btn-warning btn-sm">
|
||||
Modifier
|
||||
</a>
|
||||
|
||||
<button class="btn btn-danger btn-sm" onclick="supprimerCategorie(${index})">
|
||||
Supprimer
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
tableBody.innerHTML += row;
|
||||
});
|
||||
}
|
||||
|
||||
afficherCategories();
|
||||
|
||||
// Suppression
|
||||
function supprimerCategorie(index) {
|
||||
if (confirm("Voulez-vous vraiment supprimer cette catégorie ?")) {
|
||||
|
||||
const nomCat = categories[index].nom;
|
||||
|
||||
categories.splice(index, 1);
|
||||
|
||||
afficherCategories();
|
||||
|
||||
successMsg.textContent = `La catégorie "${nomCat}" a été supprimée avec succès.`;
|
||||
successMsg.classList.remove("d-none");
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Modifier une catégorie</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
|
||||
|
||||
<style>
|
||||
body {
|
||||
background: #f4f6f981;
|
||||
|
||||
}
|
||||
.container {
|
||||
max-width: 600px;
|
||||
margin: 50px auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<h2 class="mb-5 text-center">Modifier une catégorie</h2>
|
||||
|
||||
<div id="errorMsg" class="alert alert-danger d-none">Veuillez ezmplir tous les champs obligatoires</div>
|
||||
|
||||
<div id="successMsg" class="alert alert-success d-none">La catégorie a été modifiée avec succès !</div>
|
||||
|
||||
<form id="modifierCategorie">
|
||||
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="form-label fw-bold">Nom de la catégorie (obligatoire)</label>
|
||||
<input type="text" id="categoryName" class="form-control" placeholder="Entrez le nom de la catégorie" required>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-bold">Description (optionnel)</label>
|
||||
<textarea id="categorieDescription" class="form-control" rows="4" placeholder="Entrez une description" required></textarea>
|
||||
</div>
|
||||
|
||||
<div class="d-flex gap-3 mt-4">
|
||||
<a href="../../categories/liste_categorie/liste_categorie.html" class="btn btn-secondary w-50">Annuler</a>
|
||||
<button type="submit" class="btn btn-primary w-50">Enregistrer</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,26 +0,0 @@
|
||||
|
||||
const form = document.getElementById("modifierCategorie");
|
||||
const nameField = document.getElementById("categoryName");
|
||||
const descField = document.getElementById("categorieDescription");
|
||||
const errorMsg = document.getElementById("errorMsg");
|
||||
const successMsg = document.getElementById("successMsg");
|
||||
|
||||
form.addEventListener("submit", function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
// Vérification des champs obligatoires
|
||||
if (nameField.value.trim() === "" || descField.value.trim() === "") {
|
||||
errorMsg.classList.remove("d-none");
|
||||
successMsg.classList.add("d-none");
|
||||
return;
|
||||
}
|
||||
|
||||
// Succès
|
||||
errorMsg.classList.add("d-none");
|
||||
successMsg.classList.remove("d-none");
|
||||
|
||||
// Redirection après succès
|
||||
setTimeout(() => {
|
||||
window.location.href = "../../../blog/categories/liste_categorie/liste_categorie.html";
|
||||
}, 1500);
|
||||
});
|
||||
Reference in New Issue
Block a user