Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
th-app-java
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Oscar Enrique Gonzalez Escurra
th-app-java
Commits
37797605
Commit
37797605
authored
Nov 01, 2021
by
Cesar Giulano Gonzalez Maqueda
Browse files
Options
Browse Files
Download
Plain Diff
Merge con joel-001
parents
a39a887f
b4fafd3a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
71 deletions
+86
-71
curriculumsearch/src/main/resources/static/main.js
+45
-49
curriculumsearch/src/main/webapp/jsp/postulante-form.jsp
+41
-22
No files found.
curriculumsearch/src/main/resources/static/main.js
View file @
37797605
var
cont_experiencia
=
0
;
let
cont_estudios
=
0
;
let
cont_tecnologia
=
0
;
function
agregarFieldExpierncia
(
evt
){
const
experiencias
=
[];
const
estudios
=
[];
const
tecnologias
=
[];
function
agregarFieldExpierncia
(){
//recoger del form
const
pairs
=
{};
const
formexp
=
document
.
querySelector
(
"[name=experiencia-form]"
);
const
formData
=
new
FormData
(
formexp
);
for
(
const
[
name
,
value
]
of
formData
){
pairs
[
name
]
=
value
}
experiencias
[
cont_experiencia
]
=
pairs
;
formexp
.
reset
();
//imprimir lista actualizada
const
div
=
document
.
querySelector
(
"#experiencias"
)
const
div1
=
document
.
createElement
(
'div'
);
let
content
=
'<ul>'
const
btn
=
evt
.
target
for
(
let
index
=
0
;
index
<
experiencias
.
length
;
index
++
)
{
const
exp
=
experiencias
[
index
];
if
(
exp
==
null
)
continue
;
content
+=
`
<li id="exp-
${
index
}
">
${
exp
.
institucion
}
<button type="button" onclick="eliminarExperiencia(event)">Eliminar</button>
</li>
`
}
content
+=
"</ul>"
div1
.
innerHTML
=
content
div
.
innerHTML
=
''
;
div
.
appendChild
(
div1
);
cont_experiencia
++
;
const
nee
=
document
.
createElement
(
"div"
)
nee
.
innerHTML
=
`
<label for="institucion" class="form-label">Institucion</label>
<input type="text" class="form-control " name="experiencia-
${
cont_experiencia
}
-institucion" id="institucion" >
<label for="fechaDesde" class="form-label">FechaDesde</label>
<input type="date" class="form-control " name="experiencia-
${
cont_experiencia
}
-fechaDesde" id="fechaDesde" >
<label for="fechaHasta" class="form-label">Fecha Hasta</label>
<input type="date" class="form-control " name="experiencia-
${
cont_experiencia
}
-fechaHasta" id="fechaHasta" >
<label for="cargo" class="form-label">Cargo</label>
<input type="cargo" class="form-control " name="experiencia-
${
cont_experiencia
}
-cargo" id="cargo" >
<label for="refNombre" class="form-label">Referencia Nombre</label>
<input type="text" class="form-control " name="experiencia-
${
cont_experiencia
}
-referencias" id="refNombre" >
`
;
nee
.
className
=
"mb-3 col-5"
form
.
insertBefore
(
nee
,
btn
)
}
function
eliminarExperiencia
(
event
)
{
//eliminar del array
console
.
log
(
event
.
target
.
parentElement
.
id
.
split
(
"-"
)[
1
])
experiencias
[
event
.
target
.
parentElement
.
id
.
split
(
"-"
)[
1
]]
=
null
//eliminar en html
event
.
target
.
parentElement
.
remove
()
}
function
serializeJSON
(
form
)
{
// Create a new FormData object
...
...
@@ -28,41 +51,14 @@ function serializeJSON (form) {
// Create an object to hold the name/value pairs
const
pairs
=
{};
const
experiencias
=
[{}];
const
estudios
=
[{}];
const
tecnologias
=
[{}];
// Add each name/value pair to the object
for
(
const
[
name
,
value
]
of
formData
)
{
//los atributos no primitivos tiene una nomenclatura distinta en sus names
//ej.: experiencia-4-institucion == experencias[4].institucion
let
codificacion
=
name
.
split
(
"-"
)
if
(
codificacion
.
length
==
1
){
pairs
[
name
]
=
value
}
else
{
switch
(
codificacion
[
0
])
{
case
"experiencia"
:
if
(
experiencias
[
codificacion
[
1
]]
==
null
)
experiencias
[
codificacion
[
1
]]
=
{};
experiencias
[
codificacion
[
1
]][
codificacion
[
2
]]
=
value
break
;
case
"estudio"
:
if
(
estudios
[
codificacion
[
1
]]
==
null
)
estudios
[
codificacion
[
1
]]
=
{};
estudios
[
codificacion
[
1
]][
codificacion
[
2
]]
=
value
break
;
case
"tecnologia"
:
if
(
tecnologias
[
codificacion
[
1
]]
==
null
)
tecnologias
[
codificacion
[
1
]]
=
{};
tecnologias
[
codificacion
[
1
]][
codificacion
[
2
]]
=
value
break
;
default
:
break
;
}
}
pairs
[
name
]
=
value
}
pairs
[
"experiencias"
]
=
experiencias
pairs
[
"estudios"
]
=
estudios
pairs
[
"tecnologias"
]
=
tecnologias
pairs
[
"experiencias"
]
=
experiencias
.
filter
(
exp
=>
exp
)
//eliminacion de nulos
pairs
[
"estudios"
]
=
estudios
.
filter
(
est
=>
est
)
//eliminacion de nulos
pairs
[
"tecnologias"
]
=
tecnologias
.
filter
(
tec
=>
tec
)
//eliminacion de nulos
// Return the JSON string
return
JSON
.
stringify
(
pairs
,
null
,
2
);
...
...
curriculumsearch/src/main/webapp/jsp/postulante-form.jsp
View file @
37797605
...
...
@@ -68,35 +68,53 @@
<input
type=
"text"
class=
"form-control "
name=
"modalidad"
id=
"modalidad"
>
</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"
class=
"btn btn-primary"
data-toggle=
"modal"
data-target=
"#experienciaForm"
>
Agregar Experiencia
</button>
<div
id=
"experiencias"
>
</div>
<button
type=
"submit"
class=
"btn btn-primary"
>
Submit
</button>
</form>
<!-- Optional JavaScript; choose one of the two! -->
<div
class=
"modal fade"
id=
"experienciaForm"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"experienciaForm"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
role=
"document"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<h5
class=
"modal-title"
id=
"exampleModalLabel"
>
Experiencia
</h5>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
>
<span
aria-hidden=
"true"
>
×
</span>
</button>
</div>
<div
class=
"modal-body"
>
<form
name=
"experiencia-form"
>
<label
for=
"institucion"
class=
"form-label"
>
Institucion
</label>
<input
type=
"text"
class=
"form-control "
name=
"institucion"
id=
"institucion"
>
<label
for=
"fechaDesde"
class=
"form-label"
>
FechaDesde
</label>
<input
type=
"date"
class=
"form-control "
name=
"fechaDesde"
id=
"fechaDesde"
>
<label
for=
"fechaHasta"
class=
"form-label"
>
Fecha Hasta
</label>
<input
type=
"date"
class=
"form-control "
name=
"fechaHasta"
id=
"fechaHasta"
>
<label
for=
"cargo"
class=
"form-label"
>
Cargo
</label>
<input
type=
"cargo"
class=
"form-control "
name=
"cargo"
id=
"cargo"
>
<label
for=
"refNombre"
class=
"form-label"
>
Referencia Nombre
</label>
<input
type=
"text"
class=
"form-control "
name=
"referencias"
id=
"refNombre"
>
</form>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-secondary"
data-dismiss=
"modal"
>
Close
</button>
<button
type=
"button"
class=
"btn btn-primary"
onclick=
"agregarFieldExpierncia()"
data-dismiss=
"modal"
>
Agregar
</button>
</div>
</div>
</div>
</div>
<!-- Option 1: Bootstrap Bundle with Popper -->
<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>
<!-- Optional JavaScript; choose one of the two! -->
<!-- Option 2: Separate Popper and Bootstrap JS -->
<!--
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.10.2/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
-->
<script
src=
"https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity=
"sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin=
"anonymous"
></script>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity=
"sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin=
"anonymous"
></script>
<script
src=
"https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity=
"sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin=
"anonymous"
></script>
<script
src=
"./main.js"
></script>
</body>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment