meta-enc 1.4.5 → 1.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +18 -18
- package/dist/client/meta-enc.d.ts.map +1 -0
- package/dist/client/meta-enc.ts +334 -0
- package/dist/server/app-meta-enc.d.ts +698 -69
- package/dist/server/app-meta-enc.d.ts.map +1 -0
- package/dist/server/app-meta-enc.ts +96 -0
- package/dist/server/def-config.d.ts.map +1 -0
- package/dist/server/def-config.ts +59 -0
- package/dist/server/procedures-meta-enc.d.ts.map +1 -0
- package/dist/server/procedures-meta-enc.ts +398 -0
- package/dist/server/server-meta-enc.d.ts.map +1 -0
- package/dist/server/server-meta-enc.ts +7 -0
- package/dist/server/table-casilleros.d.ts.map +1 -0
- package/dist/server/table-casilleros.js +23 -23
- package/dist/server/table-casilleros.ts +88 -0
- package/dist/server/table-casilleros_principales.d.ts.map +1 -0
- package/dist/server/table-casilleros_principales.js +1 -1
- package/dist/server/table-casilleros_principales.ts +10 -0
- package/dist/server/table-formularios_json.d.ts.map +1 -0
- package/dist/server/table-formularios_json.js +1 -1
- package/dist/server/table-formularios_json.ts +15 -0
- package/dist/server/table-subcasilleros.js +13 -13
- package/dist/server/table-tipoc.d.ts.map +1 -0
- package/dist/server/table-tipoc.ts +25 -0
- package/dist/server/table-tipoc_tipoc.d.ts.map +1 -0
- package/dist/server/table-tipoc_tipoc.ts +20 -0
- package/dist/server/table-unidad_analisis.d.ts.map +1 -0
- package/dist/server/table-unidad_analisis.js +1 -1
- package/dist/server/table-unidad_analisis.ts +29 -0
- package/dist/server/types-meta-enc.d.ts.map +1 -0
- package/dist/server/types-meta-enc.ts +2 -0
- package/install/example-casilleros.tab-ejemplo +26 -26
- package/install/prepare.sql +59 -59
- package/install/tipoc_tipoc.tab +6 -0
- package/install/tipoc_tipoc.tab.bak +23 -0
- package/package.json +51 -51
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 Codenautas
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Codenautas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
# meta-enc
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
language: 
|
|
6
|
-
also available in:
|
|
7
|
-
[](LEEME.md)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
see spanish
|
|
11
|
-
|
|
12
|
-
## License
|
|
13
|
-
|
|
14
|
-
[MIT](LICENSE)
|
|
15
|
-
|
|
16
|
-
----------------
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
|
|
2
|
+
# meta-enc
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
language: 
|
|
6
|
+
also available in:
|
|
7
|
+
[](LEEME.md)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
see spanish
|
|
11
|
+
|
|
12
|
+
## License
|
|
13
|
+
|
|
14
|
+
[MIT](LICENSE)
|
|
15
|
+
|
|
16
|
+
----------------
|
|
17
|
+
|
|
18
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta-enc.d.ts","sourceRoot":"","sources":["../../src/client/meta-enc.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var PANTALLA_RESUMEN = false;
|
|
4
|
+
const MAIN_FORM_ID = 'main-form';
|
|
5
|
+
import * as formStructure from "rel-enc/dist/client/form-structure";
|
|
6
|
+
import { changing } from "best-globals";
|
|
7
|
+
var SurveyManager = formStructure.SurveyManager;
|
|
8
|
+
var FormManager = formStructure.FormManager;
|
|
9
|
+
|
|
10
|
+
function gotoInnerUrl(innerUrl:string){
|
|
11
|
+
history.pushState(null, null, innerUrl);
|
|
12
|
+
my.showPage();
|
|
13
|
+
}
|
|
14
|
+
function onclickUrl(event){
|
|
15
|
+
if(!event.ctrlKey){
|
|
16
|
+
gotoInnerUrl(this.href);
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
myOwn.wScreens.proc.result.goToEnc=function(result, div, opts){
|
|
21
|
+
my.ajax.preguntas_operativo_traer({operativo:result.operativo}).then(function(preguntas){
|
|
22
|
+
var idEnc_js=result.id_caso;
|
|
23
|
+
var idOp_js=result.operativo;
|
|
24
|
+
sessionStorage.setItem('surveyId', idEnc_js);
|
|
25
|
+
sessionStorage.setItem('operativo', idOp_js);
|
|
26
|
+
sessionStorage.setItem('innerPk' , JSON.stringify({}));
|
|
27
|
+
sessionStorage.setItem('formularioPrincipal', result.formulario);
|
|
28
|
+
sessionStorage.setItem('UAInfo', JSON.stringify(preguntas));
|
|
29
|
+
localStorage.setItem('survey_opts', JSON.stringify(opts || {buttons:{guardar:true,devolver:true}}));
|
|
30
|
+
localStorage.setItem(idOp_js + '_survey_' + idEnc_js, JSON.stringify(result.datos_caso));
|
|
31
|
+
div.textContent='Se cargará el caso ' + result.id_caso + '. Redirigiendo...';
|
|
32
|
+
div.style.backgroundColor='#5F5';
|
|
33
|
+
setTimeout(function(){
|
|
34
|
+
gotoInnerUrl('menu#w=formulario&operativo='+result.operativo + '&formulario='+ result.formulario)
|
|
35
|
+
},250);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
myOwn.wScreens.proc.result.desplegarFormulario=function(surveyStructure:formStructure.SurveyStructure, div:HTMLDivElement, surveyData:any, formId:string, formManager?:formStructure.FormManager, formElementsToDisplay?:HTMLElement){
|
|
39
|
+
var surveyOpts = JSON.parse(localStorage.getItem('survey_opts')) || {buttons:{guardar:true,devolver:true}};
|
|
40
|
+
var guardarButton;
|
|
41
|
+
var guardarBottomButton;
|
|
42
|
+
var devolverButton;
|
|
43
|
+
var devolverBottomButton;
|
|
44
|
+
if(surveyOpts.buttons.guardar){
|
|
45
|
+
guardarButton = html.button({id:'guardar-top-button', class:['rel_button', 'guardar']}, "Grabar").create();
|
|
46
|
+
guardarBottomButton = html.button({id:'guardar-bottom-button', class:['rel_button', 'guardar']}, "Grabar").create();
|
|
47
|
+
guardarButton.onclick=guardar;
|
|
48
|
+
guardarBottomButton.onclick=guardar;
|
|
49
|
+
}
|
|
50
|
+
if(surveyOpts.buttons.devolver){
|
|
51
|
+
devolverButton = html.button({id:'devolver-top-button', class:['rel_button', 'devolver']}, "Devolver").create();
|
|
52
|
+
devolverBottomButton = html.button({id:'devolver-bottom-button', class:['rel_button', 'devolver']}, "Devolver").create();
|
|
53
|
+
devolverButton.onclick=devolver;
|
|
54
|
+
devolverBottomButton.onclick=devolver;
|
|
55
|
+
}
|
|
56
|
+
if(PANTALLA_RESUMEN){
|
|
57
|
+
var resumenButton = html.button({id:'summary-button'}, "Resumen").create();
|
|
58
|
+
resumenButton.onclick=verResumen;
|
|
59
|
+
document.getElementById('total-layout').appendChild(resumenButton);
|
|
60
|
+
}
|
|
61
|
+
if(!formElementsToDisplay && !formManager){
|
|
62
|
+
var {formElementsToDisplay, formManager}=my.displayForm(surveyStructure, surveyData, formId, []);
|
|
63
|
+
}
|
|
64
|
+
div.appendChild(html.div({class:'prueba-despliegue'},[
|
|
65
|
+
html.p({id:'genericMsg'},['']),
|
|
66
|
+
]
|
|
67
|
+
.concat([guardarButton, devolverButton])
|
|
68
|
+
.concat([
|
|
69
|
+
html.p({id:'idCaso'},['N° Caso: ',surveyData.idCaso]),
|
|
70
|
+
formElementsToDisplay
|
|
71
|
+
])
|
|
72
|
+
.concat([guardarBottomButton, devolverBottomButton])
|
|
73
|
+
).create());
|
|
74
|
+
formManager.irAlSiguienteDespliegue(formManager.state.primeraVacia,devolverBottomButton);
|
|
75
|
+
SurveyManager.performCustomActionForLoadedFormManager(formManager);
|
|
76
|
+
}
|
|
77
|
+
function verResumen() {
|
|
78
|
+
var summaryDiv = document.getElementById('summary');
|
|
79
|
+
summaryDiv.innerHTML= '';
|
|
80
|
+
var summary = my.displaySummary(sessionStorage.getItem('operativo'), sessionStorage.getItem('surveyId'));
|
|
81
|
+
summaryDiv.appendChild(summary);
|
|
82
|
+
document.getElementById('main-form-wrapper').setAttribute('summary',true);
|
|
83
|
+
document.getElementById('summary-button').onclick = quitarResumen;
|
|
84
|
+
}
|
|
85
|
+
function quitarResumen() {
|
|
86
|
+
document.getElementById('main-form-wrapper').setAttribute('summary', false);
|
|
87
|
+
document.getElementById('summary-button').onclick = verResumen;
|
|
88
|
+
}
|
|
89
|
+
function devolver() {
|
|
90
|
+
guardar().then(function(result){
|
|
91
|
+
var surveyId = sessionStorage.getItem('surveyId');
|
|
92
|
+
var operativo = sessionStorage.getItem('operativo');
|
|
93
|
+
//sessionStorage.setItem('surveyId', ''); /* lo comento para que recuerde el anterior*/
|
|
94
|
+
sessionStorage.setItem('innerPk', '');
|
|
95
|
+
sessionStorage.setItem('operativo', '');
|
|
96
|
+
sessionStorage.setItem('UAInfo', '');
|
|
97
|
+
localStorage.setItem(operativo + '_survey_' + surveyId, '');
|
|
98
|
+
var idCaso = sessionStorage.getItem('surveyId');
|
|
99
|
+
gotoInnerUrl('menu#w=ingresarFormulario&consistir='+idCaso);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function guardar(){
|
|
103
|
+
var surveyId = sessionStorage.getItem('surveyId');
|
|
104
|
+
var operativo = sessionStorage.getItem('operativo');
|
|
105
|
+
var datosCaso = JSON.parse(localStorage.getItem(operativo + '_survey_' + surveyId));
|
|
106
|
+
return my.ajax.caso_guardar({operativo: operativo, id_caso: surveyId, datos_caso: datosCaso})
|
|
107
|
+
.then(function(result){
|
|
108
|
+
document.getElementById('genericMsg').textContent='Encuesta guardada';
|
|
109
|
+
return result;
|
|
110
|
+
})
|
|
111
|
+
.catch(function(error){
|
|
112
|
+
document.getElementById('genericMsg').textContent='Hubo un problema, intente nuevamente.';
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
myOwn.wScreens.formulario=function(addrParams){
|
|
116
|
+
var my=this;
|
|
117
|
+
main_layout.textContent='cargando...';
|
|
118
|
+
var operativo = addrParams.operativo || sessionStorage.getItem('operativo') || null;
|
|
119
|
+
var formulario = addrParams.formulario || sessionStorage.getItem('formularioPrincipal') || null;
|
|
120
|
+
if(operativo && formulario){
|
|
121
|
+
Promise.all([
|
|
122
|
+
my.ajax.operativo_estructura({operativo:operativo}),
|
|
123
|
+
myOwn.getSurveyData(),
|
|
124
|
+
]).then(function(all){
|
|
125
|
+
var structOperativo=all[0];
|
|
126
|
+
var surveyData=all[1];
|
|
127
|
+
if(surveyData.idCaso && surveyData.surveyContent){
|
|
128
|
+
main_layout.innerHTML='';
|
|
129
|
+
my.wScreens.proc.result.desplegarFormulario(structOperativo,main_layout,surveyData,formulario); //MODIFICADO
|
|
130
|
+
}else{
|
|
131
|
+
gotoInnerUrl('menu#w=ingresarFormulario');
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}else{
|
|
135
|
+
gotoInnerUrl('menu#w=ingresarFormulario');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
};
|
|
140
|
+
myOwn.wScreens.cambio_for=function(addrParams){
|
|
141
|
+
// ******************* ANTES QUE NADA ************************
|
|
142
|
+
// ***** revisar si esta función se sigue usando *************
|
|
143
|
+
// ***********************************************************
|
|
144
|
+
var surveyId = sessionStorage.getItem('surveyId');
|
|
145
|
+
//TODO: s.especial https://github.com/codenautas/meta-enc/issues/1
|
|
146
|
+
// acá habría que parametriza el módulo poniendo cuál es la innerPK default y que '{"persona": 0}' vaya a ese parámetro
|
|
147
|
+
var innerPk = JSON.parse(sessionStorage.getItem('innerPk')||'{"persona": 0}');
|
|
148
|
+
//TODO: s.especial https://github.com/codenautas/meta-enc/issues/1
|
|
149
|
+
// acá habría que ver si nombre del atributo "persona" no se puede parametrizar
|
|
150
|
+
var delta = Number(addrParams.delta);
|
|
151
|
+
var newFormId = Number(innerPk.persona) + delta;
|
|
152
|
+
if(addrParams.absoluta){
|
|
153
|
+
newFormId = addrParams.absoluta - 1 || 0;
|
|
154
|
+
}
|
|
155
|
+
if(newFormId<0){
|
|
156
|
+
newFormId = 0;
|
|
157
|
+
}
|
|
158
|
+
if(delta>0){
|
|
159
|
+
var surveyData = JSON.parse(localStorage.getItem(operativo + '_survey_'+ surveyId)); //REVISAR si se puede sacar todo
|
|
160
|
+
if(newFormId>surveyData.forms.F2.length){
|
|
161
|
+
newFormId=surveyData.forms.F2.length;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
innerPk.persona=newFormId;
|
|
165
|
+
sessionStorage.setItem('innerPk', JSON.stringify(innerPk));
|
|
166
|
+
gotoInnerUrl('./menu?i=personas');
|
|
167
|
+
}
|
|
168
|
+
myOwn.displayForm = function displayForm(surveyStructure, surveyData, formId, pilaDeRetroceso){
|
|
169
|
+
var surveyMetadata = {
|
|
170
|
+
operative: sessionStorage.getItem('operativo'),
|
|
171
|
+
structure: surveyStructure,
|
|
172
|
+
mainForm: formId,
|
|
173
|
+
analysisUnitStructure: JSON.parse(sessionStorage.getItem('UAInfo'))
|
|
174
|
+
}
|
|
175
|
+
var surveyManager = new SurveyManager(surveyMetadata, surveyData.idCaso, surveyData.surveyContent);
|
|
176
|
+
var formManager = new FormManager(surveyManager, formId, surveyData.surveyContent, []);
|
|
177
|
+
var toDisplay = formManager.display();
|
|
178
|
+
formManager.validateDepot();
|
|
179
|
+
formManager.refreshState();
|
|
180
|
+
var pantallaResumen = PANTALLA_RESUMEN?html.div({id:'summary'}, my.displaySummary(surveyMetadata.operative, surveyData.idCaso)):null;
|
|
181
|
+
return {
|
|
182
|
+
formElementsToDisplay:html.div({id: 'main-form-wrapper'},[html.div({id: MAIN_FORM_ID}, [toDisplay]), pantallaResumen]),
|
|
183
|
+
formManager: formManager
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
myOwn.displaySummary = function displaySummary(operativo:string, surveyId:string){
|
|
187
|
+
var mySurvey = JSON.parse(localStorage.getItem(operativo +'_survey_'+surveyId));
|
|
188
|
+
//return html.img({id:'summary-img', src:my.path.img + 'local-resumen.png', alt:'imagen resumen'}).create();
|
|
189
|
+
var table = html.table({id:'summary-table'},[
|
|
190
|
+
html.tr({},[
|
|
191
|
+
html.th({},'año'),
|
|
192
|
+
html.th({},'edad'),
|
|
193
|
+
html.th({},'lugar'),
|
|
194
|
+
html.th({colspan:6},'vivienda'),
|
|
195
|
+
html.th({colspan:3},'educ'),
|
|
196
|
+
html.th({colspan:6},'trabajo'),
|
|
197
|
+
html.th({colspan:4},'conv')
|
|
198
|
+
])
|
|
199
|
+
]).create();
|
|
200
|
+
if(mySurvey.personas[0]){
|
|
201
|
+
var persona = mySurvey.personas[0];
|
|
202
|
+
if(persona.p3a){ //TODO: s.especial https://github.com/codenautas/meta-enc/issues/1
|
|
203
|
+
var fechaNac = persona.p3a;
|
|
204
|
+
var fechaNacArray = fechaNac.split('-');
|
|
205
|
+
var date = new Date();
|
|
206
|
+
var j=0;
|
|
207
|
+
for(var i=fechaNacArray[0];i<=date.getFullYear();i++){
|
|
208
|
+
var attrs = j%10==0?{'ten-years':true}:{}
|
|
209
|
+
table.appendChild(
|
|
210
|
+
html.tr(attrs,[
|
|
211
|
+
html.td({'is-first':true, 'is-last':true},i),
|
|
212
|
+
html.td({'is-first':true, 'is-last':true},j),
|
|
213
|
+
].concat(my.completarLugares(persona, i, j))
|
|
214
|
+
.concat(my.completarViviendas(persona, i, j))
|
|
215
|
+
.concat(my.completarEducacion(persona, i, j))
|
|
216
|
+
.concat(my.completarTrabajo(persona, i, j))
|
|
217
|
+
.concat(my.completarConvivencia(persona, i, j))
|
|
218
|
+
).create()
|
|
219
|
+
);
|
|
220
|
+
j++;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return table;
|
|
225
|
+
}
|
|
226
|
+
//TODO: s.especial https://github.com/codenautas/meta-enc/issues/1 Esta función debería estar afuera
|
|
227
|
+
myOwn.completarLugares = function completarLugares(persona, year, age){
|
|
228
|
+
if(age == 0){
|
|
229
|
+
return [html.td({},persona['2_1'])];
|
|
230
|
+
}else{
|
|
231
|
+
var result = persona['annios_personas'].find(function(annioPersona){
|
|
232
|
+
return annioPersona['2a'] == year || annioPersona['2b'] == age;
|
|
233
|
+
})
|
|
234
|
+
return [html.td({'is-first':true, 'is-last':true},result?result['2_3']:'')];
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
//TODO: s.especial https://github.com/codenautas/meta-enc/issues/1 Estas funciones "completar" deberían estar afuera
|
|
238
|
+
myOwn.completarViviendas = function completarViviendas(persona, year, age){
|
|
239
|
+
var result = persona['annios_personas'].find(function(annioPersona){
|
|
240
|
+
return annioPersona['3a'] == year || annioPersona['3b'] == age;
|
|
241
|
+
})
|
|
242
|
+
return [
|
|
243
|
+
html.td({'is-first':true},result?result['3_2']:''),
|
|
244
|
+
html.td({},result?result['3_3']:''),
|
|
245
|
+
html.td({},result?result['3_4']:''),
|
|
246
|
+
html.td({},result?result['3_5']:''),
|
|
247
|
+
html.td({},result?result['3_6']:''),
|
|
248
|
+
html.td({'is-last':true},result?result['3_7']:'')
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
myOwn.completarEducacion = function completarEducacion(persona, year, age){
|
|
252
|
+
var result = persona['annios_personas'].find(function(annioPersona){
|
|
253
|
+
return annioPersona['4a'] == year || annioPersona['4b'] == age;
|
|
254
|
+
})
|
|
255
|
+
return [
|
|
256
|
+
html.td({'is-first':true},result?result['4_2']:''),
|
|
257
|
+
html.td({},result?result['4_3']:''),
|
|
258
|
+
html.td({'is-last':true},result?result['4_4']:'')
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
myOwn.completarTrabajo = function completarTrabajo(persona, year, age){
|
|
262
|
+
var result = persona['annios_personas'].find(function(annioPersona){
|
|
263
|
+
return annioPersona['6a'] == year || annioPersona['6b'] == age;
|
|
264
|
+
})
|
|
265
|
+
return [
|
|
266
|
+
html.td({'is-first':true},result?result['6_2a']:''),
|
|
267
|
+
html.td({},result?result['6_2b']:''),
|
|
268
|
+
html.td({},result?result['6_2c']:''),
|
|
269
|
+
html.td({},result?result['6_2d']:''),
|
|
270
|
+
html.td({},result?result['6_2e']:''),
|
|
271
|
+
html.td({'is-last':true},result?result['6_3']:'')
|
|
272
|
+
]
|
|
273
|
+
}
|
|
274
|
+
myOwn.completarConvivencia = function completarConvivencia(persona, year, age){
|
|
275
|
+
var result = persona['annios_personas'].find(function(annioPersona){
|
|
276
|
+
return annioPersona['7a'] == year || annioPersona['7b'] == age;
|
|
277
|
+
})
|
|
278
|
+
return [
|
|
279
|
+
html.td({'is-first':true},result?result['7_3']:''),
|
|
280
|
+
html.td({},result?result['7_4']:''),
|
|
281
|
+
html.td({},result?result['7_5']:''),
|
|
282
|
+
html.td({'is-last':true},result?result['7_6']:''),
|
|
283
|
+
]
|
|
284
|
+
}
|
|
285
|
+
myOwn.surveyDataEmpty = function surveyDataEmpty(surveyId){
|
|
286
|
+
return JSON.stringify({
|
|
287
|
+
idCaso:surveyId,
|
|
288
|
+
surveyContent:{}
|
|
289
|
+
})
|
|
290
|
+
};
|
|
291
|
+
myOwn.getSurveyData = function getSurveyData(){
|
|
292
|
+
var my = this;
|
|
293
|
+
var surveyId = sessionStorage.getItem('surveyId');
|
|
294
|
+
var operativo = sessionStorage.getItem('operativo');
|
|
295
|
+
var surveyContent = JSON.parse(localStorage.getItem(operativo + '_survey_' + surveyId));
|
|
296
|
+
return {idCaso:surveyId, /*innerPk:innerPk,*/ surveyContent:surveyContent};
|
|
297
|
+
}
|
|
298
|
+
myOwn.wScreens.loadForm=async function(addrParams){
|
|
299
|
+
var idCaso = addrParams.idCaso;
|
|
300
|
+
var formId = addrParams.formId;
|
|
301
|
+
var formData = JSON.parse(addrParams.formData);
|
|
302
|
+
var operativo = addrParams.operativo;
|
|
303
|
+
var surveyStructure:formStructure.SurveyStructure = JSON.parse(localStorage.getItem('estructura-'+operativo));
|
|
304
|
+
var datosCaso:any = JSON.parse(localStorage.getItem(operativo+'_survey_'+idCaso));
|
|
305
|
+
if(!datosCaso){
|
|
306
|
+
var result:any = await my.ajax.caso_traer({operativo:operativo, id_caso: idCaso});
|
|
307
|
+
var preguntas:any = await my.ajax.preguntas_operativo_traer({operativo:result.operativo});
|
|
308
|
+
var idEnc_js=result.id_caso;
|
|
309
|
+
var idOp_js=result.operativo;
|
|
310
|
+
sessionStorage.setItem('surveyId', idEnc_js);
|
|
311
|
+
sessionStorage.setItem('operativo', idOp_js);
|
|
312
|
+
sessionStorage.setItem('innerPk' , JSON.stringify({}));
|
|
313
|
+
sessionStorage.setItem('formularioPrincipal', result.formulario);
|
|
314
|
+
sessionStorage.setItem('UAInfo', JSON.stringify(preguntas));
|
|
315
|
+
localStorage.setItem('survey_opts', JSON.stringify({buttons:{guardar:true,devolver:true}}));
|
|
316
|
+
localStorage.setItem(idOp_js + '_survey_' + idEnc_js, JSON.stringify(result.datos_caso));
|
|
317
|
+
}
|
|
318
|
+
var surveyData:formStructure.SurveyData = myOwn.getSurveyData();
|
|
319
|
+
if(!surveyStructure){
|
|
320
|
+
surveyStructure = await my.ajax.operativo_estructura({operativo:operativo});
|
|
321
|
+
localStorage.setItem('estructura-'+operativo, JSON.stringify(surveyStructure));
|
|
322
|
+
}
|
|
323
|
+
var surveyMetadata:formStructure.SurveyMetadata = {
|
|
324
|
+
operative: operativo,
|
|
325
|
+
structure: surveyStructure,
|
|
326
|
+
mainForm: sessionStorage.getItem('formularioPrincipal'),
|
|
327
|
+
analysisUnitStructure: JSON.parse(sessionStorage.getItem('UAInfo'))
|
|
328
|
+
}
|
|
329
|
+
var surveyManager = new SurveyManager(surveyMetadata, surveyData.idCaso, surveyData.surveyContent);
|
|
330
|
+
//FALTA REVISAR STACK, POSIBLEMENTE SE PUEDA METER EN SESSION STORAGE
|
|
331
|
+
var myForm = new FormManager(surveyManager, formId, formData, []);
|
|
332
|
+
var formElementsToDisplay = myForm.display()
|
|
333
|
+
my.wScreens.proc.result.desplegarFormulario(surveyStructure,main_layout,changing(surveyData,{surveyContent: formData}),formId, myForm, formElementsToDisplay); //MODIFICADO
|
|
334
|
+
};
|