ng-pli-commons 0.0.1663 → 0.0.1666
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/services/token.service.mjs +2 -5
- package/esm2020/lib/utils/formio-util.mjs +20 -26
- package/esm2020/version.mjs +3 -3
- package/fesm2015/ng-pli-commons.mjs +1429 -1437
- package/fesm2015/ng-pli-commons.mjs.map +1 -1
- package/fesm2020/ng-pli-commons.mjs +1102 -1110
- package/fesm2020/ng-pli-commons.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ import { FormioModule, FormioComponent } from 'formioangular-colfuturo';
|
|
|
17
17
|
import * as i4$2 from '@tinymce/tinymce-angular';
|
|
18
18
|
import { EditorModule } from '@tinymce/tinymce-angular';
|
|
19
19
|
import * as i7 from 'ng-pli-util';
|
|
20
|
-
import { NumberUtil, AuthenticationUtil, JwtUtil, PliPatrocinador, PliPrograma, PliPromocion, HEADER_JSON, Moneda, Rubro, TasaCambio, Proceso, DateUtil, primeLocaleEs, UtilString, EPermission,
|
|
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';
|
|
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,7 +32,6 @@ 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';
|
|
36
35
|
import * as i2 from 'ngx-toastr';
|
|
37
36
|
import * as i4$1 from '@angular/router';
|
|
38
37
|
import { map, catchError } from 'rxjs/operators';
|
|
@@ -47,6 +46,7 @@ import Panzoom__default from 'panzoom/dist/panzoom';
|
|
|
47
46
|
import * as i1$2 from '@angular/fire/compat/auth';
|
|
48
47
|
import 'jquery';
|
|
49
48
|
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,1456 +1226,929 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImpor
|
|
|
1226
1226
|
args: [LOCALE_ID]
|
|
1227
1227
|
}] } });
|
|
1228
1228
|
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
* @param components
|
|
1235
|
-
* @return the object is [{panel: , items: [{ value: , label: }]}]
|
|
1236
|
-
*/
|
|
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;
|
|
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' }) };
|
|
1259
1234
|
}
|
|
1260
|
-
/**
|
|
1261
|
-
|
|
1262
|
-
|
|
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;
|
|
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()) });
|
|
1297
1238
|
}
|
|
1298
|
-
/**
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
*/
|
|
1302
|
-
static getUniqueComponents(components) {
|
|
1303
|
-
return FormioUtil.getComponentsByFeature(components, [EFormioKey.UNIQUE], true);
|
|
1239
|
+
/** It returns the list of form by prom codigo */
|
|
1240
|
+
getAll() {
|
|
1241
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getAll');
|
|
1304
1242
|
}
|
|
1305
|
-
/**
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
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
|
+
});
|
|
1311
1299
|
}
|
|
1312
1300
|
/**
|
|
1313
|
-
*
|
|
1314
|
-
* @param
|
|
1315
|
-
* @param properties path of properties example [validate, required] or [unique]
|
|
1316
|
-
* @param value the value that should have the property
|
|
1301
|
+
* Get form by Id
|
|
1302
|
+
* @param statusId
|
|
1317
1303
|
*/
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1304
|
+
getByStateId(statusId) {
|
|
1305
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getByStateId', {
|
|
1306
|
+
params: new HttpParams().set('statusId', statusId)
|
|
1307
|
+
});
|
|
1308
|
+
}
|
|
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
|
+
});
|
|
1315
|
+
}
|
|
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
|
+
});
|
|
1323
|
+
}
|
|
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;
|
|
1345
|
+
}
|
|
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
|
+
}
|
|
1347
1374
|
}
|
|
1348
1375
|
}
|
|
1349
1376
|
}
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
* @param components
|
|
1358
|
-
*/
|
|
1359
|
-
static getComponents(components) {
|
|
1360
|
-
return FormioUtil.getComponentsByRecursion(components, '', null);
|
|
1361
|
-
}
|
|
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];
|
|
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);
|
|
1379
1384
|
}
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
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;
|
|
1385
|
+
lFormFieldsToken = [];
|
|
1386
|
+
for (let formComp of form) {
|
|
1387
|
+
let newComponents;
|
|
1388
|
+
let components = [];
|
|
1389
|
+
if (formComp.components) {
|
|
1390
|
+
newComponents = formComp.components;
|
|
1401
1391
|
}
|
|
1402
|
-
else {
|
|
1403
|
-
|
|
1392
|
+
else if (formComp.columns) {
|
|
1393
|
+
newComponents = formComp.columns;
|
|
1404
1394
|
}
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
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);
|
|
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);
|
|
1422
1406
|
}
|
|
1423
1407
|
}
|
|
1408
|
+
resolve(lFormFieldsToken);
|
|
1409
|
+
},
|
|
1410
|
+
error: (error) => {
|
|
1411
|
+
reject(error);
|
|
1424
1412
|
}
|
|
1425
|
-
}
|
|
1426
|
-
}
|
|
1427
|
-
return result;
|
|
1428
|
-
}
|
|
1429
|
-
/**
|
|
1430
|
-
* It returns the components
|
|
1431
|
-
* @param components
|
|
1432
|
-
* @param keepEditGrids
|
|
1433
|
-
*/
|
|
1434
|
-
static getComponentsWithEditGrids(components) {
|
|
1435
|
-
return FormioUtil.getComponentsByRecursionWithEditGrids(components, '', null);
|
|
1413
|
+
});
|
|
1414
|
+
});
|
|
1436
1415
|
}
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
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];
|
|
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);
|
|
1453
1424
|
}
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
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);
|
|
1425
|
+
lFormFieldsToken = [];
|
|
1426
|
+
for (let formComp of form) {
|
|
1427
|
+
let newComponents;
|
|
1428
|
+
let components = [];
|
|
1429
|
+
if (formComp.components) {
|
|
1430
|
+
newComponents = formComp.components;
|
|
1468
1431
|
}
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
if (
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
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);
|
|
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);
|
|
1494
1446
|
}
|
|
1495
1447
|
}
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1448
|
+
resolve(lFormFieldsToken);
|
|
1449
|
+
}, (error) => {
|
|
1450
|
+
reject(error);
|
|
1451
|
+
});
|
|
1452
|
+
});
|
|
1499
1453
|
}
|
|
1500
|
-
/**
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
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;
|
|
1474
|
+
}
|
|
1475
|
+
else if (formComp.columns) {
|
|
1476
|
+
newComponents = formComp.columns;
|
|
1477
|
+
}
|
|
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);
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
resolve(lFormPannelsToken);
|
|
1492
|
+
}, (error) => {
|
|
1493
|
+
reject(error);
|
|
1494
|
+
});
|
|
1495
|
+
});
|
|
1515
1496
|
}
|
|
1516
1497
|
/**
|
|
1517
|
-
*
|
|
1498
|
+
* A recursive method to get all the information of the editGrid dynamic form
|
|
1518
1499
|
* @param components
|
|
1500
|
+
* @param form
|
|
1519
1501
|
*/
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
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];
|
|
1538
|
-
}
|
|
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
|
-
}
|
|
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;
|
|
1566
1511
|
}
|
|
1567
|
-
else {
|
|
1512
|
+
else if (formComp.columns) {
|
|
1513
|
+
newComponents = formComp.columns;
|
|
1568
1514
|
}
|
|
1515
|
+
components = this.getPanelComponenet(components, newComponents, panelName);
|
|
1569
1516
|
}
|
|
1570
1517
|
}
|
|
1571
|
-
return
|
|
1518
|
+
return components;
|
|
1572
1519
|
}
|
|
1573
1520
|
/**
|
|
1574
|
-
*
|
|
1521
|
+
* A recursive method to get all the information of the components a columns of the dynamic form
|
|
1575
1522
|
* @param components
|
|
1576
|
-
* @param
|
|
1523
|
+
* @param form
|
|
1577
1524
|
*/
|
|
1578
|
-
|
|
1579
|
-
|
|
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
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
else if (formComp.columns) {
|
|
1537
|
+
newComponents = formComp.columns;
|
|
1538
|
+
}
|
|
1539
|
+
if (formComp.type && formComp.type === 'panel') {
|
|
1540
|
+
panelName = formComp.title;
|
|
1541
|
+
}
|
|
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
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
return components;
|
|
1580
1552
|
}
|
|
1581
|
-
/**
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
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];
|
|
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);
|
|
1597
1566
|
}
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
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
|
-
}
|
|
1567
|
+
lFormFieldsToken = [];
|
|
1568
|
+
for (let formComp of form) {
|
|
1569
|
+
let newComponents;
|
|
1570
|
+
let components = [];
|
|
1571
|
+
if (formComp.components) {
|
|
1572
|
+
newComponents = formComp.components;
|
|
1654
1573
|
}
|
|
1655
|
-
|
|
1656
|
-
|
|
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;
|
|
1574
|
+
else if (formComp.columns) {
|
|
1575
|
+
newComponents = formComp.columns;
|
|
1664
1576
|
}
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
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);
|
|
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);
|
|
1683
1588
|
}
|
|
1684
1589
|
}
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1590
|
+
resolve(lFormFieldsToken);
|
|
1591
|
+
}, (error) => {
|
|
1592
|
+
reject(error);
|
|
1593
|
+
});
|
|
1594
|
+
});
|
|
1688
1595
|
}
|
|
1689
1596
|
/**
|
|
1690
|
-
*
|
|
1691
|
-
* @param
|
|
1692
|
-
* @
|
|
1597
|
+
* A recursive method to get all the information of the editGrid dynamic form
|
|
1598
|
+
* @param components
|
|
1599
|
+
* @param form
|
|
1693
1600
|
*/
|
|
1694
|
-
|
|
1695
|
-
let
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
if (
|
|
1703
|
-
|
|
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;
|
|
1704
1611
|
}
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
});
|
|
1708
|
-
if (!form) {
|
|
1709
|
-
//console.error('No se encontró el formulario con id ' + dForm.formId);
|
|
1710
|
-
continue;
|
|
1612
|
+
else if (formComp.columns) {
|
|
1613
|
+
newComponents = formComp.columns;
|
|
1711
1614
|
}
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
listData[key] = dForm.data[key];
|
|
1715
|
-
listDataByForm[keyFormTitle + key] = dForm.data[key];
|
|
1615
|
+
if (formComp.type && formComp.type === 'panel') {
|
|
1616
|
+
panelName = formComp.title;
|
|
1716
1617
|
}
|
|
1618
|
+
components = this.getEditGridComponenet(components, newComponents, panelName);
|
|
1717
1619
|
}
|
|
1718
1620
|
}
|
|
1719
|
-
return
|
|
1720
|
-
listData: listData,
|
|
1721
|
-
listDataByForm: listDataByForm
|
|
1722
|
-
};
|
|
1621
|
+
return components;
|
|
1723
1622
|
}
|
|
1724
|
-
/**
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
*/
|
|
1728
|
-
static getPanelComponents(components) {
|
|
1729
|
-
return FormioUtil.getComponentsByPanel(components);
|
|
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()) });
|
|
1730
1626
|
}
|
|
1731
|
-
/**
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
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);
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
|
-
}
|
|
1749
|
-
}
|
|
1750
|
-
return result;
|
|
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
|
+
});
|
|
1751
1632
|
}
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
constructor(environment, httpClient) {
|
|
1756
|
-
this.environment = environment;
|
|
1757
|
-
this.httpClient = httpClient;
|
|
1758
|
-
this.headerJson = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) };
|
|
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) });
|
|
1759
1636
|
}
|
|
1760
|
-
/** It
|
|
1761
|
-
|
|
1762
|
-
return this.httpClient.
|
|
1637
|
+
/** It saves the token */
|
|
1638
|
+
save(token) {
|
|
1639
|
+
return this.httpClient.post(this.environment.host.backend.configuration + 'token/save', token, HEADER_JSON);
|
|
1763
1640
|
}
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
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 '';
|
|
1767
1647
|
}
|
|
1768
|
-
/** It returns
|
|
1769
|
-
|
|
1770
|
-
return this.httpClient.get(this.environment.host.backend.
|
|
1771
|
-
|
|
1772
|
-
|
|
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() });
|
|
1773
1655
|
}
|
|
1774
|
-
/** It
|
|
1775
|
-
|
|
1776
|
-
|
|
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);
|
|
1777
1668
|
}
|
|
1778
|
-
|
|
1779
|
-
return
|
|
1669
|
+
static getKeyBudget() {
|
|
1670
|
+
return UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_BUDGET);
|
|
1780
1671
|
}
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
return this.httpClient.delete(this.environment.host.backend.configuration + 'form/delete', {
|
|
1784
|
-
params: new HttpParams().set('id', id)
|
|
1785
|
-
});
|
|
1672
|
+
static getKeyDocument() {
|
|
1673
|
+
return UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_DOCUMENTO);
|
|
1786
1674
|
}
|
|
1787
|
-
|
|
1788
|
-
|
|
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 });
|
|
1675
|
+
static getKeyTask() {
|
|
1676
|
+
return UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_TASKL);
|
|
1794
1677
|
}
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getByListPromCodigo', { params: new HttpParams().set('listPromCodigo', listPromCod.toString()) });
|
|
1678
|
+
static getKeyStatic() {
|
|
1679
|
+
return UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_STATIC);
|
|
1798
1680
|
}
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
});
|
|
1681
|
+
static getKeyCalculated(token) {
|
|
1682
|
+
return (UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_CALCULATED) +
|
|
1683
|
+
'_' +
|
|
1684
|
+
UtilString.replaceAccentSpacesOthers(token.name));
|
|
1804
1685
|
}
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
params: new HttpParams()
|
|
1810
|
-
.set('promCodigo', promCodigo.toString())
|
|
1811
|
-
.set('title', title)
|
|
1812
|
-
});
|
|
1686
|
+
static getKeySnapshot(token) {
|
|
1687
|
+
return (UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_SNAPSHOT) +
|
|
1688
|
+
'_' +
|
|
1689
|
+
UtilString.replaceAccentSpacesOthers(token.name));
|
|
1813
1690
|
}
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
params: new HttpParams()
|
|
1819
|
-
.set('promCodigo', promCodigo.toString())
|
|
1820
|
-
.set('patCodigo', patCodigo.toString())
|
|
1821
|
-
.set('formId', formId)
|
|
1822
|
-
.set('username', username)
|
|
1823
|
-
});
|
|
1691
|
+
static getKeyGuarantee(token) {
|
|
1692
|
+
return (UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_GUARANTEE) +
|
|
1693
|
+
'_' +
|
|
1694
|
+
UtilString.replaceAccentSpacesOthers(token.name));
|
|
1824
1695
|
}
|
|
1825
1696
|
/**
|
|
1826
|
-
*
|
|
1827
|
-
* @param
|
|
1697
|
+
* Return a value that represent the type of label: 1=Form, 2=Budget, 3=Static, 4=Calculated
|
|
1698
|
+
* @param key Value to evalueate
|
|
1828
1699
|
*/
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
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;
|
|
1848
1719
|
}
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
this.formService = formService;
|
|
1869
|
-
this.currencyPipe = currencyPipe;
|
|
1720
|
+
/**
|
|
1721
|
+
* Depends of the type of formFieldToken return de value of the valueData
|
|
1722
|
+
* @param formFieldToken
|
|
1723
|
+
* @param valueData
|
|
1724
|
+
*/
|
|
1725
|
+
getValueFromFormField(formFieldToken, valueData) {
|
|
1726
|
+
if (typeof valueData == 'object') {
|
|
1727
|
+
if (formFieldToken.type) {
|
|
1728
|
+
if (formFieldToken.type == 'address') {
|
|
1729
|
+
return valueData.formatted_address;
|
|
1730
|
+
}
|
|
1731
|
+
if (formFieldToken.type == 'select' &&
|
|
1732
|
+
formFieldToken.searchField &&
|
|
1733
|
+
valueData.hasOwnProperty(formFieldToken.searchField)) {
|
|
1734
|
+
return valueData[formFieldToken.searchField];
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
return valueData;
|
|
1870
1739
|
}
|
|
1871
|
-
/**
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1740
|
+
/**
|
|
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
|
|
1745
|
+
*/
|
|
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 = '';
|
|
1759
|
+
}
|
|
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);
|
|
1767
|
+
}
|
|
1768
|
+
else {
|
|
1769
|
+
console.log('El dato [' +
|
|
1770
|
+
dataValue +
|
|
1771
|
+
'] para el token [' +
|
|
1772
|
+
token +
|
|
1773
|
+
'] tipo númerico no es valido');
|
|
1774
|
+
valueReplace = '';
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
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
|
+
}
|
|
1792
|
+
return stringText;
|
|
1793
|
+
}
|
|
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;
|
|
1902
1821
|
}
|
|
1903
1822
|
}
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
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);
|
|
1823
|
+
}
|
|
1824
|
+
result.push(infoToken);
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
return result;
|
|
1828
|
+
}
|
|
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];
|
|
1933
1838
|
}
|
|
1934
|
-
}
|
|
1935
|
-
resolve(lFormFieldsToken);
|
|
1936
|
-
},
|
|
1937
|
-
error: (error) => {
|
|
1938
|
-
reject(error);
|
|
1839
|
+
});
|
|
1939
1840
|
}
|
|
1940
1841
|
});
|
|
1842
|
+
if (objData) {
|
|
1843
|
+
newData.push(objData);
|
|
1844
|
+
}
|
|
1941
1845
|
});
|
|
1846
|
+
return newData;
|
|
1942
1847
|
}
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
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);
|
|
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]);
|
|
1973
1858
|
}
|
|
1974
|
-
}
|
|
1975
|
-
resolve(lFormFieldsToken);
|
|
1976
|
-
}, (error) => {
|
|
1977
|
-
reject(error);
|
|
1859
|
+
});
|
|
1978
1860
|
});
|
|
1861
|
+
translatedCards.push(htmlTranslated);
|
|
1979
1862
|
});
|
|
1863
|
+
return translatedCards;
|
|
1980
1864
|
}
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
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;
|
|
1994
1888
|
}
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
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);
|
|
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
|
+
}
|
|
2016
1897
|
}
|
|
2017
1898
|
}
|
|
2018
|
-
|
|
2019
|
-
}
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
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;
|
|
1949
|
+
}
|
|
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;
|
|
2023
1961
|
}
|
|
2024
1962
|
/**
|
|
2025
|
-
*
|
|
2026
|
-
* @param
|
|
2027
|
-
* @param
|
|
1963
|
+
* It reuses replaceTokensFromListObjectPublic but set all keys lobjecttokens as lowercase
|
|
1964
|
+
* @param tokenName
|
|
1965
|
+
* @param formula
|
|
1966
|
+
* @param lObjectTokens
|
|
2028
1967
|
*/
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
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;
|
|
2041
|
-
}
|
|
2042
|
-
components = this.getPanelComponenet(components, newComponents, panelName);
|
|
1968
|
+
replaceTokensFromListObjectPublic(tokenName, formula, lObjectTokens) {
|
|
1969
|
+
let lDataOrg = [];
|
|
1970
|
+
if (lObjectTokens) {
|
|
1971
|
+
for (let dataForm in lObjectTokens) {
|
|
1972
|
+
lDataOrg[dataForm.toLowerCase()] = lObjectTokens[dataForm];
|
|
2043
1973
|
}
|
|
2044
1974
|
}
|
|
2045
|
-
return
|
|
1975
|
+
return this.replaceTokensFromListObject(tokenName, formula, lDataOrg);
|
|
2046
1976
|
}
|
|
2047
1977
|
/**
|
|
2048
|
-
*
|
|
2049
|
-
* @param
|
|
2050
|
-
* @param
|
|
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
|
|
2051
1981
|
*/
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
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;
|
|
2068
2017
|
}
|
|
2069
|
-
components = this.getComponenetForm(components, newComponents, panelName, editgrid, editGridKey);
|
|
2070
2018
|
}
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
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 = '';
|
|
2076
2029
|
}
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
let
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
value: formComp.title,
|
|
2109
|
-
object: formComp
|
|
2110
|
-
},
|
|
2111
|
-
value: []
|
|
2112
|
-
});
|
|
2113
|
-
lFormFieldsToken[lFormFieldsToken.length - 1].value =
|
|
2114
|
-
this.getEditGridComponenet(components, newComponents, null);
|
|
2115
|
-
}
|
|
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);
|
|
2055
|
+
}
|
|
2056
|
+
else {
|
|
2057
|
+
lAuxformExpression.push(expression);
|
|
2058
|
+
}
|
|
2059
|
+
});
|
|
2060
|
+
replacedTokens = lAuxformExpression.join(' ');
|
|
2116
2061
|
}
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
});
|
|
2121
|
-
});
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
return replacedTokens;
|
|
2122
2065
|
}
|
|
2123
2066
|
/**
|
|
2124
|
-
*
|
|
2125
|
-
*
|
|
2126
|
-
*
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
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;
|
|
2144
|
-
}
|
|
2145
|
-
components = this.getEditGridComponenet(components, newComponents, panelName);
|
|
2146
|
-
}
|
|
2147
|
-
}
|
|
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, '-'));
|
|
2172
|
-
}
|
|
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
|
|
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
|
|
2226
2074
|
*/
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
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;
|
|
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';
|
|
2241
2084
|
}
|
|
2242
|
-
|
|
2243
|
-
|
|
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';
|
|
2244
2096
|
}
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
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;
|
|
2264
2119
|
}
|
|
2265
|
-
|
|
2120
|
+
expression = isTagFound ? 'true' : 'false';
|
|
2121
|
+
return expression;
|
|
2266
2122
|
}
|
|
2267
2123
|
/**
|
|
2268
|
-
* Try to
|
|
2269
|
-
* @param
|
|
2270
|
-
* @param
|
|
2271
|
-
* @param
|
|
2124
|
+
* Try to eval the formula depend of the type of fields.
|
|
2125
|
+
* @param lStaticToken
|
|
2126
|
+
* @param formulaName
|
|
2127
|
+
* @param formula
|
|
2272
2128
|
*/
|
|
2273
|
-
|
|
2274
|
-
let
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
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 = '';
|
|
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
|
+
}
|
|
2302
2143
|
}
|
|
2303
2144
|
}
|
|
2304
|
-
else {
|
|
2305
|
-
console.log('tipo de token indefinido. [typeToken[' + typeToken + ']]');
|
|
2306
|
-
}
|
|
2307
2145
|
}
|
|
2308
|
-
|
|
2309
|
-
|
|
2146
|
+
try {
|
|
2147
|
+
formula = this.replaceTokensFromListObject(formulaName, formula, objectTokens);
|
|
2310
2148
|
}
|
|
2311
|
-
|
|
2312
|
-
console.
|
|
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;
|
|
2149
|
+
catch (error) {
|
|
2150
|
+
//console.error(error);
|
|
2151
|
+
throw error;
|
|
2679
2152
|
}
|
|
2680
2153
|
if (formula !== null) {
|
|
2681
2154
|
try {
|
|
@@ -10255,108 +9728,627 @@ class SegmentationUserService {
|
|
|
10255
9728
|
return this.httpClient.post(this.environment.host.backend.segmentation +
|
|
10256
9729
|
'PlicSegmentationUserController/updatePositionSegmentation', lSegmentationUser, this.headerJson);
|
|
10257
9730
|
}
|
|
10258
|
-
saveAllSegmentation(lSegmentationUser) {
|
|
10259
|
-
return this.httpClient.post(this.environment.host.backend.segmentation +
|
|
10260
|
-
'PlicSegmentationUserController/saveAllSegmentation', lSegmentationUser, this.headerJson);
|
|
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
|
+
});
|
|
9756
|
+
}
|
|
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()) });
|
|
9760
|
+
}
|
|
9761
|
+
getSegmentationById(segmentationId) {
|
|
9762
|
+
return this.httpClient.get(this.environment.host.backend.segmentation +
|
|
9763
|
+
'PlicSegmentationUserController/getSegmentationById', { params: new HttpParams().set('segmentationId', segmentationId) });
|
|
9764
|
+
}
|
|
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()) });
|
|
9768
|
+
}
|
|
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())
|
|
9775
|
+
});
|
|
9776
|
+
}
|
|
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)
|
|
9788
|
+
});
|
|
9789
|
+
}
|
|
9790
|
+
}
|
|
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: [{
|
|
9794
|
+
type: Injectable,
|
|
9795
|
+
args: [{
|
|
9796
|
+
providedIn: 'root'
|
|
9797
|
+
}]
|
|
9798
|
+
}], ctorParameters: function () {
|
|
9799
|
+
return [{ type: undefined, decorators: [{
|
|
9800
|
+
type: Inject,
|
|
9801
|
+
args: ['environment']
|
|
9802
|
+
}] }, { type: i1.HttpClient }];
|
|
9803
|
+
} });
|
|
9804
|
+
|
|
9805
|
+
class SegmentationService {
|
|
9806
|
+
constructor(environment, httpClient) {
|
|
9807
|
+
this.environment = environment;
|
|
9808
|
+
this.httpClient = httpClient;
|
|
9809
|
+
this.headerJson = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) };
|
|
9810
|
+
}
|
|
9811
|
+
/** It send the email */
|
|
9812
|
+
send(segmentation) {
|
|
9813
|
+
return this.httpClient.post(this.environment.host.backend.queue + 'segmentation/send', segmentation, this.headerJson);
|
|
9814
|
+
}
|
|
9815
|
+
/** It send the email */
|
|
9816
|
+
sendMultiple(listSegmentation) {
|
|
9817
|
+
return this.httpClient.post(this.environment.host.backend.queue + 'segmentation/sendMassive', listSegmentation, this.headerJson);
|
|
9818
|
+
}
|
|
9819
|
+
}
|
|
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: [{
|
|
9823
|
+
type: Injectable,
|
|
9824
|
+
args: [{
|
|
9825
|
+
providedIn: 'root'
|
|
9826
|
+
}]
|
|
9827
|
+
}], ctorParameters: function () {
|
|
9828
|
+
return [{ type: undefined, decorators: [{
|
|
9829
|
+
type: Inject,
|
|
9830
|
+
args: ['environment']
|
|
9831
|
+
}] }, { type: i1.HttpClient }];
|
|
9832
|
+
} });
|
|
9833
|
+
|
|
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;
|
|
9864
|
+
}
|
|
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;
|
|
9902
|
+
}
|
|
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);
|
|
10261
9909
|
}
|
|
10262
|
-
/**
|
|
10263
|
-
|
|
10264
|
-
|
|
10265
|
-
|
|
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);
|
|
10266
9916
|
}
|
|
10267
|
-
|
|
10268
|
-
|
|
10269
|
-
|
|
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;
|
|
10270
9959
|
}
|
|
10271
|
-
|
|
10272
|
-
|
|
10273
|
-
|
|
9960
|
+
/**
|
|
9961
|
+
* It returns the components
|
|
9962
|
+
* @param components
|
|
9963
|
+
*/
|
|
9964
|
+
static getComponents(components) {
|
|
9965
|
+
return FormioUtil.getComponentsByRecursion(components, '', null);
|
|
10274
9966
|
}
|
|
10275
|
-
|
|
10276
|
-
|
|
10277
|
-
|
|
10278
|
-
|
|
10279
|
-
|
|
10280
|
-
|
|
10281
|
-
|
|
10282
|
-
|
|
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
|
+
// resolve conditional parent conditional
|
|
9988
|
+
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
9989
|
+
// change condition
|
|
9990
|
+
if (conditional)
|
|
9991
|
+
conditionalParent = conditional;
|
|
9992
|
+
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
9993
|
+
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
9994
|
+
? component[EFormioKey.COMPONENTS]
|
|
9995
|
+
: component[EFormioKey.COLUMNS];
|
|
9996
|
+
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
9997
|
+
const recursionResult = FormioUtil.getComponentsByRecursion(subComponents, titlePanel, conditionalParent);
|
|
9998
|
+
// if recursion result then result concats the recursionResult
|
|
9999
|
+
if (recursionResult)
|
|
10000
|
+
result = result.concat(recursionResult);
|
|
10001
|
+
// reset conditional Parent
|
|
10002
|
+
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
10003
|
+
conditionalParent = undefined;
|
|
10004
|
+
}
|
|
10005
|
+
else {
|
|
10006
|
+
// avoid the component type button
|
|
10007
|
+
if (component[EFormioKey.TYPE] !== EFormioKey.BUTTON &&
|
|
10008
|
+
component[EFormioKey.KEY] &&
|
|
10009
|
+
component[EFormioKey.LABEL]) {
|
|
10010
|
+
// resolve conditional conditional object
|
|
10011
|
+
let conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
10012
|
+
if (!conditional)
|
|
10013
|
+
conditional = conditionalParent;
|
|
10014
|
+
component[EFormioKey.CONDITIONAL] = conditional[EFormioKey.CONDITIONAL];
|
|
10015
|
+
component[EFormioKey.CUSTOM_CONDITIONAL] =
|
|
10016
|
+
conditional[EFormioKey.CUSTOM_CONDITIONAL];
|
|
10017
|
+
// add namPanel as property
|
|
10018
|
+
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
10019
|
+
// add component to the result
|
|
10020
|
+
result.push(component);
|
|
10021
|
+
}
|
|
10022
|
+
}
|
|
10023
|
+
}
|
|
10024
|
+
}
|
|
10025
|
+
}
|
|
10026
|
+
return result;
|
|
10283
10027
|
}
|
|
10284
|
-
|
|
10285
|
-
|
|
10286
|
-
|
|
10028
|
+
/**
|
|
10029
|
+
* It returns the components
|
|
10030
|
+
* @param components
|
|
10031
|
+
* @param keepEditGrids
|
|
10032
|
+
*/
|
|
10033
|
+
static getComponentsWithEditGrids(components) {
|
|
10034
|
+
return FormioUtil.getComponentsByRecursionWithEditGrids(components, '', null);
|
|
10287
10035
|
}
|
|
10288
|
-
|
|
10289
|
-
|
|
10290
|
-
|
|
10036
|
+
/**
|
|
10037
|
+
* It returns the components array of the form by recursion
|
|
10038
|
+
* @param components array of components
|
|
10039
|
+
* @param titlePanel name of parent panel, so children components will inherit the panelName
|
|
10040
|
+
* @param conditionalObject conditional object it will be inherited from panel {conditional: { eq: , value: , when: , json: }, customConditional: }
|
|
10041
|
+
*/
|
|
10042
|
+
static getComponentsByRecursionWithEditGrids(components, titlePanel, conditionalParent) {
|
|
10043
|
+
// it contains the result array
|
|
10044
|
+
let result = [];
|
|
10045
|
+
if (components) {
|
|
10046
|
+
// iterate over components
|
|
10047
|
+
for (const component of components) {
|
|
10048
|
+
// avoid the editgrid component ot if it has a different behavior it should have an else statement
|
|
10049
|
+
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
10050
|
+
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
10051
|
+
titlePanel = component[EFormioKey.TITLE];
|
|
10052
|
+
}
|
|
10053
|
+
if (typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
10054
|
+
typeof component[EFormioKey.COLUMNS] !== 'undefined') {
|
|
10055
|
+
// resolve conditional parent conditional
|
|
10056
|
+
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
10057
|
+
// change condition
|
|
10058
|
+
if (conditional)
|
|
10059
|
+
conditionalParent = conditional;
|
|
10060
|
+
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
10061
|
+
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
10062
|
+
? component[EFormioKey.COMPONENTS]
|
|
10063
|
+
: component[EFormioKey.COLUMNS];
|
|
10064
|
+
if (component[EFormioKey.TYPE] === EFormioKey.EDITGRID) {
|
|
10065
|
+
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
10066
|
+
result.push(component);
|
|
10067
|
+
}
|
|
10068
|
+
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
10069
|
+
const recursionResult = FormioUtil.getComponentsByRecursionWithEditGrids(subComponents, titlePanel, conditionalParent);
|
|
10070
|
+
// if recursion result then result concats the recursionResult
|
|
10071
|
+
if (recursionResult)
|
|
10072
|
+
result = result.concat(recursionResult);
|
|
10073
|
+
// reset conditional Parent
|
|
10074
|
+
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
10075
|
+
conditionalParent = undefined;
|
|
10076
|
+
}
|
|
10077
|
+
else {
|
|
10078
|
+
// avoid the component type button
|
|
10079
|
+
if (component[EFormioKey.TYPE] !== EFormioKey.BUTTON &&
|
|
10080
|
+
component[EFormioKey.KEY] &&
|
|
10081
|
+
component[EFormioKey.LABEL]) {
|
|
10082
|
+
// resolve conditional conditional object
|
|
10083
|
+
let conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
10084
|
+
if (!conditional)
|
|
10085
|
+
conditional = conditionalParent;
|
|
10086
|
+
component[EFormioKey.CONDITIONAL] = conditional[EFormioKey.CONDITIONAL];
|
|
10087
|
+
component[EFormioKey.CUSTOM_CONDITIONAL] =
|
|
10088
|
+
conditional[EFormioKey.CUSTOM_CONDITIONAL];
|
|
10089
|
+
// add namPanel as property
|
|
10090
|
+
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
10091
|
+
// add component to the result
|
|
10092
|
+
result.push(component);
|
|
10093
|
+
}
|
|
10094
|
+
}
|
|
10095
|
+
}
|
|
10096
|
+
}
|
|
10097
|
+
return result;
|
|
10291
10098
|
}
|
|
10292
|
-
|
|
10293
|
-
|
|
10294
|
-
|
|
10099
|
+
/**
|
|
10100
|
+
* It resolve the inheritance conditional
|
|
10101
|
+
* @param conditionalObject
|
|
10102
|
+
* @param conditional
|
|
10103
|
+
* @param customConditional
|
|
10104
|
+
*/
|
|
10105
|
+
static resolveInheritanceConditional(conditionalObject, conditional, customConditional, parentId) {
|
|
10106
|
+
// validate if there is a condition with the new fields
|
|
10107
|
+
if (!conditionalObject ||
|
|
10108
|
+
customConditional ||
|
|
10109
|
+
(conditional && conditional[EFormioKey.WHEN] && conditional[EFormioKey.EQ]) ||
|
|
10110
|
+
(conditional && conditional[EFormioKey.JSON])) {
|
|
10111
|
+
return { conditional: conditional, customConditional: customConditional, id: parentId };
|
|
10112
|
+
}
|
|
10113
|
+
return null;
|
|
10295
10114
|
}
|
|
10296
|
-
|
|
10297
|
-
|
|
10298
|
-
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
-
|
|
10302
|
-
|
|
10115
|
+
/**
|
|
10116
|
+
* It returns the edit grid components
|
|
10117
|
+
* @param components
|
|
10118
|
+
*/
|
|
10119
|
+
static getEditGridKeyLabels(components) {
|
|
10120
|
+
return FormioUtil.getEditGridKeyLabelsByRecursion(components, '', null);
|
|
10121
|
+
}
|
|
10122
|
+
/**
|
|
10123
|
+
* It returns the components edit grid array of the form by recursion
|
|
10124
|
+
* @param components array of components
|
|
10125
|
+
* @param titlePanel name of parent panel, so children components will inherit the panelName
|
|
10126
|
+
* @param conditionalObject conditional object it will be inherited from panel {conditional: { eq: , value: , when: , json: }, customConditional: }
|
|
10127
|
+
*/
|
|
10128
|
+
static getEditGridKeyLabelsByRecursion(components, titlePanel, conditionalParent) {
|
|
10129
|
+
// it contains the result array
|
|
10130
|
+
let result = [];
|
|
10131
|
+
if (components) {
|
|
10132
|
+
// iterate over components
|
|
10133
|
+
for (const component of components) {
|
|
10134
|
+
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
10135
|
+
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
10136
|
+
titlePanel = component[EFormioKey.TITLE];
|
|
10137
|
+
}
|
|
10138
|
+
if (typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
10139
|
+
typeof component[EFormioKey.COLUMNS] !== 'undefined') {
|
|
10140
|
+
// resolve conditional parent conditional
|
|
10141
|
+
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
10142
|
+
// change condition
|
|
10143
|
+
if (conditional)
|
|
10144
|
+
conditionalParent = conditional;
|
|
10145
|
+
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
10146
|
+
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
10147
|
+
? component[EFormioKey.COMPONENTS]
|
|
10148
|
+
: component[EFormioKey.COLUMNS];
|
|
10149
|
+
if (component[EFormioKey.TYPE] == EFormioKey.EDITGRID) {
|
|
10150
|
+
// add namPanel as property
|
|
10151
|
+
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
10152
|
+
// add component to the result
|
|
10153
|
+
result.push(component);
|
|
10154
|
+
}
|
|
10155
|
+
else {
|
|
10156
|
+
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
10157
|
+
const recursionResult = FormioUtil.getEditGridKeyLabelsByRecursion(subComponents, titlePanel, conditionalParent);
|
|
10158
|
+
// if recursion result then result concats the recursionResult
|
|
10159
|
+
if (recursionResult)
|
|
10160
|
+
result = result.concat(recursionResult);
|
|
10161
|
+
// reset conditional Parent
|
|
10162
|
+
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
10163
|
+
conditionalParent = undefined;
|
|
10164
|
+
}
|
|
10165
|
+
}
|
|
10166
|
+
else {
|
|
10167
|
+
}
|
|
10168
|
+
}
|
|
10169
|
+
}
|
|
10170
|
+
return result;
|
|
10303
10171
|
}
|
|
10304
|
-
|
|
10305
|
-
|
|
10306
|
-
|
|
10172
|
+
/**
|
|
10173
|
+
* It returns the components
|
|
10174
|
+
* @param components
|
|
10175
|
+
* @param keepEditGrids
|
|
10176
|
+
*/
|
|
10177
|
+
static getComponentsIntoEditGrids(components, editGridName) {
|
|
10178
|
+
return FormioUtil.getComponentsByRecursionIntoEditGrids(components, '', null, editGridName, false);
|
|
10307
10179
|
}
|
|
10308
|
-
|
|
10309
|
-
|
|
10310
|
-
|
|
10311
|
-
|
|
10312
|
-
|
|
10313
|
-
|
|
10314
|
-
|
|
10315
|
-
|
|
10180
|
+
/**
|
|
10181
|
+
* It returns the components array of the form by recursion
|
|
10182
|
+
* @param components array of components
|
|
10183
|
+
* @param titlePanel name of parent panel, so children components will inherit the panelName
|
|
10184
|
+
* @param conditionalObject conditional object it will be inherited from panel {conditional: { eq: , value: , when: , json: }, customConditional: }
|
|
10185
|
+
*/
|
|
10186
|
+
static getComponentsByRecursionIntoEditGrids(components, titlePanel, conditionalParent, editGridName, existEditGrid) {
|
|
10187
|
+
// it contains the result array
|
|
10188
|
+
let result = [];
|
|
10189
|
+
if (components) {
|
|
10190
|
+
// iterate over components
|
|
10191
|
+
for (const component of components) {
|
|
10192
|
+
// avoid the editgrid component ot if it has a different behavior it should have an else statement
|
|
10193
|
+
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
10194
|
+
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
10195
|
+
titlePanel = component[EFormioKey.TITLE];
|
|
10196
|
+
}
|
|
10197
|
+
if (typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
10198
|
+
typeof component[EFormioKey.COLUMNS] !== 'undefined') {
|
|
10199
|
+
// resolve conditional parent conditional
|
|
10200
|
+
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
10201
|
+
// change condition
|
|
10202
|
+
if (conditional)
|
|
10203
|
+
conditionalParent = conditional;
|
|
10204
|
+
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
10205
|
+
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
10206
|
+
? component[EFormioKey.COMPONENTS]
|
|
10207
|
+
: component[EFormioKey.COLUMNS];
|
|
10208
|
+
if (component[EFormioKey.TYPE] === EFormioKey.EDITGRID &&
|
|
10209
|
+
component['key'] == editGridName) {
|
|
10210
|
+
existEditGrid = true;
|
|
10211
|
+
if (typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
10212
|
+
typeof component[EFormioKey.COLUMNS] !== 'undefined') {
|
|
10213
|
+
// resolve conditional parent conditional
|
|
10214
|
+
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
10215
|
+
// change condition
|
|
10216
|
+
if (conditional)
|
|
10217
|
+
conditionalParent = conditional;
|
|
10218
|
+
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
10219
|
+
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
10220
|
+
? component[EFormioKey.COMPONENTS]
|
|
10221
|
+
: component[EFormioKey.COLUMNS];
|
|
10222
|
+
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
10223
|
+
const recursionResult = FormioUtil.getComponentsByRecursionIntoEditGrids(subComponents, titlePanel, conditionalParent, editGridName, existEditGrid);
|
|
10224
|
+
// if recursion result then result concats the recursionResult
|
|
10225
|
+
if (recursionResult)
|
|
10226
|
+
result = result.concat(recursionResult);
|
|
10227
|
+
// reset conditional Parent
|
|
10228
|
+
if (component && conditionalParent) {
|
|
10229
|
+
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
10230
|
+
conditionalParent = undefined;
|
|
10231
|
+
}
|
|
10232
|
+
}
|
|
10233
|
+
else {
|
|
10234
|
+
// avoid the component type button
|
|
10235
|
+
if (component[EFormioKey.TYPE] !== EFormioKey.BUTTON &&
|
|
10236
|
+
component[EFormioKey.KEY] &&
|
|
10237
|
+
component[EFormioKey.LABEL] &&
|
|
10238
|
+
existEditGrid) {
|
|
10239
|
+
// resolve conditional conditional object
|
|
10240
|
+
let conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
10241
|
+
if (!conditional)
|
|
10242
|
+
conditional = conditionalParent;
|
|
10243
|
+
component[EFormioKey.CONDITIONAL] =
|
|
10244
|
+
conditional[EFormioKey.CONDITIONAL];
|
|
10245
|
+
component[EFormioKey.CUSTOM_CONDITIONAL] =
|
|
10246
|
+
conditional[EFormioKey.CUSTOM_CONDITIONAL];
|
|
10247
|
+
// add namPanel as property
|
|
10248
|
+
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
10249
|
+
// add component to the result
|
|
10250
|
+
result.push(component);
|
|
10251
|
+
}
|
|
10252
|
+
}
|
|
10253
|
+
}
|
|
10254
|
+
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
10255
|
+
const recursionResult = FormioUtil.getComponentsByRecursionIntoEditGrids(subComponents, titlePanel, conditionalParent, editGridName, existEditGrid);
|
|
10256
|
+
// if recursion result then result concats the recursionResult
|
|
10257
|
+
if (recursionResult)
|
|
10258
|
+
result = result.concat(recursionResult);
|
|
10259
|
+
// reset conditional Parent
|
|
10260
|
+
if (component && conditionalParent) {
|
|
10261
|
+
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
10262
|
+
conditionalParent = undefined;
|
|
10263
|
+
}
|
|
10264
|
+
}
|
|
10265
|
+
else {
|
|
10266
|
+
// avoid the component type button
|
|
10267
|
+
if (component[EFormioKey.TYPE] !== EFormioKey.BUTTON &&
|
|
10268
|
+
component[EFormioKey.KEY] &&
|
|
10269
|
+
component[EFormioKey.LABEL] &&
|
|
10270
|
+
existEditGrid) {
|
|
10271
|
+
// resolve conditional conditional object
|
|
10272
|
+
let conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
10273
|
+
if (!conditional)
|
|
10274
|
+
conditional = conditionalParent;
|
|
10275
|
+
component[EFormioKey.CONDITIONAL] = conditional[EFormioKey.CONDITIONAL];
|
|
10276
|
+
component[EFormioKey.CUSTOM_CONDITIONAL] =
|
|
10277
|
+
conditional[EFormioKey.CUSTOM_CONDITIONAL];
|
|
10278
|
+
// add namPanel as property
|
|
10279
|
+
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
10280
|
+
// add component to the result
|
|
10281
|
+
result.push(component);
|
|
10282
|
+
}
|
|
10283
|
+
}
|
|
10284
|
+
}
|
|
10285
|
+
}
|
|
10286
|
+
return result;
|
|
10316
10287
|
}
|
|
10317
|
-
|
|
10318
|
-
|
|
10319
|
-
|
|
10320
|
-
|
|
10321
|
-
|
|
10322
|
-
|
|
10323
|
-
|
|
10324
|
-
|
|
10325
|
-
|
|
10326
|
-
|
|
10327
|
-
|
|
10328
|
-
|
|
10329
|
-
|
|
10330
|
-
|
|
10331
|
-
|
|
10332
|
-
|
|
10333
|
-
|
|
10334
|
-
|
|
10335
|
-
|
|
10336
|
-
|
|
10288
|
+
/**
|
|
10289
|
+
* Create 2 jason objects of data form by component key and other by component key and title form key
|
|
10290
|
+
* @param dataForm dataForm model object
|
|
10291
|
+
* @returns Object of 2 element
|
|
10292
|
+
*/
|
|
10293
|
+
static createListDataByDataFormList(dataForm, listForm) {
|
|
10294
|
+
let listData = {};
|
|
10295
|
+
let listDataByForm = {};
|
|
10296
|
+
if (dataForm && dataForm.length > 0) {
|
|
10297
|
+
listData = {};
|
|
10298
|
+
listDataByForm = {};
|
|
10299
|
+
let dForm;
|
|
10300
|
+
for (dForm of dataForm) {
|
|
10301
|
+
if (!dForm.data) {
|
|
10302
|
+
continue;
|
|
10303
|
+
}
|
|
10304
|
+
const form = listForm.find(function (formTmp) {
|
|
10305
|
+
return formTmp.id == dForm.formId;
|
|
10306
|
+
});
|
|
10307
|
+
if (!form) {
|
|
10308
|
+
//console.error('No se encontró el formulario con id ' + dForm.formId);
|
|
10309
|
+
continue;
|
|
10310
|
+
}
|
|
10311
|
+
const keyFormTitle = TokenService.getKeyFormulario(form.title) + '_';
|
|
10312
|
+
for (const key in dForm.data) {
|
|
10313
|
+
listData[key] = dForm.data[key];
|
|
10314
|
+
listDataByForm[keyFormTitle + key] = dForm.data[key];
|
|
10315
|
+
}
|
|
10316
|
+
}
|
|
10317
|
+
}
|
|
10318
|
+
return {
|
|
10319
|
+
listData: listData,
|
|
10320
|
+
listDataByForm: listDataByForm
|
|
10321
|
+
};
|
|
10337
10322
|
}
|
|
10338
|
-
/**
|
|
10339
|
-
|
|
10340
|
-
|
|
10323
|
+
/**
|
|
10324
|
+
* It returns the components
|
|
10325
|
+
* @param components
|
|
10326
|
+
*/
|
|
10327
|
+
static getPanelComponents(components) {
|
|
10328
|
+
return FormioUtil.getComponentsByPanel(components);
|
|
10341
10329
|
}
|
|
10342
|
-
/**
|
|
10343
|
-
|
|
10344
|
-
|
|
10330
|
+
/**
|
|
10331
|
+
* It returns the components array of the form
|
|
10332
|
+
* @param components array of components
|
|
10333
|
+
*/
|
|
10334
|
+
static getComponentsByPanel(components) {
|
|
10335
|
+
// it contains the result array
|
|
10336
|
+
let result = [];
|
|
10337
|
+
if (components) {
|
|
10338
|
+
// iterate over components
|
|
10339
|
+
for (const component of components) {
|
|
10340
|
+
// avoid the editgrid component ot if it has a different behavior it should have an else statement
|
|
10341
|
+
if (component[EFormioKey.TYPE] !== EFormioKey.EDITGRID) {
|
|
10342
|
+
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
10343
|
+
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
10344
|
+
result.push(component);
|
|
10345
|
+
}
|
|
10346
|
+
}
|
|
10347
|
+
}
|
|
10348
|
+
}
|
|
10349
|
+
return result;
|
|
10345
10350
|
}
|
|
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
|
-
} });
|
|
10351
|
+
}
|
|
10360
10352
|
|
|
10361
10353
|
class SendApplicationService {
|
|
10362
10354
|
constructor(environment, tokenService, emailService, interactionApplicationUserService) {
|
|
@@ -15331,8 +15323,8 @@ const VERSION = {
|
|
|
15331
15323
|
},
|
|
15332
15324
|
"suffix": "1932-g573770da-dirty",
|
|
15333
15325
|
"semverString": "0.0.18+1932.g573770da",
|
|
15334
|
-
"version": "0.0.
|
|
15335
|
-
"buildTimestamp": "2022-12-
|
|
15326
|
+
"version": "0.0.1666",
|
|
15327
|
+
"buildTimestamp": "2022-12-14T14:12:03.733Z"
|
|
15336
15328
|
};
|
|
15337
15329
|
/* tslint:enable */
|
|
15338
15330
|
|