From ba75ef2eac23e8f3ffb6c35f3319c222779b5739 Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 23 Nov 2021 15:00:10 -0300 Subject: [PATCH] paginacion en las listas --- curriculumsearch/src/main/java/com/roshka/controller/CargoController.java | 17 +++++++++++------ curriculumsearch/src/main/java/com/roshka/controller/ConvocatoriaController.java | 13 +++++++++++-- curriculumsearch/src/main/java/com/roshka/controller/PostulanteRRHHController.java | 2 +- curriculumsearch/src/main/java/com/roshka/controller/TecnologiaController.java | 16 +++++++++++----- curriculumsearch/src/main/java/com/roshka/repositorio/CargoRepository.java | 2 +- curriculumsearch/src/main/java/com/roshka/repositorio/ConvocatoriaRepository.java | 4 +++- curriculumsearch/src/main/java/com/roshka/repositorio/TecnologiaRepository.java | 2 +- curriculumsearch/src/main/webapp/jsp/cargos.jsp | 58 +++++++++++++++++++++++++++++----------------------------- curriculumsearch/src/main/webapp/jsp/convocatorias.jsp | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------ curriculumsearch/src/main/webapp/jsp/layouts/base.jsp | 23 +++++++++++++++++++++++ curriculumsearch/src/main/webapp/jsp/postulantes.jsp | 12 +----------- curriculumsearch/src/main/webapp/jsp/tecnologias.jsp | 36 ++++++++++++++++++++---------------- 12 files changed, 177 insertions(+), 91 deletions(-) diff --git a/curriculumsearch/src/main/java/com/roshka/controller/CargoController.java b/curriculumsearch/src/main/java/com/roshka/controller/CargoController.java index 8d2bfdd..502fad7 100644 --- a/curriculumsearch/src/main/java/com/roshka/controller/CargoController.java +++ b/curriculumsearch/src/main/java/com/roshka/controller/CargoController.java @@ -34,13 +34,18 @@ public class CargoController { @RequestMapping("/cargos") public String menuCargos(Model model,@RequestParam(required = false) String nombre,@RequestParam(defaultValue = "0")Integer nroPagina) { - final Integer CANTIDAD_POR_PAGINA = 10; + final Integer CANTIDAD_POR_PAGINA = 1; Pageable page = PageRequest.of(nroPagina,CANTIDAD_POR_PAGINA,Sort.by("id")); - Page CargoPag=cargoRepo.findAllCargo(page); - List cargo = CargoPag.getContent(); - model.addAttribute("pages", CargoPag.getTotalPages()); - if(nombre == null || nombre.trim().isEmpty()) model.addAttribute("cargos", cargo); - else model.addAttribute("cargos", cargoRepo.findByNombreContainingIgnoreCase(nombre)); + if(nombre == null || nombre.trim().isEmpty()) { + Page CargoPag=cargoRepo.findAll(page); + model.addAttribute("cargos", CargoPag.getContent()); + model.addAttribute("pages", CargoPag.getTotalPages()); + } + else { + Page CargoPag=cargoRepo.findByNombreContainingIgnoreCase(nombre,page); + model.addAttribute("pages", CargoPag.getTotalPages()); + model.addAttribute("cargos", CargoPag.getContent()); + } return "cargos"; } diff --git a/curriculumsearch/src/main/java/com/roshka/controller/ConvocatoriaController.java b/curriculumsearch/src/main/java/com/roshka/controller/ConvocatoriaController.java index 5b41f69..1650aac 100644 --- a/curriculumsearch/src/main/java/com/roshka/controller/ConvocatoriaController.java +++ b/curriculumsearch/src/main/java/com/roshka/controller/ConvocatoriaController.java @@ -18,6 +18,10 @@ import org.hibernate.type.IntegerType; import org.hibernate.type.LongType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.MessageSource; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.validation.BindingResult; @@ -43,12 +47,17 @@ public class ConvocatoriaController { @RequestMapping("/convocatorias") public String menuConvocatorias(Model model,RedirectAttributes redirectAttrs, @RequestParam(required = false) Long cargoId, - @RequestParam(required = false) Integer isOpen//1: true, 0: false + @RequestParam(required = false) Integer isOpen,//1: true, 0: false + @RequestParam(defaultValue = "0")Integer nroPagina ) { + final Integer CANTIDAD_POR_PAGINA = 1; + Pageable page = PageRequest.of(nroPagina,CANTIDAD_POR_PAGINA,Sort.by("id")); model.addAttribute("cargos", cargoRepo.findAll()); + Page convoPag=convoRepo.f1ndByCargoAndEstado(new TypedParameterValue(LongType.INSTANCE, cargoId), new Date(), new TypedParameterValue(IntegerType.INSTANCE, isOpen),page); + model.addAttribute("convocatorias", convoPag.getContent()); + model.addAttribute("pages", convoPag.getTotalPages()); - model.addAttribute("convocatorias", convoRepo.f1ndByCargoAndEstado(new TypedParameterValue(LongType.INSTANCE, cargoId), new Date(), new TypedParameterValue(IntegerType.INSTANCE, isOpen))); //model.addAttribute("convocatorias",cargoId==null? convoRepo.findAll() : convoRepo.findByCargoId(cargoId)); return "convocatorias"; } diff --git a/curriculumsearch/src/main/java/com/roshka/controller/PostulanteRRHHController.java b/curriculumsearch/src/main/java/com/roshka/controller/PostulanteRRHHController.java index 20b20ba..f6be2d0 100644 --- a/curriculumsearch/src/main/java/com/roshka/controller/PostulanteRRHHController.java +++ b/curriculumsearch/src/main/java/com/roshka/controller/PostulanteRRHHController.java @@ -100,7 +100,7 @@ public class PostulanteRRHHController { @RequestParam(required = false)Long convId, @RequestParam(defaultValue = "0")Integer nroPagina ) throws IOException { - final Integer CANTIDAD_POR_PAGINA = 5; + final Integer CANTIDAD_POR_PAGINA = 1; Pageable page = PageRequest.of(nroPagina,CANTIDAD_POR_PAGINA,Sort.by("id")); model.addAttribute("tecnologias", tecRepo.findAll()); model.addAttribute("disponibilidades", Disponibilidad.values()); diff --git a/curriculumsearch/src/main/java/com/roshka/controller/TecnologiaController.java b/curriculumsearch/src/main/java/com/roshka/controller/TecnologiaController.java index 9c89632..3dc7872 100644 --- a/curriculumsearch/src/main/java/com/roshka/controller/TecnologiaController.java +++ b/curriculumsearch/src/main/java/com/roshka/controller/TecnologiaController.java @@ -47,11 +47,17 @@ public String addtecnologiaView(Model model,@PathVariable(required = false) Long public String menuTecnologias(Model model,@RequestParam(required = false) String nombre,@RequestParam(defaultValue = "0")Integer nroPagina) { final Integer CANTIDAD_POR_PAGINA = 10; Pageable page = PageRequest.of(nroPagina,CANTIDAD_POR_PAGINA,Sort.by("id")); - Page tecnologiaPag=tecRepo.findAllTecnologia(page); - List tecnologia = tecnologiaPag.getContent(); - model.addAttribute("pages", tecnologiaPag.getTotalPages()); - if(nombre == null || nombre.trim().isEmpty()) model.addAttribute("tecnologias", tecnologia); - else model.addAttribute("tecnologias", tecRepo.findByNombreContainingIgnoreCase(nombre)); + + if(nombre == null || nombre.trim().isEmpty()) { + Page tecnologiaPag=tecRepo.findAllTecnologia(page); + model.addAttribute("tecnologias", tecnologiaPag.getContent()); + model.addAttribute("pages", tecnologiaPag.getTotalPages()); + } + else { + Page tecnologiaPag=tecRepo.findByNombreContainingIgnoreCase(nombre,page); + model.addAttribute("pages", tecnologiaPag.getTotalPages()); + model.addAttribute("tecnologias", tecnologiaPag.getContent()); + } return "tecnologias"; } diff --git a/curriculumsearch/src/main/java/com/roshka/repositorio/CargoRepository.java b/curriculumsearch/src/main/java/com/roshka/repositorio/CargoRepository.java index dd7c024..30734d1 100644 --- a/curriculumsearch/src/main/java/com/roshka/repositorio/CargoRepository.java +++ b/curriculumsearch/src/main/java/com/roshka/repositorio/CargoRepository.java @@ -10,7 +10,7 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; public interface CargoRepository extends JpaRepository{ - public List findByNombreContainingIgnoreCase(String nombre); + public Page findByNombreContainingIgnoreCase(String nombre, Pageable pageable); public boolean existsByNombreIgnoreCase(String nombre); diff --git a/curriculumsearch/src/main/java/com/roshka/repositorio/ConvocatoriaRepository.java b/curriculumsearch/src/main/java/com/roshka/repositorio/ConvocatoriaRepository.java index 726a7ae..21caf6f 100644 --- a/curriculumsearch/src/main/java/com/roshka/repositorio/ConvocatoriaRepository.java +++ b/curriculumsearch/src/main/java/com/roshka/repositorio/ConvocatoriaRepository.java @@ -6,6 +6,8 @@ import java.util.List; import com.roshka.modelo.ConvocatoriaCargo; import org.hibernate.jpa.TypedParameterValue; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; @@ -16,7 +18,7 @@ public interface ConvocatoriaRepository extends JpaRepository findConvocatoriaCargoByCargo(Date fechaFinal); @Query("select c from ConvocatoriaCargo c where ( ?1 is null and ?3 is null) or ( ( ( ((c.fechaFin > ?2 or c.fechaFin=null) and ?3 = 1) or ((c.fechaFin < ?2 ) and ?3 = 0)) or ?3 is null ) and (c.cargoId = ?1 or ?1 is null) )") - public List f1ndByCargoAndEstado(TypedParameterValue cargoId, Date fecha, TypedParameterValue isOpen); + public Page f1ndByCargoAndEstado(TypedParameterValue cargoId, Date fecha, TypedParameterValue isOpen, Pageable page); @Query("SELECT c FROM ConvocatoriaCargo c WHERE (cargoId=?1)") public List filtrarConvocatoriasPorCargo(Long cargoId); diff --git a/curriculumsearch/src/main/java/com/roshka/repositorio/TecnologiaRepository.java b/curriculumsearch/src/main/java/com/roshka/repositorio/TecnologiaRepository.java index 8ed77e1..29e6b4c 100644 --- a/curriculumsearch/src/main/java/com/roshka/repositorio/TecnologiaRepository.java +++ b/curriculumsearch/src/main/java/com/roshka/repositorio/TecnologiaRepository.java @@ -11,7 +11,7 @@ import com.roshka.modelo.Tecnologia; public interface TecnologiaRepository extends JpaRepository { - public List findByNombreContainingIgnoreCase(String nombre); + public Page findByNombreContainingIgnoreCase(String nombre, Pageable pageable); public boolean existsByNombreIgnoreCase(String nombre); diff --git a/curriculumsearch/src/main/webapp/jsp/cargos.jsp b/curriculumsearch/src/main/webapp/jsp/cargos.jsp index cfa6c05..5d9754a 100644 --- a/curriculumsearch/src/main/webapp/jsp/cargos.jsp +++ b/curriculumsearch/src/main/webapp/jsp/cargos.jsp @@ -9,16 +9,25 @@ contentType="text/html;charset=UTF-8" language="java" %>

Lista de cargos

- - - +
+
+ + +
+
+ + +
+ +
- Agregar Nuevo Cargo
@@ -48,16 +57,16 @@ contentType="text/html;charset=UTF-8" language="java" %>
- - @@ -65,16 +74,7 @@ contentType="text/html;charset=UTF-8" language="java" %> diff --git a/curriculumsearch/src/main/webapp/jsp/convocatorias.jsp b/curriculumsearch/src/main/webapp/jsp/convocatorias.jsp index f4a8463..a22f7c6 100644 --- a/curriculumsearch/src/main/webapp/jsp/convocatorias.jsp +++ b/curriculumsearch/src/main/webapp/jsp/convocatorias.jsp @@ -5,29 +5,65 @@ <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> - + + +

Lista de convocatorias

- - - Estado: - -
- -
- -
- +
+ +
+
+
+ + +
+
+ + +
+
+
+
+ + +
+ + +
+
+
+ + +
+
+
+ + +
+
+
+
+ + +
+ + +
- Agregar Nueva Convocatoria +
${SUCCESS_MESSAGE}
@@ -55,7 +91,7 @@ Ver postulantes - + Cerrar convocatoria @@ -65,6 +101,17 @@ +
diff --git a/curriculumsearch/src/main/webapp/jsp/layouts/base.jsp b/curriculumsearch/src/main/webapp/jsp/layouts/base.jsp index b5be976..5493334 100644 --- a/curriculumsearch/src/main/webapp/jsp/layouts/base.jsp +++ b/curriculumsearch/src/main/webapp/jsp/layouts/base.jsp @@ -78,6 +78,29 @@ + diff --git a/curriculumsearch/src/main/webapp/jsp/postulantes.jsp b/curriculumsearch/src/main/webapp/jsp/postulantes.jsp index f0db0b2..d65a582 100644 --- a/curriculumsearch/src/main/webapp/jsp/postulantes.jsp +++ b/curriculumsearch/src/main/webapp/jsp/postulantes.jsp @@ -280,17 +280,7 @@ } - function buscarPagina(nro){ - nro-- - const aBuscar = 'nroPagina='+nro - if(!location.search) location.search = aBuscar - const inicial = location.search.search(aBuscar); - if(inicial==-1){//si no se encuentra y hay otros queries - location.search = "&"+aBuscar; - } - location.search.replace('nroPagina=',aBuscar) - console.log(location.search) - } + const tecId = document.querySelector("#tecId"); const lvlTec = document.querySelector("#lvlTec"); tecId.addEventListener('change',habilitarLvlTec); diff --git a/curriculumsearch/src/main/webapp/jsp/tecnologias.jsp b/curriculumsearch/src/main/webapp/jsp/tecnologias.jsp index 4577271..c5ca2cf 100644 --- a/curriculumsearch/src/main/webapp/jsp/tecnologias.jsp +++ b/curriculumsearch/src/main/webapp/jsp/tecnologias.jsp @@ -9,11 +9,26 @@
- - - +
+
+ + +
+
+ + +
+ +
- Agregar Nueva Tecnologia +
@@ -61,17 +76,6 @@ - + -- libgit2 0.26.0