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