end article start edit article

This commit is contained in:
Parpaillax
2024-04-26 14:29:43 +02:00
parent 5183bf0a7a
commit bd37441f9c
5 changed files with 18 additions and 5 deletions

View File

@@ -63,6 +63,7 @@ public class ArticleController {
UserProfil user = userService.utilisateurById(article.getUtilisateur()); UserProfil user = userService.utilisateurById(article.getUtilisateur());
Categorie cate = categorieService.findCategorieById(article.getNumCategorie()); Categorie cate = categorieService.findCategorieById(article.getNumCategorie());
Retrait retrait = retraitService.retraitByNumarticle(article.getId()); Retrait retrait = retraitService.retraitByNumarticle(article.getId());
article.setPseudoUtilisateur(user.getPseudo());
List<Enchere> lastEnchere = this.enchereService.enchereByArticle(article.getId()); List<Enchere> lastEnchere = this.enchereService.enchereByArticle(article.getId());
Optional<Float> maxMontantEnchere = lastEnchere.stream() Optional<Float> maxMontantEnchere = lastEnchere.stream()
.map(Enchere::getMontantEnchere) // Récupère seulement les montants d'enchère .map(Enchere::getMontantEnchere) // Récupère seulement les montants d'enchère
@@ -72,7 +73,9 @@ public class ArticleController {
model.addAttribute("cate", cate.getLibelle()); model.addAttribute("cate", cate.getLibelle());
model.addAttribute("retrait", retrait); model.addAttribute("retrait", retrait);
model.addAttribute("enchere", new Enchere()); model.addAttribute("enchere", new Enchere());
model.addAttribute("maxEnchere", maxMontantEnchere.get()); if (maxMontantEnchere.isPresent()) {
model.addAttribute("maxEnchere", maxMontantEnchere.get());
}
List<ObjectError> errors = (List<ObjectError>) session.getAttribute("errors"); List<ObjectError> errors = (List<ObjectError>) session.getAttribute("errors");
if (errors != null) { if (errors != null) {
model.addAttribute("errors", errors); model.addAttribute("errors", errors);

View File

@@ -28,7 +28,7 @@ public class UserInterceptor implements HandlerInterceptor {
if (authentication != null && authentication.isAuthenticated() && !authentication.getName().equals("anonymousUser")) { if (authentication != null && authentication.isAuthenticated() && !authentication.getName().equals("anonymousUser")) {
UserProfil user = this.userService.utilisateurByName(authentication.getName()); UserProfil user = this.userService.utilisateurByName(authentication.getName());
if (modelAndView != null && modelAndView.getViewName() != null && !modelAndView.getViewName().startsWith("redirect:")) { if (modelAndView != null && modelAndView.getViewName() != null && !modelAndView.getViewName().startsWith("redirect:")) {
modelAndView.addObject("user", user.getCredit()); modelAndView.addObject("user", user);
} }
} }
} }

View File

@@ -38,7 +38,7 @@
</div> </div>
<div class="mt-2 d-flex flex-row align-items-end justify-content-between"> <div class="mt-2 d-flex flex-row align-items-end justify-content-between">
<strong><label class="col-form-label">Dernière offre</label></strong> <strong><label class="col-form-label">Dernière offre</label></strong>
<span th:text="${maxEnchere}"></span> <span th:text="${maxEnchere} ? ${maxEnchere} : 'Aucune offre en cours'"></span>
</div> </div>
<div class="mt-2 d-flex flex-row align-items-end justify-content-between"> <div class="mt-2 d-flex flex-row align-items-end justify-content-between">
<strong><label class="col-form-label">Date fin enchère</label></strong> <strong><label class="col-form-label">Date fin enchère</label></strong>
@@ -63,7 +63,7 @@
</form> </form>
<div class="mt-5"> <div class="mt-5">
<a class="btn btn-secondary" href="/accueil" th:text="'Retour'"></a> <a class="btn btn-secondary" href="/accueil" th:text="'Retour'"></a>
<!-- <a th:if="${#strings.equals(${username.pseudo}, ${article.getPseudoUtilisateur()})}" class="btn btn-secondary" href="/accueil" th:text="'Modifier'"></a>--> <a th:if="${#strings.equals(user.getPseudo(), article.pseudoUtilisateur)}" class="btn btn-secondary" href="/article/edit" th:text="'Modifier'"></a>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
</html>

View File

@@ -24,7 +24,7 @@
<img href="/accueil" src="/img/logo.png" width="70" height="70" alt="Logo"> <img href="/accueil" src="/img/logo.png" width="70" height="70" alt="Logo">
<label href="/accueil" class="text-light"><strong>ENI-Encheres</strong></label> <label href="/accueil" class="text-light"><strong>ENI-Encheres</strong></label>
</a> </a>
<div th:if="${#authentication.principal != 'anonymousUser'}" class="text-light text-center d-flex justify-content-center align-items-center" th:text="#{home.credit} + ${user}"></div> <div th:if="${#authentication.principal != 'anonymousUser'}" class="text-light text-center d-flex justify-content-center align-items-center" th:text="#{home.credit} + ${user.getCredit()}"></div>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>