ng-pli-commons 0.0.1662 → 0.0.1663
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/esm2020/lib/services/token.service.mjs +5 -2
- package/esm2020/version.mjs +3 -3
- package/fesm2015/ng-pli-commons.mjs +1572 -1570
- package/fesm2015/ng-pli-commons.mjs.map +1 -1
- package/fesm2020/ng-pli-commons.mjs +1552 -1550
- package/fesm2020/ng-pli-commons.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ import { FormioModule, FormioComponent } from 'formioangular-colfuturo';
|
|
|
17
17
|
import * as i4$2 from '@tinymce/tinymce-angular';
|
|
18
18
|
import { EditorModule } from '@tinymce/tinymce-angular';
|
|
19
19
|
import * as i7 from 'ng-pli-util';
|
|
20
|
-
import { NumberUtil, AuthenticationUtil, JwtUtil, PliPatrocinador, PliPrograma, PliPromocion, HEADER_JSON, Moneda, Rubro, TasaCambio, Proceso, DateUtil, primeLocaleEs, UtilString, EPermission, PliCnfPresupuestoGlobal, PliCnfPresupuestoGlobalRubro, PliCnfPresupuestoAsistente, PliCnfSnapshotToken, PliCnfGuaranteeToken, ETipoPresupuesto, Token, ETypeColumn, SegFilter, EPdfSize, EPdfOrientation, EProceso, RequestPdf, PdfDocument, PliUsuario,
|
|
20
|
+
import { NumberUtil, AuthenticationUtil, JwtUtil, PliPatrocinador, PliPrograma, PliPromocion, HEADER_JSON, Moneda, Rubro, TasaCambio, Proceso, DateUtil, primeLocaleEs, UtilString, EPermission, EFormioKey, PliCnfPresupuestoGlobal, PliCnfPresupuestoGlobalRubro, PliCnfPresupuestoAsistente, PliCnfSnapshotToken, PliCnfGuaranteeToken, ETipoPresupuesto, Token, ETypeColumn, SegFilter, EPdfSize, EPdfOrientation, EProceso, RequestPdf, PdfDocument, PliUsuario, Email, InteractionApplicationUser, ETypeStaticInteraction, SendApplication, EDocumentState, Document, EBudgetError, EBudgetBuildType, ECnfPageSection, DatatableUtil, NgPliUtilModule, ApplicationBudgetTotal, Archive } from 'ng-pli-util';
|
|
21
21
|
import * as i5 from 'primeng/dialog';
|
|
22
22
|
import { DialogModule } from 'primeng/dialog';
|
|
23
23
|
import * as i2$1 from 'primeng/dropdown';
|
|
@@ -31,6 +31,7 @@ import { TieredMenuModule } from 'primeng/tieredmenu';
|
|
|
31
31
|
import * as i4$3 from 'primeng/picklist';
|
|
32
32
|
import { PickListModule } from 'primeng/picklist';
|
|
33
33
|
import { BehaviorSubject, Subject, throwError, Observable } from 'rxjs';
|
|
34
|
+
import * as utils_ from 'formiojs-colfuturo/utils/utils';
|
|
34
35
|
import * as i2 from 'ngx-toastr';
|
|
35
36
|
import * as i4$1 from '@angular/router';
|
|
36
37
|
import { map, catchError } from 'rxjs/operators';
|
|
@@ -45,7 +46,6 @@ import Panzoom__default from 'panzoom/dist/panzoom';
|
|
|
45
46
|
import * as i1$2 from '@angular/fire/compat/auth';
|
|
46
47
|
import 'jquery';
|
|
47
48
|
import * as FileSaver from 'file-saver';
|
|
48
|
-
import * as utils_ from 'formiojs-colfuturo/utils/utils';
|
|
49
49
|
import Cropper from 'cropperjs';
|
|
50
50
|
|
|
51
51
|
class NgPliCommonsService {
|
|
@@ -1209,943 +1209,1470 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImpor
|
|
|
1209
1209
|
args: [LOCALE_ID]
|
|
1210
1210
|
}] } });
|
|
1211
1211
|
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
this.httpClient = httpClient;
|
|
1216
|
-
this.headerJson = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) };
|
|
1217
|
-
}
|
|
1218
|
-
/** It returns the list of form by prom codigo */
|
|
1219
|
-
getByPromCodigo(promCodigo) {
|
|
1220
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getByPromCodigo', { params: new HttpParams().set('promCodigo', promCodigo.toString()) });
|
|
1221
|
-
}
|
|
1222
|
-
/** It returns the list of form by prom codigo */
|
|
1223
|
-
getAll() {
|
|
1224
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getAll');
|
|
1225
|
-
}
|
|
1226
|
-
/** It returns a form by id */
|
|
1227
|
-
getById(id) {
|
|
1228
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getById', {
|
|
1229
|
-
params: new HttpParams().set('id', id)
|
|
1230
|
-
});
|
|
1231
|
-
}
|
|
1232
|
-
/** It saves a form */
|
|
1233
|
-
save(form) {
|
|
1234
|
-
return this.httpClient.post(this.environment.host.backend.configuration + 'form/save', form, this.headerJson);
|
|
1235
|
-
}
|
|
1236
|
-
saveFormMultiPromCodigo(reMultPromCodDto) {
|
|
1237
|
-
return this.httpClient.post(this.environment.host.backend.configuration + 'form/saveMultiaplicacionPromCod', reMultPromCodDto, this.headerJson);
|
|
1238
|
-
}
|
|
1239
|
-
/** It deletes a form by id */
|
|
1240
|
-
delete(id) {
|
|
1241
|
-
return this.httpClient.delete(this.environment.host.backend.configuration + 'form/delete', {
|
|
1242
|
-
params: new HttpParams().set('id', id)
|
|
1243
|
-
});
|
|
1244
|
-
}
|
|
1245
|
-
/** It returns the form according to profile have been setting up in form */
|
|
1246
|
-
getByPromCodigoAccordingToProfile(promCodigo, patCodigo, formId) {
|
|
1247
|
-
let params = new HttpParams()
|
|
1248
|
-
.set('promCodigo', promCodigo.toString())
|
|
1249
|
-
.set('patCodigo', patCodigo.toString())
|
|
1250
|
-
.set('formId', formId !== undefined ? formId : '');
|
|
1251
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getByPromCodigoAndProfile', { params: params });
|
|
1252
|
-
}
|
|
1253
|
-
/** It returns the form according to list of prom codigo */
|
|
1254
|
-
getByListPromCodigo(listPromCod) {
|
|
1255
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getByListPromCodigo', { params: new HttpParams().set('listPromCodigo', listPromCod.toString()) });
|
|
1256
|
-
}
|
|
1257
|
-
/** It remove the redis cache of the form by prom codigo */
|
|
1258
|
-
removeFromCacheByPromCodigo(promCodigo) {
|
|
1259
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'form/removeFromCacheByPromCodigo', {
|
|
1260
|
-
params: new HttpParams().set('promCodigo', promCodigo.toString())
|
|
1261
|
-
});
|
|
1262
|
-
}
|
|
1263
|
-
/** It remove the redis cache of the form by prom codigo */
|
|
1264
|
-
removeFromCacheByPromCodigoAndTitle(promCodigo, title) {
|
|
1265
|
-
return this.httpClient.get(this.environment.host.backend.configuration +
|
|
1266
|
-
'form/removeFromCacheByPromCodigoAndTitle', {
|
|
1267
|
-
params: new HttpParams()
|
|
1268
|
-
.set('promCodigo', promCodigo.toString())
|
|
1269
|
-
.set('title', title)
|
|
1270
|
-
});
|
|
1271
|
-
}
|
|
1272
|
-
/** It remove the redis cache of the form by prom codigo */
|
|
1273
|
-
removeFromCacheByPromCodigoAndProfile(promCodigo, patCodigo, formId, username) {
|
|
1274
|
-
return this.httpClient.get(this.environment.host.backend.configuration +
|
|
1275
|
-
'form/removeFromCacheByPromCodigoAndProfile', {
|
|
1276
|
-
params: new HttpParams()
|
|
1277
|
-
.set('promCodigo', promCodigo.toString())
|
|
1278
|
-
.set('patCodigo', patCodigo.toString())
|
|
1279
|
-
.set('formId', formId)
|
|
1280
|
-
.set('username', username)
|
|
1281
|
-
});
|
|
1282
|
-
}
|
|
1212
|
+
// import * as utils_ from 'formiojs-proyectoscolfuturo/utils/utils';
|
|
1213
|
+
const utils = utils_;
|
|
1214
|
+
class FormioUtil {
|
|
1283
1215
|
/**
|
|
1284
|
-
*
|
|
1285
|
-
* @param
|
|
1216
|
+
* It returns the components formated by panel
|
|
1217
|
+
* @param components
|
|
1218
|
+
* @return the object is [{panel: , items: [{ value: , label: }]}]
|
|
1286
1219
|
*/
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1220
|
+
static getFormattedComponentsByPanel(components) {
|
|
1221
|
+
let result = [];
|
|
1222
|
+
if (components) {
|
|
1223
|
+
let group = null;
|
|
1224
|
+
let object = null;
|
|
1225
|
+
for (const component of components) {
|
|
1226
|
+
if (component[EFormioKey.TITLE_PANEL] !== group) {
|
|
1227
|
+
if (group !== null) {
|
|
1228
|
+
result.push(object);
|
|
1229
|
+
}
|
|
1230
|
+
object = { label: component[EFormioKey.TITLE_PANEL], items: [], toggle: false };
|
|
1231
|
+
group = component[EFormioKey.TITLE_PANEL];
|
|
1232
|
+
}
|
|
1233
|
+
object.items.push({
|
|
1234
|
+
label: component[EFormioKey.LABEL],
|
|
1235
|
+
value: component[EFormioKey.KEY]
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1238
|
+
if (group !== null)
|
|
1239
|
+
result.push(object);
|
|
1240
|
+
}
|
|
1241
|
+
return result;
|
|
1291
1242
|
}
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1243
|
+
/**
|
|
1244
|
+
* It returns the components are required according with data
|
|
1245
|
+
* @param components array of components
|
|
1246
|
+
* @param data
|
|
1247
|
+
*/
|
|
1248
|
+
static getRequiredComponentsByData(components, data) {
|
|
1249
|
+
// get the required components
|
|
1250
|
+
let array = FormioUtil.getRequiredComponents(components);
|
|
1251
|
+
// if not data then return components
|
|
1252
|
+
if (data && array) {
|
|
1253
|
+
for (let i = 0; i < array.length; i++) {
|
|
1254
|
+
const component = array[i];
|
|
1255
|
+
// use formio to check condition according with data
|
|
1256
|
+
if (utils.checkCondition(component, null, data, null, null)) {
|
|
1257
|
+
const key = component[EFormioKey.KEY];
|
|
1258
|
+
if (data[key] != undefined && data[key] != null && data[key] != '') {
|
|
1259
|
+
// remove item from array
|
|
1260
|
+
array.splice(i, 1);
|
|
1261
|
+
i--;
|
|
1262
|
+
}
|
|
1263
|
+
else {
|
|
1264
|
+
if (component.customConditional &&
|
|
1265
|
+
component.customConditional.includes('show')) {
|
|
1266
|
+
// remove item from array
|
|
1267
|
+
array.splice(i, 1);
|
|
1268
|
+
i--;
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
else {
|
|
1273
|
+
// remove item from array
|
|
1274
|
+
array.splice(i, 1);
|
|
1275
|
+
i--;
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
return array;
|
|
1298
1280
|
}
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
});
|
|
1281
|
+
/**
|
|
1282
|
+
* It returns the components that are required
|
|
1283
|
+
* @param components array of components
|
|
1284
|
+
*/
|
|
1285
|
+
static getUniqueComponents(components) {
|
|
1286
|
+
return FormioUtil.getComponentsByFeature(components, [EFormioKey.UNIQUE], true);
|
|
1306
1287
|
}
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
providedIn: 'root'
|
|
1314
|
-
}]
|
|
1315
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1316
|
-
type: Inject,
|
|
1317
|
-
args: ['environment']
|
|
1318
|
-
}] }, { type: i1.HttpClient }]; } });
|
|
1319
|
-
|
|
1320
|
-
class TokenService {
|
|
1321
|
-
constructor(environment, httpClient, formService, currencyPipe) {
|
|
1322
|
-
this.environment = environment;
|
|
1323
|
-
this.httpClient = httpClient;
|
|
1324
|
-
this.formService = formService;
|
|
1325
|
-
this.currencyPipe = currencyPipe;
|
|
1288
|
+
/**
|
|
1289
|
+
* It returns the components that are required
|
|
1290
|
+
* @param components array of components
|
|
1291
|
+
*/
|
|
1292
|
+
static getRequiredComponents(components) {
|
|
1293
|
+
return FormioUtil.getComponentsByFeature(components, [EFormioKey.VALIDATE, EFormioKey.REQUIRED], true);
|
|
1326
1294
|
}
|
|
1327
|
-
/**
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1295
|
+
/**
|
|
1296
|
+
* It returns the components that have a specific feature defined by properties and value
|
|
1297
|
+
* @param components array of components
|
|
1298
|
+
* @param properties path of properties example [validate, required] or [unique]
|
|
1299
|
+
* @param value the value that should have the property
|
|
1300
|
+
*/
|
|
1301
|
+
static getComponentsByFeature(components, properties, value) {
|
|
1302
|
+
let result = [];
|
|
1303
|
+
if (properties && properties.length > 0) {
|
|
1304
|
+
// get components
|
|
1305
|
+
const fields = FormioUtil.getComponents(components);
|
|
1306
|
+
// get first and last property
|
|
1307
|
+
const firstProperty = properties[0];
|
|
1308
|
+
const lastProperty = properties[properties.length - 1];
|
|
1309
|
+
if (fields) {
|
|
1310
|
+
// iterate the fields
|
|
1311
|
+
for (let i = 0; i < fields.length; i++) {
|
|
1312
|
+
// it contains the entire object field
|
|
1313
|
+
const field = fields[i];
|
|
1314
|
+
// it contains the current component and it is gonna be the component of every property
|
|
1315
|
+
let component = field;
|
|
1316
|
+
if (field[firstProperty]) {
|
|
1317
|
+
for (let j = 0; j < properties.length; j++) {
|
|
1318
|
+
const property = properties[j];
|
|
1319
|
+
// if component.property doesnt exist then break
|
|
1320
|
+
if (!component[property])
|
|
1321
|
+
break;
|
|
1322
|
+
if (property === lastProperty) {
|
|
1323
|
+
// it is the last property so if the value is equals to component.lastproperty then it is added to result
|
|
1324
|
+
if (component[property] == value)
|
|
1325
|
+
result.push(field);
|
|
1326
|
+
}
|
|
1327
|
+
else {
|
|
1328
|
+
// otherwise component will be equal to the component.property
|
|
1329
|
+
component = component[property];
|
|
1355
1330
|
}
|
|
1356
1331
|
}
|
|
1357
1332
|
}
|
|
1358
|
-
let form = arrayForms;
|
|
1359
|
-
if (!form ||
|
|
1360
|
-
!form[0] ||
|
|
1361
|
-
!form[0].promCodigo ||
|
|
1362
|
-
form[0].promCodigo != promCodigo) {
|
|
1363
|
-
// this.router.navigate(['404']);
|
|
1364
|
-
resolve(lFormFieldsToken);
|
|
1365
|
-
}
|
|
1366
|
-
lFormFieldsToken = [];
|
|
1367
|
-
for (let formComp of form) {
|
|
1368
|
-
let newComponents;
|
|
1369
|
-
let components = [];
|
|
1370
|
-
if (formComp.components) {
|
|
1371
|
-
newComponents = formComp.components;
|
|
1372
|
-
}
|
|
1373
|
-
else if (formComp.columns) {
|
|
1374
|
-
newComponents = formComp.columns;
|
|
1375
|
-
}
|
|
1376
|
-
if (newComponents && UtilString.isValid(formComp.title)) {
|
|
1377
|
-
lFormFieldsToken.push({
|
|
1378
|
-
title: {
|
|
1379
|
-
key: TokenService.getKeyFormulario(formComp.title),
|
|
1380
|
-
value: formComp.title,
|
|
1381
|
-
object: formComp
|
|
1382
|
-
},
|
|
1383
|
-
value: []
|
|
1384
|
-
});
|
|
1385
|
-
lFormFieldsToken[lFormFieldsToken.length - 1].value =
|
|
1386
|
-
this.getComponenetForm(components, newComponents, null, false, null);
|
|
1387
|
-
}
|
|
1388
|
-
}
|
|
1389
|
-
resolve(lFormFieldsToken);
|
|
1390
|
-
},
|
|
1391
|
-
error: (error) => {
|
|
1392
|
-
reject(error);
|
|
1393
1333
|
}
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
return result;
|
|
1396
1337
|
}
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
if (!form || !form[0]) {
|
|
1404
|
-
resolve(lFormFieldsToken);
|
|
1405
|
-
}
|
|
1406
|
-
lFormFieldsToken = [];
|
|
1407
|
-
for (let formComp of form) {
|
|
1408
|
-
let newComponents;
|
|
1409
|
-
let components = [];
|
|
1410
|
-
if (formComp.components) {
|
|
1411
|
-
newComponents = formComp.components;
|
|
1412
|
-
}
|
|
1413
|
-
else if (formComp.columns) {
|
|
1414
|
-
newComponents = formComp.columns;
|
|
1415
|
-
}
|
|
1416
|
-
if (newComponents && UtilString.isValid(formComp.title)) {
|
|
1417
|
-
lFormFieldsToken.push({
|
|
1418
|
-
title: {
|
|
1419
|
-
key: TokenService.getKeyFormulario(formComp.title),
|
|
1420
|
-
value: formComp.title,
|
|
1421
|
-
object: formComp
|
|
1422
|
-
},
|
|
1423
|
-
value: []
|
|
1424
|
-
});
|
|
1425
|
-
lFormFieldsToken[lFormFieldsToken.length - 1].value =
|
|
1426
|
-
this.getComponenetForm(components, newComponents, null, false, null);
|
|
1427
|
-
}
|
|
1428
|
-
}
|
|
1429
|
-
resolve(lFormFieldsToken);
|
|
1430
|
-
}, (error) => {
|
|
1431
|
-
reject(error);
|
|
1432
|
-
});
|
|
1433
|
-
});
|
|
1338
|
+
/**
|
|
1339
|
+
* It returns the components
|
|
1340
|
+
* @param components
|
|
1341
|
+
*/
|
|
1342
|
+
static getComponents(components) {
|
|
1343
|
+
return FormioUtil.getComponentsByRecursion(components, '', null);
|
|
1434
1344
|
}
|
|
1435
|
-
/**
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
let components = [];
|
|
1453
|
-
if (formComp.components) {
|
|
1454
|
-
newComponents = formComp.components;
|
|
1345
|
+
/**
|
|
1346
|
+
* It returns the components array of the form by recursion
|
|
1347
|
+
* @param components array of components
|
|
1348
|
+
* @param titlePanel name of parent panel, so children components will inherit the panelName
|
|
1349
|
+
* @param conditionalObject conditional object it will be inherited from panel {conditional: { eq: , value: , when: , json: }, customConditional: }
|
|
1350
|
+
*/
|
|
1351
|
+
static getComponentsByRecursion(components, titlePanel, conditionalParent) {
|
|
1352
|
+
// it contains the result array
|
|
1353
|
+
let result = [];
|
|
1354
|
+
if (components) {
|
|
1355
|
+
// iterate over components
|
|
1356
|
+
for (const component of components) {
|
|
1357
|
+
// avoid the editgrid component ot if it has a different behavior it should have an else statement
|
|
1358
|
+
if (component[EFormioKey.TYPE] !== EFormioKey.EDITGRID) {
|
|
1359
|
+
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
1360
|
+
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
1361
|
+
titlePanel = component[EFormioKey.TITLE];
|
|
1455
1362
|
}
|
|
1456
|
-
|
|
1457
|
-
|
|
1363
|
+
if ((typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
1364
|
+
typeof component[EFormioKey.COLUMNS] !== 'undefined') &&
|
|
1365
|
+
component["type"] !== "address") {
|
|
1366
|
+
if (component["type"] !== "address") {
|
|
1367
|
+
// resolve conditional parent conditional
|
|
1368
|
+
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
1369
|
+
// change condition
|
|
1370
|
+
if (conditional)
|
|
1371
|
+
conditionalParent = conditional;
|
|
1372
|
+
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
1373
|
+
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
1374
|
+
? component[EFormioKey.COMPONENTS]
|
|
1375
|
+
: component[EFormioKey.COLUMNS];
|
|
1376
|
+
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
1377
|
+
const recursionResult = FormioUtil.getComponentsByRecursion(subComponents, titlePanel, conditionalParent);
|
|
1378
|
+
// if recursion result then result concats the recursionResult
|
|
1379
|
+
if (recursionResult)
|
|
1380
|
+
result = result.concat(recursionResult);
|
|
1381
|
+
// reset conditional Parent
|
|
1382
|
+
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
1383
|
+
conditionalParent = undefined;
|
|
1384
|
+
}
|
|
1385
|
+
else {
|
|
1386
|
+
result.push(component);
|
|
1387
|
+
}
|
|
1458
1388
|
}
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1389
|
+
else {
|
|
1390
|
+
// avoid the component type button
|
|
1391
|
+
if (component[EFormioKey.TYPE] !== EFormioKey.BUTTON &&
|
|
1392
|
+
component[EFormioKey.KEY] &&
|
|
1393
|
+
component[EFormioKey.LABEL]) {
|
|
1394
|
+
// resolve conditional conditional object
|
|
1395
|
+
let conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
1396
|
+
if (!conditional)
|
|
1397
|
+
conditional = conditionalParent;
|
|
1398
|
+
component[EFormioKey.CONDITIONAL] = conditional[EFormioKey.CONDITIONAL];
|
|
1399
|
+
component[EFormioKey.CUSTOM_CONDITIONAL] =
|
|
1400
|
+
conditional[EFormioKey.CUSTOM_CONDITIONAL];
|
|
1401
|
+
// add namPanel as property
|
|
1402
|
+
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
1403
|
+
// add component to the result
|
|
1404
|
+
result.push(component);
|
|
1405
|
+
}
|
|
1470
1406
|
}
|
|
1471
1407
|
}
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
});
|
|
1476
|
-
});
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
return result;
|
|
1477
1411
|
}
|
|
1478
1412
|
/**
|
|
1479
|
-
*
|
|
1413
|
+
* It returns the components
|
|
1480
1414
|
* @param components
|
|
1481
|
-
* @param
|
|
1415
|
+
* @param keepEditGrids
|
|
1482
1416
|
*/
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1417
|
+
static getComponentsWithEditGrids(components) {
|
|
1418
|
+
return FormioUtil.getComponentsByRecursionWithEditGrids(components, '', null);
|
|
1419
|
+
}
|
|
1420
|
+
/**
|
|
1421
|
+
* It returns the components array of the form by recursion
|
|
1422
|
+
* @param components array of components
|
|
1423
|
+
* @param titlePanel name of parent panel, so children components will inherit the panelName
|
|
1424
|
+
* @param conditionalObject conditional object it will be inherited from panel {conditional: { eq: , value: , when: , json: }, customConditional: }
|
|
1425
|
+
*/
|
|
1426
|
+
static getComponentsByRecursionWithEditGrids(components, titlePanel, conditionalParent) {
|
|
1427
|
+
// it contains the result array
|
|
1428
|
+
let result = [];
|
|
1429
|
+
if (components) {
|
|
1430
|
+
// iterate over components
|
|
1431
|
+
for (const component of components) {
|
|
1432
|
+
// avoid the editgrid component ot if it has a different behavior it should have an else statement
|
|
1433
|
+
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
1434
|
+
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
1435
|
+
titlePanel = component[EFormioKey.TITLE];
|
|
1492
1436
|
}
|
|
1493
|
-
|
|
1494
|
-
|
|
1437
|
+
if (typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
1438
|
+
typeof component[EFormioKey.COLUMNS] !== 'undefined') {
|
|
1439
|
+
// resolve conditional parent conditional
|
|
1440
|
+
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
1441
|
+
// change condition
|
|
1442
|
+
if (conditional)
|
|
1443
|
+
conditionalParent = conditional;
|
|
1444
|
+
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
1445
|
+
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
1446
|
+
? component[EFormioKey.COMPONENTS]
|
|
1447
|
+
: component[EFormioKey.COLUMNS];
|
|
1448
|
+
if (component[EFormioKey.TYPE] === EFormioKey.EDITGRID) {
|
|
1449
|
+
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
1450
|
+
result.push(component);
|
|
1451
|
+
}
|
|
1452
|
+
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
1453
|
+
const recursionResult = FormioUtil.getComponentsByRecursionWithEditGrids(subComponents, titlePanel, conditionalParent);
|
|
1454
|
+
// if recursion result then result concats the recursionResult
|
|
1455
|
+
if (recursionResult)
|
|
1456
|
+
result = result.concat(recursionResult);
|
|
1457
|
+
// reset conditional Parent
|
|
1458
|
+
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
1459
|
+
conditionalParent = undefined;
|
|
1460
|
+
}
|
|
1461
|
+
else {
|
|
1462
|
+
// avoid the component type button
|
|
1463
|
+
if (component[EFormioKey.TYPE] !== EFormioKey.BUTTON &&
|
|
1464
|
+
component[EFormioKey.KEY] &&
|
|
1465
|
+
component[EFormioKey.LABEL]) {
|
|
1466
|
+
// resolve conditional conditional object
|
|
1467
|
+
let conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
1468
|
+
if (!conditional)
|
|
1469
|
+
conditional = conditionalParent;
|
|
1470
|
+
component[EFormioKey.CONDITIONAL] = conditional[EFormioKey.CONDITIONAL];
|
|
1471
|
+
component[EFormioKey.CUSTOM_CONDITIONAL] =
|
|
1472
|
+
conditional[EFormioKey.CUSTOM_CONDITIONAL];
|
|
1473
|
+
// add namPanel as property
|
|
1474
|
+
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
1475
|
+
// add component to the result
|
|
1476
|
+
result.push(component);
|
|
1477
|
+
}
|
|
1495
1478
|
}
|
|
1496
|
-
components = this.getPanelComponenet(components, newComponents, panelName);
|
|
1497
1479
|
}
|
|
1498
1480
|
}
|
|
1499
|
-
return
|
|
1481
|
+
return result;
|
|
1500
1482
|
}
|
|
1501
1483
|
/**
|
|
1502
|
-
*
|
|
1503
|
-
* @param
|
|
1504
|
-
* @param
|
|
1484
|
+
* It resolve the inheritance conditional
|
|
1485
|
+
* @param conditionalObject
|
|
1486
|
+
* @param conditional
|
|
1487
|
+
* @param customConditional
|
|
1505
1488
|
*/
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
editgrid = true;
|
|
1514
|
-
editGridKey = formComp.key;
|
|
1515
|
-
}
|
|
1516
|
-
}
|
|
1517
|
-
else if (formComp.columns) {
|
|
1518
|
-
newComponents = formComp.columns;
|
|
1519
|
-
}
|
|
1520
|
-
if (formComp.type && formComp.type === 'panel') {
|
|
1521
|
-
panelName = formComp.title;
|
|
1522
|
-
}
|
|
1523
|
-
components = this.getComponenetForm(components, newComponents, panelName, editgrid, editGridKey);
|
|
1524
|
-
}
|
|
1525
|
-
else {
|
|
1526
|
-
formComp.panelName = panelName;
|
|
1527
|
-
formComp.editgrid = editgrid;
|
|
1528
|
-
formComp.editGridKey = editGridKey;
|
|
1529
|
-
components.push(formComp);
|
|
1530
|
-
}
|
|
1489
|
+
static resolveInheritanceConditional(conditionalObject, conditional, customConditional, parentId) {
|
|
1490
|
+
// validate if there is a condition with the new fields
|
|
1491
|
+
if (!conditionalObject ||
|
|
1492
|
+
customConditional ||
|
|
1493
|
+
(conditional && conditional[EFormioKey.WHEN] && conditional[EFormioKey.EQ]) ||
|
|
1494
|
+
(conditional && conditional[EFormioKey.JSON])) {
|
|
1495
|
+
return { conditional: conditional, customConditional: customConditional, id: parentId };
|
|
1531
1496
|
}
|
|
1532
|
-
return
|
|
1533
|
-
}
|
|
1534
|
-
/** This promise allows to execute a function when consulting the form fields. */
|
|
1535
|
-
getFormEditGridFieldsByPromCode(promCodigo) {
|
|
1536
|
-
return new Promise((resolve, reject) => {
|
|
1537
|
-
// Search the dynamic form
|
|
1538
|
-
let lFormFieldsToken = null;
|
|
1539
|
-
this.formService.getByPromCodigo(promCodigo).subscribe((result) => {
|
|
1540
|
-
let form = result;
|
|
1541
|
-
if (!form ||
|
|
1542
|
-
!form[0] ||
|
|
1543
|
-
!form[0].promCodigo ||
|
|
1544
|
-
form[0].promCodigo != promCodigo) {
|
|
1545
|
-
// this.router.navigate(['404']);
|
|
1546
|
-
resolve(lFormFieldsToken);
|
|
1547
|
-
}
|
|
1548
|
-
lFormFieldsToken = [];
|
|
1549
|
-
for (let formComp of form) {
|
|
1550
|
-
let newComponents;
|
|
1551
|
-
let components = [];
|
|
1552
|
-
if (formComp.components) {
|
|
1553
|
-
newComponents = formComp.components;
|
|
1554
|
-
}
|
|
1555
|
-
else if (formComp.columns) {
|
|
1556
|
-
newComponents = formComp.columns;
|
|
1557
|
-
}
|
|
1558
|
-
if (newComponents && UtilString.isValid(formComp.title)) {
|
|
1559
|
-
lFormFieldsToken.push({
|
|
1560
|
-
title: {
|
|
1561
|
-
key: TokenService.getKeyFormulario(formComp.title),
|
|
1562
|
-
value: formComp.title,
|
|
1563
|
-
object: formComp
|
|
1564
|
-
},
|
|
1565
|
-
value: []
|
|
1566
|
-
});
|
|
1567
|
-
lFormFieldsToken[lFormFieldsToken.length - 1].value =
|
|
1568
|
-
this.getEditGridComponenet(components, newComponents, null);
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
resolve(lFormFieldsToken);
|
|
1572
|
-
}, (error) => {
|
|
1573
|
-
reject(error);
|
|
1574
|
-
});
|
|
1575
|
-
});
|
|
1497
|
+
return null;
|
|
1576
1498
|
}
|
|
1577
1499
|
/**
|
|
1578
|
-
*
|
|
1500
|
+
* It returns the edit grid components
|
|
1579
1501
|
* @param components
|
|
1580
|
-
* @param form
|
|
1581
1502
|
*/
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1503
|
+
static getEditGridKeyLabels(components) {
|
|
1504
|
+
return FormioUtil.getEditGridKeyLabelsByRecursion(components, '', null);
|
|
1505
|
+
}
|
|
1506
|
+
/**
|
|
1507
|
+
* It returns the components edit grid array of the form by recursion
|
|
1508
|
+
* @param components array of components
|
|
1509
|
+
* @param titlePanel name of parent panel, so children components will inherit the panelName
|
|
1510
|
+
* @param conditionalObject conditional object it will be inherited from panel {conditional: { eq: , value: , when: , json: }, customConditional: }
|
|
1511
|
+
*/
|
|
1512
|
+
static getEditGridKeyLabelsByRecursion(components, titlePanel, conditionalParent) {
|
|
1513
|
+
// it contains the result array
|
|
1514
|
+
let result = [];
|
|
1515
|
+
if (components) {
|
|
1516
|
+
// iterate over components
|
|
1517
|
+
for (const component of components) {
|
|
1518
|
+
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
1519
|
+
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
1520
|
+
titlePanel = component[EFormioKey.TITLE];
|
|
1592
1521
|
}
|
|
1593
|
-
|
|
1594
|
-
|
|
1522
|
+
if (typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
1523
|
+
typeof component[EFormioKey.COLUMNS] !== 'undefined') {
|
|
1524
|
+
// resolve conditional parent conditional
|
|
1525
|
+
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
1526
|
+
// change condition
|
|
1527
|
+
if (conditional)
|
|
1528
|
+
conditionalParent = conditional;
|
|
1529
|
+
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
1530
|
+
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
1531
|
+
? component[EFormioKey.COMPONENTS]
|
|
1532
|
+
: component[EFormioKey.COLUMNS];
|
|
1533
|
+
if (component[EFormioKey.TYPE] == EFormioKey.EDITGRID) {
|
|
1534
|
+
// add namPanel as property
|
|
1535
|
+
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
1536
|
+
// add component to the result
|
|
1537
|
+
result.push(component);
|
|
1538
|
+
}
|
|
1539
|
+
else {
|
|
1540
|
+
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
1541
|
+
const recursionResult = FormioUtil.getEditGridKeyLabelsByRecursion(subComponents, titlePanel, conditionalParent);
|
|
1542
|
+
// if recursion result then result concats the recursionResult
|
|
1543
|
+
if (recursionResult)
|
|
1544
|
+
result = result.concat(recursionResult);
|
|
1545
|
+
// reset conditional Parent
|
|
1546
|
+
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
1547
|
+
conditionalParent = undefined;
|
|
1548
|
+
}
|
|
1595
1549
|
}
|
|
1596
|
-
|
|
1597
|
-
panelName = formComp.title;
|
|
1550
|
+
else {
|
|
1598
1551
|
}
|
|
1599
|
-
components = this.getEditGridComponenet(components, newComponents, panelName);
|
|
1600
1552
|
}
|
|
1601
1553
|
}
|
|
1602
|
-
return
|
|
1603
|
-
}
|
|
1604
|
-
/** It returns the tokens by promCodigo */
|
|
1605
|
-
getListByPromCodigo(promCode) {
|
|
1606
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'token/getByPromCodigo', { params: new HttpParams().set('promCodigo', promCode.toString()) });
|
|
1607
|
-
}
|
|
1608
|
-
/** It returns the token by id */
|
|
1609
|
-
getById(id) {
|
|
1610
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'token/getById', {
|
|
1611
|
-
params: new HttpParams().set('id', id.toString())
|
|
1612
|
-
});
|
|
1613
|
-
}
|
|
1614
|
-
/** It deletes a form by id */
|
|
1615
|
-
delete(id) {
|
|
1616
|
-
return this.httpClient.delete(this.environment.host.backend.configuration + 'token/delete', { params: new HttpParams().set('id', id) });
|
|
1617
|
-
}
|
|
1618
|
-
/** It saves the token */
|
|
1619
|
-
save(token) {
|
|
1620
|
-
return this.httpClient.post(this.environment.host.backend.configuration + 'token/save', token, HEADER_JSON);
|
|
1621
|
-
}
|
|
1622
|
-
static getKeyFormulario(formTitle) {
|
|
1623
|
-
if (UtilString.isValid(formTitle)) {
|
|
1624
|
-
return (UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_FORM) +
|
|
1625
|
-
UtilString.replaceAccentSpacesOthers(formTitle).replace(/_/g, '-'));
|
|
1626
|
-
}
|
|
1627
|
-
return '';
|
|
1628
|
-
}
|
|
1629
|
-
/** It returns the unique verification code */
|
|
1630
|
-
getUniqueVerificationCode(login, token) {
|
|
1631
|
-
return this.httpClient.get(this.environment.host.backend.documentsRepository +
|
|
1632
|
-
'documento/consultarCodigoUnico/' +
|
|
1633
|
-
login +
|
|
1634
|
-
'/' +
|
|
1635
|
-
token, { params: new HttpParams() });
|
|
1636
|
-
}
|
|
1637
|
-
/** It send the information to copy the Document viewer */
|
|
1638
|
-
copyDocumentInformationViewer(login, token, uniqueCode, documentURL, documentName) {
|
|
1639
|
-
let infoDocumento = {
|
|
1640
|
-
codigoUnico: uniqueCode,
|
|
1641
|
-
rutaDocumento: documentURL,
|
|
1642
|
-
documentName: documentName
|
|
1643
|
-
};
|
|
1644
|
-
return this.httpClient.post(this.environment.host.backend.documentsRepository +
|
|
1645
|
-
'documento/adicionarDocumento/' +
|
|
1646
|
-
login +
|
|
1647
|
-
'/' +
|
|
1648
|
-
token, infoDocumento, HEADER_JSON);
|
|
1649
|
-
}
|
|
1650
|
-
static getKeyBudget() {
|
|
1651
|
-
return UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_BUDGET);
|
|
1652
|
-
}
|
|
1653
|
-
static getKeyDocument() {
|
|
1654
|
-
return UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_DOCUMENTO);
|
|
1655
|
-
}
|
|
1656
|
-
static getKeyTask() {
|
|
1657
|
-
return UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_TASKL);
|
|
1658
|
-
}
|
|
1659
|
-
static getKeyStatic() {
|
|
1660
|
-
return UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_STATIC);
|
|
1661
|
-
}
|
|
1662
|
-
static getKeyCalculated(token) {
|
|
1663
|
-
return (UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_CALCULATED) +
|
|
1664
|
-
'_' +
|
|
1665
|
-
UtilString.replaceAccentSpacesOthers(token.name));
|
|
1666
|
-
}
|
|
1667
|
-
static getKeySnapshot(token) {
|
|
1668
|
-
return (UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_SNAPSHOT) +
|
|
1669
|
-
'_' +
|
|
1670
|
-
UtilString.replaceAccentSpacesOthers(token.name));
|
|
1671
|
-
}
|
|
1672
|
-
static getKeyGuarantee(token) {
|
|
1673
|
-
return (UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_GUARANTEE) +
|
|
1674
|
-
'_' +
|
|
1675
|
-
UtilString.replaceAccentSpacesOthers(token.name));
|
|
1554
|
+
return result;
|
|
1676
1555
|
}
|
|
1677
1556
|
/**
|
|
1678
|
-
*
|
|
1679
|
-
* @param
|
|
1557
|
+
* It returns the components
|
|
1558
|
+
* @param components
|
|
1559
|
+
* @param keepEditGrids
|
|
1680
1560
|
*/
|
|
1681
|
-
static
|
|
1682
|
-
|
|
1683
|
-
key = key.substring(1, key.indexOf('_'));
|
|
1684
|
-
if (key.startsWith(UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_FORM))) {
|
|
1685
|
-
return 1;
|
|
1686
|
-
}
|
|
1687
|
-
else if (key.startsWith(UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_BUDGET))) {
|
|
1688
|
-
return 2;
|
|
1689
|
-
}
|
|
1690
|
-
else if (key.startsWith(UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_STATIC))) {
|
|
1691
|
-
return 3;
|
|
1692
|
-
}
|
|
1693
|
-
else if (key.startsWith(UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_CALCULATED))) {
|
|
1694
|
-
return 4;
|
|
1695
|
-
}
|
|
1696
|
-
else if (key.startsWith(UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_TASKL))) {
|
|
1697
|
-
return 5;
|
|
1698
|
-
}
|
|
1699
|
-
return null;
|
|
1561
|
+
static getComponentsIntoEditGrids(components, editGridName) {
|
|
1562
|
+
return FormioUtil.getComponentsByRecursionIntoEditGrids(components, '', null, editGridName, false);
|
|
1700
1563
|
}
|
|
1701
1564
|
/**
|
|
1702
|
-
*
|
|
1703
|
-
* @param
|
|
1704
|
-
* @param
|
|
1565
|
+
* It returns the components array of the form by recursion
|
|
1566
|
+
* @param components array of components
|
|
1567
|
+
* @param titlePanel name of parent panel, so children components will inherit the panelName
|
|
1568
|
+
* @param conditionalObject conditional object it will be inherited from panel {conditional: { eq: , value: , when: , json: }, customConditional: }
|
|
1705
1569
|
*/
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1570
|
+
static getComponentsByRecursionIntoEditGrids(components, titlePanel, conditionalParent, editGridName, existEditGrid) {
|
|
1571
|
+
// it contains the result array
|
|
1572
|
+
let result = [];
|
|
1573
|
+
if (components) {
|
|
1574
|
+
// iterate over components
|
|
1575
|
+
for (const component of components) {
|
|
1576
|
+
// avoid the editgrid component ot if it has a different behavior it should have an else statement
|
|
1577
|
+
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
1578
|
+
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
1579
|
+
titlePanel = component[EFormioKey.TITLE];
|
|
1711
1580
|
}
|
|
1712
|
-
if (
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1581
|
+
if (typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
1582
|
+
typeof component[EFormioKey.COLUMNS] !== 'undefined') {
|
|
1583
|
+
// resolve conditional parent conditional
|
|
1584
|
+
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
1585
|
+
// change condition
|
|
1586
|
+
if (conditional)
|
|
1587
|
+
conditionalParent = conditional;
|
|
1588
|
+
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
1589
|
+
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
1590
|
+
? component[EFormioKey.COMPONENTS]
|
|
1591
|
+
: component[EFormioKey.COLUMNS];
|
|
1592
|
+
if (component[EFormioKey.TYPE] === EFormioKey.EDITGRID &&
|
|
1593
|
+
component['key'] == editGridName) {
|
|
1594
|
+
existEditGrid = true;
|
|
1595
|
+
if (typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
1596
|
+
typeof component[EFormioKey.COLUMNS] !== 'undefined') {
|
|
1597
|
+
// resolve conditional parent conditional
|
|
1598
|
+
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
1599
|
+
// change condition
|
|
1600
|
+
if (conditional)
|
|
1601
|
+
conditionalParent = conditional;
|
|
1602
|
+
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
1603
|
+
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
1604
|
+
? component[EFormioKey.COMPONENTS]
|
|
1605
|
+
: component[EFormioKey.COLUMNS];
|
|
1606
|
+
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
1607
|
+
const recursionResult = FormioUtil.getComponentsByRecursionIntoEditGrids(subComponents, titlePanel, conditionalParent, editGridName, existEditGrid);
|
|
1608
|
+
// if recursion result then result concats the recursionResult
|
|
1609
|
+
if (recursionResult)
|
|
1610
|
+
result = result.concat(recursionResult);
|
|
1611
|
+
// reset conditional Parent
|
|
1612
|
+
if (component && conditionalParent) {
|
|
1613
|
+
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
1614
|
+
conditionalParent = undefined;
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
else {
|
|
1618
|
+
// avoid the component type button
|
|
1619
|
+
if (component[EFormioKey.TYPE] !== EFormioKey.BUTTON &&
|
|
1620
|
+
component[EFormioKey.KEY] &&
|
|
1621
|
+
component[EFormioKey.LABEL] &&
|
|
1622
|
+
existEditGrid) {
|
|
1623
|
+
// resolve conditional conditional object
|
|
1624
|
+
let conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
1625
|
+
if (!conditional)
|
|
1626
|
+
conditional = conditionalParent;
|
|
1627
|
+
component[EFormioKey.CONDITIONAL] =
|
|
1628
|
+
conditional[EFormioKey.CONDITIONAL];
|
|
1629
|
+
component[EFormioKey.CUSTOM_CONDITIONAL] =
|
|
1630
|
+
conditional[EFormioKey.CUSTOM_CONDITIONAL];
|
|
1631
|
+
// add namPanel as property
|
|
1632
|
+
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
1633
|
+
// add component to the result
|
|
1634
|
+
result.push(component);
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
1639
|
+
const recursionResult = FormioUtil.getComponentsByRecursionIntoEditGrids(subComponents, titlePanel, conditionalParent, editGridName, existEditGrid);
|
|
1640
|
+
// if recursion result then result concats the recursionResult
|
|
1641
|
+
if (recursionResult)
|
|
1642
|
+
result = result.concat(recursionResult);
|
|
1643
|
+
// reset conditional Parent
|
|
1644
|
+
if (component && conditionalParent) {
|
|
1645
|
+
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
1646
|
+
conditionalParent = undefined;
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
else {
|
|
1650
|
+
// avoid the component type button
|
|
1651
|
+
if (component[EFormioKey.TYPE] !== EFormioKey.BUTTON &&
|
|
1652
|
+
component[EFormioKey.KEY] &&
|
|
1653
|
+
component[EFormioKey.LABEL] &&
|
|
1654
|
+
existEditGrid) {
|
|
1655
|
+
// resolve conditional conditional object
|
|
1656
|
+
let conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
1657
|
+
if (!conditional)
|
|
1658
|
+
conditional = conditionalParent;
|
|
1659
|
+
component[EFormioKey.CONDITIONAL] = conditional[EFormioKey.CONDITIONAL];
|
|
1660
|
+
component[EFormioKey.CUSTOM_CONDITIONAL] =
|
|
1661
|
+
conditional[EFormioKey.CUSTOM_CONDITIONAL];
|
|
1662
|
+
// add namPanel as property
|
|
1663
|
+
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
1664
|
+
// add component to the result
|
|
1665
|
+
result.push(component);
|
|
1666
|
+
}
|
|
1716
1667
|
}
|
|
1717
1668
|
}
|
|
1718
1669
|
}
|
|
1719
|
-
return
|
|
1670
|
+
return result;
|
|
1720
1671
|
}
|
|
1721
1672
|
/**
|
|
1722
|
-
*
|
|
1723
|
-
* @param
|
|
1724
|
-
* @
|
|
1725
|
-
* @param dataValue
|
|
1673
|
+
* Create 2 jason objects of data form by component key and other by component key and title form key
|
|
1674
|
+
* @param dataForm dataForm model object
|
|
1675
|
+
* @returns Object of 2 element
|
|
1726
1676
|
*/
|
|
1727
|
-
|
|
1728
|
-
let
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
if (
|
|
1736
|
-
|
|
1737
|
-
}
|
|
1738
|
-
else {
|
|
1739
|
-
valueReplace = '';
|
|
1677
|
+
static createListDataByDataFormList(dataForm, listForm) {
|
|
1678
|
+
let listData = {};
|
|
1679
|
+
let listDataByForm = {};
|
|
1680
|
+
if (dataForm && dataForm.length > 0) {
|
|
1681
|
+
listData = {};
|
|
1682
|
+
listDataByForm = {};
|
|
1683
|
+
let dForm;
|
|
1684
|
+
for (dForm of dataForm) {
|
|
1685
|
+
if (!dForm.data) {
|
|
1686
|
+
continue;
|
|
1740
1687
|
}
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
if (
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
valueReplace = this.currencyPipe.transform(numberValue, this.locale, '', numberFormat);
|
|
1688
|
+
const form = listForm.find(function (formTmp) {
|
|
1689
|
+
return formTmp.id == dForm.formId;
|
|
1690
|
+
});
|
|
1691
|
+
if (!form) {
|
|
1692
|
+
//console.error('No se encontró el formulario con id ' + dForm.formId);
|
|
1693
|
+
continue;
|
|
1748
1694
|
}
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
token +
|
|
1754
|
-
'] tipo númerico no es valido');
|
|
1755
|
-
valueReplace = '';
|
|
1695
|
+
const keyFormTitle = TokenService.getKeyFormulario(form.title) + '_';
|
|
1696
|
+
for (const key in dForm.data) {
|
|
1697
|
+
listData[key] = dForm.data[key];
|
|
1698
|
+
listDataByForm[keyFormTitle + key] = dForm.data[key];
|
|
1756
1699
|
}
|
|
1757
1700
|
}
|
|
1758
|
-
else {
|
|
1759
|
-
console.log('tipo de token indefinido. [typeToken[' + typeToken + ']]');
|
|
1760
|
-
}
|
|
1761
|
-
}
|
|
1762
|
-
else if (token && token[0] == '$') {
|
|
1763
|
-
valueReplace = dataValue;
|
|
1764
|
-
}
|
|
1765
|
-
else {
|
|
1766
|
-
console.log('El token no es valido. [token[' + token + ']]');
|
|
1767
|
-
}
|
|
1768
|
-
if (stringText && valueReplace !== null) {
|
|
1769
|
-
// replace text in a more efficient way
|
|
1770
|
-
stringText = stringText.split(token).join(valueReplace);
|
|
1771
|
-
//stringText = stringText.replace(token, valueReplace);
|
|
1772
1701
|
}
|
|
1773
|
-
return
|
|
1702
|
+
return {
|
|
1703
|
+
listData: listData,
|
|
1704
|
+
listDataByForm: listDataByForm
|
|
1705
|
+
};
|
|
1774
1706
|
}
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
for (const tokenFormatted of arrayTokenFormatted) {
|
|
1798
|
-
const index = tokenFormatted.indexOf(token);
|
|
1799
|
-
if (index >= 0) {
|
|
1800
|
-
infoToken.value = tokenFormatted;
|
|
1801
|
-
break;
|
|
1802
|
-
}
|
|
1707
|
+
/**
|
|
1708
|
+
* It returns the components
|
|
1709
|
+
* @param components
|
|
1710
|
+
*/
|
|
1711
|
+
static getPanelComponents(components) {
|
|
1712
|
+
return FormioUtil.getComponentsByPanel(components);
|
|
1713
|
+
}
|
|
1714
|
+
/**
|
|
1715
|
+
* It returns the components array of the form
|
|
1716
|
+
* @param components array of components
|
|
1717
|
+
*/
|
|
1718
|
+
static getComponentsByPanel(components) {
|
|
1719
|
+
// it contains the result array
|
|
1720
|
+
let result = [];
|
|
1721
|
+
if (components) {
|
|
1722
|
+
// iterate over components
|
|
1723
|
+
for (const component of components) {
|
|
1724
|
+
// avoid the editgrid component ot if it has a different behavior it should have an else statement
|
|
1725
|
+
if (component[EFormioKey.TYPE] !== EFormioKey.EDITGRID) {
|
|
1726
|
+
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
1727
|
+
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
1728
|
+
result.push(component);
|
|
1803
1729
|
}
|
|
1804
1730
|
}
|
|
1805
|
-
result.push(infoToken);
|
|
1806
1731
|
}
|
|
1807
1732
|
}
|
|
1808
1733
|
return result;
|
|
1809
1734
|
}
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
if (column.idColumn.toString() === property) {
|
|
1818
|
-
objData[column.key] = data[property];
|
|
1819
|
-
}
|
|
1820
|
-
});
|
|
1821
|
-
}
|
|
1822
|
-
});
|
|
1823
|
-
if (objData) {
|
|
1824
|
-
newData.push(objData);
|
|
1825
|
-
}
|
|
1826
|
-
});
|
|
1827
|
-
return newData;
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
class FormService {
|
|
1738
|
+
constructor(environment, httpClient) {
|
|
1739
|
+
this.environment = environment;
|
|
1740
|
+
this.httpClient = httpClient;
|
|
1741
|
+
this.headerJson = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) };
|
|
1828
1742
|
}
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
});
|
|
1842
|
-
translatedCards.push(htmlTranslated);
|
|
1743
|
+
/** It returns the list of form by prom codigo */
|
|
1744
|
+
getByPromCodigo(promCodigo) {
|
|
1745
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getByPromCodigo', { params: new HttpParams().set('promCodigo', promCodigo.toString()) });
|
|
1746
|
+
}
|
|
1747
|
+
/** It returns the list of form by prom codigo */
|
|
1748
|
+
getAll() {
|
|
1749
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getAll');
|
|
1750
|
+
}
|
|
1751
|
+
/** It returns a form by id */
|
|
1752
|
+
getById(id) {
|
|
1753
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getById', {
|
|
1754
|
+
params: new HttpParams().set('id', id)
|
|
1843
1755
|
});
|
|
1844
|
-
return translatedCards;
|
|
1845
1756
|
}
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
var arrayTokenFormattedNumber = stringText.match(/\#number[^)]+\)/g);
|
|
1850
|
-
var arrayTokenFormatted = [];
|
|
1851
|
-
if (arrayTokenFormattedDate &&
|
|
1852
|
-
arrayTokenFormattedDate.length > 0 &&
|
|
1853
|
-
arrayTokenFormattedNumber &&
|
|
1854
|
-
arrayTokenFormattedNumber.length > 0) {
|
|
1855
|
-
arrayTokenFormatted = arrayTokenFormattedDate.concat(arrayTokenFormattedNumber);
|
|
1856
|
-
}
|
|
1857
|
-
else if (arrayTokenFormattedDate && arrayTokenFormattedDate.length > 0) {
|
|
1858
|
-
arrayTokenFormatted = arrayTokenFormattedDate.slice();
|
|
1859
|
-
}
|
|
1860
|
-
else if (arrayTokenFormattedNumber && arrayTokenFormattedNumber.length > 0) {
|
|
1861
|
-
arrayTokenFormatted = arrayTokenFormattedNumber.slice();
|
|
1862
|
-
}
|
|
1863
|
-
var result = [];
|
|
1864
|
-
if (arrayToken) {
|
|
1865
|
-
for (const token of arrayToken) {
|
|
1866
|
-
let keyType = TokenService.getKeyType(token);
|
|
1867
|
-
if (keyType === null) {
|
|
1868
|
-
continue;
|
|
1869
|
-
}
|
|
1870
|
-
var infoToken = { key: token, value: token };
|
|
1871
|
-
if (arrayTokenFormatted) {
|
|
1872
|
-
for (const tokenFormatted of arrayTokenFormatted) {
|
|
1873
|
-
var index = tokenFormatted.indexOf(token);
|
|
1874
|
-
if (index >= 0) {
|
|
1875
|
-
infoToken.value = tokenFormatted;
|
|
1876
|
-
break;
|
|
1877
|
-
}
|
|
1878
|
-
}
|
|
1879
|
-
}
|
|
1880
|
-
result.push(infoToken);
|
|
1881
|
-
}
|
|
1882
|
-
}
|
|
1883
|
-
return result;
|
|
1884
|
-
// let tokens: any[] = [];
|
|
1885
|
-
// let i = this.nextValidPositionTokens(stringText, 0);
|
|
1886
|
-
// let count = 0;
|
|
1887
|
-
// while (i >= 0 && count <= 10) {
|
|
1888
|
-
// let infoToken: {} = null;
|
|
1889
|
-
// let nextI: number = i;
|
|
1890
|
-
// let character = stringText.substring(i, (i + 1));
|
|
1891
|
-
// if (character == "$") {
|
|
1892
|
-
// let nextCharacter = stringText.substring((i + 1), (i + 2));
|
|
1893
|
-
// // The next character need to be a { sign
|
|
1894
|
-
// if (nextCharacter != "{") {
|
|
1895
|
-
// i = this.nextValidPositionTokens(stringText, nextI + 1);
|
|
1896
|
-
// continue;
|
|
1897
|
-
// }
|
|
1898
|
-
// let keyToken: string = stringText.substring(i, stringText.indexOf("}", i) + 1);
|
|
1899
|
-
// // If the token have a valid key type
|
|
1900
|
-
// let keyType: number = TokenService.getKeyType(keyToken.replace("{", "").replace("}", ""));
|
|
1901
|
-
// if (keyType === null) {
|
|
1902
|
-
// i = this.nextValidPositionTokens(stringText, nextI + 1);
|
|
1903
|
-
// continue;
|
|
1904
|
-
// }
|
|
1905
|
-
// infoToken = {
|
|
1906
|
-
// key: keyToken,
|
|
1907
|
-
// value: keyToken
|
|
1908
|
-
// };
|
|
1909
|
-
// nextI = stringText.indexOf("}", i);
|
|
1910
|
-
// } else {
|
|
1911
|
-
// let nextSign: number = stringText.indexOf("$", i);
|
|
1912
|
-
// // We inly support #date($ and #number($ in this 2 scenarios the lenght can't be more than 10 characters
|
|
1913
|
-
// if (nextSign < 0 || (nextSign - i) > 10) {
|
|
1914
|
-
// i = this.nextValidPositionTokens(stringText, nextI + 1);
|
|
1915
|
-
// continue;
|
|
1916
|
-
// }
|
|
1917
|
-
// let keyToken: string = stringText.substring(stringText.indexOf("$", i), stringText.indexOf("}", i) + 1);
|
|
1918
|
-
// let valueToken: string = stringText.substring(i, stringText.indexOf(")", i) + 1);
|
|
1919
|
-
// infoToken = {
|
|
1920
|
-
// key: keyToken,
|
|
1921
|
-
// value: valueToken
|
|
1922
|
-
// };
|
|
1923
|
-
// nextI = stringText.indexOf(")", i);
|
|
1924
|
-
// }
|
|
1925
|
-
// tokens.push(infoToken);
|
|
1926
|
-
// i = this.nextValidPositionTokens(stringText, nextI);
|
|
1927
|
-
// count++;
|
|
1928
|
-
// }
|
|
1929
|
-
// return tokens;
|
|
1757
|
+
/** It saves a form */
|
|
1758
|
+
save(form) {
|
|
1759
|
+
return this.httpClient.post(this.environment.host.backend.configuration + 'form/save', form, this.headerJson);
|
|
1930
1760
|
}
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
let tokenNumSign = stringText.indexOf('#', nextI);
|
|
1934
|
-
let i = tokenDollarSign < 0 && tokenNumSign >= 0
|
|
1935
|
-
? tokenNumSign
|
|
1936
|
-
: tokenNumSign < 0 && tokenDollarSign >= 0
|
|
1937
|
-
? tokenDollarSign
|
|
1938
|
-
: tokenDollarSign < tokenNumSign
|
|
1939
|
-
? tokenDollarSign
|
|
1940
|
-
: tokenNumSign;
|
|
1941
|
-
return i;
|
|
1761
|
+
saveFormMultiPromCodigo(reMultPromCodDto) {
|
|
1762
|
+
return this.httpClient.post(this.environment.host.backend.configuration + 'form/saveMultiaplicacionPromCod', reMultPromCodDto, this.headerJson);
|
|
1942
1763
|
}
|
|
1943
|
-
/**
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
}
|
|
1956
|
-
|
|
1764
|
+
/** It deletes a form by id */
|
|
1765
|
+
delete(id) {
|
|
1766
|
+
return this.httpClient.delete(this.environment.host.backend.configuration + 'form/delete', {
|
|
1767
|
+
params: new HttpParams().set('id', id)
|
|
1768
|
+
});
|
|
1769
|
+
}
|
|
1770
|
+
/** It returns the form according to profile have been setting up in form */
|
|
1771
|
+
getByPromCodigoAccordingToProfile(promCodigo, patCodigo, formId) {
|
|
1772
|
+
let params = new HttpParams()
|
|
1773
|
+
.set('promCodigo', promCodigo.toString())
|
|
1774
|
+
.set('patCodigo', patCodigo.toString())
|
|
1775
|
+
.set('formId', formId !== undefined ? formId : '');
|
|
1776
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getByPromCodigoAndProfile', { params: params });
|
|
1777
|
+
}
|
|
1778
|
+
/** It returns the form according to list of prom codigo */
|
|
1779
|
+
getByListPromCodigo(listPromCod) {
|
|
1780
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getByListPromCodigo', { params: new HttpParams().set('listPromCodigo', listPromCod.toString()) });
|
|
1781
|
+
}
|
|
1782
|
+
/** It remove the redis cache of the form by prom codigo */
|
|
1783
|
+
removeFromCacheByPromCodigo(promCodigo) {
|
|
1784
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'form/removeFromCacheByPromCodigo', {
|
|
1785
|
+
params: new HttpParams().set('promCodigo', promCodigo.toString())
|
|
1786
|
+
});
|
|
1787
|
+
}
|
|
1788
|
+
/** It remove the redis cache of the form by prom codigo */
|
|
1789
|
+
removeFromCacheByPromCodigoAndTitle(promCodigo, title) {
|
|
1790
|
+
return this.httpClient.get(this.environment.host.backend.configuration +
|
|
1791
|
+
'form/removeFromCacheByPromCodigoAndTitle', {
|
|
1792
|
+
params: new HttpParams()
|
|
1793
|
+
.set('promCodigo', promCodigo.toString())
|
|
1794
|
+
.set('title', title)
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1797
|
+
/** It remove the redis cache of the form by prom codigo */
|
|
1798
|
+
removeFromCacheByPromCodigoAndProfile(promCodigo, patCodigo, formId, username) {
|
|
1799
|
+
return this.httpClient.get(this.environment.host.backend.configuration +
|
|
1800
|
+
'form/removeFromCacheByPromCodigoAndProfile', {
|
|
1801
|
+
params: new HttpParams()
|
|
1802
|
+
.set('promCodigo', promCodigo.toString())
|
|
1803
|
+
.set('patCodigo', patCodigo.toString())
|
|
1804
|
+
.set('formId', formId)
|
|
1805
|
+
.set('username', username)
|
|
1806
|
+
});
|
|
1957
1807
|
}
|
|
1958
1808
|
/**
|
|
1959
|
-
*
|
|
1960
|
-
* @param
|
|
1961
|
-
* @param lObjectTokens List of tokens with the values to replace
|
|
1809
|
+
* Get form by Id
|
|
1810
|
+
* @param statusId
|
|
1962
1811
|
*/
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
isTagFound = this.findTag(expression);
|
|
2035
|
-
lAuxformExpression.push(isTagFound);
|
|
1812
|
+
getByStateId(statusId) {
|
|
1813
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getByStateId', {
|
|
1814
|
+
params: new HttpParams().set('statusId', statusId)
|
|
1815
|
+
});
|
|
1816
|
+
}
|
|
1817
|
+
getConfigCloningFormMap(oldFormPPP, newFormPPP) {
|
|
1818
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getConfigCloningFormMap', {
|
|
1819
|
+
params: new HttpParams()
|
|
1820
|
+
.set('oldFormPPP', oldFormPPP.toString())
|
|
1821
|
+
.set('newFormPPP', newFormPPP.toString())
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1824
|
+
getListFormProjectSummaryConfigByPromCodigo(promCodigo, patCodigo) {
|
|
1825
|
+
return this.httpClient.get(this.environment.host.backend.configuration +
|
|
1826
|
+
'form/getListFormProjectSummaryConfigByPromCodigo', {
|
|
1827
|
+
params: new HttpParams()
|
|
1828
|
+
.set('promCodigo', promCodigo.toString())
|
|
1829
|
+
.set('patCodigo', patCodigo.toString())
|
|
1830
|
+
});
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
FormService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: FormService, deps: [{ token: 'environment' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1834
|
+
FormService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: FormService, providedIn: 'root' });
|
|
1835
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: FormService, decorators: [{
|
|
1836
|
+
type: Injectable,
|
|
1837
|
+
args: [{
|
|
1838
|
+
providedIn: 'root'
|
|
1839
|
+
}]
|
|
1840
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1841
|
+
type: Inject,
|
|
1842
|
+
args: ['environment']
|
|
1843
|
+
}] }, { type: i1.HttpClient }]; } });
|
|
1844
|
+
|
|
1845
|
+
class TokenService {
|
|
1846
|
+
constructor(environment, httpClient, formService, currencyPipe) {
|
|
1847
|
+
this.environment = environment;
|
|
1848
|
+
this.httpClient = httpClient;
|
|
1849
|
+
this.formService = formService;
|
|
1850
|
+
this.currencyPipe = currencyPipe;
|
|
1851
|
+
}
|
|
1852
|
+
/** This promise allows to execute a function when consulting the form fields. */
|
|
1853
|
+
getFormFieldsByPromCode(promCodigo) {
|
|
1854
|
+
return new Promise((resolve, reject) => {
|
|
1855
|
+
// Search the dynamic form
|
|
1856
|
+
let lFormFieldsToken = null;
|
|
1857
|
+
this.formService.getByPromCodigo(promCodigo).subscribe({
|
|
1858
|
+
next: (arrayForms) => {
|
|
1859
|
+
if (arrayForms.length > 0) {
|
|
1860
|
+
for (const forms of arrayForms) {
|
|
1861
|
+
let components = [];
|
|
1862
|
+
components.push(...FormioUtil.getComponents(forms.components));
|
|
1863
|
+
if (forms.components && forms.components.length > 0) {
|
|
1864
|
+
for (const components of forms.components) {
|
|
1865
|
+
if (components.components && components.components.length > 0) {
|
|
1866
|
+
for (const component of components.components) {
|
|
1867
|
+
if (component.columns && component.columns.length > 0) {
|
|
1868
|
+
for (const cComponents of component.columns) {
|
|
1869
|
+
if (cComponents.components &&
|
|
1870
|
+
cComponents.components.length > 0) {
|
|
1871
|
+
for (const iterator of cComponents.components) {
|
|
1872
|
+
if (iterator.type === 'address') {
|
|
1873
|
+
delete iterator.components;
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
2036
1883
|
}
|
|
2037
|
-
|
|
2038
|
-
|
|
1884
|
+
}
|
|
1885
|
+
let form = arrayForms;
|
|
1886
|
+
if (!form ||
|
|
1887
|
+
!form[0] ||
|
|
1888
|
+
!form[0].promCodigo ||
|
|
1889
|
+
form[0].promCodigo != promCodigo) {
|
|
1890
|
+
// this.router.navigate(['404']);
|
|
1891
|
+
resolve(lFormFieldsToken);
|
|
1892
|
+
}
|
|
1893
|
+
lFormFieldsToken = [];
|
|
1894
|
+
for (let formComp of form) {
|
|
1895
|
+
let newComponents;
|
|
1896
|
+
let components = [];
|
|
1897
|
+
if (formComp.components) {
|
|
1898
|
+
newComponents = formComp.components;
|
|
2039
1899
|
}
|
|
2040
|
-
|
|
2041
|
-
|
|
1900
|
+
else if (formComp.columns) {
|
|
1901
|
+
newComponents = formComp.columns;
|
|
1902
|
+
}
|
|
1903
|
+
if (newComponents && UtilString.isValid(formComp.title)) {
|
|
1904
|
+
lFormFieldsToken.push({
|
|
1905
|
+
title: {
|
|
1906
|
+
key: TokenService.getKeyFormulario(formComp.title),
|
|
1907
|
+
value: formComp.title,
|
|
1908
|
+
object: formComp
|
|
1909
|
+
},
|
|
1910
|
+
value: []
|
|
1911
|
+
});
|
|
1912
|
+
lFormFieldsToken[lFormFieldsToken.length - 1].value =
|
|
1913
|
+
this.getComponenetForm(components, newComponents, null, false, null);
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
resolve(lFormFieldsToken);
|
|
1917
|
+
},
|
|
1918
|
+
error: (error) => {
|
|
1919
|
+
reject(error);
|
|
1920
|
+
}
|
|
1921
|
+
});
|
|
1922
|
+
});
|
|
1923
|
+
}
|
|
1924
|
+
getFormFieldsByFormId(formId) {
|
|
1925
|
+
return new Promise((resolve, reject) => {
|
|
1926
|
+
// Search the dynamic form
|
|
1927
|
+
let lFormFieldsToken = null;
|
|
1928
|
+
this.formService.getById(formId).subscribe((result) => {
|
|
1929
|
+
let form = result;
|
|
1930
|
+
if (!form || !form[0]) {
|
|
1931
|
+
resolve(lFormFieldsToken);
|
|
1932
|
+
}
|
|
1933
|
+
lFormFieldsToken = [];
|
|
1934
|
+
for (let formComp of form) {
|
|
1935
|
+
let newComponents;
|
|
1936
|
+
let components = [];
|
|
1937
|
+
if (formComp.components) {
|
|
1938
|
+
newComponents = formComp.components;
|
|
1939
|
+
}
|
|
1940
|
+
else if (formComp.columns) {
|
|
1941
|
+
newComponents = formComp.columns;
|
|
1942
|
+
}
|
|
1943
|
+
if (newComponents && UtilString.isValid(formComp.title)) {
|
|
1944
|
+
lFormFieldsToken.push({
|
|
1945
|
+
title: {
|
|
1946
|
+
key: TokenService.getKeyFormulario(formComp.title),
|
|
1947
|
+
value: formComp.title,
|
|
1948
|
+
object: formComp
|
|
1949
|
+
},
|
|
1950
|
+
value: []
|
|
1951
|
+
});
|
|
1952
|
+
lFormFieldsToken[lFormFieldsToken.length - 1].value =
|
|
1953
|
+
this.getComponenetForm(components, newComponents, null, false, null);
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
resolve(lFormFieldsToken);
|
|
1957
|
+
}, (error) => {
|
|
1958
|
+
reject(error);
|
|
1959
|
+
});
|
|
1960
|
+
});
|
|
1961
|
+
}
|
|
1962
|
+
/** This promise allows to execute a function when consulting the form fields. */
|
|
1963
|
+
getFormPanelsByPromCode(promCodigo) {
|
|
1964
|
+
return new Promise((resolve, reject) => {
|
|
1965
|
+
// Search the dynamic form
|
|
1966
|
+
let lFormPannelsToken = null;
|
|
1967
|
+
this.formService.getByPromCodigo(promCodigo).subscribe((result) => {
|
|
1968
|
+
let form = result;
|
|
1969
|
+
if (!form ||
|
|
1970
|
+
!form[0] ||
|
|
1971
|
+
!form[0].promCodigo ||
|
|
1972
|
+
form[0].promCodigo != promCodigo) {
|
|
1973
|
+
// this.router.navigate(['404']);
|
|
1974
|
+
resolve(lFormPannelsToken);
|
|
1975
|
+
}
|
|
1976
|
+
lFormPannelsToken = [];
|
|
1977
|
+
for (let formComp of form) {
|
|
1978
|
+
let newComponents;
|
|
1979
|
+
let components = [];
|
|
1980
|
+
if (formComp.components) {
|
|
1981
|
+
newComponents = formComp.components;
|
|
1982
|
+
}
|
|
1983
|
+
else if (formComp.columns) {
|
|
1984
|
+
newComponents = formComp.columns;
|
|
1985
|
+
}
|
|
1986
|
+
if (newComponents && UtilString.isValid(formComp.title)) {
|
|
1987
|
+
lFormPannelsToken.push({
|
|
1988
|
+
title: {
|
|
1989
|
+
key: TokenService.getKeyFormulario(formComp.title),
|
|
1990
|
+
value: formComp.title,
|
|
1991
|
+
object: formComp
|
|
1992
|
+
},
|
|
1993
|
+
value: []
|
|
1994
|
+
});
|
|
1995
|
+
lFormPannelsToken[lFormPannelsToken.length - 1].value =
|
|
1996
|
+
this.getPanelComponenet(components, newComponents, null);
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
resolve(lFormPannelsToken);
|
|
2000
|
+
}, (error) => {
|
|
2001
|
+
reject(error);
|
|
2002
|
+
});
|
|
2003
|
+
});
|
|
2004
|
+
}
|
|
2005
|
+
/**
|
|
2006
|
+
* A recursive method to get all the information of the editGrid dynamic form
|
|
2007
|
+
* @param components
|
|
2008
|
+
* @param form
|
|
2009
|
+
*/
|
|
2010
|
+
getPanelComponenet(components, form, panelName) {
|
|
2011
|
+
for (let formComp of form) {
|
|
2012
|
+
if (formComp.type === 'panel') {
|
|
2013
|
+
components.push(formComp);
|
|
2014
|
+
}
|
|
2015
|
+
else if (formComp.components || formComp.columns) {
|
|
2016
|
+
let newComponents;
|
|
2017
|
+
if (formComp.components) {
|
|
2018
|
+
newComponents = formComp.components;
|
|
2042
2019
|
}
|
|
2020
|
+
else if (formComp.columns) {
|
|
2021
|
+
newComponents = formComp.columns;
|
|
2022
|
+
}
|
|
2023
|
+
components = this.getPanelComponenet(components, newComponents, panelName);
|
|
2043
2024
|
}
|
|
2044
2025
|
}
|
|
2045
|
-
return
|
|
2026
|
+
return components;
|
|
2046
2027
|
}
|
|
2047
2028
|
/**
|
|
2048
|
-
*
|
|
2049
|
-
*
|
|
2050
|
-
*
|
|
2051
|
-
*
|
|
2052
|
-
* @param expression Operando que evalua tag. Es de la forma ['tag1', 'tag2']==tag3
|
|
2053
|
-
* @returns Retorna 'true' o 'false' en string que despues sera pasado a un eval()
|
|
2054
|
-
* mas adelante en el flujo
|
|
2029
|
+
* A recursive method to get all the information of the components a columns of the dynamic form
|
|
2030
|
+
* @param components
|
|
2031
|
+
* @param form
|
|
2055
2032
|
*/
|
|
2056
|
-
|
|
2057
|
-
let
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
valueToken = valueToken.split(',');
|
|
2082
|
-
// Se trata de constatar si el valor a comparar se encuetra o no dentro
|
|
2083
|
-
// Si el operador que se encontro == returna true si lo encuentra
|
|
2084
|
-
let isTagFound = true;
|
|
2085
|
-
switch (operator[0]) {
|
|
2086
|
-
case '==':
|
|
2087
|
-
isTagFound = valueToken.some((tag) => tag == valueToCompare);
|
|
2088
|
-
break;
|
|
2089
|
-
case '===':
|
|
2090
|
-
isTagFound = valueToken.some((tag) => tag === valueToCompare);
|
|
2091
|
-
break;
|
|
2092
|
-
case '!==':
|
|
2093
|
-
isTagFound = valueToken.some((tag) => tag !== valueToCompare);
|
|
2094
|
-
break;
|
|
2095
|
-
case '!=':
|
|
2096
|
-
isTagFound = valueToken.some((tag) => tag != valueToCompare);
|
|
2097
|
-
break;
|
|
2098
|
-
default:
|
|
2099
|
-
break;
|
|
2033
|
+
getComponenetForm(components, form, panelName, editgrid, editGridKey) {
|
|
2034
|
+
for (let formComp of form) {
|
|
2035
|
+
if ((formComp.components || formComp.columns) && (formComp.type !== "address")) {
|
|
2036
|
+
let newComponents;
|
|
2037
|
+
if (formComp.components) {
|
|
2038
|
+
newComponents = formComp.components;
|
|
2039
|
+
if (formComp.type === 'editgrid') {
|
|
2040
|
+
editgrid = true;
|
|
2041
|
+
editGridKey = formComp.key;
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
else if (formComp.columns) {
|
|
2045
|
+
newComponents = formComp.columns;
|
|
2046
|
+
}
|
|
2047
|
+
if (formComp.type && formComp.type === 'panel') {
|
|
2048
|
+
panelName = formComp.title;
|
|
2049
|
+
}
|
|
2050
|
+
components = this.getComponenetForm(components, newComponents, panelName, editgrid, editGridKey);
|
|
2051
|
+
}
|
|
2052
|
+
else {
|
|
2053
|
+
formComp.panelName = panelName;
|
|
2054
|
+
formComp.editgrid = editgrid;
|
|
2055
|
+
formComp.editGridKey = editGridKey;
|
|
2056
|
+
components.push(formComp);
|
|
2057
|
+
}
|
|
2100
2058
|
}
|
|
2101
|
-
|
|
2102
|
-
|
|
2059
|
+
return components;
|
|
2060
|
+
}
|
|
2061
|
+
/** This promise allows to execute a function when consulting the form fields. */
|
|
2062
|
+
getFormEditGridFieldsByPromCode(promCodigo) {
|
|
2063
|
+
return new Promise((resolve, reject) => {
|
|
2064
|
+
// Search the dynamic form
|
|
2065
|
+
let lFormFieldsToken = null;
|
|
2066
|
+
this.formService.getByPromCodigo(promCodigo).subscribe((result) => {
|
|
2067
|
+
let form = result;
|
|
2068
|
+
if (!form ||
|
|
2069
|
+
!form[0] ||
|
|
2070
|
+
!form[0].promCodigo ||
|
|
2071
|
+
form[0].promCodigo != promCodigo) {
|
|
2072
|
+
// this.router.navigate(['404']);
|
|
2073
|
+
resolve(lFormFieldsToken);
|
|
2074
|
+
}
|
|
2075
|
+
lFormFieldsToken = [];
|
|
2076
|
+
for (let formComp of form) {
|
|
2077
|
+
let newComponents;
|
|
2078
|
+
let components = [];
|
|
2079
|
+
if (formComp.components) {
|
|
2080
|
+
newComponents = formComp.components;
|
|
2081
|
+
}
|
|
2082
|
+
else if (formComp.columns) {
|
|
2083
|
+
newComponents = formComp.columns;
|
|
2084
|
+
}
|
|
2085
|
+
if (newComponents && UtilString.isValid(formComp.title)) {
|
|
2086
|
+
lFormFieldsToken.push({
|
|
2087
|
+
title: {
|
|
2088
|
+
key: TokenService.getKeyFormulario(formComp.title),
|
|
2089
|
+
value: formComp.title,
|
|
2090
|
+
object: formComp
|
|
2091
|
+
},
|
|
2092
|
+
value: []
|
|
2093
|
+
});
|
|
2094
|
+
lFormFieldsToken[lFormFieldsToken.length - 1].value =
|
|
2095
|
+
this.getEditGridComponenet(components, newComponents, null);
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
resolve(lFormFieldsToken);
|
|
2099
|
+
}, (error) => {
|
|
2100
|
+
reject(error);
|
|
2101
|
+
});
|
|
2102
|
+
});
|
|
2103
2103
|
}
|
|
2104
2104
|
/**
|
|
2105
|
-
*
|
|
2106
|
-
* @param
|
|
2107
|
-
* @param
|
|
2108
|
-
* @param formula
|
|
2105
|
+
* A recursive method to get all the information of the editGrid dynamic form
|
|
2106
|
+
* @param components
|
|
2107
|
+
* @param form
|
|
2109
2108
|
*/
|
|
2110
|
-
|
|
2111
|
-
let
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
}
|
|
2109
|
+
getEditGridComponenet(components, form, panelName) {
|
|
2110
|
+
for (let formComp of form) {
|
|
2111
|
+
if (formComp.type === 'editgrid') {
|
|
2112
|
+
formComp.panelName = panelName;
|
|
2113
|
+
components.push(formComp);
|
|
2114
|
+
}
|
|
2115
|
+
else if (formComp.components || formComp.columns) {
|
|
2116
|
+
let newComponents;
|
|
2117
|
+
if (formComp.components) {
|
|
2118
|
+
newComponents = formComp.components;
|
|
2119
|
+
}
|
|
2120
|
+
else if (formComp.columns) {
|
|
2121
|
+
newComponents = formComp.columns;
|
|
2124
2122
|
}
|
|
2123
|
+
if (formComp.type && formComp.type === 'panel') {
|
|
2124
|
+
panelName = formComp.title;
|
|
2125
|
+
}
|
|
2126
|
+
components = this.getEditGridComponenet(components, newComponents, panelName);
|
|
2125
2127
|
}
|
|
2126
2128
|
}
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
+
return components;
|
|
2130
|
+
}
|
|
2131
|
+
/** It returns the tokens by promCodigo */
|
|
2132
|
+
getListByPromCodigo(promCode) {
|
|
2133
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'token/getByPromCodigo', { params: new HttpParams().set('promCodigo', promCode.toString()) });
|
|
2134
|
+
}
|
|
2135
|
+
/** It returns the token by id */
|
|
2136
|
+
getById(id) {
|
|
2137
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'token/getById', {
|
|
2138
|
+
params: new HttpParams().set('id', id.toString())
|
|
2139
|
+
});
|
|
2140
|
+
}
|
|
2141
|
+
/** It deletes a form by id */
|
|
2142
|
+
delete(id) {
|
|
2143
|
+
return this.httpClient.delete(this.environment.host.backend.configuration + 'token/delete', { params: new HttpParams().set('id', id) });
|
|
2144
|
+
}
|
|
2145
|
+
/** It saves the token */
|
|
2146
|
+
save(token) {
|
|
2147
|
+
return this.httpClient.post(this.environment.host.backend.configuration + 'token/save', token, HEADER_JSON);
|
|
2148
|
+
}
|
|
2149
|
+
static getKeyFormulario(formTitle) {
|
|
2150
|
+
if (UtilString.isValid(formTitle)) {
|
|
2151
|
+
return (UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_FORM) +
|
|
2152
|
+
UtilString.replaceAccentSpacesOthers(formTitle).replace(/_/g, '-'));
|
|
2129
2153
|
}
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2154
|
+
return '';
|
|
2155
|
+
}
|
|
2156
|
+
/** It returns the unique verification code */
|
|
2157
|
+
getUniqueVerificationCode(login, token) {
|
|
2158
|
+
return this.httpClient.get(this.environment.host.backend.documentsRepository +
|
|
2159
|
+
'documento/consultarCodigoUnico/' +
|
|
2160
|
+
login +
|
|
2161
|
+
'/' +
|
|
2162
|
+
token, { params: new HttpParams() });
|
|
2163
|
+
}
|
|
2164
|
+
/** It send the information to copy the Document viewer */
|
|
2165
|
+
copyDocumentInformationViewer(login, token, uniqueCode, documentURL, documentName) {
|
|
2166
|
+
let infoDocumento = {
|
|
2167
|
+
codigoUnico: uniqueCode,
|
|
2168
|
+
rutaDocumento: documentURL,
|
|
2169
|
+
documentName: documentName
|
|
2170
|
+
};
|
|
2171
|
+
return this.httpClient.post(this.environment.host.backend.documentsRepository +
|
|
2172
|
+
'documento/adicionarDocumento/' +
|
|
2173
|
+
login +
|
|
2174
|
+
'/' +
|
|
2175
|
+
token, infoDocumento, HEADER_JSON);
|
|
2176
|
+
}
|
|
2177
|
+
static getKeyBudget() {
|
|
2178
|
+
return UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_BUDGET);
|
|
2179
|
+
}
|
|
2180
|
+
static getKeyDocument() {
|
|
2181
|
+
return UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_DOCUMENTO);
|
|
2182
|
+
}
|
|
2183
|
+
static getKeyTask() {
|
|
2184
|
+
return UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_TASKL);
|
|
2185
|
+
}
|
|
2186
|
+
static getKeyStatic() {
|
|
2187
|
+
return UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_STATIC);
|
|
2188
|
+
}
|
|
2189
|
+
static getKeyCalculated(token) {
|
|
2190
|
+
return (UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_CALCULATED) +
|
|
2191
|
+
'_' +
|
|
2192
|
+
UtilString.replaceAccentSpacesOthers(token.name));
|
|
2193
|
+
}
|
|
2194
|
+
static getKeySnapshot(token) {
|
|
2195
|
+
return (UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_SNAPSHOT) +
|
|
2196
|
+
'_' +
|
|
2197
|
+
UtilString.replaceAccentSpacesOthers(token.name));
|
|
2198
|
+
}
|
|
2199
|
+
static getKeyGuarantee(token) {
|
|
2200
|
+
return (UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_GUARANTEE) +
|
|
2201
|
+
'_' +
|
|
2202
|
+
UtilString.replaceAccentSpacesOthers(token.name));
|
|
2203
|
+
}
|
|
2204
|
+
/**
|
|
2205
|
+
* Return a value that represent the type of label: 1=Form, 2=Budget, 3=Static, 4=Calculated
|
|
2206
|
+
* @param key Value to evalueate
|
|
2207
|
+
*/
|
|
2208
|
+
static getKeyType(key) {
|
|
2209
|
+
key = key.replace('{', '').replace('}', '');
|
|
2210
|
+
key = key.substring(1, key.indexOf('_'));
|
|
2211
|
+
if (key.startsWith(UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_FORM))) {
|
|
2212
|
+
return 1;
|
|
2133
2213
|
}
|
|
2134
|
-
if (
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2214
|
+
else if (key.startsWith(UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_BUDGET))) {
|
|
2215
|
+
return 2;
|
|
2216
|
+
}
|
|
2217
|
+
else if (key.startsWith(UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_STATIC))) {
|
|
2218
|
+
return 3;
|
|
2219
|
+
}
|
|
2220
|
+
else if (key.startsWith(UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_CALCULATED))) {
|
|
2221
|
+
return 4;
|
|
2222
|
+
}
|
|
2223
|
+
else if (key.startsWith(UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_TASKL))) {
|
|
2224
|
+
return 5;
|
|
2225
|
+
}
|
|
2226
|
+
return null;
|
|
2227
|
+
}
|
|
2228
|
+
/**
|
|
2229
|
+
* Depends of the type of formFieldToken return de value of the valueData
|
|
2230
|
+
* @param formFieldToken
|
|
2231
|
+
* @param valueData
|
|
2232
|
+
*/
|
|
2233
|
+
getValueFromFormField(formFieldToken, valueData) {
|
|
2234
|
+
if (typeof valueData == 'object') {
|
|
2235
|
+
if (formFieldToken.type) {
|
|
2236
|
+
if (formFieldToken.type == 'address') {
|
|
2237
|
+
return valueData.formatted_address;
|
|
2238
|
+
}
|
|
2239
|
+
if (formFieldToken.type == 'select' &&
|
|
2240
|
+
formFieldToken.searchField &&
|
|
2241
|
+
valueData.hasOwnProperty(formFieldToken.searchField)) {
|
|
2242
|
+
return valueData[formFieldToken.searchField];
|
|
2243
|
+
}
|
|
2146
2244
|
}
|
|
2147
2245
|
}
|
|
2148
|
-
return
|
|
2246
|
+
return valueData;
|
|
2247
|
+
}
|
|
2248
|
+
/**
|
|
2249
|
+
* Try to find the token in the stringText and replace with dataValue. If detect format of number or date try to format the dataValue
|
|
2250
|
+
* @param stringText
|
|
2251
|
+
* @param token
|
|
2252
|
+
* @param dataValue
|
|
2253
|
+
*/
|
|
2254
|
+
replaceToken(stringText, token, dataValue) {
|
|
2255
|
+
let valueReplace = null;
|
|
2256
|
+
if (token && token[0] == '#') {
|
|
2257
|
+
let typeToken = token.substring(1, token.indexOf('('));
|
|
2258
|
+
if (typeToken == 'date') {
|
|
2259
|
+
let dateFormat = token.substring(token.indexOf('}') + 1, token.indexOf(')'));
|
|
2260
|
+
dateFormat = dateFormat.trim().replace(/\"/g, '').replace(/\'/g, '');
|
|
2261
|
+
let dateValue = DateUtil.getDate(dataValue);
|
|
2262
|
+
if (dateValue) {
|
|
2263
|
+
valueReplace = DateUtil.getMoment(dateValue).format(dateFormat);
|
|
2264
|
+
}
|
|
2265
|
+
else {
|
|
2266
|
+
valueReplace = '';
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
else if (typeToken == 'number') {
|
|
2270
|
+
let numberValue = Number(dataValue);
|
|
2271
|
+
if (numberValue != undefined && !isNaN(numberValue)) {
|
|
2272
|
+
let numberFormat = token.substring(token.indexOf('}') + 1, token.indexOf(')'));
|
|
2273
|
+
numberFormat = numberFormat.trim().replace(/\"/g, '').replace(/\'/g, '');
|
|
2274
|
+
valueReplace = this.currencyPipe.transform(numberValue, this.locale, '', numberFormat);
|
|
2275
|
+
}
|
|
2276
|
+
else {
|
|
2277
|
+
console.log('El dato [' +
|
|
2278
|
+
dataValue +
|
|
2279
|
+
'] para el token [' +
|
|
2280
|
+
token +
|
|
2281
|
+
'] tipo númerico no es valido');
|
|
2282
|
+
valueReplace = '';
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
else {
|
|
2286
|
+
console.log('tipo de token indefinido. [typeToken[' + typeToken + ']]');
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
else if (token && token[0] == '$') {
|
|
2290
|
+
valueReplace = dataValue;
|
|
2291
|
+
}
|
|
2292
|
+
else {
|
|
2293
|
+
console.log('El token no es valido. [token[' + token + ']]');
|
|
2294
|
+
}
|
|
2295
|
+
if (stringText && valueReplace !== null) {
|
|
2296
|
+
// replace text in a more efficient way
|
|
2297
|
+
stringText = stringText.split(token).join(valueReplace);
|
|
2298
|
+
//stringText = stringText.replace(token, valueReplace);
|
|
2299
|
+
}
|
|
2300
|
+
return stringText;
|
|
2301
|
+
}
|
|
2302
|
+
getListTokensByStringSegmentation(stringText) {
|
|
2303
|
+
const arrayToken = stringText.match(/\${([^}]+)\}/g);
|
|
2304
|
+
const arrayTokenFormattedDate = stringText.match(/\#date[^)]+\)/g);
|
|
2305
|
+
const arrayTokenFormattedNumber = stringText.match(/\#number[^)]+\)/g);
|
|
2306
|
+
let arrayTokenFormatted = [];
|
|
2307
|
+
if (arrayTokenFormattedDate &&
|
|
2308
|
+
arrayTokenFormattedDate.length > 0 &&
|
|
2309
|
+
arrayTokenFormattedNumber &&
|
|
2310
|
+
arrayTokenFormattedNumber.length > 0) {
|
|
2311
|
+
arrayTokenFormatted = arrayTokenFormattedDate.concat(arrayTokenFormattedNumber);
|
|
2312
|
+
}
|
|
2313
|
+
else if (arrayTokenFormattedDate && arrayTokenFormattedDate.length > 0) {
|
|
2314
|
+
arrayTokenFormatted = arrayTokenFormattedDate.slice();
|
|
2315
|
+
}
|
|
2316
|
+
else if (arrayTokenFormattedNumber && arrayTokenFormattedNumber.length > 0) {
|
|
2317
|
+
arrayTokenFormatted = arrayTokenFormattedNumber.slice();
|
|
2318
|
+
}
|
|
2319
|
+
const result = [];
|
|
2320
|
+
if (arrayToken) {
|
|
2321
|
+
for (const token of arrayToken) {
|
|
2322
|
+
const infoToken = { key: token, value: token };
|
|
2323
|
+
if (arrayTokenFormatted) {
|
|
2324
|
+
for (const tokenFormatted of arrayTokenFormatted) {
|
|
2325
|
+
const index = tokenFormatted.indexOf(token);
|
|
2326
|
+
if (index >= 0) {
|
|
2327
|
+
infoToken.value = tokenFormatted;
|
|
2328
|
+
break;
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
result.push(infoToken);
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
return result;
|
|
2336
|
+
}
|
|
2337
|
+
changeIdPropertiesOfObject(normalizationColumns, listData) {
|
|
2338
|
+
const newData = [];
|
|
2339
|
+
listData.forEach((data) => {
|
|
2340
|
+
const objData = {};
|
|
2341
|
+
Object.keys(data).forEach((property) => {
|
|
2342
|
+
if (data.hasOwnProperty(property)) {
|
|
2343
|
+
normalizationColumns.forEach((column) => {
|
|
2344
|
+
if (column.idColumn.toString() === property) {
|
|
2345
|
+
objData[column.key] = data[property];
|
|
2346
|
+
}
|
|
2347
|
+
});
|
|
2348
|
+
}
|
|
2349
|
+
});
|
|
2350
|
+
if (objData) {
|
|
2351
|
+
newData.push(objData);
|
|
2352
|
+
}
|
|
2353
|
+
});
|
|
2354
|
+
return newData;
|
|
2355
|
+
}
|
|
2356
|
+
generateHtmlByTokensAndData(html, listData, listTokens) {
|
|
2357
|
+
const translatedCards = [];
|
|
2358
|
+
listData.forEach((data) => {
|
|
2359
|
+
const objToken = {};
|
|
2360
|
+
const htmlTranslated = { html: html };
|
|
2361
|
+
Object.keys(data).forEach((property) => {
|
|
2362
|
+
listTokens.forEach((token) => {
|
|
2363
|
+
if (property == token.key.replace('${', '').replace('}', '')) {
|
|
2364
|
+
objToken[token.key] = data[property];
|
|
2365
|
+
htmlTranslated.html = htmlTranslated.html.replace(token.key, data[property]);
|
|
2366
|
+
}
|
|
2367
|
+
});
|
|
2368
|
+
});
|
|
2369
|
+
translatedCards.push(htmlTranslated);
|
|
2370
|
+
});
|
|
2371
|
+
return translatedCards;
|
|
2372
|
+
}
|
|
2373
|
+
getListTokensByString(stringText) {
|
|
2374
|
+
var arrayToken = stringText.match(/\${([^}]+)\}/g);
|
|
2375
|
+
var arrayTokenFormattedDate = stringText.match(/\#date[^)]+\)/g);
|
|
2376
|
+
var arrayTokenFormattedNumber = stringText.match(/\#number[^)]+\)/g);
|
|
2377
|
+
var arrayTokenFormatted = [];
|
|
2378
|
+
if (arrayTokenFormattedDate &&
|
|
2379
|
+
arrayTokenFormattedDate.length > 0 &&
|
|
2380
|
+
arrayTokenFormattedNumber &&
|
|
2381
|
+
arrayTokenFormattedNumber.length > 0) {
|
|
2382
|
+
arrayTokenFormatted = arrayTokenFormattedDate.concat(arrayTokenFormattedNumber);
|
|
2383
|
+
}
|
|
2384
|
+
else if (arrayTokenFormattedDate && arrayTokenFormattedDate.length > 0) {
|
|
2385
|
+
arrayTokenFormatted = arrayTokenFormattedDate.slice();
|
|
2386
|
+
}
|
|
2387
|
+
else if (arrayTokenFormattedNumber && arrayTokenFormattedNumber.length > 0) {
|
|
2388
|
+
arrayTokenFormatted = arrayTokenFormattedNumber.slice();
|
|
2389
|
+
}
|
|
2390
|
+
var result = [];
|
|
2391
|
+
if (arrayToken) {
|
|
2392
|
+
for (const token of arrayToken) {
|
|
2393
|
+
let keyType = TokenService.getKeyType(token);
|
|
2394
|
+
if (keyType === null) {
|
|
2395
|
+
continue;
|
|
2396
|
+
}
|
|
2397
|
+
var infoToken = { key: token, value: token };
|
|
2398
|
+
if (arrayTokenFormatted) {
|
|
2399
|
+
for (const tokenFormatted of arrayTokenFormatted) {
|
|
2400
|
+
var index = tokenFormatted.indexOf(token);
|
|
2401
|
+
if (index >= 0) {
|
|
2402
|
+
infoToken.value = tokenFormatted;
|
|
2403
|
+
break;
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
result.push(infoToken);
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
return result;
|
|
2411
|
+
// let tokens: any[] = [];
|
|
2412
|
+
// let i = this.nextValidPositionTokens(stringText, 0);
|
|
2413
|
+
// let count = 0;
|
|
2414
|
+
// while (i >= 0 && count <= 10) {
|
|
2415
|
+
// let infoToken: {} = null;
|
|
2416
|
+
// let nextI: number = i;
|
|
2417
|
+
// let character = stringText.substring(i, (i + 1));
|
|
2418
|
+
// if (character == "$") {
|
|
2419
|
+
// let nextCharacter = stringText.substring((i + 1), (i + 2));
|
|
2420
|
+
// // The next character need to be a { sign
|
|
2421
|
+
// if (nextCharacter != "{") {
|
|
2422
|
+
// i = this.nextValidPositionTokens(stringText, nextI + 1);
|
|
2423
|
+
// continue;
|
|
2424
|
+
// }
|
|
2425
|
+
// let keyToken: string = stringText.substring(i, stringText.indexOf("}", i) + 1);
|
|
2426
|
+
// // If the token have a valid key type
|
|
2427
|
+
// let keyType: number = TokenService.getKeyType(keyToken.replace("{", "").replace("}", ""));
|
|
2428
|
+
// if (keyType === null) {
|
|
2429
|
+
// i = this.nextValidPositionTokens(stringText, nextI + 1);
|
|
2430
|
+
// continue;
|
|
2431
|
+
// }
|
|
2432
|
+
// infoToken = {
|
|
2433
|
+
// key: keyToken,
|
|
2434
|
+
// value: keyToken
|
|
2435
|
+
// };
|
|
2436
|
+
// nextI = stringText.indexOf("}", i);
|
|
2437
|
+
// } else {
|
|
2438
|
+
// let nextSign: number = stringText.indexOf("$", i);
|
|
2439
|
+
// // We inly support #date($ and #number($ in this 2 scenarios the lenght can't be more than 10 characters
|
|
2440
|
+
// if (nextSign < 0 || (nextSign - i) > 10) {
|
|
2441
|
+
// i = this.nextValidPositionTokens(stringText, nextI + 1);
|
|
2442
|
+
// continue;
|
|
2443
|
+
// }
|
|
2444
|
+
// let keyToken: string = stringText.substring(stringText.indexOf("$", i), stringText.indexOf("}", i) + 1);
|
|
2445
|
+
// let valueToken: string = stringText.substring(i, stringText.indexOf(")", i) + 1);
|
|
2446
|
+
// infoToken = {
|
|
2447
|
+
// key: keyToken,
|
|
2448
|
+
// value: valueToken
|
|
2449
|
+
// };
|
|
2450
|
+
// nextI = stringText.indexOf(")", i);
|
|
2451
|
+
// }
|
|
2452
|
+
// tokens.push(infoToken);
|
|
2453
|
+
// i = this.nextValidPositionTokens(stringText, nextI);
|
|
2454
|
+
// count++;
|
|
2455
|
+
// }
|
|
2456
|
+
// return tokens;
|
|
2457
|
+
}
|
|
2458
|
+
nextValidPositionTokens(stringText, nextI) {
|
|
2459
|
+
let tokenDollarSign = stringText.indexOf('$', nextI);
|
|
2460
|
+
let tokenNumSign = stringText.indexOf('#', nextI);
|
|
2461
|
+
let i = tokenDollarSign < 0 && tokenNumSign >= 0
|
|
2462
|
+
? tokenNumSign
|
|
2463
|
+
: tokenNumSign < 0 && tokenDollarSign >= 0
|
|
2464
|
+
? tokenDollarSign
|
|
2465
|
+
: tokenDollarSign < tokenNumSign
|
|
2466
|
+
? tokenDollarSign
|
|
2467
|
+
: tokenNumSign;
|
|
2468
|
+
return i;
|
|
2469
|
+
}
|
|
2470
|
+
/**
|
|
2471
|
+
* It reuses replaceTokensFromListObjectPublic but set all keys lobjecttokens as lowercase
|
|
2472
|
+
* @param tokenName
|
|
2473
|
+
* @param formula
|
|
2474
|
+
* @param lObjectTokens
|
|
2475
|
+
*/
|
|
2476
|
+
replaceTokensFromListObjectPublic(tokenName, formula, lObjectTokens) {
|
|
2477
|
+
let lDataOrg = [];
|
|
2478
|
+
if (lObjectTokens) {
|
|
2479
|
+
for (let dataForm in lObjectTokens) {
|
|
2480
|
+
lDataOrg[dataForm.toLowerCase()] = lObjectTokens[dataForm];
|
|
2481
|
+
}
|
|
2482
|
+
}
|
|
2483
|
+
return this.replaceTokensFromListObject(tokenName, formula, lDataOrg);
|
|
2484
|
+
}
|
|
2485
|
+
/**
|
|
2486
|
+
* @param tokenName token name
|
|
2487
|
+
* @param formula String with the formula to execute
|
|
2488
|
+
* @param lObjectTokens List of tokens with the values to replace
|
|
2489
|
+
*/
|
|
2490
|
+
replaceTokensFromListObject(tokenName, formula, lObjectTokens) {
|
|
2491
|
+
if (!formula || formula.length == 0) {
|
|
2492
|
+
throw {
|
|
2493
|
+
message: 'La formula del token ' + tokenName + ' esta vacía',
|
|
2494
|
+
title: 'Alerta!',
|
|
2495
|
+
error: 'La formula del token ' + tokenName + ' esta vacía. [formula[' + formula + ']]'
|
|
2496
|
+
};
|
|
2497
|
+
}
|
|
2498
|
+
let replacedTokens = formula.toString();
|
|
2499
|
+
if (replacedTokens.startsWith('file://')) {
|
|
2500
|
+
return replacedTokens;
|
|
2501
|
+
}
|
|
2502
|
+
// Find the tokens in the formula
|
|
2503
|
+
let tokensArray = this.getListTokensByString(replacedTokens);
|
|
2504
|
+
if (tokensArray.length == 0) {
|
|
2505
|
+
return replacedTokens;
|
|
2506
|
+
}
|
|
2507
|
+
// If there any token, try to replace
|
|
2508
|
+
for (let i = 0; i < tokensArray.length; i++) {
|
|
2509
|
+
let objectToken = lObjectTokens[tokensArray[i].key] !== undefined
|
|
2510
|
+
? lObjectTokens[tokensArray[i].key]
|
|
2511
|
+
: null;
|
|
2512
|
+
let clearKey;
|
|
2513
|
+
if (objectToken == null) {
|
|
2514
|
+
clearKey = tokensArray[i].key.replace('${', '').replace('}', '').toLowerCase();
|
|
2515
|
+
objectToken =
|
|
2516
|
+
lObjectTokens[clearKey] !== undefined ? lObjectTokens[clearKey] : null;
|
|
2517
|
+
if (objectToken == null) {
|
|
2518
|
+
clearKey = tokensArray[i].key
|
|
2519
|
+
.replace('{', '')
|
|
2520
|
+
.replace('}', '')
|
|
2521
|
+
.split('_')[1]
|
|
2522
|
+
.toLowerCase();
|
|
2523
|
+
objectToken =
|
|
2524
|
+
lObjectTokens[clearKey] !== undefined ? lObjectTokens[clearKey] : null;
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
if (objectToken == null) {
|
|
2528
|
+
// If not find the token, by default put an empty string
|
|
2529
|
+
/*if (TokenService.excludedToken.indexOf(clearKey) === -1) {
|
|
2530
|
+
console.error(
|
|
2531
|
+
'El token ' + tokensArray[i].value + ' no fue encontrado.',
|
|
2532
|
+
lObjectTokens,
|
|
2533
|
+
tokensArray
|
|
2534
|
+
);
|
|
2535
|
+
}*/
|
|
2536
|
+
objectToken = '';
|
|
2537
|
+
}
|
|
2538
|
+
if (objectToken != null) {
|
|
2539
|
+
let value = Number(objectToken)
|
|
2540
|
+
? objectToken
|
|
2541
|
+
: Array.isArray(objectToken)
|
|
2542
|
+
? JSON.stringify(objectToken)
|
|
2543
|
+
: "'" + objectToken + "'";
|
|
2544
|
+
replacedTokens = this.replaceToken(replacedTokens, tokensArray[i].value, value);
|
|
2545
|
+
// } else {
|
|
2546
|
+
// console.error(lObjectTokens, tokensArray);
|
|
2547
|
+
// throw {
|
|
2548
|
+
// message: "No se encontró valor para un token",
|
|
2549
|
+
// title: "Alerta!",
|
|
2550
|
+
// error: "El token " + tokensArray[i].value + " no fue encontrado."
|
|
2551
|
+
// };
|
|
2552
|
+
//
|
|
2553
|
+
// Si es la ultima iteracion y la formula tiene [ es porque tiene un array en el valor que resolvio el token
|
|
2554
|
+
if (i == tokensArray.length - 1 && replacedTokens.includes('[')) {
|
|
2555
|
+
// Se ponen todos los operandos como elementos en un array ['expresion a', '&&', 'Expresion B']
|
|
2556
|
+
let formExpressions = replacedTokens.split(/ (\|\||&&) /);
|
|
2557
|
+
let lAuxformExpression = [];
|
|
2558
|
+
formExpressions.forEach((expression) => {
|
|
2559
|
+
if (expression.charAt(0) == '[') {
|
|
2560
|
+
let isTagFound = '';
|
|
2561
|
+
isTagFound = this.findTag(expression);
|
|
2562
|
+
lAuxformExpression.push(isTagFound);
|
|
2563
|
+
}
|
|
2564
|
+
else {
|
|
2565
|
+
lAuxformExpression.push(expression);
|
|
2566
|
+
}
|
|
2567
|
+
});
|
|
2568
|
+
replacedTokens = lAuxformExpression.join(' ');
|
|
2569
|
+
}
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
return replacedTokens;
|
|
2573
|
+
}
|
|
2574
|
+
/**
|
|
2575
|
+
* MEtodo que teniendo una expresion de la forma ['tag1', 'tag2']==tag3
|
|
2576
|
+
* evalua si tag3 hace parte del array si tiene el operador ==.
|
|
2577
|
+
* Si tiene el operador != examina que tag3 no haga parte del array+
|
|
2578
|
+
*
|
|
2579
|
+
* @param expression Operando que evalua tag. Es de la forma ['tag1', 'tag2']==tag3
|
|
2580
|
+
* @returns Retorna 'true' o 'false' en string que despues sera pasado a un eval()
|
|
2581
|
+
* mas adelante en el flujo
|
|
2582
|
+
*/
|
|
2583
|
+
findTag(expression) {
|
|
2584
|
+
let regexOperator = new RegExp('(===|==|!==|!=)');
|
|
2585
|
+
// Retorna el operador
|
|
2586
|
+
let operator = expression.match(regexOperator);
|
|
2587
|
+
// Si no encuentra un operador segun el patron retorna 'false'
|
|
2588
|
+
// para evitar resultados inesperados
|
|
2589
|
+
if (operator == null) {
|
|
2590
|
+
console.error('No se encontro un operador permitido para la expresion');
|
|
2591
|
+
return 'false';
|
|
2592
|
+
}
|
|
2593
|
+
// Separa la sentencia por el operador
|
|
2594
|
+
// La primera parte es el valor por el cual se remplaza el token que es un array en string "['a', 'b']"
|
|
2595
|
+
// El segundo es el valor con el cual se va a comparar
|
|
2596
|
+
let valueToken, valueToCompare;
|
|
2597
|
+
[valueToken, valueToCompare] = expression.split(operator[0]);
|
|
2598
|
+
// Se limpia el string correspondiente al array para que los elementos queden separados por ","
|
|
2599
|
+
valueToken = valueToken.replace(/[^a-zA-Z0-9 ,]/g, '');
|
|
2600
|
+
// Si no hay tags asociados al registro se devuelve 'false'
|
|
2601
|
+
if (!valueToken) {
|
|
2602
|
+
console.error('No hay tags asociados a esta aplicación');
|
|
2603
|
+
return 'false';
|
|
2604
|
+
}
|
|
2605
|
+
// Se limpia el string correspondiente al valor por comparar
|
|
2606
|
+
valueToCompare = valueToCompare.replace(/[^a-zA-Z0-9 ]/g, '');
|
|
2607
|
+
// El string correspondiente al array pasa a ser tipo array
|
|
2608
|
+
valueToken = valueToken.split(',');
|
|
2609
|
+
// Se trata de constatar si el valor a comparar se encuetra o no dentro
|
|
2610
|
+
// Si el operador que se encontro == returna true si lo encuentra
|
|
2611
|
+
let isTagFound = true;
|
|
2612
|
+
switch (operator[0]) {
|
|
2613
|
+
case '==':
|
|
2614
|
+
isTagFound = valueToken.some((tag) => tag == valueToCompare);
|
|
2615
|
+
break;
|
|
2616
|
+
case '===':
|
|
2617
|
+
isTagFound = valueToken.some((tag) => tag === valueToCompare);
|
|
2618
|
+
break;
|
|
2619
|
+
case '!==':
|
|
2620
|
+
isTagFound = valueToken.some((tag) => tag !== valueToCompare);
|
|
2621
|
+
break;
|
|
2622
|
+
case '!=':
|
|
2623
|
+
isTagFound = valueToken.some((tag) => tag != valueToCompare);
|
|
2624
|
+
break;
|
|
2625
|
+
default:
|
|
2626
|
+
break;
|
|
2627
|
+
}
|
|
2628
|
+
expression = isTagFound ? 'true' : 'false';
|
|
2629
|
+
return expression;
|
|
2630
|
+
}
|
|
2631
|
+
/**
|
|
2632
|
+
* Try to eval the formula depend of the type of fields.
|
|
2633
|
+
* @param lStaticToken
|
|
2634
|
+
* @param formulaName
|
|
2635
|
+
* @param formula
|
|
2636
|
+
*/
|
|
2637
|
+
validateFormula(lStaticToken, formulaName, formula) {
|
|
2638
|
+
let evalFormula = false;
|
|
2639
|
+
// To validate the formula, first organize the info to key - value array
|
|
2640
|
+
let objectTokens = [];
|
|
2641
|
+
for (let panel of lStaticToken) {
|
|
2642
|
+
for (let groupToken of panel.value) {
|
|
2643
|
+
for (let staticToken of groupToken.value) {
|
|
2644
|
+
for (let arrayTokenInfo of staticToken) {
|
|
2645
|
+
objectTokens[arrayTokenInfo.key] = arrayTokenInfo.object
|
|
2646
|
+
? arrayTokenInfo.object.type == 'number'
|
|
2647
|
+
? '0'
|
|
2648
|
+
: ''
|
|
2649
|
+
: '';
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
try {
|
|
2655
|
+
formula = this.replaceTokensFromListObject(formulaName, formula, objectTokens);
|
|
2656
|
+
}
|
|
2657
|
+
catch (error) {
|
|
2658
|
+
//console.error(error);
|
|
2659
|
+
throw error;
|
|
2660
|
+
}
|
|
2661
|
+
if (formula !== null) {
|
|
2662
|
+
try {
|
|
2663
|
+
let result = formula.startsWith('file://') ? formula : eval(formula);
|
|
2664
|
+
evalFormula = true;
|
|
2665
|
+
}
|
|
2666
|
+
catch (e) {
|
|
2667
|
+
//console.error("Error evaluating the formula", e);
|
|
2668
|
+
throw {
|
|
2669
|
+
message: 'La formula no fue posible evaluar',
|
|
2670
|
+
title: 'Alerta!',
|
|
2671
|
+
error: e
|
|
2672
|
+
};
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
return evalFormula;
|
|
2149
2676
|
}
|
|
2150
2677
|
getConfigCloningTokenMap(oldPPP, newPPP) {
|
|
2151
2678
|
return this.httpClient.get(this.environment.host.backend.configuration + 'token/getConfigCloningTokenMap', {
|
|
@@ -9469,112 +9996,9 @@ class PliTagService {
|
|
|
9469
9996
|
});
|
|
9470
9997
|
}
|
|
9471
9998
|
}
|
|
9472
|
-
PliTagService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: PliTagService, deps: [{ token: 'environment' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
9473
|
-
PliTagService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: PliTagService, providedIn: 'root' });
|
|
9474
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: PliTagService, decorators: [{
|
|
9475
|
-
type: Injectable,
|
|
9476
|
-
args: [{
|
|
9477
|
-
providedIn: 'root'
|
|
9478
|
-
}]
|
|
9479
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
9480
|
-
type: Inject,
|
|
9481
|
-
args: ['environment']
|
|
9482
|
-
}] }, { type: i1.HttpClient }]; } });
|
|
9483
|
-
|
|
9484
|
-
class PliUserService {
|
|
9485
|
-
constructor(environment, httpClient) {
|
|
9486
|
-
this.environment = environment;
|
|
9487
|
-
this.httpClient = httpClient;
|
|
9488
|
-
this.headerJson = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) };
|
|
9489
|
-
}
|
|
9490
|
-
/** It returns the list */
|
|
9491
|
-
getAll() {
|
|
9492
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'pliUser/getAll');
|
|
9493
|
-
}
|
|
9494
|
-
/** It deletes a form by id */
|
|
9495
|
-
delete(id) {
|
|
9496
|
-
return this.httpClient.delete(this.environment.host.backend.configuration + 'pliUser/delete', { params: new HttpParams().set('id', id) });
|
|
9497
|
-
}
|
|
9498
|
-
/** It returns the user by id */
|
|
9499
|
-
getById(id) {
|
|
9500
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'pliUser/getById', { params: new HttpParams().set('id', id.toString()) });
|
|
9501
|
-
}
|
|
9502
|
-
/** It returns the user by id */
|
|
9503
|
-
getByLogin(login) {
|
|
9504
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'pliUser/getByLogin', { params: new HttpParams().set('login', login) });
|
|
9505
|
-
}
|
|
9506
|
-
/** It saves a user */
|
|
9507
|
-
save(user) {
|
|
9508
|
-
return this.httpClient.post(this.environment.host.backend.configuration + 'pliUser/save', user, this.headerJson);
|
|
9509
|
-
}
|
|
9510
|
-
/** It returns the list of users by patCodigo and list of profiles id */
|
|
9511
|
-
getByPatCodigoAndProfileIdList(patCodigo, listProfileId) {
|
|
9512
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'pliUser/getByPatCodigoAndProfileIdList', {
|
|
9513
|
-
params: new HttpParams()
|
|
9514
|
-
.set('patCodigo', patCodigo.toString())
|
|
9515
|
-
.set('listProfileId', listProfileId.toString())
|
|
9516
|
-
});
|
|
9517
|
-
}
|
|
9518
|
-
}
|
|
9519
|
-
PliUserService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: PliUserService, deps: [{ token: 'environment' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
9520
|
-
PliUserService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: PliUserService, providedIn: 'root' });
|
|
9521
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: PliUserService, decorators: [{
|
|
9522
|
-
type: Injectable,
|
|
9523
|
-
args: [{
|
|
9524
|
-
providedIn: 'root'
|
|
9525
|
-
}]
|
|
9526
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
9527
|
-
type: Inject,
|
|
9528
|
-
args: ['environment']
|
|
9529
|
-
}] }, { type: i1.HttpClient }]; } });
|
|
9530
|
-
|
|
9531
|
-
class ProfileService {
|
|
9532
|
-
constructor(environment, httpClient) {
|
|
9533
|
-
this.environment = environment;
|
|
9534
|
-
this.httpClient = httpClient;
|
|
9535
|
-
this.headerJson = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) };
|
|
9536
|
-
}
|
|
9537
|
-
/** It returns the profile by id */
|
|
9538
|
-
getAll() {
|
|
9539
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'profile/getAll');
|
|
9540
|
-
}
|
|
9541
|
-
/** It returns the profile by id */
|
|
9542
|
-
getById(id) {
|
|
9543
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'profile/getById', { params: new HttpParams().set('id', id.toString()) });
|
|
9544
|
-
}
|
|
9545
|
-
/** It returns the profile by userId and patCodigo */
|
|
9546
|
-
getByUserIdAndPatCodigo(userId, patCodigo, cargarListas) {
|
|
9547
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'profile/getByUserIdAndPatCodigo', {
|
|
9548
|
-
params: new HttpParams()
|
|
9549
|
-
.set('userId', userId.toString())
|
|
9550
|
-
.set('patCodigo', patCodigo.toString())
|
|
9551
|
-
.set('cargarListas', cargarListas.toString())
|
|
9552
|
-
});
|
|
9553
|
-
}
|
|
9554
|
-
/** It returns the profile by patCodigo */
|
|
9555
|
-
getByPatCodigo(patCodigo) {
|
|
9556
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'profile/getByPatCodigo', { params: new HttpParams().set('patCodigo', patCodigo.toString()) });
|
|
9557
|
-
}
|
|
9558
|
-
/** It returns the profile by form id */
|
|
9559
|
-
getByFormId(formId, cargarListas) {
|
|
9560
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'profile/getByFormId', {
|
|
9561
|
-
params: new HttpParams()
|
|
9562
|
-
.set('formId', formId)
|
|
9563
|
-
.set('cargarListas', cargarListas.toString())
|
|
9564
|
-
});
|
|
9565
|
-
}
|
|
9566
|
-
/** It saves a profile */
|
|
9567
|
-
save(profile) {
|
|
9568
|
-
return this.httpClient.post(this.environment.host.backend.configuration + 'profile/save', profile, this.headerJson);
|
|
9569
|
-
}
|
|
9570
|
-
/** It deletes a form by id */
|
|
9571
|
-
delete(id) {
|
|
9572
|
-
return this.httpClient.delete(this.environment.host.backend.configuration + 'profile/delete', { params: new HttpParams().set('id', id) });
|
|
9573
|
-
}
|
|
9574
|
-
}
|
|
9575
|
-
ProfileService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ProfileService, deps: [{ token: 'environment' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
9576
|
-
ProfileService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ProfileService, providedIn: 'root' });
|
|
9577
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ProfileService, decorators: [{
|
|
9999
|
+
PliTagService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: PliTagService, deps: [{ token: 'environment' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
10000
|
+
PliTagService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: PliTagService, providedIn: 'root' });
|
|
10001
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: PliTagService, decorators: [{
|
|
9578
10002
|
type: Injectable,
|
|
9579
10003
|
args: [{
|
|
9580
10004
|
providedIn: 'root'
|
|
@@ -9584,83 +10008,44 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImpor
|
|
|
9584
10008
|
args: ['environment']
|
|
9585
10009
|
}] }, { type: i1.HttpClient }]; } });
|
|
9586
10010
|
|
|
9587
|
-
class
|
|
10011
|
+
class PliUserService {
|
|
9588
10012
|
constructor(environment, httpClient) {
|
|
9589
10013
|
this.environment = environment;
|
|
9590
10014
|
this.httpClient = httpClient;
|
|
9591
10015
|
this.headerJson = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) };
|
|
9592
10016
|
}
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
}
|
|
9597
|
-
updatePositionSegmentation(lSegmentationUser) {
|
|
9598
|
-
return this.httpClient.post(this.environment.host.backend.segmentation +
|
|
9599
|
-
'PlicSegmentationUserController/updatePositionSegmentation', lSegmentationUser, this.headerJson);
|
|
9600
|
-
}
|
|
9601
|
-
saveAllSegmentation(lSegmentationUser) {
|
|
9602
|
-
return this.httpClient.post(this.environment.host.backend.segmentation +
|
|
9603
|
-
'PlicSegmentationUserController/saveAllSegmentation', lSegmentationUser, this.headerJson);
|
|
9604
|
-
}
|
|
9605
|
-
/** It deletes a search object by id */
|
|
9606
|
-
deleteSegmentation(id) {
|
|
9607
|
-
return this.httpClient.delete(this.environment.host.backend.segmentation +
|
|
9608
|
-
'PlicSegmentationUserController/deleteSegmentation', { params: new HttpParams().set('id', id) });
|
|
9609
|
-
}
|
|
9610
|
-
changeTopFiveSegmentation(username, type) {
|
|
9611
|
-
return this.httpClient.get(this.environment.host.backend.segmentation +
|
|
9612
|
-
'PlicSegmentationUserController/changeTopFiveSegmentation', { params: new HttpParams().set('username', username).set('type', type.toString()) });
|
|
9613
|
-
}
|
|
9614
|
-
showEllipsisSegmentationByUser(username, type) {
|
|
9615
|
-
return this.httpClient.get(this.environment.host.backend.segmentation +
|
|
9616
|
-
'PlicSegmentationUserController/showEllipsisSegmentationByUser', { params: new HttpParams().set('username', username).set('type', type.toString()) });
|
|
9617
|
-
}
|
|
9618
|
-
getSegmentationGreaterThanPosition(username, type, position) {
|
|
9619
|
-
return this.httpClient.get(this.environment.host.backend.segmentation +
|
|
9620
|
-
'PlicSegmentationUserController/getSegmentationGreaterThanPosition', {
|
|
9621
|
-
params: new HttpParams()
|
|
9622
|
-
.set('username', username)
|
|
9623
|
-
.set('type', type.toString())
|
|
9624
|
-
.set('position', position.toString())
|
|
9625
|
-
});
|
|
9626
|
-
}
|
|
9627
|
-
getSegmentationByIdOrderByName(username, type) {
|
|
9628
|
-
return this.httpClient.get(this.environment.host.backend.segmentation +
|
|
9629
|
-
'PlicSegmentationUserController/getSegmentationByIdOrderByName', { params: new HttpParams().set('username', username).set('type', type.toString()) });
|
|
10017
|
+
/** It returns the list */
|
|
10018
|
+
getAll() {
|
|
10019
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'pliUser/getAll');
|
|
9630
10020
|
}
|
|
9631
|
-
|
|
9632
|
-
|
|
9633
|
-
|
|
10021
|
+
/** It deletes a form by id */
|
|
10022
|
+
delete(id) {
|
|
10023
|
+
return this.httpClient.delete(this.environment.host.backend.configuration + 'pliUser/delete', { params: new HttpParams().set('id', id) });
|
|
9634
10024
|
}
|
|
9635
|
-
|
|
9636
|
-
|
|
9637
|
-
|
|
10025
|
+
/** It returns the user by id */
|
|
10026
|
+
getById(id) {
|
|
10027
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'pliUser/getById', { params: new HttpParams().set('id', id.toString()) });
|
|
9638
10028
|
}
|
|
9639
|
-
|
|
9640
|
-
|
|
9641
|
-
|
|
9642
|
-
params: new HttpParams()
|
|
9643
|
-
.set('lastNHours', lastNHours.toString())
|
|
9644
|
-
.set('type', type.toString())
|
|
9645
|
-
});
|
|
10029
|
+
/** It returns the user by id */
|
|
10030
|
+
getByLogin(login) {
|
|
10031
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'pliUser/getByLogin', { params: new HttpParams().set('login', login) });
|
|
9646
10032
|
}
|
|
9647
|
-
|
|
9648
|
-
|
|
9649
|
-
|
|
10033
|
+
/** It saves a user */
|
|
10034
|
+
save(user) {
|
|
10035
|
+
return this.httpClient.post(this.environment.host.backend.configuration + 'pliUser/save', user, this.headerJson);
|
|
9650
10036
|
}
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
10037
|
+
/** It returns the list of users by patCodigo and list of profiles id */
|
|
10038
|
+
getByPatCodigoAndProfileIdList(patCodigo, listProfileId) {
|
|
10039
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'pliUser/getByPatCodigoAndProfileIdList', {
|
|
9654
10040
|
params: new HttpParams()
|
|
9655
|
-
.set('
|
|
9656
|
-
.set('
|
|
9657
|
-
.set('name', name)
|
|
10041
|
+
.set('patCodigo', patCodigo.toString())
|
|
10042
|
+
.set('listProfileId', listProfileId.toString())
|
|
9658
10043
|
});
|
|
9659
10044
|
}
|
|
9660
10045
|
}
|
|
9661
|
-
|
|
9662
|
-
|
|
9663
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type:
|
|
10046
|
+
PliUserService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: PliUserService, deps: [{ token: 'environment' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
10047
|
+
PliUserService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: PliUserService, providedIn: 'root' });
|
|
10048
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: PliUserService, decorators: [{
|
|
9664
10049
|
type: Injectable,
|
|
9665
10050
|
args: [{
|
|
9666
10051
|
providedIn: 'root'
|
|
@@ -9670,557 +10055,174 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImpor
|
|
|
9670
10055
|
args: ['environment']
|
|
9671
10056
|
}] }, { type: i1.HttpClient }]; } });
|
|
9672
10057
|
|
|
9673
|
-
class
|
|
10058
|
+
class ProfileService {
|
|
9674
10059
|
constructor(environment, httpClient) {
|
|
9675
10060
|
this.environment = environment;
|
|
9676
10061
|
this.httpClient = httpClient;
|
|
9677
10062
|
this.headerJson = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) };
|
|
9678
10063
|
}
|
|
9679
|
-
/** It
|
|
9680
|
-
|
|
9681
|
-
return this.httpClient.
|
|
9682
|
-
}
|
|
9683
|
-
/** It send the email */
|
|
9684
|
-
sendMultiple(listSegmentation) {
|
|
9685
|
-
return this.httpClient.post(this.environment.host.backend.queue + 'segmentation/sendMassive', listSegmentation, this.headerJson);
|
|
9686
|
-
}
|
|
9687
|
-
}
|
|
9688
|
-
SegmentationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: SegmentationService, deps: [{ token: 'environment' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
9689
|
-
SegmentationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: SegmentationService, providedIn: 'root' });
|
|
9690
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: SegmentationService, decorators: [{
|
|
9691
|
-
type: Injectable,
|
|
9692
|
-
args: [{
|
|
9693
|
-
providedIn: 'root'
|
|
9694
|
-
}]
|
|
9695
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
9696
|
-
type: Inject,
|
|
9697
|
-
args: ['environment']
|
|
9698
|
-
}] }, { type: i1.HttpClient }]; } });
|
|
9699
|
-
|
|
9700
|
-
// import * as utils_ from 'formiojs-proyectoscolfuturo/utils/utils';
|
|
9701
|
-
const utils = utils_;
|
|
9702
|
-
class FormioUtil {
|
|
9703
|
-
/**
|
|
9704
|
-
* It returns the components formated by panel
|
|
9705
|
-
* @param components
|
|
9706
|
-
* @return the object is [{panel: , items: [{ value: , label: }]}]
|
|
9707
|
-
*/
|
|
9708
|
-
static getFormattedComponentsByPanel(components) {
|
|
9709
|
-
let result = [];
|
|
9710
|
-
if (components) {
|
|
9711
|
-
let group = null;
|
|
9712
|
-
let object = null;
|
|
9713
|
-
for (const component of components) {
|
|
9714
|
-
if (component[EFormioKey.TITLE_PANEL] !== group) {
|
|
9715
|
-
if (group !== null) {
|
|
9716
|
-
result.push(object);
|
|
9717
|
-
}
|
|
9718
|
-
object = { label: component[EFormioKey.TITLE_PANEL], items: [], toggle: false };
|
|
9719
|
-
group = component[EFormioKey.TITLE_PANEL];
|
|
9720
|
-
}
|
|
9721
|
-
object.items.push({
|
|
9722
|
-
label: component[EFormioKey.LABEL],
|
|
9723
|
-
value: component[EFormioKey.KEY]
|
|
9724
|
-
});
|
|
9725
|
-
}
|
|
9726
|
-
if (group !== null)
|
|
9727
|
-
result.push(object);
|
|
9728
|
-
}
|
|
9729
|
-
return result;
|
|
10064
|
+
/** It returns the profile by id */
|
|
10065
|
+
getAll() {
|
|
10066
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'profile/getAll');
|
|
9730
10067
|
}
|
|
9731
|
-
/**
|
|
9732
|
-
|
|
9733
|
-
|
|
9734
|
-
* @param data
|
|
9735
|
-
*/
|
|
9736
|
-
static getRequiredComponentsByData(components, data) {
|
|
9737
|
-
// get the required components
|
|
9738
|
-
let array = FormioUtil.getRequiredComponents(components);
|
|
9739
|
-
// if not data then return components
|
|
9740
|
-
if (data && array) {
|
|
9741
|
-
for (let i = 0; i < array.length; i++) {
|
|
9742
|
-
const component = array[i];
|
|
9743
|
-
// use formio to check condition according with data
|
|
9744
|
-
if (utils.checkCondition(component, null, data, null, null)) {
|
|
9745
|
-
const key = component[EFormioKey.KEY];
|
|
9746
|
-
if (data[key] != undefined && data[key] != null && data[key] != '') {
|
|
9747
|
-
// remove item from array
|
|
9748
|
-
array.splice(i, 1);
|
|
9749
|
-
i--;
|
|
9750
|
-
}
|
|
9751
|
-
else {
|
|
9752
|
-
if (component.customConditional &&
|
|
9753
|
-
component.customConditional.includes('show')) {
|
|
9754
|
-
// remove item from array
|
|
9755
|
-
array.splice(i, 1);
|
|
9756
|
-
i--;
|
|
9757
|
-
}
|
|
9758
|
-
}
|
|
9759
|
-
}
|
|
9760
|
-
else {
|
|
9761
|
-
// remove item from array
|
|
9762
|
-
array.splice(i, 1);
|
|
9763
|
-
i--;
|
|
9764
|
-
}
|
|
9765
|
-
}
|
|
9766
|
-
}
|
|
9767
|
-
return array;
|
|
10068
|
+
/** It returns the profile by id */
|
|
10069
|
+
getById(id) {
|
|
10070
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'profile/getById', { params: new HttpParams().set('id', id.toString()) });
|
|
9768
10071
|
}
|
|
9769
|
-
/**
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
|
|
10072
|
+
/** It returns the profile by userId and patCodigo */
|
|
10073
|
+
getByUserIdAndPatCodigo(userId, patCodigo, cargarListas) {
|
|
10074
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'profile/getByUserIdAndPatCodigo', {
|
|
10075
|
+
params: new HttpParams()
|
|
10076
|
+
.set('userId', userId.toString())
|
|
10077
|
+
.set('patCodigo', patCodigo.toString())
|
|
10078
|
+
.set('cargarListas', cargarListas.toString())
|
|
10079
|
+
});
|
|
9775
10080
|
}
|
|
9776
|
-
/**
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
*/
|
|
9780
|
-
static getRequiredComponents(components) {
|
|
9781
|
-
return FormioUtil.getComponentsByFeature(components, [EFormioKey.VALIDATE, EFormioKey.REQUIRED], true);
|
|
10081
|
+
/** It returns the profile by patCodigo */
|
|
10082
|
+
getByPatCodigo(patCodigo) {
|
|
10083
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'profile/getByPatCodigo', { params: new HttpParams().set('patCodigo', patCodigo.toString()) });
|
|
9782
10084
|
}
|
|
9783
|
-
/**
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
|
|
9788
|
-
|
|
9789
|
-
|
|
9790
|
-
let result = [];
|
|
9791
|
-
if (properties && properties.length > 0) {
|
|
9792
|
-
// get components
|
|
9793
|
-
const fields = FormioUtil.getComponents(components);
|
|
9794
|
-
// get first and last property
|
|
9795
|
-
const firstProperty = properties[0];
|
|
9796
|
-
const lastProperty = properties[properties.length - 1];
|
|
9797
|
-
if (fields) {
|
|
9798
|
-
// iterate the fields
|
|
9799
|
-
for (let i = 0; i < fields.length; i++) {
|
|
9800
|
-
// it contains the entire object field
|
|
9801
|
-
const field = fields[i];
|
|
9802
|
-
// it contains the current component and it is gonna be the component of every property
|
|
9803
|
-
let component = field;
|
|
9804
|
-
if (field[firstProperty]) {
|
|
9805
|
-
for (let j = 0; j < properties.length; j++) {
|
|
9806
|
-
const property = properties[j];
|
|
9807
|
-
// if component.property doesnt exist then break
|
|
9808
|
-
if (!component[property])
|
|
9809
|
-
break;
|
|
9810
|
-
if (property === lastProperty) {
|
|
9811
|
-
// it is the last property so if the value is equals to component.lastproperty then it is added to result
|
|
9812
|
-
if (component[property] == value)
|
|
9813
|
-
result.push(field);
|
|
9814
|
-
}
|
|
9815
|
-
else {
|
|
9816
|
-
// otherwise component will be equal to the component.property
|
|
9817
|
-
component = component[property];
|
|
9818
|
-
}
|
|
9819
|
-
}
|
|
9820
|
-
}
|
|
9821
|
-
}
|
|
9822
|
-
}
|
|
9823
|
-
}
|
|
9824
|
-
return result;
|
|
10085
|
+
/** It returns the profile by form id */
|
|
10086
|
+
getByFormId(formId, cargarListas) {
|
|
10087
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'profile/getByFormId', {
|
|
10088
|
+
params: new HttpParams()
|
|
10089
|
+
.set('formId', formId)
|
|
10090
|
+
.set('cargarListas', cargarListas.toString())
|
|
10091
|
+
});
|
|
9825
10092
|
}
|
|
9826
|
-
/**
|
|
9827
|
-
|
|
9828
|
-
|
|
9829
|
-
*/
|
|
9830
|
-
static getComponents(components) {
|
|
9831
|
-
return FormioUtil.getComponentsByRecursion(components, '', null);
|
|
10093
|
+
/** It saves a profile */
|
|
10094
|
+
save(profile) {
|
|
10095
|
+
return this.httpClient.post(this.environment.host.backend.configuration + 'profile/save', profile, this.headerJson);
|
|
9832
10096
|
}
|
|
9833
|
-
/**
|
|
9834
|
-
|
|
9835
|
-
|
|
9836
|
-
* @param titlePanel name of parent panel, so children components will inherit the panelName
|
|
9837
|
-
* @param conditionalObject conditional object it will be inherited from panel {conditional: { eq: , value: , when: , json: }, customConditional: }
|
|
9838
|
-
*/
|
|
9839
|
-
static getComponentsByRecursion(components, titlePanel, conditionalParent) {
|
|
9840
|
-
// it contains the result array
|
|
9841
|
-
let result = [];
|
|
9842
|
-
if (components) {
|
|
9843
|
-
// iterate over components
|
|
9844
|
-
for (const component of components) {
|
|
9845
|
-
// avoid the editgrid component ot if it has a different behavior it should have an else statement
|
|
9846
|
-
if (component[EFormioKey.TYPE] !== EFormioKey.EDITGRID) {
|
|
9847
|
-
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
9848
|
-
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
9849
|
-
titlePanel = component[EFormioKey.TITLE];
|
|
9850
|
-
}
|
|
9851
|
-
if ((typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
9852
|
-
typeof component[EFormioKey.COLUMNS] !== 'undefined') &&
|
|
9853
|
-
component["type"] !== "address") {
|
|
9854
|
-
if (component["type"] !== "address") {
|
|
9855
|
-
// resolve conditional parent conditional
|
|
9856
|
-
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
9857
|
-
// change condition
|
|
9858
|
-
if (conditional)
|
|
9859
|
-
conditionalParent = conditional;
|
|
9860
|
-
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
9861
|
-
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
9862
|
-
? component[EFormioKey.COMPONENTS]
|
|
9863
|
-
: component[EFormioKey.COLUMNS];
|
|
9864
|
-
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
9865
|
-
const recursionResult = FormioUtil.getComponentsByRecursion(subComponents, titlePanel, conditionalParent);
|
|
9866
|
-
// if recursion result then result concats the recursionResult
|
|
9867
|
-
if (recursionResult)
|
|
9868
|
-
result = result.concat(recursionResult);
|
|
9869
|
-
// reset conditional Parent
|
|
9870
|
-
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
9871
|
-
conditionalParent = undefined;
|
|
9872
|
-
}
|
|
9873
|
-
else {
|
|
9874
|
-
result.push(component);
|
|
9875
|
-
}
|
|
9876
|
-
}
|
|
9877
|
-
else {
|
|
9878
|
-
// avoid the component type button
|
|
9879
|
-
if (component[EFormioKey.TYPE] !== EFormioKey.BUTTON &&
|
|
9880
|
-
component[EFormioKey.KEY] &&
|
|
9881
|
-
component[EFormioKey.LABEL]) {
|
|
9882
|
-
// resolve conditional conditional object
|
|
9883
|
-
let conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
9884
|
-
if (!conditional)
|
|
9885
|
-
conditional = conditionalParent;
|
|
9886
|
-
component[EFormioKey.CONDITIONAL] = conditional[EFormioKey.CONDITIONAL];
|
|
9887
|
-
component[EFormioKey.CUSTOM_CONDITIONAL] =
|
|
9888
|
-
conditional[EFormioKey.CUSTOM_CONDITIONAL];
|
|
9889
|
-
// add namPanel as property
|
|
9890
|
-
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
9891
|
-
// add component to the result
|
|
9892
|
-
result.push(component);
|
|
9893
|
-
}
|
|
9894
|
-
}
|
|
9895
|
-
}
|
|
9896
|
-
}
|
|
9897
|
-
}
|
|
9898
|
-
return result;
|
|
10097
|
+
/** It deletes a form by id */
|
|
10098
|
+
delete(id) {
|
|
10099
|
+
return this.httpClient.delete(this.environment.host.backend.configuration + 'profile/delete', { params: new HttpParams().set('id', id) });
|
|
9899
10100
|
}
|
|
9900
|
-
|
|
9901
|
-
|
|
9902
|
-
|
|
9903
|
-
|
|
9904
|
-
|
|
9905
|
-
|
|
9906
|
-
|
|
10101
|
+
}
|
|
10102
|
+
ProfileService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ProfileService, deps: [{ token: 'environment' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
10103
|
+
ProfileService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ProfileService, providedIn: 'root' });
|
|
10104
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ProfileService, decorators: [{
|
|
10105
|
+
type: Injectable,
|
|
10106
|
+
args: [{
|
|
10107
|
+
providedIn: 'root'
|
|
10108
|
+
}]
|
|
10109
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
10110
|
+
type: Inject,
|
|
10111
|
+
args: ['environment']
|
|
10112
|
+
}] }, { type: i1.HttpClient }]; } });
|
|
10113
|
+
|
|
10114
|
+
class SegmentationUserService {
|
|
10115
|
+
constructor(environment, httpClient) {
|
|
10116
|
+
this.environment = environment;
|
|
10117
|
+
this.httpClient = httpClient;
|
|
10118
|
+
this.headerJson = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) };
|
|
9907
10119
|
}
|
|
9908
|
-
|
|
9909
|
-
|
|
9910
|
-
|
|
9911
|
-
* @param titlePanel name of parent panel, so children components will inherit the panelName
|
|
9912
|
-
* @param conditionalObject conditional object it will be inherited from panel {conditional: { eq: , value: , when: , json: }, customConditional: }
|
|
9913
|
-
*/
|
|
9914
|
-
static getComponentsByRecursionWithEditGrids(components, titlePanel, conditionalParent) {
|
|
9915
|
-
// it contains the result array
|
|
9916
|
-
let result = [];
|
|
9917
|
-
if (components) {
|
|
9918
|
-
// iterate over components
|
|
9919
|
-
for (const component of components) {
|
|
9920
|
-
// avoid the editgrid component ot if it has a different behavior it should have an else statement
|
|
9921
|
-
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
9922
|
-
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
9923
|
-
titlePanel = component[EFormioKey.TITLE];
|
|
9924
|
-
}
|
|
9925
|
-
if (typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
9926
|
-
typeof component[EFormioKey.COLUMNS] !== 'undefined') {
|
|
9927
|
-
// resolve conditional parent conditional
|
|
9928
|
-
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
9929
|
-
// change condition
|
|
9930
|
-
if (conditional)
|
|
9931
|
-
conditionalParent = conditional;
|
|
9932
|
-
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
9933
|
-
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
9934
|
-
? component[EFormioKey.COMPONENTS]
|
|
9935
|
-
: component[EFormioKey.COLUMNS];
|
|
9936
|
-
if (component[EFormioKey.TYPE] === EFormioKey.EDITGRID) {
|
|
9937
|
-
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
9938
|
-
result.push(component);
|
|
9939
|
-
}
|
|
9940
|
-
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
9941
|
-
const recursionResult = FormioUtil.getComponentsByRecursionWithEditGrids(subComponents, titlePanel, conditionalParent);
|
|
9942
|
-
// if recursion result then result concats the recursionResult
|
|
9943
|
-
if (recursionResult)
|
|
9944
|
-
result = result.concat(recursionResult);
|
|
9945
|
-
// reset conditional Parent
|
|
9946
|
-
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
9947
|
-
conditionalParent = undefined;
|
|
9948
|
-
}
|
|
9949
|
-
else {
|
|
9950
|
-
// avoid the component type button
|
|
9951
|
-
if (component[EFormioKey.TYPE] !== EFormioKey.BUTTON &&
|
|
9952
|
-
component[EFormioKey.KEY] &&
|
|
9953
|
-
component[EFormioKey.LABEL]) {
|
|
9954
|
-
// resolve conditional conditional object
|
|
9955
|
-
let conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
9956
|
-
if (!conditional)
|
|
9957
|
-
conditional = conditionalParent;
|
|
9958
|
-
component[EFormioKey.CONDITIONAL] = conditional[EFormioKey.CONDITIONAL];
|
|
9959
|
-
component[EFormioKey.CUSTOM_CONDITIONAL] =
|
|
9960
|
-
conditional[EFormioKey.CUSTOM_CONDITIONAL];
|
|
9961
|
-
// add namPanel as property
|
|
9962
|
-
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
9963
|
-
// add component to the result
|
|
9964
|
-
result.push(component);
|
|
9965
|
-
}
|
|
9966
|
-
}
|
|
9967
|
-
}
|
|
9968
|
-
}
|
|
9969
|
-
return result;
|
|
10120
|
+
getSegmentationByUserTopFive(username, type) {
|
|
10121
|
+
return this.httpClient.get(this.environment.host.backend.segmentation +
|
|
10122
|
+
'PlicSegmentationUserController/getSegmentationByUserTopFive', { params: new HttpParams().set('username', username).set('type', type.toString()) });
|
|
9970
10123
|
}
|
|
9971
|
-
|
|
9972
|
-
|
|
9973
|
-
|
|
9974
|
-
* @param conditional
|
|
9975
|
-
* @param customConditional
|
|
9976
|
-
*/
|
|
9977
|
-
static resolveInheritanceConditional(conditionalObject, conditional, customConditional, parentId) {
|
|
9978
|
-
// validate if there is a condition with the new fields
|
|
9979
|
-
if (!conditionalObject ||
|
|
9980
|
-
customConditional ||
|
|
9981
|
-
(conditional && conditional[EFormioKey.WHEN] && conditional[EFormioKey.EQ]) ||
|
|
9982
|
-
(conditional && conditional[EFormioKey.JSON])) {
|
|
9983
|
-
return { conditional: conditional, customConditional: customConditional, id: parentId };
|
|
9984
|
-
}
|
|
9985
|
-
return null;
|
|
10124
|
+
updatePositionSegmentation(lSegmentationUser) {
|
|
10125
|
+
return this.httpClient.post(this.environment.host.backend.segmentation +
|
|
10126
|
+
'PlicSegmentationUserController/updatePositionSegmentation', lSegmentationUser, this.headerJson);
|
|
9986
10127
|
}
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
*/
|
|
9991
|
-
static getEditGridKeyLabels(components) {
|
|
9992
|
-
return FormioUtil.getEditGridKeyLabelsByRecursion(components, '', null);
|
|
10128
|
+
saveAllSegmentation(lSegmentationUser) {
|
|
10129
|
+
return this.httpClient.post(this.environment.host.backend.segmentation +
|
|
10130
|
+
'PlicSegmentationUserController/saveAllSegmentation', lSegmentationUser, this.headerJson);
|
|
9993
10131
|
}
|
|
9994
|
-
/**
|
|
9995
|
-
|
|
9996
|
-
|
|
9997
|
-
|
|
9998
|
-
|
|
9999
|
-
|
|
10000
|
-
|
|
10001
|
-
|
|
10002
|
-
let result = [];
|
|
10003
|
-
if (components) {
|
|
10004
|
-
// iterate over components
|
|
10005
|
-
for (const component of components) {
|
|
10006
|
-
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
10007
|
-
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
10008
|
-
titlePanel = component[EFormioKey.TITLE];
|
|
10009
|
-
}
|
|
10010
|
-
if (typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
10011
|
-
typeof component[EFormioKey.COLUMNS] !== 'undefined') {
|
|
10012
|
-
// resolve conditional parent conditional
|
|
10013
|
-
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
10014
|
-
// change condition
|
|
10015
|
-
if (conditional)
|
|
10016
|
-
conditionalParent = conditional;
|
|
10017
|
-
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
10018
|
-
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
10019
|
-
? component[EFormioKey.COMPONENTS]
|
|
10020
|
-
: component[EFormioKey.COLUMNS];
|
|
10021
|
-
if (component[EFormioKey.TYPE] == EFormioKey.EDITGRID) {
|
|
10022
|
-
// add namPanel as property
|
|
10023
|
-
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
10024
|
-
// add component to the result
|
|
10025
|
-
result.push(component);
|
|
10026
|
-
}
|
|
10027
|
-
else {
|
|
10028
|
-
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
10029
|
-
const recursionResult = FormioUtil.getEditGridKeyLabelsByRecursion(subComponents, titlePanel, conditionalParent);
|
|
10030
|
-
// if recursion result then result concats the recursionResult
|
|
10031
|
-
if (recursionResult)
|
|
10032
|
-
result = result.concat(recursionResult);
|
|
10033
|
-
// reset conditional Parent
|
|
10034
|
-
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
10035
|
-
conditionalParent = undefined;
|
|
10036
|
-
}
|
|
10037
|
-
}
|
|
10038
|
-
else {
|
|
10039
|
-
}
|
|
10040
|
-
}
|
|
10041
|
-
}
|
|
10042
|
-
return result;
|
|
10132
|
+
/** It deletes a search object by id */
|
|
10133
|
+
deleteSegmentation(id) {
|
|
10134
|
+
return this.httpClient.delete(this.environment.host.backend.segmentation +
|
|
10135
|
+
'PlicSegmentationUserController/deleteSegmentation', { params: new HttpParams().set('id', id) });
|
|
10136
|
+
}
|
|
10137
|
+
changeTopFiveSegmentation(username, type) {
|
|
10138
|
+
return this.httpClient.get(this.environment.host.backend.segmentation +
|
|
10139
|
+
'PlicSegmentationUserController/changeTopFiveSegmentation', { params: new HttpParams().set('username', username).set('type', type.toString()) });
|
|
10043
10140
|
}
|
|
10044
|
-
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
* @param keepEditGrids
|
|
10048
|
-
*/
|
|
10049
|
-
static getComponentsIntoEditGrids(components, editGridName) {
|
|
10050
|
-
return FormioUtil.getComponentsByRecursionIntoEditGrids(components, '', null, editGridName, false);
|
|
10141
|
+
showEllipsisSegmentationByUser(username, type) {
|
|
10142
|
+
return this.httpClient.get(this.environment.host.backend.segmentation +
|
|
10143
|
+
'PlicSegmentationUserController/showEllipsisSegmentationByUser', { params: new HttpParams().set('username', username).set('type', type.toString()) });
|
|
10051
10144
|
}
|
|
10052
|
-
|
|
10053
|
-
|
|
10054
|
-
|
|
10055
|
-
|
|
10056
|
-
|
|
10057
|
-
|
|
10058
|
-
|
|
10059
|
-
|
|
10060
|
-
let result = [];
|
|
10061
|
-
if (components) {
|
|
10062
|
-
// iterate over components
|
|
10063
|
-
for (const component of components) {
|
|
10064
|
-
// avoid the editgrid component ot if it has a different behavior it should have an else statement
|
|
10065
|
-
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
10066
|
-
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
10067
|
-
titlePanel = component[EFormioKey.TITLE];
|
|
10068
|
-
}
|
|
10069
|
-
if (typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
10070
|
-
typeof component[EFormioKey.COLUMNS] !== 'undefined') {
|
|
10071
|
-
// resolve conditional parent conditional
|
|
10072
|
-
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
10073
|
-
// change condition
|
|
10074
|
-
if (conditional)
|
|
10075
|
-
conditionalParent = conditional;
|
|
10076
|
-
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
10077
|
-
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
10078
|
-
? component[EFormioKey.COMPONENTS]
|
|
10079
|
-
: component[EFormioKey.COLUMNS];
|
|
10080
|
-
if (component[EFormioKey.TYPE] === EFormioKey.EDITGRID &&
|
|
10081
|
-
component['key'] == editGridName) {
|
|
10082
|
-
existEditGrid = true;
|
|
10083
|
-
if (typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
10084
|
-
typeof component[EFormioKey.COLUMNS] !== 'undefined') {
|
|
10085
|
-
// resolve conditional parent conditional
|
|
10086
|
-
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
10087
|
-
// change condition
|
|
10088
|
-
if (conditional)
|
|
10089
|
-
conditionalParent = conditional;
|
|
10090
|
-
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
10091
|
-
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
10092
|
-
? component[EFormioKey.COMPONENTS]
|
|
10093
|
-
: component[EFormioKey.COLUMNS];
|
|
10094
|
-
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
10095
|
-
const recursionResult = FormioUtil.getComponentsByRecursionIntoEditGrids(subComponents, titlePanel, conditionalParent, editGridName, existEditGrid);
|
|
10096
|
-
// if recursion result then result concats the recursionResult
|
|
10097
|
-
if (recursionResult)
|
|
10098
|
-
result = result.concat(recursionResult);
|
|
10099
|
-
// reset conditional Parent
|
|
10100
|
-
if (component && conditionalParent) {
|
|
10101
|
-
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
10102
|
-
conditionalParent = undefined;
|
|
10103
|
-
}
|
|
10104
|
-
}
|
|
10105
|
-
else {
|
|
10106
|
-
// avoid the component type button
|
|
10107
|
-
if (component[EFormioKey.TYPE] !== EFormioKey.BUTTON &&
|
|
10108
|
-
component[EFormioKey.KEY] &&
|
|
10109
|
-
component[EFormioKey.LABEL] &&
|
|
10110
|
-
existEditGrid) {
|
|
10111
|
-
// resolve conditional conditional object
|
|
10112
|
-
let conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
10113
|
-
if (!conditional)
|
|
10114
|
-
conditional = conditionalParent;
|
|
10115
|
-
component[EFormioKey.CONDITIONAL] =
|
|
10116
|
-
conditional[EFormioKey.CONDITIONAL];
|
|
10117
|
-
component[EFormioKey.CUSTOM_CONDITIONAL] =
|
|
10118
|
-
conditional[EFormioKey.CUSTOM_CONDITIONAL];
|
|
10119
|
-
// add namPanel as property
|
|
10120
|
-
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
10121
|
-
// add component to the result
|
|
10122
|
-
result.push(component);
|
|
10123
|
-
}
|
|
10124
|
-
}
|
|
10125
|
-
}
|
|
10126
|
-
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
10127
|
-
const recursionResult = FormioUtil.getComponentsByRecursionIntoEditGrids(subComponents, titlePanel, conditionalParent, editGridName, existEditGrid);
|
|
10128
|
-
// if recursion result then result concats the recursionResult
|
|
10129
|
-
if (recursionResult)
|
|
10130
|
-
result = result.concat(recursionResult);
|
|
10131
|
-
// reset conditional Parent
|
|
10132
|
-
if (component && conditionalParent) {
|
|
10133
|
-
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
10134
|
-
conditionalParent = undefined;
|
|
10135
|
-
}
|
|
10136
|
-
}
|
|
10137
|
-
else {
|
|
10138
|
-
// avoid the component type button
|
|
10139
|
-
if (component[EFormioKey.TYPE] !== EFormioKey.BUTTON &&
|
|
10140
|
-
component[EFormioKey.KEY] &&
|
|
10141
|
-
component[EFormioKey.LABEL] &&
|
|
10142
|
-
existEditGrid) {
|
|
10143
|
-
// resolve conditional conditional object
|
|
10144
|
-
let conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
10145
|
-
if (!conditional)
|
|
10146
|
-
conditional = conditionalParent;
|
|
10147
|
-
component[EFormioKey.CONDITIONAL] = conditional[EFormioKey.CONDITIONAL];
|
|
10148
|
-
component[EFormioKey.CUSTOM_CONDITIONAL] =
|
|
10149
|
-
conditional[EFormioKey.CUSTOM_CONDITIONAL];
|
|
10150
|
-
// add namPanel as property
|
|
10151
|
-
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
10152
|
-
// add component to the result
|
|
10153
|
-
result.push(component);
|
|
10154
|
-
}
|
|
10155
|
-
}
|
|
10156
|
-
}
|
|
10157
|
-
}
|
|
10158
|
-
return result;
|
|
10145
|
+
getSegmentationGreaterThanPosition(username, type, position) {
|
|
10146
|
+
return this.httpClient.get(this.environment.host.backend.segmentation +
|
|
10147
|
+
'PlicSegmentationUserController/getSegmentationGreaterThanPosition', {
|
|
10148
|
+
params: new HttpParams()
|
|
10149
|
+
.set('username', username)
|
|
10150
|
+
.set('type', type.toString())
|
|
10151
|
+
.set('position', position.toString())
|
|
10152
|
+
});
|
|
10159
10153
|
}
|
|
10160
|
-
|
|
10161
|
-
|
|
10162
|
-
|
|
10163
|
-
* @returns Object of 2 element
|
|
10164
|
-
*/
|
|
10165
|
-
static createListDataByDataFormList(dataForm, listForm) {
|
|
10166
|
-
let listData = {};
|
|
10167
|
-
let listDataByForm = {};
|
|
10168
|
-
if (dataForm && dataForm.length > 0) {
|
|
10169
|
-
listData = {};
|
|
10170
|
-
listDataByForm = {};
|
|
10171
|
-
let dForm;
|
|
10172
|
-
for (dForm of dataForm) {
|
|
10173
|
-
if (!dForm.data) {
|
|
10174
|
-
continue;
|
|
10175
|
-
}
|
|
10176
|
-
const form = listForm.find(function (formTmp) {
|
|
10177
|
-
return formTmp.id == dForm.formId;
|
|
10178
|
-
});
|
|
10179
|
-
if (!form) {
|
|
10180
|
-
//console.error('No se encontró el formulario con id ' + dForm.formId);
|
|
10181
|
-
continue;
|
|
10182
|
-
}
|
|
10183
|
-
const keyFormTitle = TokenService.getKeyFormulario(form.title) + '_';
|
|
10184
|
-
for (const key in dForm.data) {
|
|
10185
|
-
listData[key] = dForm.data[key];
|
|
10186
|
-
listDataByForm[keyFormTitle + key] = dForm.data[key];
|
|
10187
|
-
}
|
|
10188
|
-
}
|
|
10189
|
-
}
|
|
10190
|
-
return {
|
|
10191
|
-
listData: listData,
|
|
10192
|
-
listDataByForm: listDataByForm
|
|
10193
|
-
};
|
|
10154
|
+
getSegmentationByIdOrderByName(username, type) {
|
|
10155
|
+
return this.httpClient.get(this.environment.host.backend.segmentation +
|
|
10156
|
+
'PlicSegmentationUserController/getSegmentationByIdOrderByName', { params: new HttpParams().set('username', username).set('type', type.toString()) });
|
|
10194
10157
|
}
|
|
10195
|
-
|
|
10196
|
-
|
|
10197
|
-
|
|
10198
|
-
*/
|
|
10199
|
-
static getPanelComponents(components) {
|
|
10200
|
-
return FormioUtil.getComponentsByPanel(components);
|
|
10158
|
+
getSegmentationById(segmentationId) {
|
|
10159
|
+
return this.httpClient.get(this.environment.host.backend.segmentation +
|
|
10160
|
+
'PlicSegmentationUserController/getSegmentationById', { params: new HttpParams().set('segmentationId', segmentationId) });
|
|
10201
10161
|
}
|
|
10202
|
-
|
|
10203
|
-
|
|
10204
|
-
|
|
10205
|
-
*/
|
|
10206
|
-
static getComponentsByPanel(components) {
|
|
10207
|
-
// it contains the result array
|
|
10208
|
-
let result = [];
|
|
10209
|
-
if (components) {
|
|
10210
|
-
// iterate over components
|
|
10211
|
-
for (const component of components) {
|
|
10212
|
-
// avoid the editgrid component ot if it has a different behavior it should have an else statement
|
|
10213
|
-
if (component[EFormioKey.TYPE] !== EFormioKey.EDITGRID) {
|
|
10214
|
-
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
10215
|
-
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
10216
|
-
result.push(component);
|
|
10217
|
-
}
|
|
10218
|
-
}
|
|
10219
|
-
}
|
|
10220
|
-
}
|
|
10221
|
-
return result;
|
|
10162
|
+
getAllSegmentationByLoginAndType(username, type) {
|
|
10163
|
+
return this.httpClient.get(this.environment.host.backend.segmentation +
|
|
10164
|
+
'PlicSegmentationUserController/getAllSegmentationByLoginAndType', { params: new HttpParams().set('username', username).set('type', type.toString()) });
|
|
10222
10165
|
}
|
|
10223
|
-
|
|
10166
|
+
getPublicSegmentation(lastNHours, type) {
|
|
10167
|
+
return this.httpClient.get(this.environment.host.backend.segmentation +
|
|
10168
|
+
'PlicSegmentationUserController/getPublicSegmentation', {
|
|
10169
|
+
params: new HttpParams()
|
|
10170
|
+
.set('lastNHours', lastNHours.toString())
|
|
10171
|
+
.set('type', type.toString())
|
|
10172
|
+
});
|
|
10173
|
+
}
|
|
10174
|
+
getSegColumn() {
|
|
10175
|
+
return this.httpClient.get(this.environment.host.backend.segmentation +
|
|
10176
|
+
'PlicSegmentationUserController/getSegColumn', { params: new HttpParams() });
|
|
10177
|
+
}
|
|
10178
|
+
getSegmentationByName(username, type, name) {
|
|
10179
|
+
return this.httpClient.get(this.environment.host.backend.segmentation +
|
|
10180
|
+
'PlicSegmentationUserController/getSegmentationByName', {
|
|
10181
|
+
params: new HttpParams()
|
|
10182
|
+
.set('username', username)
|
|
10183
|
+
.set('type', type.toString())
|
|
10184
|
+
.set('name', name)
|
|
10185
|
+
});
|
|
10186
|
+
}
|
|
10187
|
+
}
|
|
10188
|
+
SegmentationUserService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: SegmentationUserService, deps: [{ token: 'environment' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
10189
|
+
SegmentationUserService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: SegmentationUserService, providedIn: 'root' });
|
|
10190
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: SegmentationUserService, decorators: [{
|
|
10191
|
+
type: Injectable,
|
|
10192
|
+
args: [{
|
|
10193
|
+
providedIn: 'root'
|
|
10194
|
+
}]
|
|
10195
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
10196
|
+
type: Inject,
|
|
10197
|
+
args: ['environment']
|
|
10198
|
+
}] }, { type: i1.HttpClient }]; } });
|
|
10199
|
+
|
|
10200
|
+
class SegmentationService {
|
|
10201
|
+
constructor(environment, httpClient) {
|
|
10202
|
+
this.environment = environment;
|
|
10203
|
+
this.httpClient = httpClient;
|
|
10204
|
+
this.headerJson = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) };
|
|
10205
|
+
}
|
|
10206
|
+
/** It send the email */
|
|
10207
|
+
send(segmentation) {
|
|
10208
|
+
return this.httpClient.post(this.environment.host.backend.queue + 'segmentation/send', segmentation, this.headerJson);
|
|
10209
|
+
}
|
|
10210
|
+
/** It send the email */
|
|
10211
|
+
sendMultiple(listSegmentation) {
|
|
10212
|
+
return this.httpClient.post(this.environment.host.backend.queue + 'segmentation/sendMassive', listSegmentation, this.headerJson);
|
|
10213
|
+
}
|
|
10214
|
+
}
|
|
10215
|
+
SegmentationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: SegmentationService, deps: [{ token: 'environment' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
10216
|
+
SegmentationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: SegmentationService, providedIn: 'root' });
|
|
10217
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: SegmentationService, decorators: [{
|
|
10218
|
+
type: Injectable,
|
|
10219
|
+
args: [{
|
|
10220
|
+
providedIn: 'root'
|
|
10221
|
+
}]
|
|
10222
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
10223
|
+
type: Inject,
|
|
10224
|
+
args: ['environment']
|
|
10225
|
+
}] }, { type: i1.HttpClient }]; } });
|
|
10224
10226
|
|
|
10225
10227
|
class SendApplicationService {
|
|
10226
10228
|
constructor(environment, tokenService, emailService, interactionApplicationUserService) {
|
|
@@ -15036,8 +15038,8 @@ const VERSION = {
|
|
|
15036
15038
|
},
|
|
15037
15039
|
"suffix": "1932-g573770da-dirty",
|
|
15038
15040
|
"semverString": "0.0.18+1932.g573770da",
|
|
15039
|
-
"version": "0.0.
|
|
15040
|
-
"buildTimestamp": "2022-12-
|
|
15041
|
+
"version": "0.0.1663",
|
|
15042
|
+
"buildTimestamp": "2022-12-02T17:57:24.341Z"
|
|
15041
15043
|
};
|
|
15042
15044
|
/* tslint:enable */
|
|
15043
15045
|
|