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
3d8622d4
Commit
3d8622d4
authored
Nov 01, 2021
by
Joel Florentin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
agregar experiencias adicionales
parent
f4fb9b53
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
104 additions
and
81 deletions
+104
-81
curriculumsearch/src/main/resources/static/main.js
+99
-0
curriculumsearch/src/main/webapp/jsp/postulante-form.jsp
+5
-81
No files found.
curriculumsearch/src/main/resources/static/main.js
0 → 100644
View file @
3d8622d4
var
cont_experiencia
=
0
;
let
cont_estudios
=
0
;
let
cont_tecnologia
=
0
;
function
agregarFieldExpierncia
(
evt
){
const
btn
=
evt
.
target
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
serializeJSON
(
form
)
{
// Create a new FormData object
const
formData
=
new
FormData
(
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
[
"experiencias"
]
=
experiencias
pairs
[
"estudios"
]
=
estudios
pairs
[
"tecnologias"
]
=
tecnologias
// Return the JSON string
return
JSON
.
stringify
(
pairs
,
null
,
2
);
}
async
function
postData
(
url
=
''
,
data
=
{})
{
// Default options are marked with *
const
response
=
await
fetch
(
url
,
{
method
:
'POST'
,
// *GET, POST, PUT, DELETE, etc.
mode
:
'cors'
,
// no-cors, *cors, same-origin
cache
:
'no-cache'
,
// *default, no-cache, reload, force-cache, only-if-cached
credentials
:
'same-origin'
,
// include, *same-origin, omit
headers
:
{
'Content-Type'
:
'application/json'
// 'Content-Type': 'application/x-www-form-urlencoded',
},
redirect
:
'follow'
,
// manual, *follow, error
referrerPolicy
:
'no-referrer'
,
// no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
body
:
data
// body data type must match "Content-Type" header
});
return
response
;
// parses JSON response into native JavaScript objects
}
form
=
document
.
querySelector
(
"form"
);
form
.
addEventListener
(
"submit"
,(
evt
)
=>
{
postData
(
'postulante'
,
serializeJSON
(
form
))
.
then
(
response
=>
{
console
.
log
(
response
);
// JSON data parsed by `data.json()` call
location
.
replace
(
response
.
url
);
});
evt
.
preventDefault
();
}
);
\ No newline at end of file
curriculumsearch/src/main/webapp/jsp/postulante-form.jsp
View file @
3d8622d4
...
...
@@ -67,7 +67,7 @@
<label
for=
"modalidad"
class=
"form-label"
>
Modalidad
</label>
<input
type=
"text"
class=
"form-control "
name=
"modalidad"
id=
"modalidad"
>
</div>
<fieldset>
<div
class=
"mb-3 col-5"
>
<label
for=
"institucion"
class=
"form-label"
>
Institucion
</label>
...
...
@@ -82,7 +82,8 @@
<input
type=
"text"
class=
"form-control "
name=
"experiencia-0-referencias"
id=
"refNombre"
>
</div>
</fieldset>
<button
type=
"button"
name=
"addExp"
onclick=
"agregarFieldExpierncia(event)"
>
Agregar
</button>
<button
type=
"submit"
class=
"btn btn-primary"
>
Submit
</button>
</form>
...
...
@@ -96,84 +97,6 @@
<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>
let
cont_experiencia
=
0
;
let
cont_estudios
=
0
;
let
cont_tecnologia
=
0
;
function
serializeJSON
(
form
)
{
// Create a new FormData object
const
formData
=
new
FormData
(
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
[
"experiencias"
]
=
experiencias
pairs
[
"estudios"
]
=
estudios
pairs
[
"tecnologias"
]
=
tecnologias
// Return the JSON string
return
JSON
.
stringify
(
pairs
,
null
,
2
);
}
async
function
postData
(
url
=
''
,
data
=
{})
{
// Default options are marked with *
const
response
=
await
fetch
(
url
,
{
method
:
'POST'
,
// *GET, POST, PUT, DELETE, etc.
mode
:
'cors'
,
// no-cors, *cors, same-origin
cache
:
'no-cache'
,
// *default, no-cache, reload, force-cache, only-if-cached
credentials
:
'same-origin'
,
// include, *same-origin, omit
headers
:
{
'Content-Type'
:
'application/json'
// 'Content-Type': 'application/x-www-form-urlencoded',
},
redirect
:
'follow'
,
// manual, *follow, error
referrerPolicy
:
'no-referrer'
,
// no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
body
:
data
// body data type must match "Content-Type" header
});
return
response
;
// parses JSON response into native JavaScript objects
}
form
=
document
.
querySelector
(
"form"
);
form
.
addEventListener
(
"submit"
,(
evt
)
=>
{
postData
(
'postulante'
,
serializeJSON
(
form
))
.
then
(
response
=>
{
console
.
log
(
response
);
// JSON data parsed by `data.json()` call
location
.
replace
(
response
.
url
);
});
evt
.
preventDefault
();
}
);
</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