feat: add pagination to equipment and licence search screens
AS Talange CI/CD Pipeline / Build & Run Unit Tests (push) Successful in 4m43s
AS Talange CI/CD Pipeline / Deploy to Test Environment (push) Successful in 6m17s

This commit is contained in:
2026-08-03 16:00:02 +02:00
parent 4956e1a70c
commit 63c71d504e
4 changed files with 155 additions and 7 deletions
@@ -139,14 +139,25 @@ public class LicenceController {
@RequestParam(required = false) String numeroLicence,
@RequestParam(required = false) String email,
@RequestParam(required = false) String typeDemande,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "20") int size,
org.springframework.ui.Model model) {
Saison saisonActive = saisonRepository.findByEstActiveTrue().orElse(null);
org.springframework.data.jpa.domain.Specification<Licence> spec = buildLicenceSpecification(nom, prenom, categorieId, numeroLicence, email, typeDemande, saisonActive);
List<Licence> licences = licenceRepository.findAll(spec);
List<Licence> allLicences = licenceRepository.findAll(spec);
model.addAttribute("licences", licences);
int totalElements = allLicences.size();
int totalPages = (int) Math.ceil((double) totalElements / size);
if (page < 0) page = 0;
if (page >= totalPages && totalPages > 0) page = totalPages - 1;
int start = page * size;
int end = Math.min(start + size, totalElements);
List<Licence> pageContent = (start < totalElements) ? allLicences.subList(start, end) : List.of();
model.addAttribute("licences", pageContent);
model.addAttribute("categories", categorieRepository.findAll());
model.addAttribute("nomFilter", nom);
model.addAttribute("prenomFilter", prenom);
@@ -155,6 +166,11 @@ public class LicenceController {
model.addAttribute("emailFilter", email);
model.addAttribute("typeDemandeFilter", typeDemande);
model.addAttribute("currentPage", page);
model.addAttribute("totalPages", totalPages);
model.addAttribute("totalElements", totalElements);
model.addAttribute("pageSize", size);
return "parametrage/licences_recherche";
}