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';
|
|
@@ -31,7 +31,6 @@ import { TieredMenuModule } from 'primeng/tieredmenu';
|
|
|
31
31
|
import * as i4$3 from 'primeng/picklist';
|
|
32
32
|
import { PickListModule } from 'primeng/picklist';
|
|
33
33
|
import { BehaviorSubject, Subject, throwError, Observable } from 'rxjs';
|
|
34
|
-
import * as utils_ from 'formiojs-colfuturo/utils/utils';
|
|
35
34
|
import * as i2 from 'ngx-toastr';
|
|
36
35
|
import * as i4$1 from '@angular/router';
|
|
37
36
|
import { map, catchError } from 'rxjs/operators';
|
|
@@ -46,6 +45,7 @@ import Panzoom__default from 'panzoom/dist/panzoom';
|
|
|
46
45
|
import * as i1$2 from '@angular/fire/compat/auth';
|
|
47
46
|
import 'jquery';
|
|
48
47
|
import * as FileSaver from 'file-saver';
|
|
48
|
+
import * as utils_ from 'formiojs-colfuturo/utils/utils';
|
|
49
49
|
import Cropper from 'cropperjs';
|
|
50
50
|
|
|
51
51
|
class NgPliCommonsService {
|
|
@@ -1209,1202 +1209,675 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImpor
|
|
|
1209
1209
|
args: [LOCALE_ID]
|
|
1210
1210
|
}] } });
|
|
1211
1211
|
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
* @param components
|
|
1218
|
-
* @return the object is [{panel: , items: [{ value: , label: }]}]
|
|
1219
|
-
*/
|
|
1220
|
-
static getFormattedComponentsByPanel(components) {
|
|
1221
|
-
let result = [];
|
|
1222
|
-
if (components) {
|
|
1223
|
-
let group = null;
|
|
1224
|
-
let object = null;
|
|
1225
|
-
for (const component of components) {
|
|
1226
|
-
if (component[EFormioKey.TITLE_PANEL] !== group) {
|
|
1227
|
-
if (group !== null) {
|
|
1228
|
-
result.push(object);
|
|
1229
|
-
}
|
|
1230
|
-
object = { label: component[EFormioKey.TITLE_PANEL], items: [], toggle: false };
|
|
1231
|
-
group = component[EFormioKey.TITLE_PANEL];
|
|
1232
|
-
}
|
|
1233
|
-
object.items.push({
|
|
1234
|
-
label: component[EFormioKey.LABEL],
|
|
1235
|
-
value: component[EFormioKey.KEY]
|
|
1236
|
-
});
|
|
1237
|
-
}
|
|
1238
|
-
if (group !== null)
|
|
1239
|
-
result.push(object);
|
|
1240
|
-
}
|
|
1241
|
-
return result;
|
|
1212
|
+
class FormService {
|
|
1213
|
+
constructor(environment, httpClient) {
|
|
1214
|
+
this.environment = environment;
|
|
1215
|
+
this.httpClient = httpClient;
|
|
1216
|
+
this.headerJson = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) };
|
|
1242
1217
|
}
|
|
1243
|
-
/**
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
* @param data
|
|
1247
|
-
*/
|
|
1248
|
-
static getRequiredComponentsByData(components, data) {
|
|
1249
|
-
// get the required components
|
|
1250
|
-
let array = FormioUtil.getRequiredComponents(components);
|
|
1251
|
-
// if not data then return components
|
|
1252
|
-
if (data && array) {
|
|
1253
|
-
for (let i = 0; i < array.length; i++) {
|
|
1254
|
-
const component = array[i];
|
|
1255
|
-
// use formio to check condition according with data
|
|
1256
|
-
if (utils.checkCondition(component, null, data, null, null)) {
|
|
1257
|
-
const key = component[EFormioKey.KEY];
|
|
1258
|
-
if (data[key] != undefined && data[key] != null && data[key] != '') {
|
|
1259
|
-
// remove item from array
|
|
1260
|
-
array.splice(i, 1);
|
|
1261
|
-
i--;
|
|
1262
|
-
}
|
|
1263
|
-
else {
|
|
1264
|
-
if (component.customConditional &&
|
|
1265
|
-
component.customConditional.includes('show')) {
|
|
1266
|
-
// remove item from array
|
|
1267
|
-
array.splice(i, 1);
|
|
1268
|
-
i--;
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
else {
|
|
1273
|
-
// remove item from array
|
|
1274
|
-
array.splice(i, 1);
|
|
1275
|
-
i--;
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
return array;
|
|
1218
|
+
/** It returns the list of form by prom codigo */
|
|
1219
|
+
getByPromCodigo(promCodigo) {
|
|
1220
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getByPromCodigo', { params: new HttpParams().set('promCodigo', promCodigo.toString()) });
|
|
1280
1221
|
}
|
|
1281
|
-
/**
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
*/
|
|
1285
|
-
static getUniqueComponents(components) {
|
|
1286
|
-
return FormioUtil.getComponentsByFeature(components, [EFormioKey.UNIQUE], true);
|
|
1222
|
+
/** It returns the list of form by prom codigo */
|
|
1223
|
+
getAll() {
|
|
1224
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getAll');
|
|
1287
1225
|
}
|
|
1288
|
-
/**
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1226
|
+
/** It returns a form by id */
|
|
1227
|
+
getById(id) {
|
|
1228
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getById', {
|
|
1229
|
+
params: new HttpParams().set('id', id)
|
|
1230
|
+
});
|
|
1231
|
+
}
|
|
1232
|
+
/** It saves a form */
|
|
1233
|
+
save(form) {
|
|
1234
|
+
return this.httpClient.post(this.environment.host.backend.configuration + 'form/save', form, this.headerJson);
|
|
1235
|
+
}
|
|
1236
|
+
saveFormMultiPromCodigo(reMultPromCodDto) {
|
|
1237
|
+
return this.httpClient.post(this.environment.host.backend.configuration + 'form/saveMultiaplicacionPromCod', reMultPromCodDto, this.headerJson);
|
|
1238
|
+
}
|
|
1239
|
+
/** It deletes a form by id */
|
|
1240
|
+
delete(id) {
|
|
1241
|
+
return this.httpClient.delete(this.environment.host.backend.configuration + 'form/delete', {
|
|
1242
|
+
params: new HttpParams().set('id', id)
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
/** It returns the form according to profile have been setting up in form */
|
|
1246
|
+
getByPromCodigoAccordingToProfile(promCodigo, patCodigo, formId) {
|
|
1247
|
+
let params = new HttpParams()
|
|
1248
|
+
.set('promCodigo', promCodigo.toString())
|
|
1249
|
+
.set('patCodigo', patCodigo.toString())
|
|
1250
|
+
.set('formId', formId !== undefined ? formId : '');
|
|
1251
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getByPromCodigoAndProfile', { params: params });
|
|
1252
|
+
}
|
|
1253
|
+
/** It returns the form according to list of prom codigo */
|
|
1254
|
+
getByListPromCodigo(listPromCod) {
|
|
1255
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getByListPromCodigo', { params: new HttpParams().set('listPromCodigo', listPromCod.toString()) });
|
|
1256
|
+
}
|
|
1257
|
+
/** It remove the redis cache of the form by prom codigo */
|
|
1258
|
+
removeFromCacheByPromCodigo(promCodigo) {
|
|
1259
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'form/removeFromCacheByPromCodigo', {
|
|
1260
|
+
params: new HttpParams().set('promCodigo', promCodigo.toString())
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
/** It remove the redis cache of the form by prom codigo */
|
|
1264
|
+
removeFromCacheByPromCodigoAndTitle(promCodigo, title) {
|
|
1265
|
+
return this.httpClient.get(this.environment.host.backend.configuration +
|
|
1266
|
+
'form/removeFromCacheByPromCodigoAndTitle', {
|
|
1267
|
+
params: new HttpParams()
|
|
1268
|
+
.set('promCodigo', promCodigo.toString())
|
|
1269
|
+
.set('title', title)
|
|
1270
|
+
});
|
|
1271
|
+
}
|
|
1272
|
+
/** It remove the redis cache of the form by prom codigo */
|
|
1273
|
+
removeFromCacheByPromCodigoAndProfile(promCodigo, patCodigo, formId, username) {
|
|
1274
|
+
return this.httpClient.get(this.environment.host.backend.configuration +
|
|
1275
|
+
'form/removeFromCacheByPromCodigoAndProfile', {
|
|
1276
|
+
params: new HttpParams()
|
|
1277
|
+
.set('promCodigo', promCodigo.toString())
|
|
1278
|
+
.set('patCodigo', patCodigo.toString())
|
|
1279
|
+
.set('formId', formId)
|
|
1280
|
+
.set('username', username)
|
|
1281
|
+
});
|
|
1294
1282
|
}
|
|
1295
1283
|
/**
|
|
1296
|
-
*
|
|
1297
|
-
* @param
|
|
1298
|
-
* @param properties path of properties example [validate, required] or [unique]
|
|
1299
|
-
* @param value the value that should have the property
|
|
1284
|
+
* Get form by Id
|
|
1285
|
+
* @param statusId
|
|
1300
1286
|
*/
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1287
|
+
getByStateId(statusId) {
|
|
1288
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getByStateId', {
|
|
1289
|
+
params: new HttpParams().set('statusId', statusId)
|
|
1290
|
+
});
|
|
1291
|
+
}
|
|
1292
|
+
getConfigCloningFormMap(oldFormPPP, newFormPPP) {
|
|
1293
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getConfigCloningFormMap', {
|
|
1294
|
+
params: new HttpParams()
|
|
1295
|
+
.set('oldFormPPP', oldFormPPP.toString())
|
|
1296
|
+
.set('newFormPPP', newFormPPP.toString())
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
getListFormProjectSummaryConfigByPromCodigo(promCodigo, patCodigo) {
|
|
1300
|
+
return this.httpClient.get(this.environment.host.backend.configuration +
|
|
1301
|
+
'form/getListFormProjectSummaryConfigByPromCodigo', {
|
|
1302
|
+
params: new HttpParams()
|
|
1303
|
+
.set('promCodigo', promCodigo.toString())
|
|
1304
|
+
.set('patCodigo', patCodigo.toString())
|
|
1305
|
+
});
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
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 });
|
|
1309
|
+
FormService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: FormService, providedIn: 'root' });
|
|
1310
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: FormService, decorators: [{
|
|
1311
|
+
type: Injectable,
|
|
1312
|
+
args: [{
|
|
1313
|
+
providedIn: 'root'
|
|
1314
|
+
}]
|
|
1315
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1316
|
+
type: Inject,
|
|
1317
|
+
args: ['environment']
|
|
1318
|
+
}] }, { type: i1.HttpClient }]; } });
|
|
1319
|
+
|
|
1320
|
+
class TokenService {
|
|
1321
|
+
constructor(environment, httpClient, formService, currencyPipe) {
|
|
1322
|
+
this.environment = environment;
|
|
1323
|
+
this.httpClient = httpClient;
|
|
1324
|
+
this.formService = formService;
|
|
1325
|
+
this.currencyPipe = currencyPipe;
|
|
1326
|
+
}
|
|
1327
|
+
/** This promise allows to execute a function when consulting the form fields. */
|
|
1328
|
+
getFormFieldsByPromCode(promCodigo) {
|
|
1329
|
+
return new Promise((resolve, reject) => {
|
|
1330
|
+
// Search the dynamic form
|
|
1331
|
+
let lFormFieldsToken = null;
|
|
1332
|
+
this.formService.getByPromCodigo(promCodigo).subscribe({
|
|
1333
|
+
next: (arrayForms) => {
|
|
1334
|
+
if (arrayForms.length > 0) {
|
|
1335
|
+
for (const forms of arrayForms) {
|
|
1336
|
+
if (forms.components && forms.components.length > 0) {
|
|
1337
|
+
for (const components of forms.components) {
|
|
1338
|
+
if (components.components && components.components.length > 0) {
|
|
1339
|
+
for (const component of components.components) {
|
|
1340
|
+
if (component.columns && component.columns.length > 0) {
|
|
1341
|
+
for (const cComponents of component.columns) {
|
|
1342
|
+
if (cComponents.components &&
|
|
1343
|
+
cComponents.components.length > 0) {
|
|
1344
|
+
for (const iterator of cComponents.components) {
|
|
1345
|
+
if (iterator.type === 'address') {
|
|
1346
|
+
delete iterator.components;
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1330
1355
|
}
|
|
1331
1356
|
}
|
|
1332
1357
|
}
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
* @param components
|
|
1341
|
-
*/
|
|
1342
|
-
static getComponents(components) {
|
|
1343
|
-
return FormioUtil.getComponentsByRecursion(components, '', null);
|
|
1344
|
-
}
|
|
1345
|
-
/**
|
|
1346
|
-
* It returns the components array of the form by recursion
|
|
1347
|
-
* @param components array of components
|
|
1348
|
-
* @param titlePanel name of parent panel, so children components will inherit the panelName
|
|
1349
|
-
* @param conditionalObject conditional object it will be inherited from panel {conditional: { eq: , value: , when: , json: }, customConditional: }
|
|
1350
|
-
*/
|
|
1351
|
-
static getComponentsByRecursion(components, titlePanel, conditionalParent) {
|
|
1352
|
-
// it contains the result array
|
|
1353
|
-
let result = [];
|
|
1354
|
-
if (components) {
|
|
1355
|
-
// iterate over components
|
|
1356
|
-
for (const component of components) {
|
|
1357
|
-
// avoid the editgrid component ot if it has a different behavior it should have an else statement
|
|
1358
|
-
if (component[EFormioKey.TYPE] !== EFormioKey.EDITGRID) {
|
|
1359
|
-
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
1360
|
-
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
1361
|
-
titlePanel = component[EFormioKey.TITLE];
|
|
1358
|
+
let form = arrayForms;
|
|
1359
|
+
if (!form ||
|
|
1360
|
+
!form[0] ||
|
|
1361
|
+
!form[0].promCodigo ||
|
|
1362
|
+
form[0].promCodigo != promCodigo) {
|
|
1363
|
+
// this.router.navigate(['404']);
|
|
1364
|
+
resolve(lFormFieldsToken);
|
|
1362
1365
|
}
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
// change condition
|
|
1370
|
-
if (conditional)
|
|
1371
|
-
conditionalParent = conditional;
|
|
1372
|
-
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
1373
|
-
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
1374
|
-
? component[EFormioKey.COMPONENTS]
|
|
1375
|
-
: component[EFormioKey.COLUMNS];
|
|
1376
|
-
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
1377
|
-
const recursionResult = FormioUtil.getComponentsByRecursion(subComponents, titlePanel, conditionalParent);
|
|
1378
|
-
// if recursion result then result concats the recursionResult
|
|
1379
|
-
if (recursionResult)
|
|
1380
|
-
result = result.concat(recursionResult);
|
|
1381
|
-
// reset conditional Parent
|
|
1382
|
-
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
1383
|
-
conditionalParent = undefined;
|
|
1366
|
+
lFormFieldsToken = [];
|
|
1367
|
+
for (let formComp of form) {
|
|
1368
|
+
let newComponents;
|
|
1369
|
+
let components = [];
|
|
1370
|
+
if (formComp.components) {
|
|
1371
|
+
newComponents = formComp.components;
|
|
1384
1372
|
}
|
|
1385
|
-
else {
|
|
1386
|
-
|
|
1373
|
+
else if (formComp.columns) {
|
|
1374
|
+
newComponents = formComp.columns;
|
|
1387
1375
|
}
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
component[EFormioKey.CUSTOM_CONDITIONAL] =
|
|
1400
|
-
conditional[EFormioKey.CUSTOM_CONDITIONAL];
|
|
1401
|
-
// add namPanel as property
|
|
1402
|
-
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
1403
|
-
// add component to the result
|
|
1404
|
-
result.push(component);
|
|
1376
|
+
if (newComponents && UtilString.isValid(formComp.title)) {
|
|
1377
|
+
lFormFieldsToken.push({
|
|
1378
|
+
title: {
|
|
1379
|
+
key: TokenService.getKeyFormulario(formComp.title),
|
|
1380
|
+
value: formComp.title,
|
|
1381
|
+
object: formComp
|
|
1382
|
+
},
|
|
1383
|
+
value: []
|
|
1384
|
+
});
|
|
1385
|
+
lFormFieldsToken[lFormFieldsToken.length - 1].value =
|
|
1386
|
+
this.getComponenetForm(components, newComponents, null, false, null);
|
|
1405
1387
|
}
|
|
1406
1388
|
}
|
|
1389
|
+
resolve(lFormFieldsToken);
|
|
1390
|
+
},
|
|
1391
|
+
error: (error) => {
|
|
1392
|
+
reject(error);
|
|
1407
1393
|
}
|
|
1408
|
-
}
|
|
1409
|
-
}
|
|
1410
|
-
return result;
|
|
1411
|
-
}
|
|
1412
|
-
/**
|
|
1413
|
-
* It returns the components
|
|
1414
|
-
* @param components
|
|
1415
|
-
* @param keepEditGrids
|
|
1416
|
-
*/
|
|
1417
|
-
static getComponentsWithEditGrids(components) {
|
|
1418
|
-
return FormioUtil.getComponentsByRecursionWithEditGrids(components, '', null);
|
|
1394
|
+
});
|
|
1395
|
+
});
|
|
1419
1396
|
}
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
let result = [];
|
|
1429
|
-
if (components) {
|
|
1430
|
-
// iterate over components
|
|
1431
|
-
for (const component of components) {
|
|
1432
|
-
// avoid the editgrid component ot if it has a different behavior it should have an else statement
|
|
1433
|
-
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
1434
|
-
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
1435
|
-
titlePanel = component[EFormioKey.TITLE];
|
|
1397
|
+
getFormFieldsByFormId(formId) {
|
|
1398
|
+
return new Promise((resolve, reject) => {
|
|
1399
|
+
// Search the dynamic form
|
|
1400
|
+
let lFormFieldsToken = null;
|
|
1401
|
+
this.formService.getById(formId).subscribe((result) => {
|
|
1402
|
+
let form = result;
|
|
1403
|
+
if (!form || !form[0]) {
|
|
1404
|
+
resolve(lFormFieldsToken);
|
|
1436
1405
|
}
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
conditionalParent = conditional;
|
|
1444
|
-
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
1445
|
-
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
1446
|
-
? component[EFormioKey.COMPONENTS]
|
|
1447
|
-
: component[EFormioKey.COLUMNS];
|
|
1448
|
-
if (component[EFormioKey.TYPE] === EFormioKey.EDITGRID) {
|
|
1449
|
-
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
1450
|
-
result.push(component);
|
|
1406
|
+
lFormFieldsToken = [];
|
|
1407
|
+
for (let formComp of form) {
|
|
1408
|
+
let newComponents;
|
|
1409
|
+
let components = [];
|
|
1410
|
+
if (formComp.components) {
|
|
1411
|
+
newComponents = formComp.components;
|
|
1451
1412
|
}
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
if (
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
// resolve conditional conditional object
|
|
1467
|
-
let conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
1468
|
-
if (!conditional)
|
|
1469
|
-
conditional = conditionalParent;
|
|
1470
|
-
component[EFormioKey.CONDITIONAL] = conditional[EFormioKey.CONDITIONAL];
|
|
1471
|
-
component[EFormioKey.CUSTOM_CONDITIONAL] =
|
|
1472
|
-
conditional[EFormioKey.CUSTOM_CONDITIONAL];
|
|
1473
|
-
// add namPanel as property
|
|
1474
|
-
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
1475
|
-
// add component to the result
|
|
1476
|
-
result.push(component);
|
|
1413
|
+
else if (formComp.columns) {
|
|
1414
|
+
newComponents = formComp.columns;
|
|
1415
|
+
}
|
|
1416
|
+
if (newComponents && UtilString.isValid(formComp.title)) {
|
|
1417
|
+
lFormFieldsToken.push({
|
|
1418
|
+
title: {
|
|
1419
|
+
key: TokenService.getKeyFormulario(formComp.title),
|
|
1420
|
+
value: formComp.title,
|
|
1421
|
+
object: formComp
|
|
1422
|
+
},
|
|
1423
|
+
value: []
|
|
1424
|
+
});
|
|
1425
|
+
lFormFieldsToken[lFormFieldsToken.length - 1].value =
|
|
1426
|
+
this.getComponenetForm(components, newComponents, null, false, null);
|
|
1477
1427
|
}
|
|
1478
1428
|
}
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1429
|
+
resolve(lFormFieldsToken);
|
|
1430
|
+
}, (error) => {
|
|
1431
|
+
reject(error);
|
|
1432
|
+
});
|
|
1433
|
+
});
|
|
1482
1434
|
}
|
|
1483
|
-
/**
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1435
|
+
/** This promise allows to execute a function when consulting the form fields. */
|
|
1436
|
+
getFormPanelsByPromCode(promCodigo) {
|
|
1437
|
+
return new Promise((resolve, reject) => {
|
|
1438
|
+
// Search the dynamic form
|
|
1439
|
+
let lFormPannelsToken = null;
|
|
1440
|
+
this.formService.getByPromCodigo(promCodigo).subscribe((result) => {
|
|
1441
|
+
let form = result;
|
|
1442
|
+
if (!form ||
|
|
1443
|
+
!form[0] ||
|
|
1444
|
+
!form[0].promCodigo ||
|
|
1445
|
+
form[0].promCodigo != promCodigo) {
|
|
1446
|
+
// this.router.navigate(['404']);
|
|
1447
|
+
resolve(lFormPannelsToken);
|
|
1448
|
+
}
|
|
1449
|
+
lFormPannelsToken = [];
|
|
1450
|
+
for (let formComp of form) {
|
|
1451
|
+
let newComponents;
|
|
1452
|
+
let components = [];
|
|
1453
|
+
if (formComp.components) {
|
|
1454
|
+
newComponents = formComp.components;
|
|
1455
|
+
}
|
|
1456
|
+
else if (formComp.columns) {
|
|
1457
|
+
newComponents = formComp.columns;
|
|
1458
|
+
}
|
|
1459
|
+
if (newComponents && UtilString.isValid(formComp.title)) {
|
|
1460
|
+
lFormPannelsToken.push({
|
|
1461
|
+
title: {
|
|
1462
|
+
key: TokenService.getKeyFormulario(formComp.title),
|
|
1463
|
+
value: formComp.title,
|
|
1464
|
+
object: formComp
|
|
1465
|
+
},
|
|
1466
|
+
value: []
|
|
1467
|
+
});
|
|
1468
|
+
lFormPannelsToken[lFormPannelsToken.length - 1].value =
|
|
1469
|
+
this.getPanelComponenet(components, newComponents, null);
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
resolve(lFormPannelsToken);
|
|
1473
|
+
}, (error) => {
|
|
1474
|
+
reject(error);
|
|
1475
|
+
});
|
|
1476
|
+
});
|
|
1498
1477
|
}
|
|
1499
1478
|
/**
|
|
1500
|
-
*
|
|
1479
|
+
* A recursive method to get all the information of the editGrid dynamic form
|
|
1501
1480
|
* @param components
|
|
1481
|
+
* @param form
|
|
1502
1482
|
*/
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
static getEditGridKeyLabelsByRecursion(components, titlePanel, conditionalParent) {
|
|
1513
|
-
// it contains the result array
|
|
1514
|
-
let result = [];
|
|
1515
|
-
if (components) {
|
|
1516
|
-
// iterate over components
|
|
1517
|
-
for (const component of components) {
|
|
1518
|
-
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
1519
|
-
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
1520
|
-
titlePanel = component[EFormioKey.TITLE];
|
|
1521
|
-
}
|
|
1522
|
-
if (typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
1523
|
-
typeof component[EFormioKey.COLUMNS] !== 'undefined') {
|
|
1524
|
-
// resolve conditional parent conditional
|
|
1525
|
-
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
1526
|
-
// change condition
|
|
1527
|
-
if (conditional)
|
|
1528
|
-
conditionalParent = conditional;
|
|
1529
|
-
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
1530
|
-
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
1531
|
-
? component[EFormioKey.COMPONENTS]
|
|
1532
|
-
: component[EFormioKey.COLUMNS];
|
|
1533
|
-
if (component[EFormioKey.TYPE] == EFormioKey.EDITGRID) {
|
|
1534
|
-
// add namPanel as property
|
|
1535
|
-
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
1536
|
-
// add component to the result
|
|
1537
|
-
result.push(component);
|
|
1538
|
-
}
|
|
1539
|
-
else {
|
|
1540
|
-
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
1541
|
-
const recursionResult = FormioUtil.getEditGridKeyLabelsByRecursion(subComponents, titlePanel, conditionalParent);
|
|
1542
|
-
// if recursion result then result concats the recursionResult
|
|
1543
|
-
if (recursionResult)
|
|
1544
|
-
result = result.concat(recursionResult);
|
|
1545
|
-
// reset conditional Parent
|
|
1546
|
-
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
1547
|
-
conditionalParent = undefined;
|
|
1548
|
-
}
|
|
1483
|
+
getPanelComponenet(components, form, panelName) {
|
|
1484
|
+
for (let formComp of form) {
|
|
1485
|
+
if (formComp.type === 'panel') {
|
|
1486
|
+
components.push(formComp);
|
|
1487
|
+
}
|
|
1488
|
+
else if (formComp.components || formComp.columns) {
|
|
1489
|
+
let newComponents;
|
|
1490
|
+
if (formComp.components) {
|
|
1491
|
+
newComponents = formComp.components;
|
|
1549
1492
|
}
|
|
1550
|
-
else {
|
|
1493
|
+
else if (formComp.columns) {
|
|
1494
|
+
newComponents = formComp.columns;
|
|
1551
1495
|
}
|
|
1496
|
+
components = this.getPanelComponenet(components, newComponents, panelName);
|
|
1552
1497
|
}
|
|
1553
1498
|
}
|
|
1554
|
-
return
|
|
1499
|
+
return components;
|
|
1555
1500
|
}
|
|
1556
1501
|
/**
|
|
1557
|
-
*
|
|
1502
|
+
* A recursive method to get all the information of the components a columns of the dynamic form
|
|
1558
1503
|
* @param components
|
|
1559
|
-
* @param
|
|
1504
|
+
* @param form
|
|
1560
1505
|
*/
|
|
1561
|
-
|
|
1562
|
-
|
|
1506
|
+
getComponenetForm(components, form, panelName, editgrid, editGridKey) {
|
|
1507
|
+
for (let formComp of form) {
|
|
1508
|
+
if (formComp.components || formComp.columns) {
|
|
1509
|
+
let newComponents;
|
|
1510
|
+
if (formComp.components) {
|
|
1511
|
+
newComponents = formComp.components;
|
|
1512
|
+
if (formComp.type === 'editgrid') {
|
|
1513
|
+
editgrid = true;
|
|
1514
|
+
editGridKey = formComp.key;
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
else if (formComp.columns) {
|
|
1518
|
+
newComponents = formComp.columns;
|
|
1519
|
+
}
|
|
1520
|
+
if (formComp.type && formComp.type === 'panel') {
|
|
1521
|
+
panelName = formComp.title;
|
|
1522
|
+
}
|
|
1523
|
+
components = this.getComponenetForm(components, newComponents, panelName, editgrid, editGridKey);
|
|
1524
|
+
}
|
|
1525
|
+
else {
|
|
1526
|
+
formComp.panelName = panelName;
|
|
1527
|
+
formComp.editgrid = editgrid;
|
|
1528
|
+
formComp.editGridKey = editGridKey;
|
|
1529
|
+
components.push(formComp);
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
return components;
|
|
1563
1533
|
}
|
|
1564
|
-
/**
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
1578
|
-
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
1579
|
-
titlePanel = component[EFormioKey.TITLE];
|
|
1534
|
+
/** This promise allows to execute a function when consulting the form fields. */
|
|
1535
|
+
getFormEditGridFieldsByPromCode(promCodigo) {
|
|
1536
|
+
return new Promise((resolve, reject) => {
|
|
1537
|
+
// Search the dynamic form
|
|
1538
|
+
let lFormFieldsToken = null;
|
|
1539
|
+
this.formService.getByPromCodigo(promCodigo).subscribe((result) => {
|
|
1540
|
+
let form = result;
|
|
1541
|
+
if (!form ||
|
|
1542
|
+
!form[0] ||
|
|
1543
|
+
!form[0].promCodigo ||
|
|
1544
|
+
form[0].promCodigo != promCodigo) {
|
|
1545
|
+
// this.router.navigate(['404']);
|
|
1546
|
+
resolve(lFormFieldsToken);
|
|
1580
1547
|
}
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
conditionalParent = conditional;
|
|
1588
|
-
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
1589
|
-
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
1590
|
-
? component[EFormioKey.COMPONENTS]
|
|
1591
|
-
: component[EFormioKey.COLUMNS];
|
|
1592
|
-
if (component[EFormioKey.TYPE] === EFormioKey.EDITGRID &&
|
|
1593
|
-
component['key'] == editGridName) {
|
|
1594
|
-
existEditGrid = true;
|
|
1595
|
-
if (typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
1596
|
-
typeof component[EFormioKey.COLUMNS] !== 'undefined') {
|
|
1597
|
-
// resolve conditional parent conditional
|
|
1598
|
-
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
1599
|
-
// change condition
|
|
1600
|
-
if (conditional)
|
|
1601
|
-
conditionalParent = conditional;
|
|
1602
|
-
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
1603
|
-
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
1604
|
-
? component[EFormioKey.COMPONENTS]
|
|
1605
|
-
: component[EFormioKey.COLUMNS];
|
|
1606
|
-
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
1607
|
-
const recursionResult = FormioUtil.getComponentsByRecursionIntoEditGrids(subComponents, titlePanel, conditionalParent, editGridName, existEditGrid);
|
|
1608
|
-
// if recursion result then result concats the recursionResult
|
|
1609
|
-
if (recursionResult)
|
|
1610
|
-
result = result.concat(recursionResult);
|
|
1611
|
-
// reset conditional Parent
|
|
1612
|
-
if (component && conditionalParent) {
|
|
1613
|
-
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
1614
|
-
conditionalParent = undefined;
|
|
1615
|
-
}
|
|
1616
|
-
}
|
|
1617
|
-
else {
|
|
1618
|
-
// avoid the component type button
|
|
1619
|
-
if (component[EFormioKey.TYPE] !== EFormioKey.BUTTON &&
|
|
1620
|
-
component[EFormioKey.KEY] &&
|
|
1621
|
-
component[EFormioKey.LABEL] &&
|
|
1622
|
-
existEditGrid) {
|
|
1623
|
-
// resolve conditional conditional object
|
|
1624
|
-
let conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
1625
|
-
if (!conditional)
|
|
1626
|
-
conditional = conditionalParent;
|
|
1627
|
-
component[EFormioKey.CONDITIONAL] =
|
|
1628
|
-
conditional[EFormioKey.CONDITIONAL];
|
|
1629
|
-
component[EFormioKey.CUSTOM_CONDITIONAL] =
|
|
1630
|
-
conditional[EFormioKey.CUSTOM_CONDITIONAL];
|
|
1631
|
-
// add namPanel as property
|
|
1632
|
-
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
1633
|
-
// add component to the result
|
|
1634
|
-
result.push(component);
|
|
1635
|
-
}
|
|
1636
|
-
}
|
|
1548
|
+
lFormFieldsToken = [];
|
|
1549
|
+
for (let formComp of form) {
|
|
1550
|
+
let newComponents;
|
|
1551
|
+
let components = [];
|
|
1552
|
+
if (formComp.components) {
|
|
1553
|
+
newComponents = formComp.components;
|
|
1637
1554
|
}
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
// if recursion result then result concats the recursionResult
|
|
1641
|
-
if (recursionResult)
|
|
1642
|
-
result = result.concat(recursionResult);
|
|
1643
|
-
// reset conditional Parent
|
|
1644
|
-
if (component && conditionalParent) {
|
|
1645
|
-
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
1646
|
-
conditionalParent = undefined;
|
|
1555
|
+
else if (formComp.columns) {
|
|
1556
|
+
newComponents = formComp.columns;
|
|
1647
1557
|
}
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
component[EFormioKey.CONDITIONAL] = conditional[EFormioKey.CONDITIONAL];
|
|
1660
|
-
component[EFormioKey.CUSTOM_CONDITIONAL] =
|
|
1661
|
-
conditional[EFormioKey.CUSTOM_CONDITIONAL];
|
|
1662
|
-
// add namPanel as property
|
|
1663
|
-
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
1664
|
-
// add component to the result
|
|
1665
|
-
result.push(component);
|
|
1558
|
+
if (newComponents && UtilString.isValid(formComp.title)) {
|
|
1559
|
+
lFormFieldsToken.push({
|
|
1560
|
+
title: {
|
|
1561
|
+
key: TokenService.getKeyFormulario(formComp.title),
|
|
1562
|
+
value: formComp.title,
|
|
1563
|
+
object: formComp
|
|
1564
|
+
},
|
|
1565
|
+
value: []
|
|
1566
|
+
});
|
|
1567
|
+
lFormFieldsToken[lFormFieldsToken.length - 1].value =
|
|
1568
|
+
this.getEditGridComponenet(components, newComponents, null);
|
|
1666
1569
|
}
|
|
1667
1570
|
}
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1571
|
+
resolve(lFormFieldsToken);
|
|
1572
|
+
}, (error) => {
|
|
1573
|
+
reject(error);
|
|
1574
|
+
});
|
|
1575
|
+
});
|
|
1671
1576
|
}
|
|
1672
1577
|
/**
|
|
1673
|
-
*
|
|
1674
|
-
* @param
|
|
1675
|
-
* @
|
|
1578
|
+
* A recursive method to get all the information of the editGrid dynamic form
|
|
1579
|
+
* @param components
|
|
1580
|
+
* @param form
|
|
1676
1581
|
*/
|
|
1677
|
-
|
|
1678
|
-
let
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
if (
|
|
1686
|
-
|
|
1582
|
+
getEditGridComponenet(components, form, panelName) {
|
|
1583
|
+
for (let formComp of form) {
|
|
1584
|
+
if (formComp.type === 'editgrid') {
|
|
1585
|
+
formComp.panelName = panelName;
|
|
1586
|
+
components.push(formComp);
|
|
1587
|
+
}
|
|
1588
|
+
else if (formComp.components || formComp.columns) {
|
|
1589
|
+
let newComponents;
|
|
1590
|
+
if (formComp.components) {
|
|
1591
|
+
newComponents = formComp.components;
|
|
1687
1592
|
}
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
});
|
|
1691
|
-
if (!form) {
|
|
1692
|
-
//console.error('No se encontró el formulario con id ' + dForm.formId);
|
|
1693
|
-
continue;
|
|
1593
|
+
else if (formComp.columns) {
|
|
1594
|
+
newComponents = formComp.columns;
|
|
1694
1595
|
}
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
listData[key] = dForm.data[key];
|
|
1698
|
-
listDataByForm[keyFormTitle + key] = dForm.data[key];
|
|
1596
|
+
if (formComp.type && formComp.type === 'panel') {
|
|
1597
|
+
panelName = formComp.title;
|
|
1699
1598
|
}
|
|
1599
|
+
components = this.getEditGridComponenet(components, newComponents, panelName);
|
|
1700
1600
|
}
|
|
1701
1601
|
}
|
|
1702
|
-
return
|
|
1703
|
-
listData: listData,
|
|
1704
|
-
listDataByForm: listDataByForm
|
|
1705
|
-
};
|
|
1602
|
+
return components;
|
|
1706
1603
|
}
|
|
1707
|
-
/**
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
*/
|
|
1711
|
-
static getPanelComponents(components) {
|
|
1712
|
-
return FormioUtil.getComponentsByPanel(components);
|
|
1604
|
+
/** It returns the tokens by promCodigo */
|
|
1605
|
+
getListByPromCodigo(promCode) {
|
|
1606
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'token/getByPromCodigo', { params: new HttpParams().set('promCodigo', promCode.toString()) });
|
|
1713
1607
|
}
|
|
1714
|
-
/**
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
// it contains the result array
|
|
1720
|
-
let result = [];
|
|
1721
|
-
if (components) {
|
|
1722
|
-
// iterate over components
|
|
1723
|
-
for (const component of components) {
|
|
1724
|
-
// avoid the editgrid component ot if it has a different behavior it should have an else statement
|
|
1725
|
-
if (component[EFormioKey.TYPE] !== EFormioKey.EDITGRID) {
|
|
1726
|
-
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
1727
|
-
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
1728
|
-
result.push(component);
|
|
1729
|
-
}
|
|
1730
|
-
}
|
|
1731
|
-
}
|
|
1732
|
-
}
|
|
1733
|
-
return result;
|
|
1608
|
+
/** It returns the token by id */
|
|
1609
|
+
getById(id) {
|
|
1610
|
+
return this.httpClient.get(this.environment.host.backend.configuration + 'token/getById', {
|
|
1611
|
+
params: new HttpParams().set('id', id.toString())
|
|
1612
|
+
});
|
|
1734
1613
|
}
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
constructor(environment, httpClient) {
|
|
1739
|
-
this.environment = environment;
|
|
1740
|
-
this.httpClient = httpClient;
|
|
1741
|
-
this.headerJson = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) };
|
|
1614
|
+
/** It deletes a form by id */
|
|
1615
|
+
delete(id) {
|
|
1616
|
+
return this.httpClient.delete(this.environment.host.backend.configuration + 'token/delete', { params: new HttpParams().set('id', id) });
|
|
1742
1617
|
}
|
|
1743
|
-
/** It
|
|
1744
|
-
|
|
1745
|
-
return this.httpClient.
|
|
1618
|
+
/** It saves the token */
|
|
1619
|
+
save(token) {
|
|
1620
|
+
return this.httpClient.post(this.environment.host.backend.configuration + 'token/save', token, HEADER_JSON);
|
|
1746
1621
|
}
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1622
|
+
static getKeyFormulario(formTitle) {
|
|
1623
|
+
if (UtilString.isValid(formTitle)) {
|
|
1624
|
+
return (UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_FORM) +
|
|
1625
|
+
UtilString.replaceAccentSpacesOthers(formTitle).replace(/_/g, '-'));
|
|
1626
|
+
}
|
|
1627
|
+
return '';
|
|
1750
1628
|
}
|
|
1751
|
-
/** It returns
|
|
1752
|
-
|
|
1753
|
-
return this.httpClient.get(this.environment.host.backend.
|
|
1754
|
-
|
|
1755
|
-
|
|
1629
|
+
/** It returns the unique verification code */
|
|
1630
|
+
getUniqueVerificationCode(login, token) {
|
|
1631
|
+
return this.httpClient.get(this.environment.host.backend.documentsRepository +
|
|
1632
|
+
'documento/consultarCodigoUnico/' +
|
|
1633
|
+
login +
|
|
1634
|
+
'/' +
|
|
1635
|
+
token, { params: new HttpParams() });
|
|
1756
1636
|
}
|
|
1757
|
-
/** It
|
|
1758
|
-
|
|
1759
|
-
|
|
1637
|
+
/** It send the information to copy the Document viewer */
|
|
1638
|
+
copyDocumentInformationViewer(login, token, uniqueCode, documentURL, documentName) {
|
|
1639
|
+
let infoDocumento = {
|
|
1640
|
+
codigoUnico: uniqueCode,
|
|
1641
|
+
rutaDocumento: documentURL,
|
|
1642
|
+
documentName: documentName
|
|
1643
|
+
};
|
|
1644
|
+
return this.httpClient.post(this.environment.host.backend.documentsRepository +
|
|
1645
|
+
'documento/adicionarDocumento/' +
|
|
1646
|
+
login +
|
|
1647
|
+
'/' +
|
|
1648
|
+
token, infoDocumento, HEADER_JSON);
|
|
1760
1649
|
}
|
|
1761
|
-
|
|
1762
|
-
return
|
|
1650
|
+
static getKeyBudget() {
|
|
1651
|
+
return UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_BUDGET);
|
|
1763
1652
|
}
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
return this.httpClient.delete(this.environment.host.backend.configuration + 'form/delete', {
|
|
1767
|
-
params: new HttpParams().set('id', id)
|
|
1768
|
-
});
|
|
1653
|
+
static getKeyDocument() {
|
|
1654
|
+
return UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_DOCUMENTO);
|
|
1769
1655
|
}
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
let params = new HttpParams()
|
|
1773
|
-
.set('promCodigo', promCodigo.toString())
|
|
1774
|
-
.set('patCodigo', patCodigo.toString())
|
|
1775
|
-
.set('formId', formId !== undefined ? formId : '');
|
|
1776
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getByPromCodigoAndProfile', { params: params });
|
|
1656
|
+
static getKeyTask() {
|
|
1657
|
+
return UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_TASKL);
|
|
1777
1658
|
}
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'form/getByListPromCodigo', { params: new HttpParams().set('listPromCodigo', listPromCod.toString()) });
|
|
1659
|
+
static getKeyStatic() {
|
|
1660
|
+
return UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_STATIC);
|
|
1781
1661
|
}
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
});
|
|
1662
|
+
static getKeyCalculated(token) {
|
|
1663
|
+
return (UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_CALCULATED) +
|
|
1664
|
+
'_' +
|
|
1665
|
+
UtilString.replaceAccentSpacesOthers(token.name));
|
|
1787
1666
|
}
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
params: new HttpParams()
|
|
1793
|
-
.set('promCodigo', promCodigo.toString())
|
|
1794
|
-
.set('title', title)
|
|
1795
|
-
});
|
|
1667
|
+
static getKeySnapshot(token) {
|
|
1668
|
+
return (UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_SNAPSHOT) +
|
|
1669
|
+
'_' +
|
|
1670
|
+
UtilString.replaceAccentSpacesOthers(token.name));
|
|
1796
1671
|
}
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
params: new HttpParams()
|
|
1802
|
-
.set('promCodigo', promCodigo.toString())
|
|
1803
|
-
.set('patCodigo', patCodigo.toString())
|
|
1804
|
-
.set('formId', formId)
|
|
1805
|
-
.set('username', username)
|
|
1806
|
-
});
|
|
1672
|
+
static getKeyGuarantee(token) {
|
|
1673
|
+
return (UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_GUARANTEE) +
|
|
1674
|
+
'_' +
|
|
1675
|
+
UtilString.replaceAccentSpacesOthers(token.name));
|
|
1807
1676
|
}
|
|
1808
1677
|
/**
|
|
1809
|
-
*
|
|
1810
|
-
* @param
|
|
1678
|
+
* Return a value that represent the type of label: 1=Form, 2=Budget, 3=Static, 4=Calculated
|
|
1679
|
+
* @param key Value to evalueate
|
|
1811
1680
|
*/
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1681
|
+
static getKeyType(key) {
|
|
1682
|
+
key = key.replace('{', '').replace('}', '');
|
|
1683
|
+
key = key.substring(1, key.indexOf('_'));
|
|
1684
|
+
if (key.startsWith(UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_FORM))) {
|
|
1685
|
+
return 1;
|
|
1686
|
+
}
|
|
1687
|
+
else if (key.startsWith(UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_BUDGET))) {
|
|
1688
|
+
return 2;
|
|
1689
|
+
}
|
|
1690
|
+
else if (key.startsWith(UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_STATIC))) {
|
|
1691
|
+
return 3;
|
|
1692
|
+
}
|
|
1693
|
+
else if (key.startsWith(UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_CALCULATED))) {
|
|
1694
|
+
return 4;
|
|
1695
|
+
}
|
|
1696
|
+
else if (key.startsWith(UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_TASKL))) {
|
|
1697
|
+
return 5;
|
|
1698
|
+
}
|
|
1699
|
+
return null;
|
|
1831
1700
|
}
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
}
|
|
1852
|
-
/** This promise allows to execute a function when consulting the form fields. */
|
|
1853
|
-
getFormFieldsByPromCode(promCodigo) {
|
|
1854
|
-
return new Promise((resolve, reject) => {
|
|
1855
|
-
// Search the dynamic form
|
|
1856
|
-
let lFormFieldsToken = null;
|
|
1857
|
-
this.formService.getByPromCodigo(promCodigo).subscribe({
|
|
1858
|
-
next: (arrayForms) => {
|
|
1859
|
-
if (arrayForms.length > 0) {
|
|
1860
|
-
for (const forms of arrayForms) {
|
|
1861
|
-
let components = [];
|
|
1862
|
-
components.push(...FormioUtil.getComponents(forms.components));
|
|
1863
|
-
if (forms.components && forms.components.length > 0) {
|
|
1864
|
-
for (const components of forms.components) {
|
|
1865
|
-
if (components.components && components.components.length > 0) {
|
|
1866
|
-
for (const component of components.components) {
|
|
1867
|
-
if (component.columns && component.columns.length > 0) {
|
|
1868
|
-
for (const cComponents of component.columns) {
|
|
1869
|
-
if (cComponents.components &&
|
|
1870
|
-
cComponents.components.length > 0) {
|
|
1871
|
-
for (const iterator of cComponents.components) {
|
|
1872
|
-
if (iterator.type === 'address') {
|
|
1873
|
-
delete iterator.components;
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
}
|
|
1879
|
-
}
|
|
1880
|
-
}
|
|
1881
|
-
}
|
|
1882
|
-
}
|
|
1883
|
-
}
|
|
1884
|
-
}
|
|
1885
|
-
let form = arrayForms;
|
|
1886
|
-
if (!form ||
|
|
1887
|
-
!form[0] ||
|
|
1888
|
-
!form[0].promCodigo ||
|
|
1889
|
-
form[0].promCodigo != promCodigo) {
|
|
1890
|
-
// this.router.navigate(['404']);
|
|
1891
|
-
resolve(lFormFieldsToken);
|
|
1892
|
-
}
|
|
1893
|
-
lFormFieldsToken = [];
|
|
1894
|
-
for (let formComp of form) {
|
|
1895
|
-
let newComponents;
|
|
1896
|
-
let components = [];
|
|
1897
|
-
if (formComp.components) {
|
|
1898
|
-
newComponents = formComp.components;
|
|
1899
|
-
}
|
|
1900
|
-
else if (formComp.columns) {
|
|
1901
|
-
newComponents = formComp.columns;
|
|
1902
|
-
}
|
|
1903
|
-
if (newComponents && UtilString.isValid(formComp.title)) {
|
|
1904
|
-
lFormFieldsToken.push({
|
|
1905
|
-
title: {
|
|
1906
|
-
key: TokenService.getKeyFormulario(formComp.title),
|
|
1907
|
-
value: formComp.title,
|
|
1908
|
-
object: formComp
|
|
1909
|
-
},
|
|
1910
|
-
value: []
|
|
1911
|
-
});
|
|
1912
|
-
lFormFieldsToken[lFormFieldsToken.length - 1].value =
|
|
1913
|
-
this.getComponenetForm(components, newComponents, null, false, null);
|
|
1914
|
-
}
|
|
1915
|
-
}
|
|
1916
|
-
resolve(lFormFieldsToken);
|
|
1917
|
-
},
|
|
1918
|
-
error: (error) => {
|
|
1919
|
-
reject(error);
|
|
1920
|
-
}
|
|
1921
|
-
});
|
|
1922
|
-
});
|
|
1923
|
-
}
|
|
1924
|
-
getFormFieldsByFormId(formId) {
|
|
1925
|
-
return new Promise((resolve, reject) => {
|
|
1926
|
-
// Search the dynamic form
|
|
1927
|
-
let lFormFieldsToken = null;
|
|
1928
|
-
this.formService.getById(formId).subscribe((result) => {
|
|
1929
|
-
let form = result;
|
|
1930
|
-
if (!form || !form[0]) {
|
|
1931
|
-
resolve(lFormFieldsToken);
|
|
1932
|
-
}
|
|
1933
|
-
lFormFieldsToken = [];
|
|
1934
|
-
for (let formComp of form) {
|
|
1935
|
-
let newComponents;
|
|
1936
|
-
let components = [];
|
|
1937
|
-
if (formComp.components) {
|
|
1938
|
-
newComponents = formComp.components;
|
|
1939
|
-
}
|
|
1940
|
-
else if (formComp.columns) {
|
|
1941
|
-
newComponents = formComp.columns;
|
|
1942
|
-
}
|
|
1943
|
-
if (newComponents && UtilString.isValid(formComp.title)) {
|
|
1944
|
-
lFormFieldsToken.push({
|
|
1945
|
-
title: {
|
|
1946
|
-
key: TokenService.getKeyFormulario(formComp.title),
|
|
1947
|
-
value: formComp.title,
|
|
1948
|
-
object: formComp
|
|
1949
|
-
},
|
|
1950
|
-
value: []
|
|
1951
|
-
});
|
|
1952
|
-
lFormFieldsToken[lFormFieldsToken.length - 1].value =
|
|
1953
|
-
this.getComponenetForm(components, newComponents, null, false, null);
|
|
1954
|
-
}
|
|
1955
|
-
}
|
|
1956
|
-
resolve(lFormFieldsToken);
|
|
1957
|
-
}, (error) => {
|
|
1958
|
-
reject(error);
|
|
1959
|
-
});
|
|
1960
|
-
});
|
|
1961
|
-
}
|
|
1962
|
-
/** This promise allows to execute a function when consulting the form fields. */
|
|
1963
|
-
getFormPanelsByPromCode(promCodigo) {
|
|
1964
|
-
return new Promise((resolve, reject) => {
|
|
1965
|
-
// Search the dynamic form
|
|
1966
|
-
let lFormPannelsToken = null;
|
|
1967
|
-
this.formService.getByPromCodigo(promCodigo).subscribe((result) => {
|
|
1968
|
-
let form = result;
|
|
1969
|
-
if (!form ||
|
|
1970
|
-
!form[0] ||
|
|
1971
|
-
!form[0].promCodigo ||
|
|
1972
|
-
form[0].promCodigo != promCodigo) {
|
|
1973
|
-
// this.router.navigate(['404']);
|
|
1974
|
-
resolve(lFormPannelsToken);
|
|
1975
|
-
}
|
|
1976
|
-
lFormPannelsToken = [];
|
|
1977
|
-
for (let formComp of form) {
|
|
1978
|
-
let newComponents;
|
|
1979
|
-
let components = [];
|
|
1980
|
-
if (formComp.components) {
|
|
1981
|
-
newComponents = formComp.components;
|
|
1982
|
-
}
|
|
1983
|
-
else if (formComp.columns) {
|
|
1984
|
-
newComponents = formComp.columns;
|
|
1985
|
-
}
|
|
1986
|
-
if (newComponents && UtilString.isValid(formComp.title)) {
|
|
1987
|
-
lFormPannelsToken.push({
|
|
1988
|
-
title: {
|
|
1989
|
-
key: TokenService.getKeyFormulario(formComp.title),
|
|
1990
|
-
value: formComp.title,
|
|
1991
|
-
object: formComp
|
|
1992
|
-
},
|
|
1993
|
-
value: []
|
|
1994
|
-
});
|
|
1995
|
-
lFormPannelsToken[lFormPannelsToken.length - 1].value =
|
|
1996
|
-
this.getPanelComponenet(components, newComponents, null);
|
|
1997
|
-
}
|
|
1998
|
-
}
|
|
1999
|
-
resolve(lFormPannelsToken);
|
|
2000
|
-
}, (error) => {
|
|
2001
|
-
reject(error);
|
|
2002
|
-
});
|
|
2003
|
-
});
|
|
1701
|
+
/**
|
|
1702
|
+
* Depends of the type of formFieldToken return de value of the valueData
|
|
1703
|
+
* @param formFieldToken
|
|
1704
|
+
* @param valueData
|
|
1705
|
+
*/
|
|
1706
|
+
getValueFromFormField(formFieldToken, valueData) {
|
|
1707
|
+
if (typeof valueData == 'object') {
|
|
1708
|
+
if (formFieldToken.type) {
|
|
1709
|
+
if (formFieldToken.type == 'address') {
|
|
1710
|
+
return valueData.formatted_address;
|
|
1711
|
+
}
|
|
1712
|
+
if (formFieldToken.type == 'select' &&
|
|
1713
|
+
formFieldToken.searchField &&
|
|
1714
|
+
valueData.hasOwnProperty(formFieldToken.searchField)) {
|
|
1715
|
+
return valueData[formFieldToken.searchField];
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
return valueData;
|
|
2004
1720
|
}
|
|
2005
1721
|
/**
|
|
2006
|
-
*
|
|
2007
|
-
* @param
|
|
2008
|
-
* @param
|
|
1722
|
+
* Try to find the token in the stringText and replace with dataValue. If detect format of number or date try to format the dataValue
|
|
1723
|
+
* @param stringText
|
|
1724
|
+
* @param token
|
|
1725
|
+
* @param dataValue
|
|
2009
1726
|
*/
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
1727
|
+
replaceToken(stringText, token, dataValue) {
|
|
1728
|
+
let valueReplace = null;
|
|
1729
|
+
if (token && token[0] == '#') {
|
|
1730
|
+
let typeToken = token.substring(1, token.indexOf('('));
|
|
1731
|
+
if (typeToken == 'date') {
|
|
1732
|
+
let dateFormat = token.substring(token.indexOf('}') + 1, token.indexOf(')'));
|
|
1733
|
+
dateFormat = dateFormat.trim().replace(/\"/g, '').replace(/\'/g, '');
|
|
1734
|
+
let dateValue = DateUtil.getDate(dataValue);
|
|
1735
|
+
if (dateValue) {
|
|
1736
|
+
valueReplace = DateUtil.getMoment(dateValue).format(dateFormat);
|
|
1737
|
+
}
|
|
1738
|
+
else {
|
|
1739
|
+
valueReplace = '';
|
|
1740
|
+
}
|
|
2014
1741
|
}
|
|
2015
|
-
else if (
|
|
2016
|
-
let
|
|
2017
|
-
if (
|
|
2018
|
-
|
|
1742
|
+
else if (typeToken == 'number') {
|
|
1743
|
+
let numberValue = Number(dataValue);
|
|
1744
|
+
if (numberValue != undefined && !isNaN(numberValue)) {
|
|
1745
|
+
let numberFormat = token.substring(token.indexOf('}') + 1, token.indexOf(')'));
|
|
1746
|
+
numberFormat = numberFormat.trim().replace(/\"/g, '').replace(/\'/g, '');
|
|
1747
|
+
valueReplace = this.currencyPipe.transform(numberValue, this.locale, '', numberFormat);
|
|
2019
1748
|
}
|
|
2020
|
-
else
|
|
2021
|
-
|
|
1749
|
+
else {
|
|
1750
|
+
console.log('El dato [' +
|
|
1751
|
+
dataValue +
|
|
1752
|
+
'] para el token [' +
|
|
1753
|
+
token +
|
|
1754
|
+
'] tipo númerico no es valido');
|
|
1755
|
+
valueReplace = '';
|
|
2022
1756
|
}
|
|
2023
|
-
|
|
1757
|
+
}
|
|
1758
|
+
else {
|
|
1759
|
+
console.log('tipo de token indefinido. [typeToken[' + typeToken + ']]');
|
|
2024
1760
|
}
|
|
2025
1761
|
}
|
|
2026
|
-
|
|
1762
|
+
else if (token && token[0] == '$') {
|
|
1763
|
+
valueReplace = dataValue;
|
|
1764
|
+
}
|
|
1765
|
+
else {
|
|
1766
|
+
console.log('El token no es valido. [token[' + token + ']]');
|
|
1767
|
+
}
|
|
1768
|
+
if (stringText && valueReplace !== null) {
|
|
1769
|
+
// replace text in a more efficient way
|
|
1770
|
+
stringText = stringText.split(token).join(valueReplace);
|
|
1771
|
+
//stringText = stringText.replace(token, valueReplace);
|
|
1772
|
+
}
|
|
1773
|
+
return stringText;
|
|
2027
1774
|
}
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
1775
|
+
getListTokensByStringSegmentation(stringText) {
|
|
1776
|
+
const arrayToken = stringText.match(/\${([^}]+)\}/g);
|
|
1777
|
+
const arrayTokenFormattedDate = stringText.match(/\#date[^)]+\)/g);
|
|
1778
|
+
const arrayTokenFormattedNumber = stringText.match(/\#number[^)]+\)/g);
|
|
1779
|
+
let arrayTokenFormatted = [];
|
|
1780
|
+
if (arrayTokenFormattedDate &&
|
|
1781
|
+
arrayTokenFormattedDate.length > 0 &&
|
|
1782
|
+
arrayTokenFormattedNumber &&
|
|
1783
|
+
arrayTokenFormattedNumber.length > 0) {
|
|
1784
|
+
arrayTokenFormatted = arrayTokenFormattedDate.concat(arrayTokenFormattedNumber);
|
|
1785
|
+
}
|
|
1786
|
+
else if (arrayTokenFormattedDate && arrayTokenFormattedDate.length > 0) {
|
|
1787
|
+
arrayTokenFormatted = arrayTokenFormattedDate.slice();
|
|
1788
|
+
}
|
|
1789
|
+
else if (arrayTokenFormattedNumber && arrayTokenFormattedNumber.length > 0) {
|
|
1790
|
+
arrayTokenFormatted = arrayTokenFormattedNumber.slice();
|
|
1791
|
+
}
|
|
1792
|
+
const result = [];
|
|
1793
|
+
if (arrayToken) {
|
|
1794
|
+
for (const token of arrayToken) {
|
|
1795
|
+
const infoToken = { key: token, value: token };
|
|
1796
|
+
if (arrayTokenFormatted) {
|
|
1797
|
+
for (const tokenFormatted of arrayTokenFormatted) {
|
|
1798
|
+
const index = tokenFormatted.indexOf(token);
|
|
1799
|
+
if (index >= 0) {
|
|
1800
|
+
infoToken.value = tokenFormatted;
|
|
1801
|
+
break;
|
|
1802
|
+
}
|
|
2042
1803
|
}
|
|
2043
1804
|
}
|
|
2044
|
-
|
|
2045
|
-
newComponents = formComp.columns;
|
|
2046
|
-
}
|
|
2047
|
-
if (formComp.type && formComp.type === 'panel') {
|
|
2048
|
-
panelName = formComp.title;
|
|
2049
|
-
}
|
|
2050
|
-
components = this.getComponenetForm(components, newComponents, panelName, editgrid, editGridKey);
|
|
2051
|
-
}
|
|
2052
|
-
else {
|
|
2053
|
-
formComp.panelName = panelName;
|
|
2054
|
-
formComp.editgrid = editgrid;
|
|
2055
|
-
formComp.editGridKey = editGridKey;
|
|
2056
|
-
components.push(formComp);
|
|
1805
|
+
result.push(infoToken);
|
|
2057
1806
|
}
|
|
2058
1807
|
}
|
|
2059
|
-
return
|
|
1808
|
+
return result;
|
|
2060
1809
|
}
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
// this.router.navigate(['404']);
|
|
2073
|
-
resolve(lFormFieldsToken);
|
|
2074
|
-
}
|
|
2075
|
-
lFormFieldsToken = [];
|
|
2076
|
-
for (let formComp of form) {
|
|
2077
|
-
let newComponents;
|
|
2078
|
-
let components = [];
|
|
2079
|
-
if (formComp.components) {
|
|
2080
|
-
newComponents = formComp.components;
|
|
2081
|
-
}
|
|
2082
|
-
else if (formComp.columns) {
|
|
2083
|
-
newComponents = formComp.columns;
|
|
2084
|
-
}
|
|
2085
|
-
if (newComponents && UtilString.isValid(formComp.title)) {
|
|
2086
|
-
lFormFieldsToken.push({
|
|
2087
|
-
title: {
|
|
2088
|
-
key: TokenService.getKeyFormulario(formComp.title),
|
|
2089
|
-
value: formComp.title,
|
|
2090
|
-
object: formComp
|
|
2091
|
-
},
|
|
2092
|
-
value: []
|
|
2093
|
-
});
|
|
2094
|
-
lFormFieldsToken[lFormFieldsToken.length - 1].value =
|
|
2095
|
-
this.getEditGridComponenet(components, newComponents, null);
|
|
2096
|
-
}
|
|
1810
|
+
changeIdPropertiesOfObject(normalizationColumns, listData) {
|
|
1811
|
+
const newData = [];
|
|
1812
|
+
listData.forEach((data) => {
|
|
1813
|
+
const objData = {};
|
|
1814
|
+
Object.keys(data).forEach((property) => {
|
|
1815
|
+
if (data.hasOwnProperty(property)) {
|
|
1816
|
+
normalizationColumns.forEach((column) => {
|
|
1817
|
+
if (column.idColumn.toString() === property) {
|
|
1818
|
+
objData[column.key] = data[property];
|
|
1819
|
+
}
|
|
1820
|
+
});
|
|
2097
1821
|
}
|
|
2098
|
-
resolve(lFormFieldsToken);
|
|
2099
|
-
}, (error) => {
|
|
2100
|
-
reject(error);
|
|
2101
1822
|
});
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
/**
|
|
2105
|
-
* A recursive method to get all the information of the editGrid dynamic form
|
|
2106
|
-
* @param components
|
|
2107
|
-
* @param form
|
|
2108
|
-
*/
|
|
2109
|
-
getEditGridComponenet(components, form, panelName) {
|
|
2110
|
-
for (let formComp of form) {
|
|
2111
|
-
if (formComp.type === 'editgrid') {
|
|
2112
|
-
formComp.panelName = panelName;
|
|
2113
|
-
components.push(formComp);
|
|
2114
|
-
}
|
|
2115
|
-
else if (formComp.components || formComp.columns) {
|
|
2116
|
-
let newComponents;
|
|
2117
|
-
if (formComp.components) {
|
|
2118
|
-
newComponents = formComp.components;
|
|
2119
|
-
}
|
|
2120
|
-
else if (formComp.columns) {
|
|
2121
|
-
newComponents = formComp.columns;
|
|
2122
|
-
}
|
|
2123
|
-
if (formComp.type && formComp.type === 'panel') {
|
|
2124
|
-
panelName = formComp.title;
|
|
2125
|
-
}
|
|
2126
|
-
components = this.getEditGridComponenet(components, newComponents, panelName);
|
|
1823
|
+
if (objData) {
|
|
1824
|
+
newData.push(objData);
|
|
2127
1825
|
}
|
|
2128
|
-
}
|
|
2129
|
-
return components;
|
|
2130
|
-
}
|
|
2131
|
-
/** It returns the tokens by promCodigo */
|
|
2132
|
-
getListByPromCodigo(promCode) {
|
|
2133
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'token/getByPromCodigo', { params: new HttpParams().set('promCodigo', promCode.toString()) });
|
|
2134
|
-
}
|
|
2135
|
-
/** It returns the token by id */
|
|
2136
|
-
getById(id) {
|
|
2137
|
-
return this.httpClient.get(this.environment.host.backend.configuration + 'token/getById', {
|
|
2138
|
-
params: new HttpParams().set('id', id.toString())
|
|
2139
1826
|
});
|
|
1827
|
+
return newData;
|
|
2140
1828
|
}
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
getUniqueVerificationCode(login, token) {
|
|
2158
|
-
return this.httpClient.get(this.environment.host.backend.documentsRepository +
|
|
2159
|
-
'documento/consultarCodigoUnico/' +
|
|
2160
|
-
login +
|
|
2161
|
-
'/' +
|
|
2162
|
-
token, { params: new HttpParams() });
|
|
2163
|
-
}
|
|
2164
|
-
/** It send the information to copy the Document viewer */
|
|
2165
|
-
copyDocumentInformationViewer(login, token, uniqueCode, documentURL, documentName) {
|
|
2166
|
-
let infoDocumento = {
|
|
2167
|
-
codigoUnico: uniqueCode,
|
|
2168
|
-
rutaDocumento: documentURL,
|
|
2169
|
-
documentName: documentName
|
|
2170
|
-
};
|
|
2171
|
-
return this.httpClient.post(this.environment.host.backend.documentsRepository +
|
|
2172
|
-
'documento/adicionarDocumento/' +
|
|
2173
|
-
login +
|
|
2174
|
-
'/' +
|
|
2175
|
-
token, infoDocumento, HEADER_JSON);
|
|
2176
|
-
}
|
|
2177
|
-
static getKeyBudget() {
|
|
2178
|
-
return UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_BUDGET);
|
|
2179
|
-
}
|
|
2180
|
-
static getKeyDocument() {
|
|
2181
|
-
return UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_DOCUMENTO);
|
|
2182
|
-
}
|
|
2183
|
-
static getKeyTask() {
|
|
2184
|
-
return UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_TASKL);
|
|
2185
|
-
}
|
|
2186
|
-
static getKeyStatic() {
|
|
2187
|
-
return UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_STATIC);
|
|
2188
|
-
}
|
|
2189
|
-
static getKeyCalculated(token) {
|
|
2190
|
-
return (UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_CALCULATED) +
|
|
2191
|
-
'_' +
|
|
2192
|
-
UtilString.replaceAccentSpacesOthers(token.name));
|
|
2193
|
-
}
|
|
2194
|
-
static getKeySnapshot(token) {
|
|
2195
|
-
return (UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_SNAPSHOT) +
|
|
2196
|
-
'_' +
|
|
2197
|
-
UtilString.replaceAccentSpacesOthers(token.name));
|
|
2198
|
-
}
|
|
2199
|
-
static getKeyGuarantee(token) {
|
|
2200
|
-
return (UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_GUARANTEE) +
|
|
2201
|
-
'_' +
|
|
2202
|
-
UtilString.replaceAccentSpacesOthers(token.name));
|
|
1829
|
+
generateHtmlByTokensAndData(html, listData, listTokens) {
|
|
1830
|
+
const translatedCards = [];
|
|
1831
|
+
listData.forEach((data) => {
|
|
1832
|
+
const objToken = {};
|
|
1833
|
+
const htmlTranslated = { html: html };
|
|
1834
|
+
Object.keys(data).forEach((property) => {
|
|
1835
|
+
listTokens.forEach((token) => {
|
|
1836
|
+
if (property == token.key.replace('${', '').replace('}', '')) {
|
|
1837
|
+
objToken[token.key] = data[property];
|
|
1838
|
+
htmlTranslated.html = htmlTranslated.html.replace(token.key, data[property]);
|
|
1839
|
+
}
|
|
1840
|
+
});
|
|
1841
|
+
});
|
|
1842
|
+
translatedCards.push(htmlTranslated);
|
|
1843
|
+
});
|
|
1844
|
+
return translatedCards;
|
|
2203
1845
|
}
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
else if (key.startsWith(UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_BUDGET))) {
|
|
2215
|
-
return 2;
|
|
2216
|
-
}
|
|
2217
|
-
else if (key.startsWith(UtilString.replaceAccentSpacesOthers(TokenService.TOKEN_LABEL_STATIC))) {
|
|
2218
|
-
return 3;
|
|
1846
|
+
getListTokensByString(stringText) {
|
|
1847
|
+
var arrayToken = stringText.match(/\${([^}]+)\}/g);
|
|
1848
|
+
var arrayTokenFormattedDate = stringText.match(/\#date[^)]+\)/g);
|
|
1849
|
+
var arrayTokenFormattedNumber = stringText.match(/\#number[^)]+\)/g);
|
|
1850
|
+
var arrayTokenFormatted = [];
|
|
1851
|
+
if (arrayTokenFormattedDate &&
|
|
1852
|
+
arrayTokenFormattedDate.length > 0 &&
|
|
1853
|
+
arrayTokenFormattedNumber &&
|
|
1854
|
+
arrayTokenFormattedNumber.length > 0) {
|
|
1855
|
+
arrayTokenFormatted = arrayTokenFormattedDate.concat(arrayTokenFormattedNumber);
|
|
2219
1856
|
}
|
|
2220
|
-
else if (
|
|
2221
|
-
|
|
1857
|
+
else if (arrayTokenFormattedDate && arrayTokenFormattedDate.length > 0) {
|
|
1858
|
+
arrayTokenFormatted = arrayTokenFormattedDate.slice();
|
|
2222
1859
|
}
|
|
2223
|
-
else if (
|
|
2224
|
-
|
|
1860
|
+
else if (arrayTokenFormattedNumber && arrayTokenFormattedNumber.length > 0) {
|
|
1861
|
+
arrayTokenFormatted = arrayTokenFormattedNumber.slice();
|
|
2225
1862
|
}
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
*/
|
|
2233
|
-
getValueFromFormField(formFieldToken, valueData) {
|
|
2234
|
-
if (typeof valueData == 'object') {
|
|
2235
|
-
if (formFieldToken.type) {
|
|
2236
|
-
if (formFieldToken.type == 'address') {
|
|
2237
|
-
return valueData.formatted_address;
|
|
1863
|
+
var result = [];
|
|
1864
|
+
if (arrayToken) {
|
|
1865
|
+
for (const token of arrayToken) {
|
|
1866
|
+
let keyType = TokenService.getKeyType(token);
|
|
1867
|
+
if (keyType === null) {
|
|
1868
|
+
continue;
|
|
2238
1869
|
}
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
1870
|
+
var infoToken = { key: token, value: token };
|
|
1871
|
+
if (arrayTokenFormatted) {
|
|
1872
|
+
for (const tokenFormatted of arrayTokenFormatted) {
|
|
1873
|
+
var index = tokenFormatted.indexOf(token);
|
|
1874
|
+
if (index >= 0) {
|
|
1875
|
+
infoToken.value = tokenFormatted;
|
|
1876
|
+
break;
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
2243
1879
|
}
|
|
2244
|
-
|
|
2245
|
-
}
|
|
2246
|
-
return valueData;
|
|
2247
|
-
}
|
|
2248
|
-
/**
|
|
2249
|
-
* Try to find the token in the stringText and replace with dataValue. If detect format of number or date try to format the dataValue
|
|
2250
|
-
* @param stringText
|
|
2251
|
-
* @param token
|
|
2252
|
-
* @param dataValue
|
|
2253
|
-
*/
|
|
2254
|
-
replaceToken(stringText, token, dataValue) {
|
|
2255
|
-
let valueReplace = null;
|
|
2256
|
-
if (token && token[0] == '#') {
|
|
2257
|
-
let typeToken = token.substring(1, token.indexOf('('));
|
|
2258
|
-
if (typeToken == 'date') {
|
|
2259
|
-
let dateFormat = token.substring(token.indexOf('}') + 1, token.indexOf(')'));
|
|
2260
|
-
dateFormat = dateFormat.trim().replace(/\"/g, '').replace(/\'/g, '');
|
|
2261
|
-
let dateValue = DateUtil.getDate(dataValue);
|
|
2262
|
-
if (dateValue) {
|
|
2263
|
-
valueReplace = DateUtil.getMoment(dateValue).format(dateFormat);
|
|
2264
|
-
}
|
|
2265
|
-
else {
|
|
2266
|
-
valueReplace = '';
|
|
2267
|
-
}
|
|
2268
|
-
}
|
|
2269
|
-
else if (typeToken == 'number') {
|
|
2270
|
-
let numberValue = Number(dataValue);
|
|
2271
|
-
if (numberValue != undefined && !isNaN(numberValue)) {
|
|
2272
|
-
let numberFormat = token.substring(token.indexOf('}') + 1, token.indexOf(')'));
|
|
2273
|
-
numberFormat = numberFormat.trim().replace(/\"/g, '').replace(/\'/g, '');
|
|
2274
|
-
valueReplace = this.currencyPipe.transform(numberValue, this.locale, '', numberFormat);
|
|
2275
|
-
}
|
|
2276
|
-
else {
|
|
2277
|
-
console.log('El dato [' +
|
|
2278
|
-
dataValue +
|
|
2279
|
-
'] para el token [' +
|
|
2280
|
-
token +
|
|
2281
|
-
'] tipo númerico no es valido');
|
|
2282
|
-
valueReplace = '';
|
|
2283
|
-
}
|
|
2284
|
-
}
|
|
2285
|
-
else {
|
|
2286
|
-
console.log('tipo de token indefinido. [typeToken[' + typeToken + ']]');
|
|
2287
|
-
}
|
|
2288
|
-
}
|
|
2289
|
-
else if (token && token[0] == '$') {
|
|
2290
|
-
valueReplace = dataValue;
|
|
2291
|
-
}
|
|
2292
|
-
else {
|
|
2293
|
-
console.log('El token no es valido. [token[' + token + ']]');
|
|
2294
|
-
}
|
|
2295
|
-
if (stringText && valueReplace !== null) {
|
|
2296
|
-
// replace text in a more efficient way
|
|
2297
|
-
stringText = stringText.split(token).join(valueReplace);
|
|
2298
|
-
//stringText = stringText.replace(token, valueReplace);
|
|
2299
|
-
}
|
|
2300
|
-
return stringText;
|
|
2301
|
-
}
|
|
2302
|
-
getListTokensByStringSegmentation(stringText) {
|
|
2303
|
-
const arrayToken = stringText.match(/\${([^}]+)\}/g);
|
|
2304
|
-
const arrayTokenFormattedDate = stringText.match(/\#date[^)]+\)/g);
|
|
2305
|
-
const arrayTokenFormattedNumber = stringText.match(/\#number[^)]+\)/g);
|
|
2306
|
-
let arrayTokenFormatted = [];
|
|
2307
|
-
if (arrayTokenFormattedDate &&
|
|
2308
|
-
arrayTokenFormattedDate.length > 0 &&
|
|
2309
|
-
arrayTokenFormattedNumber &&
|
|
2310
|
-
arrayTokenFormattedNumber.length > 0) {
|
|
2311
|
-
arrayTokenFormatted = arrayTokenFormattedDate.concat(arrayTokenFormattedNumber);
|
|
2312
|
-
}
|
|
2313
|
-
else if (arrayTokenFormattedDate && arrayTokenFormattedDate.length > 0) {
|
|
2314
|
-
arrayTokenFormatted = arrayTokenFormattedDate.slice();
|
|
2315
|
-
}
|
|
2316
|
-
else if (arrayTokenFormattedNumber && arrayTokenFormattedNumber.length > 0) {
|
|
2317
|
-
arrayTokenFormatted = arrayTokenFormattedNumber.slice();
|
|
2318
|
-
}
|
|
2319
|
-
const result = [];
|
|
2320
|
-
if (arrayToken) {
|
|
2321
|
-
for (const token of arrayToken) {
|
|
2322
|
-
const infoToken = { key: token, value: token };
|
|
2323
|
-
if (arrayTokenFormatted) {
|
|
2324
|
-
for (const tokenFormatted of arrayTokenFormatted) {
|
|
2325
|
-
const index = tokenFormatted.indexOf(token);
|
|
2326
|
-
if (index >= 0) {
|
|
2327
|
-
infoToken.value = tokenFormatted;
|
|
2328
|
-
break;
|
|
2329
|
-
}
|
|
2330
|
-
}
|
|
2331
|
-
}
|
|
2332
|
-
result.push(infoToken);
|
|
2333
|
-
}
|
|
2334
|
-
}
|
|
2335
|
-
return result;
|
|
2336
|
-
}
|
|
2337
|
-
changeIdPropertiesOfObject(normalizationColumns, listData) {
|
|
2338
|
-
const newData = [];
|
|
2339
|
-
listData.forEach((data) => {
|
|
2340
|
-
const objData = {};
|
|
2341
|
-
Object.keys(data).forEach((property) => {
|
|
2342
|
-
if (data.hasOwnProperty(property)) {
|
|
2343
|
-
normalizationColumns.forEach((column) => {
|
|
2344
|
-
if (column.idColumn.toString() === property) {
|
|
2345
|
-
objData[column.key] = data[property];
|
|
2346
|
-
}
|
|
2347
|
-
});
|
|
2348
|
-
}
|
|
2349
|
-
});
|
|
2350
|
-
if (objData) {
|
|
2351
|
-
newData.push(objData);
|
|
2352
|
-
}
|
|
2353
|
-
});
|
|
2354
|
-
return newData;
|
|
2355
|
-
}
|
|
2356
|
-
generateHtmlByTokensAndData(html, listData, listTokens) {
|
|
2357
|
-
const translatedCards = [];
|
|
2358
|
-
listData.forEach((data) => {
|
|
2359
|
-
const objToken = {};
|
|
2360
|
-
const htmlTranslated = { html: html };
|
|
2361
|
-
Object.keys(data).forEach((property) => {
|
|
2362
|
-
listTokens.forEach((token) => {
|
|
2363
|
-
if (property == token.key.replace('${', '').replace('}', '')) {
|
|
2364
|
-
objToken[token.key] = data[property];
|
|
2365
|
-
htmlTranslated.html = htmlTranslated.html.replace(token.key, data[property]);
|
|
2366
|
-
}
|
|
2367
|
-
});
|
|
2368
|
-
});
|
|
2369
|
-
translatedCards.push(htmlTranslated);
|
|
2370
|
-
});
|
|
2371
|
-
return translatedCards;
|
|
2372
|
-
}
|
|
2373
|
-
getListTokensByString(stringText) {
|
|
2374
|
-
var arrayToken = stringText.match(/\${([^}]+)\}/g);
|
|
2375
|
-
var arrayTokenFormattedDate = stringText.match(/\#date[^)]+\)/g);
|
|
2376
|
-
var arrayTokenFormattedNumber = stringText.match(/\#number[^)]+\)/g);
|
|
2377
|
-
var arrayTokenFormatted = [];
|
|
2378
|
-
if (arrayTokenFormattedDate &&
|
|
2379
|
-
arrayTokenFormattedDate.length > 0 &&
|
|
2380
|
-
arrayTokenFormattedNumber &&
|
|
2381
|
-
arrayTokenFormattedNumber.length > 0) {
|
|
2382
|
-
arrayTokenFormatted = arrayTokenFormattedDate.concat(arrayTokenFormattedNumber);
|
|
2383
|
-
}
|
|
2384
|
-
else if (arrayTokenFormattedDate && arrayTokenFormattedDate.length > 0) {
|
|
2385
|
-
arrayTokenFormatted = arrayTokenFormattedDate.slice();
|
|
2386
|
-
}
|
|
2387
|
-
else if (arrayTokenFormattedNumber && arrayTokenFormattedNumber.length > 0) {
|
|
2388
|
-
arrayTokenFormatted = arrayTokenFormattedNumber.slice();
|
|
2389
|
-
}
|
|
2390
|
-
var result = [];
|
|
2391
|
-
if (arrayToken) {
|
|
2392
|
-
for (const token of arrayToken) {
|
|
2393
|
-
let keyType = TokenService.getKeyType(token);
|
|
2394
|
-
if (keyType === null) {
|
|
2395
|
-
continue;
|
|
2396
|
-
}
|
|
2397
|
-
var infoToken = { key: token, value: token };
|
|
2398
|
-
if (arrayTokenFormatted) {
|
|
2399
|
-
for (const tokenFormatted of arrayTokenFormatted) {
|
|
2400
|
-
var index = tokenFormatted.indexOf(token);
|
|
2401
|
-
if (index >= 0) {
|
|
2402
|
-
infoToken.value = tokenFormatted;
|
|
2403
|
-
break;
|
|
2404
|
-
}
|
|
2405
|
-
}
|
|
2406
|
-
}
|
|
2407
|
-
result.push(infoToken);
|
|
1880
|
+
result.push(infoToken);
|
|
2408
1881
|
}
|
|
2409
1882
|
}
|
|
2410
1883
|
return result;
|
|
@@ -10224,6 +9697,525 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImpor
|
|
|
10224
9697
|
args: ['environment']
|
|
10225
9698
|
}] }, { type: i1.HttpClient }]; } });
|
|
10226
9699
|
|
|
9700
|
+
// import * as utils_ from 'formiojs-proyectoscolfuturo/utils/utils';
|
|
9701
|
+
const utils = utils_;
|
|
9702
|
+
class FormioUtil {
|
|
9703
|
+
/**
|
|
9704
|
+
* It returns the components formated by panel
|
|
9705
|
+
* @param components
|
|
9706
|
+
* @return the object is [{panel: , items: [{ value: , label: }]}]
|
|
9707
|
+
*/
|
|
9708
|
+
static getFormattedComponentsByPanel(components) {
|
|
9709
|
+
let result = [];
|
|
9710
|
+
if (components) {
|
|
9711
|
+
let group = null;
|
|
9712
|
+
let object = null;
|
|
9713
|
+
for (const component of components) {
|
|
9714
|
+
if (component[EFormioKey.TITLE_PANEL] !== group) {
|
|
9715
|
+
if (group !== null) {
|
|
9716
|
+
result.push(object);
|
|
9717
|
+
}
|
|
9718
|
+
object = { label: component[EFormioKey.TITLE_PANEL], items: [], toggle: false };
|
|
9719
|
+
group = component[EFormioKey.TITLE_PANEL];
|
|
9720
|
+
}
|
|
9721
|
+
object.items.push({
|
|
9722
|
+
label: component[EFormioKey.LABEL],
|
|
9723
|
+
value: component[EFormioKey.KEY]
|
|
9724
|
+
});
|
|
9725
|
+
}
|
|
9726
|
+
if (group !== null)
|
|
9727
|
+
result.push(object);
|
|
9728
|
+
}
|
|
9729
|
+
return result;
|
|
9730
|
+
}
|
|
9731
|
+
/**
|
|
9732
|
+
* It returns the components are required according with data
|
|
9733
|
+
* @param components array of components
|
|
9734
|
+
* @param data
|
|
9735
|
+
*/
|
|
9736
|
+
static getRequiredComponentsByData(components, data) {
|
|
9737
|
+
// get the required components
|
|
9738
|
+
let array = FormioUtil.getRequiredComponents(components);
|
|
9739
|
+
// if not data then return components
|
|
9740
|
+
if (data && array) {
|
|
9741
|
+
for (let i = 0; i < array.length; i++) {
|
|
9742
|
+
const component = array[i];
|
|
9743
|
+
// use formio to check condition according with data
|
|
9744
|
+
if (utils.checkCondition(component, null, data, null, null)) {
|
|
9745
|
+
const key = component[EFormioKey.KEY];
|
|
9746
|
+
if (data[key] != undefined && data[key] != null && data[key] != '') {
|
|
9747
|
+
// remove item from array
|
|
9748
|
+
array.splice(i, 1);
|
|
9749
|
+
i--;
|
|
9750
|
+
}
|
|
9751
|
+
else {
|
|
9752
|
+
if (component.customConditional &&
|
|
9753
|
+
component.customConditional.includes('show')) {
|
|
9754
|
+
// remove item from array
|
|
9755
|
+
array.splice(i, 1);
|
|
9756
|
+
i--;
|
|
9757
|
+
}
|
|
9758
|
+
}
|
|
9759
|
+
}
|
|
9760
|
+
else {
|
|
9761
|
+
// remove item from array
|
|
9762
|
+
array.splice(i, 1);
|
|
9763
|
+
i--;
|
|
9764
|
+
}
|
|
9765
|
+
}
|
|
9766
|
+
}
|
|
9767
|
+
return array;
|
|
9768
|
+
}
|
|
9769
|
+
/**
|
|
9770
|
+
* It returns the components that are required
|
|
9771
|
+
* @param components array of components
|
|
9772
|
+
*/
|
|
9773
|
+
static getUniqueComponents(components) {
|
|
9774
|
+
return FormioUtil.getComponentsByFeature(components, [EFormioKey.UNIQUE], true);
|
|
9775
|
+
}
|
|
9776
|
+
/**
|
|
9777
|
+
* It returns the components that are required
|
|
9778
|
+
* @param components array of components
|
|
9779
|
+
*/
|
|
9780
|
+
static getRequiredComponents(components) {
|
|
9781
|
+
return FormioUtil.getComponentsByFeature(components, [EFormioKey.VALIDATE, EFormioKey.REQUIRED], true);
|
|
9782
|
+
}
|
|
9783
|
+
/**
|
|
9784
|
+
* It returns the components that have a specific feature defined by properties and value
|
|
9785
|
+
* @param components array of components
|
|
9786
|
+
* @param properties path of properties example [validate, required] or [unique]
|
|
9787
|
+
* @param value the value that should have the property
|
|
9788
|
+
*/
|
|
9789
|
+
static getComponentsByFeature(components, properties, value) {
|
|
9790
|
+
let result = [];
|
|
9791
|
+
if (properties && properties.length > 0) {
|
|
9792
|
+
// get components
|
|
9793
|
+
const fields = FormioUtil.getComponents(components);
|
|
9794
|
+
// get first and last property
|
|
9795
|
+
const firstProperty = properties[0];
|
|
9796
|
+
const lastProperty = properties[properties.length - 1];
|
|
9797
|
+
if (fields) {
|
|
9798
|
+
// iterate the fields
|
|
9799
|
+
for (let i = 0; i < fields.length; i++) {
|
|
9800
|
+
// it contains the entire object field
|
|
9801
|
+
const field = fields[i];
|
|
9802
|
+
// it contains the current component and it is gonna be the component of every property
|
|
9803
|
+
let component = field;
|
|
9804
|
+
if (field[firstProperty]) {
|
|
9805
|
+
for (let j = 0; j < properties.length; j++) {
|
|
9806
|
+
const property = properties[j];
|
|
9807
|
+
// if component.property doesnt exist then break
|
|
9808
|
+
if (!component[property])
|
|
9809
|
+
break;
|
|
9810
|
+
if (property === lastProperty) {
|
|
9811
|
+
// it is the last property so if the value is equals to component.lastproperty then it is added to result
|
|
9812
|
+
if (component[property] == value)
|
|
9813
|
+
result.push(field);
|
|
9814
|
+
}
|
|
9815
|
+
else {
|
|
9816
|
+
// otherwise component will be equal to the component.property
|
|
9817
|
+
component = component[property];
|
|
9818
|
+
}
|
|
9819
|
+
}
|
|
9820
|
+
}
|
|
9821
|
+
}
|
|
9822
|
+
}
|
|
9823
|
+
}
|
|
9824
|
+
return result;
|
|
9825
|
+
}
|
|
9826
|
+
/**
|
|
9827
|
+
* It returns the components
|
|
9828
|
+
* @param components
|
|
9829
|
+
*/
|
|
9830
|
+
static getComponents(components) {
|
|
9831
|
+
return FormioUtil.getComponentsByRecursion(components, '', null);
|
|
9832
|
+
}
|
|
9833
|
+
/**
|
|
9834
|
+
* It returns the components array of the form by recursion
|
|
9835
|
+
* @param components array of components
|
|
9836
|
+
* @param titlePanel name of parent panel, so children components will inherit the panelName
|
|
9837
|
+
* @param conditionalObject conditional object it will be inherited from panel {conditional: { eq: , value: , when: , json: }, customConditional: }
|
|
9838
|
+
*/
|
|
9839
|
+
static getComponentsByRecursion(components, titlePanel, conditionalParent) {
|
|
9840
|
+
// it contains the result array
|
|
9841
|
+
let result = [];
|
|
9842
|
+
if (components) {
|
|
9843
|
+
// iterate over components
|
|
9844
|
+
for (const component of components) {
|
|
9845
|
+
// avoid the editgrid component ot if it has a different behavior it should have an else statement
|
|
9846
|
+
if (component[EFormioKey.TYPE] !== EFormioKey.EDITGRID) {
|
|
9847
|
+
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
9848
|
+
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
9849
|
+
titlePanel = component[EFormioKey.TITLE];
|
|
9850
|
+
}
|
|
9851
|
+
if (typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
9852
|
+
typeof component[EFormioKey.COLUMNS] !== 'undefined') {
|
|
9853
|
+
// resolve conditional parent conditional
|
|
9854
|
+
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
9855
|
+
// change condition
|
|
9856
|
+
if (conditional)
|
|
9857
|
+
conditionalParent = conditional;
|
|
9858
|
+
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
9859
|
+
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
9860
|
+
? component[EFormioKey.COMPONENTS]
|
|
9861
|
+
: component[EFormioKey.COLUMNS];
|
|
9862
|
+
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
9863
|
+
const recursionResult = FormioUtil.getComponentsByRecursion(subComponents, titlePanel, conditionalParent);
|
|
9864
|
+
// if recursion result then result concats the recursionResult
|
|
9865
|
+
if (recursionResult)
|
|
9866
|
+
result = result.concat(recursionResult);
|
|
9867
|
+
// reset conditional Parent
|
|
9868
|
+
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
9869
|
+
conditionalParent = undefined;
|
|
9870
|
+
}
|
|
9871
|
+
else {
|
|
9872
|
+
// avoid the component type button
|
|
9873
|
+
if (component[EFormioKey.TYPE] !== EFormioKey.BUTTON &&
|
|
9874
|
+
component[EFormioKey.KEY] &&
|
|
9875
|
+
component[EFormioKey.LABEL]) {
|
|
9876
|
+
// resolve conditional conditional object
|
|
9877
|
+
let conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
9878
|
+
if (!conditional)
|
|
9879
|
+
conditional = conditionalParent;
|
|
9880
|
+
component[EFormioKey.CONDITIONAL] = conditional[EFormioKey.CONDITIONAL];
|
|
9881
|
+
component[EFormioKey.CUSTOM_CONDITIONAL] =
|
|
9882
|
+
conditional[EFormioKey.CUSTOM_CONDITIONAL];
|
|
9883
|
+
// add namPanel as property
|
|
9884
|
+
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
9885
|
+
// add component to the result
|
|
9886
|
+
result.push(component);
|
|
9887
|
+
}
|
|
9888
|
+
}
|
|
9889
|
+
}
|
|
9890
|
+
}
|
|
9891
|
+
}
|
|
9892
|
+
return result;
|
|
9893
|
+
}
|
|
9894
|
+
/**
|
|
9895
|
+
* It returns the components
|
|
9896
|
+
* @param components
|
|
9897
|
+
* @param keepEditGrids
|
|
9898
|
+
*/
|
|
9899
|
+
static getComponentsWithEditGrids(components) {
|
|
9900
|
+
return FormioUtil.getComponentsByRecursionWithEditGrids(components, '', null);
|
|
9901
|
+
}
|
|
9902
|
+
/**
|
|
9903
|
+
* It returns the components array of the form by recursion
|
|
9904
|
+
* @param components array of components
|
|
9905
|
+
* @param titlePanel name of parent panel, so children components will inherit the panelName
|
|
9906
|
+
* @param conditionalObject conditional object it will be inherited from panel {conditional: { eq: , value: , when: , json: }, customConditional: }
|
|
9907
|
+
*/
|
|
9908
|
+
static getComponentsByRecursionWithEditGrids(components, titlePanel, conditionalParent) {
|
|
9909
|
+
// it contains the result array
|
|
9910
|
+
let result = [];
|
|
9911
|
+
if (components) {
|
|
9912
|
+
// iterate over components
|
|
9913
|
+
for (const component of components) {
|
|
9914
|
+
// avoid the editgrid component ot if it has a different behavior it should have an else statement
|
|
9915
|
+
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
9916
|
+
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
9917
|
+
titlePanel = component[EFormioKey.TITLE];
|
|
9918
|
+
}
|
|
9919
|
+
if (typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
9920
|
+
typeof component[EFormioKey.COLUMNS] !== 'undefined') {
|
|
9921
|
+
// resolve conditional parent conditional
|
|
9922
|
+
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
9923
|
+
// change condition
|
|
9924
|
+
if (conditional)
|
|
9925
|
+
conditionalParent = conditional;
|
|
9926
|
+
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
9927
|
+
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
9928
|
+
? component[EFormioKey.COMPONENTS]
|
|
9929
|
+
: component[EFormioKey.COLUMNS];
|
|
9930
|
+
if (component[EFormioKey.TYPE] === EFormioKey.EDITGRID) {
|
|
9931
|
+
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
9932
|
+
result.push(component);
|
|
9933
|
+
}
|
|
9934
|
+
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
9935
|
+
const recursionResult = FormioUtil.getComponentsByRecursionWithEditGrids(subComponents, titlePanel, conditionalParent);
|
|
9936
|
+
// if recursion result then result concats the recursionResult
|
|
9937
|
+
if (recursionResult)
|
|
9938
|
+
result = result.concat(recursionResult);
|
|
9939
|
+
// reset conditional Parent
|
|
9940
|
+
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
9941
|
+
conditionalParent = undefined;
|
|
9942
|
+
}
|
|
9943
|
+
else {
|
|
9944
|
+
// avoid the component type button
|
|
9945
|
+
if (component[EFormioKey.TYPE] !== EFormioKey.BUTTON &&
|
|
9946
|
+
component[EFormioKey.KEY] &&
|
|
9947
|
+
component[EFormioKey.LABEL]) {
|
|
9948
|
+
// resolve conditional conditional object
|
|
9949
|
+
let conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
9950
|
+
if (!conditional)
|
|
9951
|
+
conditional = conditionalParent;
|
|
9952
|
+
component[EFormioKey.CONDITIONAL] = conditional[EFormioKey.CONDITIONAL];
|
|
9953
|
+
component[EFormioKey.CUSTOM_CONDITIONAL] =
|
|
9954
|
+
conditional[EFormioKey.CUSTOM_CONDITIONAL];
|
|
9955
|
+
// add namPanel as property
|
|
9956
|
+
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
9957
|
+
// add component to the result
|
|
9958
|
+
result.push(component);
|
|
9959
|
+
}
|
|
9960
|
+
}
|
|
9961
|
+
}
|
|
9962
|
+
}
|
|
9963
|
+
return result;
|
|
9964
|
+
}
|
|
9965
|
+
/**
|
|
9966
|
+
* It resolve the inheritance conditional
|
|
9967
|
+
* @param conditionalObject
|
|
9968
|
+
* @param conditional
|
|
9969
|
+
* @param customConditional
|
|
9970
|
+
*/
|
|
9971
|
+
static resolveInheritanceConditional(conditionalObject, conditional, customConditional, parentId) {
|
|
9972
|
+
// validate if there is a condition with the new fields
|
|
9973
|
+
if (!conditionalObject ||
|
|
9974
|
+
customConditional ||
|
|
9975
|
+
(conditional && conditional[EFormioKey.WHEN] && conditional[EFormioKey.EQ]) ||
|
|
9976
|
+
(conditional && conditional[EFormioKey.JSON])) {
|
|
9977
|
+
return { conditional: conditional, customConditional: customConditional, id: parentId };
|
|
9978
|
+
}
|
|
9979
|
+
return null;
|
|
9980
|
+
}
|
|
9981
|
+
/**
|
|
9982
|
+
* It returns the edit grid components
|
|
9983
|
+
* @param components
|
|
9984
|
+
*/
|
|
9985
|
+
static getEditGridKeyLabels(components) {
|
|
9986
|
+
return FormioUtil.getEditGridKeyLabelsByRecursion(components, '', null);
|
|
9987
|
+
}
|
|
9988
|
+
/**
|
|
9989
|
+
* It returns the components edit grid array of the form by recursion
|
|
9990
|
+
* @param components array of components
|
|
9991
|
+
* @param titlePanel name of parent panel, so children components will inherit the panelName
|
|
9992
|
+
* @param conditionalObject conditional object it will be inherited from panel {conditional: { eq: , value: , when: , json: }, customConditional: }
|
|
9993
|
+
*/
|
|
9994
|
+
static getEditGridKeyLabelsByRecursion(components, titlePanel, conditionalParent) {
|
|
9995
|
+
// it contains the result array
|
|
9996
|
+
let result = [];
|
|
9997
|
+
if (components) {
|
|
9998
|
+
// iterate over components
|
|
9999
|
+
for (const component of components) {
|
|
10000
|
+
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
10001
|
+
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
10002
|
+
titlePanel = component[EFormioKey.TITLE];
|
|
10003
|
+
}
|
|
10004
|
+
if (typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
10005
|
+
typeof component[EFormioKey.COLUMNS] !== 'undefined') {
|
|
10006
|
+
// resolve conditional parent conditional
|
|
10007
|
+
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
10008
|
+
// change condition
|
|
10009
|
+
if (conditional)
|
|
10010
|
+
conditionalParent = conditional;
|
|
10011
|
+
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
10012
|
+
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
10013
|
+
? component[EFormioKey.COMPONENTS]
|
|
10014
|
+
: component[EFormioKey.COLUMNS];
|
|
10015
|
+
if (component[EFormioKey.TYPE] == EFormioKey.EDITGRID) {
|
|
10016
|
+
// add namPanel as property
|
|
10017
|
+
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
10018
|
+
// add component to the result
|
|
10019
|
+
result.push(component);
|
|
10020
|
+
}
|
|
10021
|
+
else {
|
|
10022
|
+
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
10023
|
+
const recursionResult = FormioUtil.getEditGridKeyLabelsByRecursion(subComponents, titlePanel, conditionalParent);
|
|
10024
|
+
// if recursion result then result concats the recursionResult
|
|
10025
|
+
if (recursionResult)
|
|
10026
|
+
result = result.concat(recursionResult);
|
|
10027
|
+
// reset conditional Parent
|
|
10028
|
+
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
10029
|
+
conditionalParent = undefined;
|
|
10030
|
+
}
|
|
10031
|
+
}
|
|
10032
|
+
else {
|
|
10033
|
+
}
|
|
10034
|
+
}
|
|
10035
|
+
}
|
|
10036
|
+
return result;
|
|
10037
|
+
}
|
|
10038
|
+
/**
|
|
10039
|
+
* It returns the components
|
|
10040
|
+
* @param components
|
|
10041
|
+
* @param keepEditGrids
|
|
10042
|
+
*/
|
|
10043
|
+
static getComponentsIntoEditGrids(components, editGridName) {
|
|
10044
|
+
return FormioUtil.getComponentsByRecursionIntoEditGrids(components, '', null, editGridName, false);
|
|
10045
|
+
}
|
|
10046
|
+
/**
|
|
10047
|
+
* It returns the components array of the form by recursion
|
|
10048
|
+
* @param components array of components
|
|
10049
|
+
* @param titlePanel name of parent panel, so children components will inherit the panelName
|
|
10050
|
+
* @param conditionalObject conditional object it will be inherited from panel {conditional: { eq: , value: , when: , json: }, customConditional: }
|
|
10051
|
+
*/
|
|
10052
|
+
static getComponentsByRecursionIntoEditGrids(components, titlePanel, conditionalParent, editGridName, existEditGrid) {
|
|
10053
|
+
// it contains the result array
|
|
10054
|
+
let result = [];
|
|
10055
|
+
if (components) {
|
|
10056
|
+
// iterate over components
|
|
10057
|
+
for (const component of components) {
|
|
10058
|
+
// avoid the editgrid component ot if it has a different behavior it should have an else statement
|
|
10059
|
+
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
10060
|
+
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
10061
|
+
titlePanel = component[EFormioKey.TITLE];
|
|
10062
|
+
}
|
|
10063
|
+
if (typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
10064
|
+
typeof component[EFormioKey.COLUMNS] !== 'undefined') {
|
|
10065
|
+
// resolve conditional parent conditional
|
|
10066
|
+
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
10067
|
+
// change condition
|
|
10068
|
+
if (conditional)
|
|
10069
|
+
conditionalParent = conditional;
|
|
10070
|
+
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
10071
|
+
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
10072
|
+
? component[EFormioKey.COMPONENTS]
|
|
10073
|
+
: component[EFormioKey.COLUMNS];
|
|
10074
|
+
if (component[EFormioKey.TYPE] === EFormioKey.EDITGRID &&
|
|
10075
|
+
component['key'] == editGridName) {
|
|
10076
|
+
existEditGrid = true;
|
|
10077
|
+
if (typeof component[EFormioKey.COMPONENTS] !== 'undefined' ||
|
|
10078
|
+
typeof component[EFormioKey.COLUMNS] !== 'undefined') {
|
|
10079
|
+
// resolve conditional parent conditional
|
|
10080
|
+
const conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
10081
|
+
// change condition
|
|
10082
|
+
if (conditional)
|
|
10083
|
+
conditionalParent = conditional;
|
|
10084
|
+
// it contains the subcomponents depending on the value of component if it has components or columns
|
|
10085
|
+
let subComponents = typeof component[EFormioKey.COMPONENTS] !== 'undefined'
|
|
10086
|
+
? component[EFormioKey.COMPONENTS]
|
|
10087
|
+
: component[EFormioKey.COLUMNS];
|
|
10088
|
+
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
10089
|
+
const recursionResult = FormioUtil.getComponentsByRecursionIntoEditGrids(subComponents, titlePanel, conditionalParent, editGridName, existEditGrid);
|
|
10090
|
+
// if recursion result then result concats the recursionResult
|
|
10091
|
+
if (recursionResult)
|
|
10092
|
+
result = result.concat(recursionResult);
|
|
10093
|
+
// reset conditional Parent
|
|
10094
|
+
if (component && conditionalParent) {
|
|
10095
|
+
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
10096
|
+
conditionalParent = undefined;
|
|
10097
|
+
}
|
|
10098
|
+
}
|
|
10099
|
+
else {
|
|
10100
|
+
// avoid the component type button
|
|
10101
|
+
if (component[EFormioKey.TYPE] !== EFormioKey.BUTTON &&
|
|
10102
|
+
component[EFormioKey.KEY] &&
|
|
10103
|
+
component[EFormioKey.LABEL] &&
|
|
10104
|
+
existEditGrid) {
|
|
10105
|
+
// resolve conditional conditional object
|
|
10106
|
+
let conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
10107
|
+
if (!conditional)
|
|
10108
|
+
conditional = conditionalParent;
|
|
10109
|
+
component[EFormioKey.CONDITIONAL] =
|
|
10110
|
+
conditional[EFormioKey.CONDITIONAL];
|
|
10111
|
+
component[EFormioKey.CUSTOM_CONDITIONAL] =
|
|
10112
|
+
conditional[EFormioKey.CUSTOM_CONDITIONAL];
|
|
10113
|
+
// add namPanel as property
|
|
10114
|
+
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
10115
|
+
// add component to the result
|
|
10116
|
+
result.push(component);
|
|
10117
|
+
}
|
|
10118
|
+
}
|
|
10119
|
+
}
|
|
10120
|
+
// if component has subComponents, then execute the recursion function to get the recursionnResult
|
|
10121
|
+
const recursionResult = FormioUtil.getComponentsByRecursionIntoEditGrids(subComponents, titlePanel, conditionalParent, editGridName, existEditGrid);
|
|
10122
|
+
// if recursion result then result concats the recursionResult
|
|
10123
|
+
if (recursionResult)
|
|
10124
|
+
result = result.concat(recursionResult);
|
|
10125
|
+
// reset conditional Parent
|
|
10126
|
+
if (component && conditionalParent) {
|
|
10127
|
+
if (component[EFormioKey.ID] == conditionalParent.id)
|
|
10128
|
+
conditionalParent = undefined;
|
|
10129
|
+
}
|
|
10130
|
+
}
|
|
10131
|
+
else {
|
|
10132
|
+
// avoid the component type button
|
|
10133
|
+
if (component[EFormioKey.TYPE] !== EFormioKey.BUTTON &&
|
|
10134
|
+
component[EFormioKey.KEY] &&
|
|
10135
|
+
component[EFormioKey.LABEL] &&
|
|
10136
|
+
existEditGrid) {
|
|
10137
|
+
// resolve conditional conditional object
|
|
10138
|
+
let conditional = this.resolveInheritanceConditional(conditionalParent, component[EFormioKey.CONDITIONAL], component[EFormioKey.CUSTOM_CONDITIONAL], component[EFormioKey.ID]);
|
|
10139
|
+
if (!conditional)
|
|
10140
|
+
conditional = conditionalParent;
|
|
10141
|
+
component[EFormioKey.CONDITIONAL] = conditional[EFormioKey.CONDITIONAL];
|
|
10142
|
+
component[EFormioKey.CUSTOM_CONDITIONAL] =
|
|
10143
|
+
conditional[EFormioKey.CUSTOM_CONDITIONAL];
|
|
10144
|
+
// add namPanel as property
|
|
10145
|
+
component[EFormioKey.TITLE_PANEL] = titlePanel;
|
|
10146
|
+
// add component to the result
|
|
10147
|
+
result.push(component);
|
|
10148
|
+
}
|
|
10149
|
+
}
|
|
10150
|
+
}
|
|
10151
|
+
}
|
|
10152
|
+
return result;
|
|
10153
|
+
}
|
|
10154
|
+
/**
|
|
10155
|
+
* Create 2 jason objects of data form by component key and other by component key and title form key
|
|
10156
|
+
* @param dataForm dataForm model object
|
|
10157
|
+
* @returns Object of 2 element
|
|
10158
|
+
*/
|
|
10159
|
+
static createListDataByDataFormList(dataForm, listForm) {
|
|
10160
|
+
let listData = {};
|
|
10161
|
+
let listDataByForm = {};
|
|
10162
|
+
if (dataForm && dataForm.length > 0) {
|
|
10163
|
+
listData = {};
|
|
10164
|
+
listDataByForm = {};
|
|
10165
|
+
let dForm;
|
|
10166
|
+
for (dForm of dataForm) {
|
|
10167
|
+
if (!dForm.data) {
|
|
10168
|
+
continue;
|
|
10169
|
+
}
|
|
10170
|
+
const form = listForm.find(function (formTmp) {
|
|
10171
|
+
return formTmp.id == dForm.formId;
|
|
10172
|
+
});
|
|
10173
|
+
if (!form) {
|
|
10174
|
+
//console.error('No se encontró el formulario con id ' + dForm.formId);
|
|
10175
|
+
continue;
|
|
10176
|
+
}
|
|
10177
|
+
const keyFormTitle = TokenService.getKeyFormulario(form.title) + '_';
|
|
10178
|
+
for (const key in dForm.data) {
|
|
10179
|
+
listData[key] = dForm.data[key];
|
|
10180
|
+
listDataByForm[keyFormTitle + key] = dForm.data[key];
|
|
10181
|
+
}
|
|
10182
|
+
}
|
|
10183
|
+
}
|
|
10184
|
+
return {
|
|
10185
|
+
listData: listData,
|
|
10186
|
+
listDataByForm: listDataByForm
|
|
10187
|
+
};
|
|
10188
|
+
}
|
|
10189
|
+
/**
|
|
10190
|
+
* It returns the components
|
|
10191
|
+
* @param components
|
|
10192
|
+
*/
|
|
10193
|
+
static getPanelComponents(components) {
|
|
10194
|
+
return FormioUtil.getComponentsByPanel(components);
|
|
10195
|
+
}
|
|
10196
|
+
/**
|
|
10197
|
+
* It returns the components array of the form
|
|
10198
|
+
* @param components array of components
|
|
10199
|
+
*/
|
|
10200
|
+
static getComponentsByPanel(components) {
|
|
10201
|
+
// it contains the result array
|
|
10202
|
+
let result = [];
|
|
10203
|
+
if (components) {
|
|
10204
|
+
// iterate over components
|
|
10205
|
+
for (const component of components) {
|
|
10206
|
+
// avoid the editgrid component ot if it has a different behavior it should have an else statement
|
|
10207
|
+
if (component[EFormioKey.TYPE] !== EFormioKey.EDITGRID) {
|
|
10208
|
+
// if component is panel then titlePanel variable is changed, and it is gonna be inherited
|
|
10209
|
+
if (component[EFormioKey.TYPE] === EFormioKey.PANEL) {
|
|
10210
|
+
result.push(component);
|
|
10211
|
+
}
|
|
10212
|
+
}
|
|
10213
|
+
}
|
|
10214
|
+
}
|
|
10215
|
+
return result;
|
|
10216
|
+
}
|
|
10217
|
+
}
|
|
10218
|
+
|
|
10227
10219
|
class SendApplicationService {
|
|
10228
10220
|
constructor(environment, tokenService, emailService, interactionApplicationUserService) {
|
|
10229
10221
|
this.environment = environment;
|
|
@@ -15038,8 +15030,8 @@ const VERSION = {
|
|
|
15038
15030
|
},
|
|
15039
15031
|
"suffix": "1932-g573770da-dirty",
|
|
15040
15032
|
"semverString": "0.0.18+1932.g573770da",
|
|
15041
|
-
"version": "0.0.
|
|
15042
|
-
"buildTimestamp": "2022-12-
|
|
15033
|
+
"version": "0.0.1666",
|
|
15034
|
+
"buildTimestamp": "2022-12-14T14:12:03.733Z"
|
|
15043
15035
|
};
|
|
15044
15036
|
/* tslint:enable */
|
|
15045
15037
|
|