Commit bce55aca by Joel Florentin

eliminar experiencias js

parent 3d8622d4
...@@ -33,6 +33,7 @@ public class PostulanteController { ...@@ -33,6 +33,7 @@ public class PostulanteController {
@PostMapping(value = "/postulante",consumes = "application/json") @PostMapping(value = "/postulante",consumes = "application/json")
public String guardarPostulante(@RequestBody Postulante postulante){ public String guardarPostulante(@RequestBody Postulante postulante){
System.out.println(postulante.getExperiencias().get(0).getCargo());
return "redirect:/"; return "redirect:/";
} }
......
...@@ -18,19 +18,24 @@ function agregarFieldExpierncia(evt){ ...@@ -18,19 +18,24 @@ function agregarFieldExpierncia(evt){
<input type="cargo" class="form-control " name="experiencia-${cont_experiencia}-cargo" id="cargo" > <input type="cargo" class="form-control " name="experiencia-${cont_experiencia}-cargo" id="cargo" >
<label for="refNombre" class="form-label">Referencia Nombre</label> <label for="refNombre" class="form-label">Referencia Nombre</label>
<input type="text" class="form-control " name="experiencia-${cont_experiencia}-referencias" id="refNombre" > <input type="text" class="form-control " name="experiencia-${cont_experiencia}-referencias" id="refNombre" >
<button type="button" onclick="eliminarExperiencia(event)">Eliminar</button>
`; `;
nee.className = "mb-3 col-5" nee.className = "mb-3 col-5"
form.insertBefore(nee,btn) form.insertBefore(nee,btn)
} }
function eliminarExperiencia(event) {
event.target.parentElement.remove()
}
function serializeJSON (form) { function serializeJSON (form) {
// Create a new FormData object // Create a new FormData object
const formData = new FormData(form); const formData = new FormData(form);
// Create an object to hold the name/value pairs // Create an object to hold the name/value pairs
const pairs = {}; const pairs = {};
const experiencias = [{}]; const experiencias = [];
const estudios = [{}]; const estudios = [];
const tecnologias = [{}]; const tecnologias = [];
// Add each name/value pair to the object // Add each name/value pair to the object
for (const [name, value] of formData) { for (const [name, value] of formData) {
...@@ -60,9 +65,9 @@ function serializeJSON (form) { ...@@ -60,9 +65,9 @@ function serializeJSON (form) {
} }
} }
} }
pairs["experiencias"] = experiencias pairs["experiencias"] = experiencias.filter(exp => exp)//eliminacion de nulos
pairs["estudios"] = estudios pairs["estudios"] = estudios.filter(est => est)//eliminacion de nulos
pairs["tecnologias"] = tecnologias pairs["tecnologias"] = tecnologias.filter(tec => tec)//eliminacion de nulos
// Return the JSON string // Return the JSON string
return JSON.stringify(pairs, null, 2); return JSON.stringify(pairs, null, 2);
......
...@@ -68,19 +68,6 @@ ...@@ -68,19 +68,6 @@
<input type="text" class="form-control " name="modalidad" id="modalidad" > <input type="text" class="form-control " name="modalidad" id="modalidad" >
</div> </div>
<div class="mb-3 col-5">
<label for="institucion" class="form-label">Institucion</label>
<input type="text" class="form-control " name="experiencia-0-institucion" id="institucion" >
<label for="fechaDesde" class="form-label">FechaDesde</label>
<input type="date" class="form-control " name="experiencia-0-fechaDesde" id="fechaDesde" >
<label for="fechaHasta" class="form-label">Fecha Hasta</label>
<input type="date" class="form-control " name="experiencia-0-fechaHasta" id="fechaHasta" >
<label for="cargo" class="form-label">Cargo</label>
<input type="cargo" class="form-control " name="experiencia-0-cargo" id="cargo" >
<label for="refNombre" class="form-label">Referencia Nombre</label>
<input type="text" class="form-control " name="experiencia-0-referencias" id="refNombre" >
</div>
<button type="button" name="addExp" onclick="agregarFieldExpierncia(event)">Agregar</button> <button type="button" name="addExp" onclick="agregarFieldExpierncia(event)">Agregar</button>
......
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