meta-enc 1.4.9 → 1.4.10
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/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 +136 -252
- 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 +0 -1
- package/dist/server/table-casilleros.d.ts.map +1 -0
- package/dist/server/table-casilleros.ts +88 -0
- package/dist/server/table-casilleros_principales.d.ts +0 -1
- package/dist/server/table-casilleros_principales.d.ts.map +1 -0
- package/dist/server/table-casilleros_principales.ts +10 -0
- package/dist/server/table-formularios_json.d.ts +0 -1
- package/dist/server/table-formularios_json.d.ts.map +1 -0
- package/dist/server/table-formularios_json.ts +15 -0
- package/dist/server/table-subcasilleros.d.ts +0 -1
- package/dist/server/table-tipoc.d.ts +0 -1
- 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 +0 -1
- 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 +0 -1
- package/dist/server/table-unidad_analisis.d.ts.map +1 -0
- 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/tipoc_tipoc.tab.bak +23 -0
- package/package.json +2 -2
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export const defConfig=`
|
|
2
|
+
server:
|
|
3
|
+
port: 3055
|
|
4
|
+
base-url: /meta-enc
|
|
5
|
+
session-store: memory
|
|
6
|
+
db:
|
|
7
|
+
motor: postgresql
|
|
8
|
+
host: localhost
|
|
9
|
+
database: metaenc_db
|
|
10
|
+
schema: meta
|
|
11
|
+
user: meta_user
|
|
12
|
+
install:
|
|
13
|
+
dump:
|
|
14
|
+
db:
|
|
15
|
+
owner: meta_owner
|
|
16
|
+
scripts:
|
|
17
|
+
post-adapt:
|
|
18
|
+
- casilleros_orden_total_fun.sql
|
|
19
|
+
- casilleros_jerarquizados_fun.sql
|
|
20
|
+
- ../node_modules/pg-triggers/lib/recreate-his.sql
|
|
21
|
+
- ../node_modules/pg-triggers/lib/table-changes.sql
|
|
22
|
+
- ../node_modules/pg-triggers/lib/function-changes-trg.sql
|
|
23
|
+
- ../node_modules/pg-triggers/lib/enance.sql
|
|
24
|
+
skip-content: true
|
|
25
|
+
login:
|
|
26
|
+
table: usuarios
|
|
27
|
+
userFieldName: usuario
|
|
28
|
+
passFieldName: md5clave
|
|
29
|
+
rolFieldName: rol
|
|
30
|
+
infoFieldList: [usuario, rol]
|
|
31
|
+
activeClausule: activo
|
|
32
|
+
lockedClausule: not activo
|
|
33
|
+
plus:
|
|
34
|
+
allowHttpLogin: true
|
|
35
|
+
fileStore: false
|
|
36
|
+
skipCheckAlreadyLoggedIn: true
|
|
37
|
+
loginForm:
|
|
38
|
+
formTitle: metaEncuesta
|
|
39
|
+
usernameLabel: usuario
|
|
40
|
+
passwordLabel: clave
|
|
41
|
+
buttonLabel: entrar
|
|
42
|
+
formImg: img/login-lock-icon.png
|
|
43
|
+
chPassForm:
|
|
44
|
+
usernameLabel: usuario
|
|
45
|
+
oldPasswordLabel: clave anterior
|
|
46
|
+
newPasswordLabel: nueva clave
|
|
47
|
+
repPasswordLabel: repetir nueva clave
|
|
48
|
+
buttonLabel: Cambiar
|
|
49
|
+
formTitle: Cambio de clave
|
|
50
|
+
messages:
|
|
51
|
+
userOrPassFail: el nombre de usuario no existe o la clave no corresponde
|
|
52
|
+
lockedFail: el usuario se encuentra bloqueado
|
|
53
|
+
inactiveFail: es usuario está marcado como inactivo
|
|
54
|
+
client-setup:
|
|
55
|
+
cursors: true
|
|
56
|
+
lang: es
|
|
57
|
+
skin: ""
|
|
58
|
+
menu: true
|
|
59
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"procedures-meta-enc.d.ts","sourceRoot":"","sources":["../../src/server/procedures-meta-enc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAqdpF,QAAA,IAAI,iBAAiB;;;;;;;;;;;4BA7YmB,gBAAgB,cAAa,sBAAsB;GA8Z1F,CAAC;AACF,OAAO,EAAC,iBAAiB,EAAC,CAAC"}
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var changing = require('best-globals').changing;
|
|
4
|
+
var bestGlobals = require('best-globals');
|
|
5
|
+
var datetime = bestGlobals.datetime;
|
|
6
|
+
var fs = require('fs-extra');
|
|
7
|
+
var likeAr = require('like-ar');
|
|
8
|
+
|
|
9
|
+
//var ProceduresMetaEnc = {};
|
|
10
|
+
|
|
11
|
+
var ProcedureCasillerosDesplegar={
|
|
12
|
+
action:'operativo_estructura',
|
|
13
|
+
parameters:[
|
|
14
|
+
{name:'operativo' ,typeName:'text', references:'operativos'},
|
|
15
|
+
],
|
|
16
|
+
resultOk:'desplegarFormulario',
|
|
17
|
+
coreFunction:function(context, parameters){
|
|
18
|
+
return context.client.query(
|
|
19
|
+
"select casilleros_jerarquizados($1)",
|
|
20
|
+
[parameters.operativo]
|
|
21
|
+
).fetchUniqueValue().then(function(result){
|
|
22
|
+
return result.value;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
var ProcedureFormularioEstructura={
|
|
28
|
+
action:'formulario_estructura',
|
|
29
|
+
method:'get',
|
|
30
|
+
parameters:[
|
|
31
|
+
{name:'operativo' ,typeName:'text', references:'operativos'},
|
|
32
|
+
{name:'formulario' ,typeName:'text', },
|
|
33
|
+
],
|
|
34
|
+
coreFunction:function(context, parameters){
|
|
35
|
+
return context.client.query(
|
|
36
|
+
"select casilleros_jerarquizados($1, $2)",
|
|
37
|
+
[parameters.operativo, parameters.formulario]
|
|
38
|
+
).fetchUniqueRow().then(function(result){
|
|
39
|
+
return result.row;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
var ProcedureCasoGuardar = {
|
|
45
|
+
action:'caso_guardar',
|
|
46
|
+
parameters:[
|
|
47
|
+
{name:'operativo' , typeName:'text', references:'operativos'},
|
|
48
|
+
{name:'id_caso' , typeName:'text' },
|
|
49
|
+
{name:'datos_caso' , typeName:'jsonb' },
|
|
50
|
+
],
|
|
51
|
+
coreFunction:function(context, parameters){
|
|
52
|
+
var client=context.client;
|
|
53
|
+
var be=context.be;
|
|
54
|
+
return Promise.resolve().then(function(){
|
|
55
|
+
return client.query('update formularios_json set datos_caso = $3 where operativo = $1 and id_caso=$2 returning *', [parameters.operativo, parameters.id_caso, parameters.datos_caso]).fetchOneRowIfExists().then(function(result){
|
|
56
|
+
if (result.rowCount===0){
|
|
57
|
+
return client.query("insert into formularios_json(operativo, id_caso, datos_caso) values ($1, $2, $3) returning *",
|
|
58
|
+
[parameters.operativo, parameters.id_caso, parameters.datos_caso]).fetchUniqueRow();
|
|
59
|
+
}else {
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}).then(function(result){
|
|
64
|
+
return result.row;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
var ProcedureNuevaEncuesta={
|
|
70
|
+
action: 'caso_nuevo',
|
|
71
|
+
parameters: [
|
|
72
|
+
{name:'operativo' ,references:'operativos', typeName:'text'},
|
|
73
|
+
],
|
|
74
|
+
resultOk: 'goToEnc',
|
|
75
|
+
coreFunction: function(context, parameters){
|
|
76
|
+
return context.client.query(
|
|
77
|
+
`select *
|
|
78
|
+
from unidad_analisis
|
|
79
|
+
where principal = true and operativo = $1
|
|
80
|
+
`,
|
|
81
|
+
[parameters.operativo]
|
|
82
|
+
).fetchOneRowIfExists().then(function(result){
|
|
83
|
+
if (result.rowCount === 0){
|
|
84
|
+
throw new Error('No se configuró una unidad de analisis como principal');
|
|
85
|
+
}
|
|
86
|
+
return result.row;
|
|
87
|
+
}).then(function(row){
|
|
88
|
+
var be=context.be;
|
|
89
|
+
return be.procedure['preguntas_ua_traer'].coreFunction(context, row).then(function(result){
|
|
90
|
+
var object = {};
|
|
91
|
+
result.forEach(function(question){
|
|
92
|
+
object[question.var_name] = question.unidad_analisis?[]:null;
|
|
93
|
+
});
|
|
94
|
+
return context.client.query(
|
|
95
|
+
`insert into formularios_json values ($1,(select (coalesce(max(id_caso::integer),0) + 1)::text from formularios_json where operativo = $1),$2) returning *`,
|
|
96
|
+
[row.operativo, object]
|
|
97
|
+
).fetchUniqueRow().then(function(result){
|
|
98
|
+
return be.procedure['caso_traer'].coreFunction(context, result.row);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
var ProcedureTraerCaso={
|
|
106
|
+
action: 'caso_traer',
|
|
107
|
+
parameters: [
|
|
108
|
+
{name:'operativo' ,references:'operativos', typeName:'text'},
|
|
109
|
+
{name:'id_caso' ,typeName:'text'},
|
|
110
|
+
],
|
|
111
|
+
resultOk: 'goToEnc',
|
|
112
|
+
coreFunction: function(context, parameters){
|
|
113
|
+
return context.client.query(
|
|
114
|
+
`select f.*, c.id_casillero as formulario
|
|
115
|
+
from formularios_json f join casilleros c on f.operativo = c.operativo
|
|
116
|
+
where c.operativo = $1 and f.id_caso=$2 and c.formulario_principal
|
|
117
|
+
`,
|
|
118
|
+
[parameters.operativo, parameters.id_caso]
|
|
119
|
+
).fetchOneRowIfExists().then(function(result){
|
|
120
|
+
if (result.rowCount === 0){
|
|
121
|
+
throw new Error('No existe dicho formulario cargado en DB');
|
|
122
|
+
}else if (!result.row.datos_caso) {
|
|
123
|
+
throw new Error('El campo forms_js se encuentra vacío, verifique si la encuesta está bien rescatada');
|
|
124
|
+
}
|
|
125
|
+
return result.row;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
var ProcedureTraerPreguntasUnidadAnalisis={
|
|
131
|
+
action: 'preguntas_ua_traer',
|
|
132
|
+
parameters: [
|
|
133
|
+
{name:'operativo' ,references:'operativos', typeName:'text'},
|
|
134
|
+
{name:'unidad_analisis' ,typeName:'text' },
|
|
135
|
+
],
|
|
136
|
+
coreFunction: function(context, parameters){
|
|
137
|
+
return context.client.query(
|
|
138
|
+
`(select lower(c1.var_name) as var_name, false as unidad_analisis, tipovar, orden:: integer, orden_total
|
|
139
|
+
from casilleros c1, lateral casilleros_recursivo(operativo, id_casillero),
|
|
140
|
+
(select operativo, id_casillero from casilleros where operativo =$1 and unidad_analisis=$2 and tipoc='F') c0
|
|
141
|
+
where c1.operativo =c0.operativo and ultimo_ancestro = c0.id_casillero and c1.tipovar is not null
|
|
142
|
+
)
|
|
143
|
+
union
|
|
144
|
+
(
|
|
145
|
+
select unidad_analisis as var_name, true as unidad_analisis, null as tipovar, orden::integer, null as orden_total
|
|
146
|
+
from unidad_analisis
|
|
147
|
+
where operativo = $1 and padre = $2
|
|
148
|
+
)
|
|
149
|
+
order by orden_total
|
|
150
|
+
`,
|
|
151
|
+
[parameters.operativo, parameters.unidad_analisis]
|
|
152
|
+
).fetchAll().then(function(result){
|
|
153
|
+
return result.rows;
|
|
154
|
+
}).catch(function(err){
|
|
155
|
+
console.log('ERROR',err.message);
|
|
156
|
+
throw err;
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
var ProcedureObtenerVariablesUnidadAnalisis={
|
|
162
|
+
action: 'variables_ua_obtener',
|
|
163
|
+
parameters: [
|
|
164
|
+
{name:'operativo' ,references:'operativos', typeName:'text'},
|
|
165
|
+
{name:'unidad_analisis' ,typeName:'text' },
|
|
166
|
+
],
|
|
167
|
+
coreFunction: async function(context, parameters){
|
|
168
|
+
var sqlParams=[parameters.operativo, parameters.unidad_analisis];
|
|
169
|
+
var results = {
|
|
170
|
+
variables: await context.client.query(
|
|
171
|
+
`select var_name, false as unidad_analisis, tipovar, orden:: integer
|
|
172
|
+
from casilleros c1, lateral casilleros_recursivo(operativo, id_casillero),
|
|
173
|
+
(select operativo, id_casillero from casilleros where operativo =$1 and unidad_analisis=$2 and tipoc='F') c0
|
|
174
|
+
where c1.operativo =c0.operativo and ultimo_ancestro = c0.id_casillero and c1.tipovar is not null
|
|
175
|
+
order by orden_total
|
|
176
|
+
`, sqlParams
|
|
177
|
+
).fetchAll(),
|
|
178
|
+
unidadAnalisisHijas: await context.client.query(`
|
|
179
|
+
select unidad_analisis as var_name, true as unidad_analisis, null as tipovar, orden::integer
|
|
180
|
+
from unidad_analisis
|
|
181
|
+
where operativo = $1 and padre = $2
|
|
182
|
+
`, sqlParams
|
|
183
|
+
).fetchAll()
|
|
184
|
+
};
|
|
185
|
+
return likeAr(results).map(result => result.rows);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
var ProcedureTraerPreguntasOperativo={
|
|
190
|
+
action: 'preguntas_operativo_traer',
|
|
191
|
+
parameters: [
|
|
192
|
+
{name:'operativo' ,references:'operativos', typeName:'text'},
|
|
193
|
+
],
|
|
194
|
+
coreFunction: function(context, parameters){
|
|
195
|
+
return context.client.query(
|
|
196
|
+
`
|
|
197
|
+
select
|
|
198
|
+
ua.unidad_analisis,
|
|
199
|
+
c.id_casillero as id_casillero_formulario,
|
|
200
|
+
c.casillero as casillero_formulario,
|
|
201
|
+
coalesce(principal, false)::boolean as unidad_de_analisis_principal,
|
|
202
|
+
ua.padre as unidad_analisis_padre,
|
|
203
|
+
coalesce(
|
|
204
|
+
(select jsonb_agg(aux)
|
|
205
|
+
from (
|
|
206
|
+
(
|
|
207
|
+
select lower(c1.var_name) as var_name, false as es_unidad_analisis, orden::integer, orden_total
|
|
208
|
+
from casilleros c1, lateral casilleros_recursivo(operativo, id_casillero),
|
|
209
|
+
(select operativo, id_casillero from casilleros where operativo =$1 and unidad_analisis=ua.unidad_analisis and tipoc='F') c0
|
|
210
|
+
where c1.operativo =c0.operativo and ultimo_ancestro = c0.id_casillero and c1.tipovar is not null
|
|
211
|
+
union
|
|
212
|
+
select unidad_analisis as var_name, true as es_unidad_analisis, orden::integer, null as orden_total
|
|
213
|
+
from unidad_analisis
|
|
214
|
+
where operativo = $1 and padre = ua.unidad_analisis
|
|
215
|
+
)
|
|
216
|
+
order by orden_total
|
|
217
|
+
) as aux
|
|
218
|
+
)
|
|
219
|
+
,'[]'::jsonb) as preguntas
|
|
220
|
+
from unidad_analisis ua inner join casilleros c on ua.unidad_analisis = c.unidad_analisis and tipoc = 'F' and c.operativo = $1
|
|
221
|
+
where ua.operativo = $1
|
|
222
|
+
group by ua.unidad_analisis, c.id_casillero, c.casillero, principal, ua.padre
|
|
223
|
+
`,
|
|
224
|
+
[parameters.operativo]
|
|
225
|
+
).fetchAll().then(function(result){
|
|
226
|
+
return result.rows;
|
|
227
|
+
}).catch(function(err){
|
|
228
|
+
console.log('ERROR',err.message);
|
|
229
|
+
throw err;
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
//TODO: REVISAR esto estaba en la app Repsic
|
|
235
|
+
var ProcedureGenerateVariablesRelevadas={
|
|
236
|
+
action: 'variables_relevadas/generar',
|
|
237
|
+
parameters: [
|
|
238
|
+
{ name: 'operativo', typeName: 'text', references: 'operativos', }
|
|
239
|
+
],
|
|
240
|
+
coreFunction: async function (context, parameters) {
|
|
241
|
+
var be = context.be;
|
|
242
|
+
var db = be.db;
|
|
243
|
+
await context.client.query(
|
|
244
|
+
`DELETE FROM variables_opciones op
|
|
245
|
+
WHERE EXISTS
|
|
246
|
+
(SELECT variable FROM variables v
|
|
247
|
+
WHERE v.operativo=op.operativo and v.variable=op.variable
|
|
248
|
+
and v.clase='relevamiento' and v.operativo=$1)`
|
|
249
|
+
, [parameters.operativo]
|
|
250
|
+
).execute();
|
|
251
|
+
await context.client.query(
|
|
252
|
+
`DELETE FROM varcal.variables WHERE operativo = $1 and clase = 'relevamiento'`,
|
|
253
|
+
[parameters.operativo]
|
|
254
|
+
).execute();
|
|
255
|
+
await context.client.query(`INSERT INTO varcal.variables(
|
|
256
|
+
operativo, variable, unidad_analisis, tipovar, nombre, activa,
|
|
257
|
+
clase, cerrada)
|
|
258
|
+
select c1.operativo, var_name, c0.unidad_analisis,
|
|
259
|
+
case tipovar
|
|
260
|
+
when 'si_no' then 'opciones'
|
|
261
|
+
when 'si_no_nn' then 'opciones'
|
|
262
|
+
else tipovar end,
|
|
263
|
+
nombre, true,
|
|
264
|
+
'relevamiento', true
|
|
265
|
+
from casilleros c1, lateral casilleros_recursivo(operativo, id_casillero),
|
|
266
|
+
(select operativo, id_casillero, unidad_analisis from casilleros where operativo =$1 and tipoc='F') c0
|
|
267
|
+
where c1.operativo =c0.operativo and ultimo_ancestro = c0.id_casillero and c1.tipovar is not null
|
|
268
|
+
order by orden_total`,
|
|
269
|
+
[parameters.operativo]
|
|
270
|
+
).execute();
|
|
271
|
+
await context.client.query(`
|
|
272
|
+
with pre as (
|
|
273
|
+
select c1.operativo, var_name, c0.unidad_analisis, tipovar, orden_total, c1.id_casillero
|
|
274
|
+
from casilleros c1, lateral casilleros_recursivo(operativo, id_casillero),
|
|
275
|
+
(select operativo, id_casillero,unidad_analisis from casilleros where operativo = $1 and tipoc='F') c0
|
|
276
|
+
where c1.operativo =c0.operativo and ultimo_ancestro = c0.id_casillero and c1.tipovar is not null
|
|
277
|
+
order by orden_total
|
|
278
|
+
)
|
|
279
|
+
INSERT INTO varcal.variables_opciones(
|
|
280
|
+
operativo, variable, opcion, nombre, orden)
|
|
281
|
+
select op.operativo, pre.var_name, casillero::integer,op.nombre, orden
|
|
282
|
+
from pre join casilleros op on pre.operativo=op.operativo and pre.id_casillero=op.padre
|
|
283
|
+
order by orden_total, orden`
|
|
284
|
+
, [parameters.operativo]
|
|
285
|
+
).execute();
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
var ProcedureGenerateTableDef={
|
|
290
|
+
action: 'tabledef_generate',
|
|
291
|
+
parameters: [
|
|
292
|
+
{name:'operativo' ,references:'operativos', typeName:'text'}
|
|
293
|
+
],
|
|
294
|
+
coreFunction: async function(context, parameters){
|
|
295
|
+
var be=context.be;
|
|
296
|
+
try{
|
|
297
|
+
var result = await context.client.query(`
|
|
298
|
+
select *, ${be.sqls.exprFieldUaPkPadre} as pk_padre,
|
|
299
|
+
(select jsonb_agg(to_jsonb(h.*)) from unidad_analisis h where ua.unidad_analisis=h.padre ) as details
|
|
300
|
+
from unidad_analisis ua
|
|
301
|
+
where operativo = $1
|
|
302
|
+
`,[parameters.operativo]
|
|
303
|
+
).fetchAll();
|
|
304
|
+
var UAs = result.rows;
|
|
305
|
+
var result2 = await context.client.query(`
|
|
306
|
+
select *
|
|
307
|
+
from casilleros
|
|
308
|
+
where operativo = $1 and var_name is not null
|
|
309
|
+
`,[parameters.operativo]
|
|
310
|
+
).fetchAll();
|
|
311
|
+
var casillerosConVarname = result2.rows;
|
|
312
|
+
var result = await context.client.query(`select * from tipovar`).fetchAll();
|
|
313
|
+
var tipovars = result.rows;
|
|
314
|
+
var varsByUA = await Promise.all(UAs.map(async function(ua){
|
|
315
|
+
var uaDef = await context.be.procedure['variables_ua_obtener'].coreFunction(context, ua);
|
|
316
|
+
var varsDef = uaDef.variables;
|
|
317
|
+
ua.pk_padre.unshift('operativo');
|
|
318
|
+
ua.pk=ua.pk_padre.concat(ua.pk_agregada);
|
|
319
|
+
var tableDef={
|
|
320
|
+
name:ua.unidad_analisis,
|
|
321
|
+
fields:varsDef.map(function(varDef){
|
|
322
|
+
return {
|
|
323
|
+
name:varDef.var_name,
|
|
324
|
+
typeName:tipovars.find(function(tipovar){return tipovar.tipovar == varDef.tipovar}).type_name,
|
|
325
|
+
nullable: varDef.var_name!=ua.pk_agregada
|
|
326
|
+
}
|
|
327
|
+
}),
|
|
328
|
+
primaryKey:ua.pk,
|
|
329
|
+
detailTables:(ua.details||[]).map(function(detailDef){
|
|
330
|
+
return {table: detailDef.unidad_analisis, fields:ua.pk, abr:detailDef.unidad_analisis.substr(0,1)}
|
|
331
|
+
}),
|
|
332
|
+
}
|
|
333
|
+
if(ua.padre){
|
|
334
|
+
tableDef.foreignKeys=[
|
|
335
|
+
{references: ua.padre, fields:ua.pk_padre}
|
|
336
|
+
];
|
|
337
|
+
}
|
|
338
|
+
if(ua.principal){
|
|
339
|
+
tableDef.fields.unshift({
|
|
340
|
+
name:ua.pk_agregada,
|
|
341
|
+
typeName:'text',
|
|
342
|
+
nullable: false
|
|
343
|
+
})
|
|
344
|
+
tableDef.fields.unshift({
|
|
345
|
+
name:'operativo',
|
|
346
|
+
typeName:'text',
|
|
347
|
+
visible: false,
|
|
348
|
+
nullable: false
|
|
349
|
+
})
|
|
350
|
+
}else{
|
|
351
|
+
for(var i=ua.pk_padre.length; i>0; i--){
|
|
352
|
+
var casileroEncontrado = casillerosConVarname.find(function(casillero){
|
|
353
|
+
return casillero.var_name == ua.pk_padre[i-1];
|
|
354
|
+
});
|
|
355
|
+
tableDef.fields.unshift({
|
|
356
|
+
name:ua.pk_padre[i-1],
|
|
357
|
+
typeName:casileroEncontrado?(tipovars.find(function(tipovar){return tipovar.tipovar == casileroEncontrado.tipovar}).type_name):'text',
|
|
358
|
+
nullable: false
|
|
359
|
+
})
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
var jsTextFile=`"use strict";
|
|
363
|
+
|
|
364
|
+
module.exports = function(context){
|
|
365
|
+
var admin=context.user.rol==='admin';
|
|
366
|
+
return context.be.tableDefAdapt(${JSON.stringify(tableDef, null, 4)},context);
|
|
367
|
+
}`;
|
|
368
|
+
var tsTextFile=`"use strict";
|
|
369
|
+
|
|
370
|
+
import {TableDefinition, TableContext} from "backend-plus";
|
|
371
|
+
export function ${tableDef.name}(context:TableContext):TableDefinition {
|
|
372
|
+
var admin=context.user.rol==='admin';
|
|
373
|
+
return ${JSON.stringify(tableDef, null, 4)};
|
|
374
|
+
}`;
|
|
375
|
+
await fs.writeFile('./local-table-'+ua.unidad_analisis+'.js',jsTextFile,{encoding:'utf8'});
|
|
376
|
+
await fs.writeFile('./local-table-'+ua.unidad_analisis+'.ts',tsTextFile,{encoding:'utf8'});
|
|
377
|
+
}));
|
|
378
|
+
return 'OK';
|
|
379
|
+
}catch(err){
|
|
380
|
+
console.log('ERROR',err.message);
|
|
381
|
+
throw err;
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
var ProceduresMetaEnc = [
|
|
387
|
+
ProcedureCasillerosDesplegar,
|
|
388
|
+
ProcedureFormularioEstructura,
|
|
389
|
+
ProcedureCasoGuardar,
|
|
390
|
+
ProcedureTraerCaso,
|
|
391
|
+
ProcedureNuevaEncuesta,
|
|
392
|
+
ProcedureTraerPreguntasUnidadAnalisis,
|
|
393
|
+
ProcedureTraerPreguntasOperativo,
|
|
394
|
+
ProcedureObtenerVariablesUnidadAnalisis,
|
|
395
|
+
ProcedureGenerateTableDef,
|
|
396
|
+
// ProcedureGenerateVariablesRelevadas
|
|
397
|
+
];
|
|
398
|
+
export {ProceduresMetaEnc};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-meta-enc.d.ts","sourceRoot":"","sources":["../../src/server/server-meta-enc.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-casilleros.d.ts","sourceRoot":"","sources":["../../src/server/table-casilleros.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,YAAY,EAAC,eAAe,EAAC,MAAM,SAAS,CAAA;AAEpD,wBAAgB,UAAU,CAAC,OAAO,EAAC,YAAY,GAAE,eAAe,CAyF/D"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = function(context){
|
|
4
|
+
var admin=context.user.rol==='admin';
|
|
5
|
+
return context.be.tableDefAdapt({
|
|
6
|
+
name:'casilleros',
|
|
7
|
+
elementName:'casillero',
|
|
8
|
+
editable:admin,
|
|
9
|
+
fields:[
|
|
10
|
+
{name:"operativo" , typeName:'text' , editable:admin },
|
|
11
|
+
{name:"id_casillero" , typeName:'text', nullable:true , editable:false },
|
|
12
|
+
{name:"padre" , typeName:'text' , editable:admin },
|
|
13
|
+
{name:"tipoc" , typeName:'text' , editable:admin },
|
|
14
|
+
{name:"casillero" , typeName:'text' , editable:admin },
|
|
15
|
+
{name:"orden" , typeName:'bigint' , editable:admin },
|
|
16
|
+
{name:"ok" , typeName:'text' , editable:false },
|
|
17
|
+
{name:"nombre" , typeName:'text' , editable:admin },
|
|
18
|
+
{name:"tipovar" , typeName:'text' , editable:admin },
|
|
19
|
+
{name:"longitud" , typeName:'text' , editable:admin },
|
|
20
|
+
{name:"tipoe" , typeName:'text' , editable:admin },
|
|
21
|
+
{name:"aclaracion" , typeName:'text' , editable:admin },
|
|
22
|
+
{name:"salto" , typeName:'text' , editable:admin },
|
|
23
|
+
{name:"unidad_analisis" , typeName:'text' , editable:admin },
|
|
24
|
+
{name:"cantidad_resumen" , typeName:'integer' , editable:admin },
|
|
25
|
+
{name:"irrepetible" , typeName:'boolean' , editable:false },
|
|
26
|
+
{name:"despliegue" , typeName:'text' , editable:admin },
|
|
27
|
+
{name:"ver_id" , typeName:'text' , editable:admin },
|
|
28
|
+
{name:"optativo" , typeName:'boolean' , editable:admin },
|
|
29
|
+
{name:"orden_total" , typeName:'ARRAY:text' ,inTable:false , editable:false },
|
|
30
|
+
{name:"ultimo_ancestro" , typeName:'text' ,inTable:false , editable:false },
|
|
31
|
+
{name:"formulario_principal" , typeName:'boolean' , editable:admin },
|
|
32
|
+
{name:"var_name" , typeName:'text' , editable:false },
|
|
33
|
+
{name:"var_name_especial" , typeName:'text' , editable:admin },
|
|
34
|
+
],
|
|
35
|
+
hiddenColumns:['id_casillero', 'irrepetible'],
|
|
36
|
+
sortColumns:[{column:'orden_total'}],
|
|
37
|
+
primaryKey:['operativo','id_casillero'],
|
|
38
|
+
foreignKeys:[
|
|
39
|
+
{references:'operativos', fields:['operativo']},
|
|
40
|
+
{references:'tipoc' , fields:['tipoc']},
|
|
41
|
+
{references:'tipovar' , fields:['tipovar']},
|
|
42
|
+
{references:'casilleros', fields:['operativo', {source:'padre', target:'id_casillero'}], alias:'p' ,consName:'casilleros padre REL', forceDeferrable:true},
|
|
43
|
+
{references:'casilleros', fields:['operativo', {source:'salto', target:'id_casillero'}], alias:'s' ,consName:'casilleros salto REL', forceDeferrable:true}
|
|
44
|
+
],
|
|
45
|
+
detailTables:[
|
|
46
|
+
{table:'casilleros', fields:['operativo',{source:'id_casillero', target:'padre'}], abr:'c', label:'contenido' }
|
|
47
|
+
],
|
|
48
|
+
constraints:[
|
|
49
|
+
{constraintType:'unique', fields:['operativo','casillero','irrepetible']},
|
|
50
|
+
{constraintType:'unique', fields:['operativo','var_name']},
|
|
51
|
+
{constraintType:'check' , expr:'irrepetible is not false' },
|
|
52
|
+
{constraintType:'check' , name:"para poner 'no' en optativo dejar en blanco", expr:'optativo' },
|
|
53
|
+
],
|
|
54
|
+
sql:{
|
|
55
|
+
fields:{
|
|
56
|
+
ok:{
|
|
57
|
+
expr:`coalesce(nullif(
|
|
58
|
+
case when casilleros.padre is not null then
|
|
59
|
+
coalesce((
|
|
60
|
+
select ''::text
|
|
61
|
+
from tipoc_tipoc tt
|
|
62
|
+
where tt.tipoc_padre=p.tipoc and tt.tipoc_hijo=casilleros.tipoc
|
|
63
|
+
), '⛔'::text) -- El hijo no es válido
|
|
64
|
+
else null end
|
|
65
|
+
||case when puede_ser_var is false and casilleros.tipovar is not null then '☒'
|
|
66
|
+
when puede_ser_var is true and casilleros.tipovar is null then '!☐'
|
|
67
|
+
else '' end -- Sobra o falta el tipovar
|
|
68
|
+
||(select case
|
|
69
|
+
when string_agg(lower(nombre), ',' order by nombre)='no,sí' and casilleros.tipoc in ('P','OM') and casilleros.tipovar is distinct from 'si_no' then '!si_no'
|
|
70
|
+
when string_agg(lower(nombre), ',' order by nombre)='no,si' then '!Sí!'
|
|
71
|
+
when count(*)>0 and casilleros.tipoc in ('P','OM') and (casilleros.tipovar is null or casilleros.tipovar not in ('opciones','si_no')) then '!opciones'
|
|
72
|
+
when count(*)>0 and casilleros.tipoc not in ('P','OM') then '¬O'
|
|
73
|
+
when count(*)=0 and casilleros.tipoc in ('P','OM') and casilleros.tipovar in ('opciones','si_no') then '!O'
|
|
74
|
+
else '' end
|
|
75
|
+
from casilleros h
|
|
76
|
+
where h.padre=casilleros.id_casillero and h.operativo=casilleros.operativo
|
|
77
|
+
and h.tipoc='O') -- faltan o sobran hijos opciones
|
|
78
|
+
,''),'✔')
|
|
79
|
+
`
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
isTable:true,
|
|
83
|
+
from:'(select * from casilleros, lateral casilleros_recursivo(operativo, id_casillero))',
|
|
84
|
+
postCreateSqls:'create trigger irrepetible_trg before insert or update on casilleros for each row execute procedure irrepetible_trg();',
|
|
85
|
+
constraintsDeferred:true,
|
|
86
|
+
}
|
|
87
|
+
},context);
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-casilleros_principales.d.ts","sourceRoot":"","sources":["../../src/server/table-casilleros_principales.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,YAAY,EAAC,eAAe,EAAC,MAAM,SAAS,CAAC;AAErD,wBAAgB,sBAAsB,CAAC,OAAO,EAAC,YAAY,GAAE,eAAe,CAK3E"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var tableCasilleros = require('./table-casilleros.js')
|
|
4
|
+
|
|
5
|
+
module.exports = function(context){
|
|
6
|
+
var def = tableCasilleros(context);
|
|
7
|
+
def.filterColumns = [{column:'padre', operator:'\u2205', value:null}];
|
|
8
|
+
def.sql.isTable=false;
|
|
9
|
+
return def;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-formularios_json.d.ts","sourceRoot":"","sources":["../../src/server/table-formularios_json.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = function(context){
|
|
4
|
+
var admin=context.user.rol==='admin';
|
|
5
|
+
return context.be.tableDefAdapt({
|
|
6
|
+
name:'formularios_json',
|
|
7
|
+
editable:admin,
|
|
8
|
+
fields:[
|
|
9
|
+
{name:"operativo" , typeName:'text' },
|
|
10
|
+
{name:"id_caso" , typeName:'text' },
|
|
11
|
+
{name:"datos_caso" , typeName:'jsonb' },
|
|
12
|
+
],
|
|
13
|
+
primaryKey:['operativo','id_caso'],
|
|
14
|
+
},context);
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-tipoc.d.ts","sourceRoot":"","sources":["../../src/server/table-tipoc.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = function(context){
|
|
4
|
+
var admin=context.user.rol==='admin';
|
|
5
|
+
return context.be.tableDefAdapt({
|
|
6
|
+
name:'tipoc',
|
|
7
|
+
title:'tipos de casillero',
|
|
8
|
+
elementName:'tipo de casillero',
|
|
9
|
+
editable:admin,
|
|
10
|
+
fields:[
|
|
11
|
+
{name:"tipoc" , typeName:'text' },
|
|
12
|
+
{name:"denominacion" , typeName:'text' ,isName:true },
|
|
13
|
+
{name:"irrepetible" , typeName:'boolean' },
|
|
14
|
+
{name:"desp_casillero" , typeName:'text' },
|
|
15
|
+
{name:"desp_hijos" , typeName:'text' },
|
|
16
|
+
{name:"puede_ser_var" , typeName:'boolean' },
|
|
17
|
+
],
|
|
18
|
+
primaryKey:['tipoc'],
|
|
19
|
+
detailTables:[
|
|
20
|
+
{table:'tipoc_tipoc', fields:[{source:'tipoc', target:'tipoc_hijo' }], abr:'p', label:'padres posibles' },
|
|
21
|
+
{table:'tipoc_tipoc', fields:[{source:'tipoc', target:'tipoc_padre'}], abr:'h', label:'hijos posibles' },
|
|
22
|
+
{table:'casilleros' , fields:['tipoc'], abr:'c', label:'casilleros' }
|
|
23
|
+
]
|
|
24
|
+
},context);
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-tipoc_tipoc.d.ts","sourceRoot":"","sources":["../../src/server/table-tipoc_tipoc.ts"],"names":[],"mappings":""}
|