diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/Experiencia.java b/curriculumsearch/src/main/java/com/roshka/modelo/Experiencia.java index cb603df..d0cf24f 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/Experiencia.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/Experiencia.java @@ -78,7 +78,7 @@ public class Experiencia { if(fechaDesde==null || fechaDesde.isEmpty()) return; try { - this.fechaDesde = new SimpleDateFormat("yyyy-mm-dd").parse(fechaDesde); + this.fechaDesde = new SimpleDateFormat("yyyy-MM-dd").parse(fechaDesde); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -94,7 +94,7 @@ public class Experiencia { if(fechaHasta==null || fechaHasta.isEmpty()) return; try { - this.fechaHasta = new SimpleDateFormat("yyyy-mm-dd").parse(fechaHasta); + this.fechaHasta = new SimpleDateFormat("yyyy-MM-dd").parse(fechaHasta); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java b/curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java index 8e15c12..312ff00 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/Postulante.java @@ -153,7 +153,7 @@ public class Postulante { if(fechaNacimiento==null || fechaNacimiento.isEmpty()) return; try { - this.fechaNacimiento = new SimpleDateFormat("yyyy-mm-dd").parse(fechaNacimiento); + this.fechaNacimiento = new SimpleDateFormat("yyyy-MM-dd").parse(fechaNacimiento); } catch (ParseException e) { // TODO Auto-generated catch block System.err.println("Error al parsear"); diff --git a/curriculumsearch/src/main/java/com/roshka/modelo/PostulanteTecnologia.java b/curriculumsearch/src/main/java/com/roshka/modelo/PostulanteTecnologia.java index 4f4747b..bed7f3c 100644 --- a/curriculumsearch/src/main/java/com/roshka/modelo/PostulanteTecnologia.java +++ b/curriculumsearch/src/main/java/com/roshka/modelo/PostulanteTecnologia.java @@ -37,30 +37,30 @@ public class PostulanteTecnologia { @JoinColumn @JsonBackReference private Postulante postulante; -public long getId() { - return id; -} -public void setId(long id) { - this.id = id; -} -public Long getNivel() { - return nivel; -} -public void setNivel(Long nivel) { - this.nivel = nivel; -} -public Tecnologia getTecnologia() { - return tecnologia; -} -public void setTecnologia(Tecnologia tecnologia) { - this.tecnologia = tecnologia; -} -public Postulante getPostulante() { - return postulante; -} -public void setPostulante(Postulante postulante) { - this.postulante = postulante; -} + public long getId() { + return id; + } + public void setId(long id) { + this.id = id; + } + public Long getNivel() { + return nivel; + } + public void setNivel(Long nivel) { + this.nivel = nivel; + } + public Tecnologia getTecnologia() { + return tecnologia; + } + public void setTecnologia(Tecnologia tecnologia) { + this.tecnologia = tecnologia; + } + public Postulante getPostulante() { + return postulante; + } + public void setPostulante(Postulante postulante) { + this.postulante = postulante; + } diff --git a/curriculumsearch/src/main/resources/static/main.js b/curriculumsearch/src/main/resources/static/main.js index a448d1f..1b78a54 100644 --- a/curriculumsearch/src/main/resources/static/main.js +++ b/curriculumsearch/src/main/resources/static/main.js @@ -4,13 +4,51 @@ let cont_tecnologia = 0; const experiencias = []; const estudios = []; const tecnologias = []; -function agregarFieldExpierncia(){ + +const formValidator = function () { + 'use strict' + + // Fetch all the forms we want to apply custom Bootstrap validation styles to + var forms = document.querySelectorAll('.needs-validation') + var expForm = document.querySelector('#agregar-exp') + + + // Loop over them and prevent submission + Array.prototype.slice.call(forms) + .forEach(function (form) { + form.addEventListener('submit', function (event) { + if (!form.checkValidity()) { + event.preventDefault() + event.stopPropagation() + } + + form.classList.add('was-validated') + }, false) + }) +} + +function agregarFieldExpierncia(event){ //recoger del form const pairs = {}; const formexp = document.querySelector("[name=experiencia-form]"); const formData = new FormData(formexp); const reconocimientos = [{},{},{}]; let pos_rec; + let returnFlag = false; + + formData.forEach((value, key)=>{ + if((key === "institucion" || key === "cargo" || key === "fechaDesde") + && value==="" && returnFlag == false){ + console.log(key, value) + returnFlag = true; + } + }); + + if(returnFlag===true){ + alert("Rellene Institucion, Fechas y Cargo como minimo"); + return; + } + for (const [name, value] of formData){ pos_rec = name.split("-");//rec-nombre-index if (pos_rec.length > 1) { @@ -44,7 +82,6 @@ function agregarFieldExpierncia(){ div.innerHTML = ''; div.appendChild(div1); cont_experiencia++; - } /*--------------------------------------------------------------------*/ function agregarFieldTecnologia(){ @@ -137,10 +174,14 @@ async function postData(url = '', data = {}) { }); return response; // parses JSON response into native JavaScript objects } - +formValidator() form = document.querySelector("form"); form.addEventListener("submit",(evt)=>{ - + // if (!form.checkValidity()) { + // evt.preventDefault() + // evt.stopPropagation() + // } + // form.classList.add('was-validated') postData('postulante', serializeJSON(form)) .then(response => { if(response.status==200 || response.status==302){ diff --git a/curriculumsearch/src/main/webapp/jsp/postulante-form.jsp b/curriculumsearch/src/main/webapp/jsp/postulante-form.jsp index 280ae0b..0ec086f 100644 --- a/curriculumsearch/src/main/webapp/jsp/postulante-form.jsp +++ b/curriculumsearch/src/main/webapp/jsp/postulante-form.jsp @@ -16,47 +16,74 @@