edit article
This commit is contained in:
@@ -226,4 +226,18 @@ public class ArticleController {
|
||||
return "redirect:/accueil";
|
||||
}
|
||||
|
||||
//Update d'un article
|
||||
|
||||
@GetMapping("/edit")
|
||||
public String edit(Model model, @RequestParam()int id) {
|
||||
Article article = this.articleService.findArticleById(id);
|
||||
Retrait retrait = this.retraitService.retraitByNumarticle(id);
|
||||
System.out.println(article.getNom());
|
||||
|
||||
model.addAttribute("article", article);
|
||||
model.addAttribute("retrait", retrait);
|
||||
model.addAttribute("categories", this.categorieService.findAllCategories());
|
||||
return "editArticle";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,3 +44,5 @@ register.city = City:
|
||||
register.credit = Credits:
|
||||
register.make = create
|
||||
register.cancel = cancel
|
||||
|
||||
edit.article.title = Edit my article
|
||||
@@ -52,3 +52,5 @@ register.password.label = Mot de passe:
|
||||
register.confirm_password.label = Confirmation du mot de passe:
|
||||
register.submit_button = Cr\u00E9er
|
||||
register.cancel_button = Annuler
|
||||
|
||||
edit.article.title = Modifier mon article
|
||||
@@ -63,7 +63,7 @@
|
||||
</form>
|
||||
<div class="mt-5">
|
||||
<a class="btn btn-secondary" href="/accueil" th:text="'Retour'"></a>
|
||||
<a th:if="${#strings.equals(user.getPseudo(), article.pseudoUtilisateur)}" class="btn btn-secondary" href="/article/edit" th:text="'Modifier'"></a>
|
||||
<a th:if="${#strings.equals(user.getPseudo(), article.pseudoUtilisateur)}" class="btn btn-secondary" th:href="@{/article/edit(id=${article.id})}" th:text="'Modifier'"></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,10 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="fr" th:replace="~{modele-page :: layout('Modifier votre article' , ~{::#link}, ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container-main" class="container mt-5">
|
||||
<h1 th:text="#{edit.article.title}"></h1>
|
||||
<form th:action="@{/article/new}" th:object="${article}">
|
||||
<div class="mb-3">
|
||||
<label for="nom" class="form-label">Titre</label>
|
||||
<input type="text" class="form-control" th:field="*{nom}" id="nom">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="categorie" class="form-label">Catégorie:</label>
|
||||
<select class="form-control" th:field="*{numCategorie}" id="categorie" required>
|
||||
<option th:each="categorie : ${categories}" th:value="${categorie.id}" th:text="${categorie.libelle}"></option>
|
||||
</select>
|
||||
<div class="invalid-feedback">Veuillez sélectionner une catégorie.</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user