Commit 1795f580 by Cesar Giulano Gonzalez Maqueda

merge con william

parents 9ef31f8f 2f3104ce
......@@ -36,11 +36,16 @@ public class CargoController {
public String menuCargos(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<Cargo> CargoPag=cargoRepo.findAllCargo(page);
List<Cargo> 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<Cargo> CargoPag=cargoRepo.findAll(page);
model.addAttribute("cargos", CargoPag.getContent());
model.addAttribute("pages", CargoPag.getTotalPages());
}
else {
Page<Cargo> CargoPag=cargoRepo.findByNombreContainingIgnoreCase(nombre,page);
model.addAttribute("pages", CargoPag.getTotalPages());
model.addAttribute("cargos", CargoPag.getContent());
}
return "cargos";
}
......
......@@ -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,18 @@ 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) EstadoConvocatoria estado,//1: true, 0: false
@RequestParam(defaultValue = "0")Integer nroPagina
) {
final Integer CANTIDAD_POR_PAGINA = 10;
Pageable page = PageRequest.of(nroPagina,CANTIDAD_POR_PAGINA,Sort.by("id"));
model.addAttribute("cargos", cargoRepo.findAll());
Page<ConvocatoriaCargo> convoPag=convoRepo.findByCargoAndEstado(cargoId,estado,page);
model.addAttribute("convocatorias", convoPag.getContent());
model.addAttribute("pages", convoPag.getTotalPages());
model.addAttribute("estados", EstadoConvocatoria.values());
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";
}
......
......@@ -29,6 +29,8 @@ import org.hibernate.jpa.TypedParameterValue;
import org.hibernate.type.IntegerType;
import org.hibernate.type.LongType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
......@@ -83,7 +85,8 @@ public class PostulanteController {
model.addAttribute("estadosCiviles", EstadoCivil.values());
model.addAttribute("nacionalidades", Nacionalidad.values());
model.addAttribute("tiposExperencia", TipoExperiencia.values());
model.addAttribute("CargosDisponibles", convoRepo.f1ndByCargoAndEstado(new TypedParameterValue(LongType.INSTANCE, null), new Date(), new TypedParameterValue(IntegerType.INSTANCE, 1)));
model.addAttribute("CargosDisponibles",
convoRepo.findByCargoAndEstado(null, EstadoConvocatoria.abierto, PageRequest.of(0,Integer.MAX_VALUE,Sort.by("id"))).getContent());
try {
model.addAttribute("ciudades", new ObjectMapper().writeValueAsString(ciuRepo.findAll()));
} catch (JsonProcessingException er) {
......
......@@ -100,7 +100,8 @@ public class PostulanteRRHHController {
@RequestParam(required = false)Long convId,
@RequestParam(defaultValue = "0")Integer nroPagina
) throws IOException {
final Integer CANTIDAD_POR_PAGINA = 1;
final Integer CANTIDAD_POR_PAGINA = 10;
Pageable page = PageRequest.of(nroPagina,CANTIDAD_POR_PAGINA,Sort.by("id"));
model.addAttribute("tecnologias", tecRepo.findAll());
model.addAttribute("disponibilidades", Disponibilidad.values());
......
......@@ -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<Tecnologia> tecnologiaPag=tecRepo.findAllTecnologia(page);
List<Tecnologia> 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<Tecnologia> tecnologiaPag=tecRepo.findAllTecnologia(page);
model.addAttribute("tecnologias", tecnologiaPag.getContent());
model.addAttribute("pages", tecnologiaPag.getTotalPages());
}
else {
Page<Tecnologia> tecnologiaPag=tecRepo.findByNombreContainingIgnoreCase(nombre,page);
model.addAttribute("pages", tecnologiaPag.getTotalPages());
model.addAttribute("tecnologias", tecnologiaPag.getContent());
}
return "tecnologias";
}
......
......@@ -26,22 +26,6 @@ public class Cargo {
@Column(name = "nombre")
private String nombre;
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public String getNombre() {
return this.nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
@OneToMany(mappedBy = "cargo")
@JsonManagedReference
private List<ConvocatoriaCargo> convocatorias;
......
......@@ -10,7 +10,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
public interface CargoRepository extends JpaRepository<Cargo,Long>{
public List<Cargo> findByNombreContainingIgnoreCase(String nombre);
public Page<Cargo> findByNombreContainingIgnoreCase(String nombre, Pageable pageable);
public boolean existsByNombreIgnoreCase(String nombre);
......
......@@ -4,8 +4,11 @@ import java.util.Date;
import java.util.List;
import com.roshka.modelo.ConvocatoriaCargo;
import com.roshka.modelo.EstadoConvocatoria;
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;
......@@ -15,8 +18,13 @@ public interface ConvocatoriaRepository extends JpaRepository<ConvocatoriaCargo,
public List<ConvocatoriaCargo> findByCargoId(Long cargoId);
//@Query(value="selec x from ConvocatoriaCargo x where (x.fechaFinal > ?1)",nativeQuery = true)
//public List<ConvocatoriaCargo> 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<ConvocatoriaCargo> f1ndByCargoAndEstado(TypedParameterValue cargoId, Date fecha, TypedParameterValue isOpen);
/* @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 Page<ConvocatoriaCargo> f1ndByCargoAndEstado(TypedParameterValue cargoId, Date fecha, TypedParameterValue isOpen, Pageable page); */
@Query("select c from ConvocatoriaCargo c "+
"where (c.cargoId = ?1 or ?1 is null) and "+
"(c.estado = ?2 or ?2 is null)")
public Page<ConvocatoriaCargo> findByCargoAndEstado(Long cargoId, EstadoConvocatoria estado, Pageable page);
@Query("SELECT c FROM ConvocatoriaCargo c WHERE (cargoId=?1)")
public List<ConvocatoriaCargo> filtrarConvocatoriasPorCargo(Long cargoId);
......
......@@ -11,7 +11,7 @@ import com.roshka.modelo.Tecnologia;
public interface TecnologiaRepository extends JpaRepository<Tecnologia,Long> {
public List<Tecnologia> findByNombreContainingIgnoreCase(String nombre);
public Page<Tecnologia> findByNombreContainingIgnoreCase(String nombre, Pageable pageable);
public boolean existsByNombreIgnoreCase(String nombre);
......
......@@ -108,7 +108,7 @@ function validarfecha(fechaDesde, fechaHasta){
return "la fecha desde no puede ser mayor a la fecha actual" ;
}
if(fechaHasta =! null && fechaDesde>fechaHasta){
if(fechaHasta =! null && fechaHasta.trim().length >0 && fechaDesde>fechaHasta){
return "la fecha desde no puede ser mayor a la fecha hasta";
}
......@@ -223,7 +223,7 @@ function agregarFieldExpierncia(event){
let pos_rec;
let returnFlag = false;
let requiredValues = ["institucion", "cargo", "fechaDesde", "descripcion"]
let requiredValues = ["institucion", "cargo", "fechaDesde", "descripcion","nombreReferencia","telefonoReferencia"]
formData.forEach((value, key)=>{
if(requiredValues.includes(key)
......
......@@ -9,16 +9,25 @@ contentType="text/html;charset=UTF-8" language="java" %>
<h2>Lista de cargos</h2>
<div>
<form>
<label for="cargos">Nombre:</label>
<input
type="text"
name="nombre"
id="nombre"
value="${param.nombre}"
/>
<input type="submit" value="Buscar" />
<div class="row justify-content-start gy-2">
<div class="col-auto">
<input
class="form-control"
placeholder="Nombre"
type="text"
name="nombre"
id="nombre"
value="${param.nombre}"
/>
</div>
<div class="col-auto">
<input type="submit" class="btn btn-primary" value="Buscar" />
</div>
</div>
</form>
<a href="/cargo">Agregar Nuevo Cargo</a>
</div>
<div class="card text-dark bg-light mt-3">
......@@ -48,16 +57,16 @@ contentType="text/html;charset=UTF-8" language="java" %>
</table>
</div>
</div>
</div>
<div class="card-footer">
<div>
<nav aria-label="Page navigation example">
<ul class="pagination">
<c:forEach begin="1" end="${pages}" var="nro">
<li class="page-item ${(param.nroPagina == null and nro == 1) or param.nroPagina == nro-1 ? 'active' : ''}"><a class="page-link" href="javascript:buscarPagina(${nro})">${nro}</a></li>
</c:forEach>
</ul>
</nav>
<div class="card-footer">
<div>
<nav aria-label="Page navigation example">
<ul class="pagination">
<c:forEach begin="1" end="${pages}" var="nro">
<li class="page-item ${(param.nroPagina == null and nro == 1) or param.nroPagina == nro-1 ? 'active' : ''}"><a class="page-link" href="javascript:buscarPagina(${nro})">${nro}</a></li>
</c:forEach>
</ul>
</nav>
</div>
</div>
</div>
</div>
......@@ -65,16 +74,7 @@ contentType="text/html;charset=UTF-8" language="java" %>
</layout:put>
<layout:put block="scripts" type="APPEND">
<script>
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)
}
</script>
</layout:put>
</layout:extends>
......@@ -5,29 +5,64 @@
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<layout:extends name="layouts/base.jsp">
<layout:put block="cssDeclaracion" type="APPEND"></layout:put>
<layout:put block="cssDeclaracion" type="APPEND">
<style>
label {
width: auto;
}
</style>
</layout:put>
<layout:put block="contents" type="REPLACE">
<h2>Lista de convocatorias</h2>
<div>
<form>
<label for="cargos">Cargos:</label>
<select name="cargoId" id="cargos">
<option value="">Todos los cargos</option>
<c:forEach items="${cargos}" var="cargo">
<option value="${cargo.id}" ${param.cargoId == cargo.id ? "selected" : ""} >${cargo.nombre}</option>
</c:forEach>
</select>
Estado:
<input type="radio" id="cualquiera" name="isOpen" checked value="">
<label for="abierto">Cualquiera</label><br>
<input type="radio" id="abierto" name="isOpen" value="1">
<label for="abierto">Abierto</label><br>
<input type="radio" id="cerrado" name="isOpen" value="0">
<label for="cerrado">Cerrado</label><br>
<input type="submit" value="Buscar">
<div class="row row-cols-2 gy-2">
<div class="col-auto">
<div class="row">
<div class="col-auto">
<label class="form-label" for="cargos">Cargos:</label>
</div>
<div class="col">
<select class="form-select form-select-sm" name="cargoId" id="cargos">
<option value="">Todos los cargos</option>
<c:forEach items="${cargos}" var="cargo">
<option value="${cargo.id}" ${param.cargoId == cargo.id ? "selected" : ""} >${cargo.nombre}</option>
</c:forEach>
</select>
</div>
</div>
</div>
<div class="col-auto">
<label for="form-check-label">Estado: </label>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="cualquiera" name="estado" checked value="">
<label class="form-check-label" for="cualquiera">Cualquiera</label><br>
</div>
<c:forEach var="estado" items="${estados}">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="${estado}" name="estado" value="${estado}">
<label class="form-check-label" for="abierto">${estado}</label><br>
</div>
</c:forEach>
</div>
<div class="col-auto">
<input type="submit" class="btn btn-primary btn-sm" value="Buscar">
</div>
</div>
</form>
</div>
<a href="/convocatoria">Agregar Nueva Convocatoria</a>
<c:if test="${SUCCESS_MESSAGE != null}">
<div id="status_message" style="color: brown;" >${SUCCESS_MESSAGE}</div>
</c:if>
......@@ -55,7 +90,11 @@
<td><fmt:formatDate value="${convocatoria.getFechaInicio()}" pattern="dd-MM-yyyy" /></td>
<td><fmt:formatDate value="${convocatoria.getFechaFin()}" pattern="dd-MM-yyyy" /></td>
<td><a href="/postulantes?convId=${convocatoria.id}">Ver postulantes</a></td>
<td><button onclick=window.location.href="/convocatoria/${convocatoria.id}">Cerrar convocatoria</button></td>
<td>
<c:if test="${convocatoria.getEstado() != 'cerrado'}">
<a class="btn btn-secondary" href="/convocatoria/${convocatoria.id}">Cerrar convocatoria</a>
</c:if>
</td>
</tr>
</c:forEach>
......@@ -65,6 +104,17 @@
</table>
</div>
</div>
<div class="card-footer">
<div>
<nav aria-label="Page navigation example">
<ul class="pagination">
<c:forEach begin="1" end="${pages}" var="nro">
<li class="page-item ${(param.nroPagina == null and nro == 1) or param.nroPagina == nro-1 ? 'active' : ''}"><a class="page-link" href="javascript:buscarPagina(${nro})">${nro}</a></li>
</c:forEach>
</ul>
</nav>
</div>
</div>
</div>
</layout:put>
......
......@@ -78,6 +78,29 @@
</div>
<layout:block name="scripts">
<script>
function buscarPagina(nro){
nro--
const queries = location.search.split("&");
let existe = false;
if(location.search.length == 0 ) location.search = "?nroPagina="+nro;
let fullquery = "";
for (const query of queries) {
let [key, value] = query.split("=");
if(key.includes('nroPagina')){
fullquery += key + "=" + nro + "&";
existe = true;
}
else{
fullquery += key + "=" + value + "&";
}
}
if(!existe) fullquery += "nroPagina" + "=" + nro + "&";
location.search = fullquery.substring(0,fullquery.length-1);
}
</script>
</layout:block>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
......
......@@ -358,11 +358,11 @@
</div>
<div class="inputs">
<label for="refNombre" class="form-label">Nombre de la Referencia</label>
<input placeholder="&#xf007; Ingrese el nombre de su referencia" type="text" class="form-control FA " name="nombreReferencia" id="refNombre" >
<input placeholder="&#xf007; Ingrese el nombre de su referencia" type="text" class="form-control FA " name="nombreReferencia" id="refNombre" required>
</div>
<div class="inputs">
<label for="refTel" class="form-label">Telefono de la Referencia</label>
<input placeholder="&#xf095; Ingrese el telefono de su referencia" type="number" class="form-control FA" name="telefonoReferencia" id="refTel" >
<input placeholder="&#xf095; Ingrese el telefono de su referencia" type="number" class="form-control FA" name="telefonoReferencia" id="refTel" required>
</div>
<div class="inputs">
......
......@@ -368,17 +368,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);
......
......@@ -9,11 +9,26 @@
<div>
<form>
<label for="tecnologias">Nombre:</label>
<input type="text" name="nombre" id="nombre" value="${param.nombre}"/>
<input type="submit" value="Buscar">
<div class="row justify-content-start gy-2">
<div class="col-auto">
<input
class="form-control"
placeholder="Nombre"
type="text"
name="nombre"
id="nombre"
value="${param.nombre}"
/>
</div>
<div class="col-auto">
<input type="submit" class="btn btn-primary" value="Buscar" />
</div>
</div>
</form>
<a href="/tecnologia">Agregar Nueva Tecnologia</a>
</div>
<div class="card text-dark bg-light mt-3">
......@@ -61,17 +76,6 @@
</layout:put>
<layout:put block="scripts" type="APPEND">
<script>
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)
}
</script>
</layout:put>
</layout:extends>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment