diff --git a/blog/categories/articles/ajouter_article.html b/blog/articles/ajouter_article/ajouter_article.html similarity index 60% rename from blog/categories/articles/ajouter_article.html rename to blog/articles/ajouter_article/ajouter_article.html index bd09ca5..18e7bf3 100644 --- a/blog/categories/articles/ajouter_article.html +++ b/blog/articles/ajouter_article/ajouter_article.html @@ -23,7 +23,7 @@

Ajouter un article

-
+ @@ -40,39 +40,40 @@
Article ajouté avec succès !
- -
- - + +
+ + - - + + +
- - -
- - -
+ +
+ + +
- -
- - -
+ +
+ + +
+ + +
+ + +
- -
- - -
-
+
diff --git a/blog/categories/articles/ajouter_article.js b/blog/articles/ajouter_article/ajouter_article.js similarity index 100% rename from blog/categories/articles/ajouter_article.js rename to blog/articles/ajouter_article/ajouter_article.js diff --git a/blog/categories/articles/liste_article.html b/blog/articles/list_article/liste_article.html similarity index 100% rename from blog/categories/articles/liste_article.html rename to blog/articles/list_article/liste_article.html diff --git a/blog/categories/articles/liste_articles.js b/blog/articles/list_article/liste_articles.js similarity index 100% rename from blog/categories/articles/liste_articles.js rename to blog/articles/list_article/liste_articles.js diff --git a/blog/categories/articles/modifier_article.html b/blog/articles/modifier_article/modifier_article.html similarity index 100% rename from blog/categories/articles/modifier_article.html rename to blog/articles/modifier_article/modifier_article.html diff --git a/blog/categories/articles/modifier_article.js b/blog/articles/modifier_article/modifier_article.js similarity index 100% rename from blog/categories/articles/modifier_article.js rename to blog/articles/modifier_article/modifier_article.js diff --git a/blog/categories/ajouter_categorie.html b/blog/categories/ajouter_categorie/ajouter_categorie.html similarity index 93% rename from blog/categories/ajouter_categorie.html rename to blog/categories/ajouter_categorie/ajouter_categorie.html index eca3a64..ca71275 100644 --- a/blog/categories/ajouter_categorie.html +++ b/blog/categories/ajouter_categorie/ajouter_categorie.html @@ -44,7 +44,7 @@
- Annuler + Annuler
diff --git a/blog/categories/ajouter_categorie.js b/blog/categories/ajouter_categorie/ajouter_categorie.js similarity index 96% rename from blog/categories/ajouter_categorie.js rename to blog/categories/ajouter_categorie/ajouter_categorie.js index f2045eb..3eedbf4 100644 --- a/blog/categories/ajouter_categorie.js +++ b/blog/categories/ajouter_categorie/ajouter_categorie.js @@ -37,6 +37,7 @@ form.addEventListener("submit", function (e) { //Ajout d'une nouvelle catégorie en BDD - categoriesExistantes.push(nom); + existingCategories.push(nom); + }); \ No newline at end of file diff --git a/blog/categories/liste_categorie/liste_categorie.html b/blog/categories/liste_categorie/liste_categorie.html new file mode 100644 index 0000000..402532f --- /dev/null +++ b/blog/categories/liste_categorie/liste_categorie.html @@ -0,0 +1,56 @@ + + + + + + Liste des catégories + + + + + + + +
+

Liste des catégories

+ + +
+ + + + + + + + + + + + + + + + +
NomDescriptionActions
+
+ + + + + + + diff --git a/blog/categories/liste_categorie/liste_categorie.js b/blog/categories/liste_categorie/liste_categorie.js new file mode 100644 index 0000000..3a4d2f8 --- /dev/null +++ b/blog/categories/liste_categorie/liste_categorie.js @@ -0,0 +1,52 @@ +// 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 = ` + + ${cat.nom} + ${cat.description || "-"} + + + + Modifier + + + + + + `; + 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"); + } +} diff --git a/blog/categories/modifier_categorie.html b/blog/categories/modifier_categorie/modifier_categorie.html similarity index 93% rename from blog/categories/modifier_categorie.html rename to blog/categories/modifier_categorie/modifier_categorie.html index 26da894..d27d7d9 100644 --- a/blog/categories/modifier_categorie.html +++ b/blog/categories/modifier_categorie/modifier_categorie.html @@ -42,7 +42,7 @@
- Annuler + Annuler
diff --git a/blog/categories/modifier_categorie.js b/blog/categories/modifier_categorie/modifier_categorie.js similarity index 73% rename from blog/categories/modifier_categorie.js rename to blog/categories/modifier_categorie/modifier_categorie.js index 80b9172..cd6df7b 100644 --- a/blog/categories/modifier_categorie.js +++ b/blog/categories/modifier_categorie/modifier_categorie.js @@ -8,15 +8,19 @@ const successMsg = document.getElementById("successMsg"); form.addEventListener("submit", function (e) { e.preventDefault(); - //vérification des champs obligatoires + // 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 + // Succès errorMsg.classList.add("d-none"); successMsg.classList.remove("d-none"); -}); \ No newline at end of file + // Redirection après succès + setTimeout(() => { + window.location.href = "../../../blog/categories/liste_categorie/liste_categorie.html"; + }, 1500); +});