From 3fc239683eff821a55fede801f0844ee379beb53 Mon Sep 17 00:00:00 2001 From: Youssef Date: Tue, 7 Jul 2026 21:54:52 +0200 Subject: [PATCH] feat: display and manage adherent clothing and shoe sizes --- .../web/controller/AdherentController.java | 26 ++++++- .../resources/templates/adherents/form.html | 35 ++++++---- .../resources/templates/adherents/list.html | 70 +++++++++++++++++-- 3 files changed, 112 insertions(+), 19 deletions(-) diff --git a/as-talange-web/src/main/java/com/astalange/web/controller/AdherentController.java b/as-talange-web/src/main/java/com/astalange/web/controller/AdherentController.java index c5060a6..33db188 100644 --- a/as-talange-web/src/main/java/com/astalange/web/controller/AdherentController.java +++ b/as-talange-web/src/main/java/com/astalange/web/controller/AdherentController.java @@ -48,6 +48,8 @@ public class AdherentController { @org.springframework.web.bind.annotation.RequestParam(required = false) String licence, @org.springframework.web.bind.annotation.RequestParam(required = false) String email, @org.springframework.web.bind.annotation.RequestParam(required = false) String paiement, + @org.springframework.web.bind.annotation.RequestParam(required = false, defaultValue = "nom") String sortField, + @org.springframework.web.bind.annotation.RequestParam(required = false, defaultValue = "asc") String sortDirection, @org.springframework.web.bind.annotation.RequestParam(defaultValue = "0") int page, @org.springframework.web.bind.annotation.RequestParam(defaultValue = "20") int size, Model model) { @@ -113,7 +115,29 @@ public class AdherentController { model.addAttribute("paiementFilter", paiement.trim()); } - // 3. Paginate + // 3. Sort + java.util.Comparator comparator = (a1, a2) -> 0; + if ("nom".equalsIgnoreCase(sortField)) { + comparator = java.util.Comparator.comparing(a -> a.getNom() != null ? a.getNom() : ""); + } else if ("prenom".equalsIgnoreCase(sortField)) { + comparator = java.util.Comparator.comparing(a -> a.getPrenom() != null ? a.getPrenom() : ""); + } else if ("categorie".equalsIgnoreCase(sortField)) { + comparator = java.util.Comparator.comparing(a -> (a.getLicenceActuelle() != null && a.getLicenceActuelle().getCategorie() != null && a.getLicenceActuelle().getCategorie().getNom() != null) ? a.getLicenceActuelle().getCategorie().getNom() : ""); + } else if ("licence".equalsIgnoreCase(sortField)) { + comparator = java.util.Comparator.comparing(a -> (a.getLicenceActuelle() != null && a.getLicenceActuelle().getNumeroLicence() != null) ? a.getLicenceActuelle().getNumeroLicence() : ""); + } else if ("email".equalsIgnoreCase(sortField)) { + comparator = java.util.Comparator.comparing(a -> a.getEmail() != null ? a.getEmail() : ""); + } + + if ("desc".equalsIgnoreCase(sortDirection)) { + comparator = comparator.reversed(); + } + adherents.sort(comparator); + + model.addAttribute("sortField", sortField); + model.addAttribute("sortDirection", sortDirection); + + // 4. Paginate int totalElements = adherents.size(); int totalPages = (int) Math.ceil((double) totalElements / size); if (page < 0) page = 0; diff --git a/as-talange-web/src/main/resources/templates/adherents/form.html b/as-talange-web/src/main/resources/templates/adherents/form.html index 1602ec2..93141b6 100644 --- a/as-talange-web/src/main/resources/templates/adherents/form.html +++ b/as-talange-web/src/main/resources/templates/adherents/form.html @@ -207,7 +207,7 @@ -
+
@@ -413,26 +413,35 @@
- +
@@ -442,16 +451,16 @@
-
+
-
- - -
+
+ + +