tuain-ng-forms-lib 0.12.31 → 0.12.35

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.
@@ -143,40 +143,12 @@ const DEFAULT_STATE_FLOW = {
143
143
  ]
144
144
  };
145
145
 
146
- const MONITORED_ATTRIBUTES$1 = {
147
- _maxLength: 'maxLength',
148
- _onValidation: '_onValidation',
149
- _fieldValue: 'value',
150
- captureType: 'captureType',
151
- fieldTitle: 'fieldTitle',
152
- fieldType: 'fieldType',
153
- errorMessage: 'errorMessage',
154
- errorType: 'errorType',
155
- errorCode: 'errorCode',
156
- visibleLabel: 'visibleLabel',
157
- fieldRequired: 'fieldRequired',
158
- fieldOptions: 'fieldOptions',
159
- };
160
146
  class FieldComponent {
161
147
  constructor() {
162
148
  this.componentConstants = Object.assign({}, componentConstants);
163
149
  }
164
150
  ngOnInit() {
165
- if (this.fieldObject) {
166
- // Atributos estáticos
167
- this.code = this.fieldObject.fieldCode;
168
- this.fieldInfo = this.fieldObject.fieldInfo;
169
- this.fieldAlignment = this.fieldObject.fieldAlignment;
170
- this.tooltipText = this.fieldObject.tooltipText;
171
- this.fieldObject.widget = this;
172
- // Atributos dinámicos
173
- this.fieldObject.attributeChange.subscribe(event => {
174
- const { name, value } = event;
175
- if (this[MONITORED_ATTRIBUTES$1[name]]) {
176
- this[MONITORED_ATTRIBUTES$1[name]] = value;
177
- }
178
- });
179
- }
151
+ this.fieldObject.widget = this;
180
152
  this.start();
181
153
  }
182
154
  start() { }
@@ -339,9 +311,9 @@ class FormElement {
339
311
  this.setVisibility((_b = elementDefinition === null || elementDefinition === void 0 ? void 0 : elementDefinition.visible) !== null && _b !== void 0 ? _b : true);
340
312
  this.widget = null;
341
313
  }
342
- isField() { return this.elementType === componentConstants.ELEMENTTYPE_FIELD; }
343
- isAction() { return this.elementType === componentConstants.ELEMENTTYPE_ACTION; }
344
- isTable() { return this.elementType === componentConstants.ELEMENTTYPE_TABLE; }
314
+ isField() { return this.type === componentConstants.ELEMENTTYPE_FIELD; }
315
+ isAction() { return this.type === componentConstants.ELEMENTTYPE_ACTION; }
316
+ isTable() { return this.type === componentConstants.ELEMENTTYPE_TABLE; }
345
317
  setVisibleStates(newStates) {
346
318
  const visibleStates = (!Array.isArray(newStates) && typeof newStates === 'string')
347
319
  ? newStates.split(',').map(state => state.trim()).filter(state => state.length > 0)
@@ -620,7 +592,7 @@ class RecordTable extends FormElement {
620
592
  this._tableColumnObj = {};
621
593
  this._actionsObj = {};
622
594
  this.allSelected = false;
623
- this.elementType = componentConstants.ELEMENTTYPE_TABLE;
595
+ this.type = componentConstants.ELEMENTTYPE_TABLE;
624
596
  this.waiting = false;
625
597
  this.complexFilter = false;
626
598
  this.currentPage = 1;
@@ -1198,7 +1170,7 @@ class RecordFormSubSection {
1198
1170
  break;
1199
1171
  }
1200
1172
  if (elementObject) {
1201
- elementObject.elementType = type;
1173
+ elementObject.type = type;
1202
1174
  arrayToAdd.push(elementObject);
1203
1175
  this.subSectionElements.push(elementObject);
1204
1176
  this.elementsArray[code] = elementObject;
@@ -1335,7 +1307,7 @@ class FormAction extends FormElement {
1335
1307
  super(actionDefinition);
1336
1308
  this._actionActivated = new Subject();
1337
1309
  this.inProgress = false;
1338
- this.elementType = componentConstants.ELEMENTTYPE_ACTION;
1310
+ this.type = componentConstants.ELEMENTTYPE_ACTION;
1339
1311
  this.actionCode = actionDefinition.actionCode ? actionDefinition.actionCode.toString() : '';
1340
1312
  this.actionName = actionDefinition.actionTitle;
1341
1313
  this.iconName = actionDefinition.iconName || this.actionCode;
@@ -1378,7 +1350,6 @@ const FIELD_TOOLTIP = 'tooltipText';
1378
1350
  const FIELD_INFO = 'info';
1379
1351
  const FIELD_EDITABLE = 'editable';
1380
1352
  const FIELD_TYPES = {
1381
- boolean: 'BOOLEAN',
1382
1353
  array: 'ARRAY',
1383
1354
  check: 'CHECK',
1384
1355
  date: 'DATE',
@@ -1404,111 +1375,64 @@ const FIELD_TYPES = {
1404
1375
  phone: 'PHONE',
1405
1376
  };
1406
1377
  const FIELD_TYPES_FORMATS = {
1407
- EMAIL: new RegExp('^\\w+([\\.-]?\\w+)@\\w+([\\.-]?\\w+)(\\.\\w{2,3})+$'),
1378
+ EMAIL: '^\\w+([\\.-]?\\w+)@\\w+([\\.-]?\\w+)(\\.\\w{2,3})+$',
1408
1379
  };
1409
- const INTRINSIC_ERROR_MESSAGES = {
1410
- EMAIL: `El valor no corresponde a un correo válido`,
1411
- DEFAULT: `El valor no se ajusta al formato establecido`,
1412
- };
1413
- const DEFAULT_ERROR_TYPE = 'error';
1414
- const DEFAULT_CAPTURE_TYPE = 'INPUT';
1415
- const DEFAULT_ALIGNMENT = 'left';
1416
- const MONITORED_ATTRIBUTES = ['_maxLength', '_onValidation', 'captureType', 'fieldTitle', 'fieldType',
1417
- 'errorMessage', 'errorType', 'errorCode', 'visibleLabel', 'fieldRequired', 'fieldOptions', '_fieldValue'];
1418
1380
  const STD_MAX_LENGTH = 50;
1419
1381
  const BIG_MAX_LENGTH = 500;
1420
- const fldAttr = {
1421
- validateOnServer: 'validateOnServer',
1422
- value: '_fieldValue',
1423
- minValue: '_minValue',
1424
- maxValue: '_maxValue',
1425
- maxLength: '_maxLength',
1426
- onValidation: '_onValidation',
1427
- intrinsicErrorMessage: '_intrinsicErrorMessage',
1428
- code: 'fieldCode',
1429
- info: 'fieldInfo',
1430
- defaultValue: 'defaultValue',
1431
- defaultEditable: 'defaultEditable',
1432
- customAttributes: 'customAttributes',
1433
- visibleLabel: 'visibleLabel',
1434
- required: 'fieldRequired',
1435
- hasChanged: 'hasChanged',
1436
- outputOnly: 'outputOnly',
1437
- captureType: 'captureType',
1438
- title: 'fieldTitle',
1439
- type: 'fieldType',
1440
- alignment: 'fieldAlignment',
1441
- format: 'fieldFormat',
1442
- externalValue: 'externalValue',
1443
- tooltipText: 'tooltipText',
1444
- errorType: 'errorType',
1445
- errorCode: 'errorCode',
1446
- errorMessage: 'errorMessage',
1447
- options: 'fieldOptions',
1448
- };
1449
1382
  class FieldDescriptor extends FormElement {
1450
1383
  constructor(inputFieldReceived) {
1451
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1384
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1452
1385
  super(inputFieldReceived);
1453
1386
  this._editionFinish = new Subject();
1454
1387
  this._editionPartial = new Subject();
1455
1388
  this._detailRequest = new Subject();
1456
- this._attributeChange = new Subject();
1457
- this.elementType = componentConstants.ELEMENTTYPE_FIELD;
1458
- const fld = (inputFieldReceived) ? inputFieldReceived : {};
1459
- this.setAttr(fldAttr.code, fld.fieldCode);
1460
- this.setAttr(fldAttr.title, (_a = fld.fieldTitle) !== null && _a !== void 0 ? _a : this.fieldCode);
1461
- this.setAttr(fldAttr.captureType, (_b = fld.captureType) !== null && _b !== void 0 ? _b : DEFAULT_CAPTURE_TYPE);
1462
- this.setAttr(fldAttr.defaultValue, (_c = fld.defaultValue) !== null && _c !== void 0 ? _c : null);
1463
- const defaultTypeAlignment = (tableFieldStyles[this.fieldType] != null)
1464
- ? tableFieldStyles[this.fieldType]['text-align'] : DEFAULT_ALIGNMENT;
1465
- const fieldAlignment = (fld.alignment != null) ? fld.alignment.toLowerCase() : defaultTypeAlignment;
1466
- this.setAttr(fldAttr.alignment, fieldAlignment);
1467
- this.setAttr(fldAttr.info, fld.info || '');
1468
- let fieldFormat;
1469
- try {
1470
- fieldFormat = (fld.format) ? new RegExp(fld.format) : null;
1471
- }
1472
- catch (e) {
1473
- fieldFormat = null;
1474
- }
1475
- this.setAttr(fldAttr.format, fieldFormat);
1476
- this.setAttr(fldAttr.validateOnServer, (_d = fld.serverAction) !== null && _d !== void 0 ? _d : false);
1477
- this.setAttr(fldAttr.customAttributes, (_e = fld.customAttributes) !== null && _e !== void 0 ? _e : {});
1478
- this.setAttr(fldAttr.tooltipText, fld.tooltip || '');
1479
- this.setAttr(fldAttr.defaultEditable, this.enabled);
1480
- this.setAttr(fldAttr.required, (_f = fld.required) !== null && _f !== void 0 ? _f : false);
1481
- this.setError(fld.errorCode, fld.errorMessage, (_g = fld.errorType) !== null && _g !== void 0 ? _g : DEFAULT_ERROR_TYPE);
1482
- this.setAttr(fldAttr.outputOnly, (_h = fld.outputOnly) !== null && _h !== void 0 ? _h : false);
1483
- const maxLength = (_j = fld.maxLength) !== null && _j !== void 0 ? _j : (this.captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
1484
- this.setAttr(fldAttr.maxLength, maxLength);
1485
- this.setAttr(fldAttr.intrinsicErrorMessage, (_k = INTRINSIC_ERROR_MESSAGES[this.fieldType]) !== null && _k !== void 0 ? _k : INTRINSIC_ERROR_MESSAGES.DEFAULT);
1486
- this.setFieldType(fld.fieldTypeCode);
1487
- this.setEditable((_l = fld.editable) !== null && _l !== void 0 ? _l : true);
1488
- this.setVisibleLabel((_m = fld.visibleLabel) !== null && _m !== void 0 ? _m : true);
1489
- this.setVisibility(fld.visible);
1490
- this.setFieldOptions(fld.fieldOptions);
1491
- this.setValue(fld.fieldValue || this.defaultValue || '');
1389
+ this.type = componentConstants.ELEMENTTYPE_FIELD;
1390
+ const fieldReceived = (inputFieldReceived) ? inputFieldReceived : {};
1391
+ this.setEditable((_a = fieldReceived === null || fieldReceived === void 0 ? void 0 : fieldReceived.editable) !== null && _a !== void 0 ? _a : true);
1392
+ this.fieldCode = fieldReceived.fieldCode;
1393
+ this.fieldTitle = fieldReceived.fieldTitle || this.fieldCode;
1394
+ this.captureType = fieldReceived.captureType || 'INPUT';
1395
+ this.setFieldType(fieldReceived.fieldTypeCode);
1396
+ this.defaultValue = fieldReceived.defaultValue || null;
1397
+ this._maxLength = (_b = fieldReceived.maxLength) !== null && _b !== void 0 ? _b : (this.captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
1398
+ this.setValue(fieldReceived.fieldValue || this.defaultValue || '');
1399
+ const defaultTypeAlignment = (tableFieldStyles[this.fieldType] != null) ? tableFieldStyles[this.fieldType]['text-align'] : 'left';
1400
+ this.fieldAlignment = (fieldReceived.alignment != null) ? fieldReceived.alignment.toLowerCase() : defaultTypeAlignment;
1401
+ this.fieldInfo = fieldReceived.info || '';
1402
+ this.fieldFormat = fieldReceived.format || null;
1403
+ this.validateOnServer = (_c = fieldReceived === null || fieldReceived === void 0 ? void 0 : fieldReceived.serverAction) !== null && _c !== void 0 ? _c : false;
1404
+ this.customAttributes = (_d = fieldReceived === null || fieldReceived === void 0 ? void 0 : fieldReceived.customAttributes) !== null && _d !== void 0 ? _d : null;
1405
+ this.setVisibility(fieldReceived.visible);
1406
+ this.visibleLabel = (_e = fieldReceived === null || fieldReceived === void 0 ? void 0 : fieldReceived.visibleLabel) !== null && _e !== void 0 ? _e : true;
1407
+ this.tooltipText = fieldReceived.tooltip || '';
1408
+ this.defaultEditable = this.enabled;
1409
+ this.fieldRequired = (_f = fieldReceived === null || fieldReceived === void 0 ? void 0 : fieldReceived.required) !== null && _f !== void 0 ? _f : false;
1410
+ this.errorMessage = fieldReceived.errorMessage || '';
1411
+ this.errorCode = (_g = fieldReceived.errorCode) !== null && _g !== void 0 ? _g : '00';
1412
+ this.outputOnly = (_h = fieldReceived === null || fieldReceived === void 0 ? void 0 : fieldReceived.outputOnly) !== null && _h !== void 0 ? _h : false;
1413
+ this.setFieldOptions(fieldReceived.fieldOptions);
1414
+ this._intrinsicErrorMessage = (this.fieldType === FIELD_TYPES.email)
1415
+ ? `El valor de ${this.fieldTitle} no corresponde a un correo válido`
1416
+ : `El valor de ${this.fieldTitle} no se ajusta al formato establecido`;
1492
1417
  }
1493
1418
  get name() { return this.fieldCode; }
1494
1419
  get editionFinish() { return this._editionFinish; }
1495
- get attributeChange() { return this._attributeChange; }
1496
1420
  get editionPartial() { return this._editionPartial; }
1497
1421
  get detailRequest() { return this._detailRequest; }
1498
1422
  get validating() { return this._onValidation; }
1499
- set validating(isValidating) { this.setAttr(fldAttr.onValidation, isValidating); }
1500
- setIntrinsicErrorMessage(message) { this.setAttr(fldAttr.intrinsicErrorMessage, message); }
1423
+ set validating(isValidating) { this._onValidation = isValidating; }
1424
+ setIntrinsicErrorMessage(message) { this._intrinsicErrorMessage = message; }
1501
1425
  set intrinsicErrorMessage(message) { this.setIntrinsicErrorMessage(message); }
1502
1426
  get fieldValue() { return this.getValue(); }
1503
1427
  get required() { return this.fieldRequired; }
1504
- set required(required) { this.setAttr(fldAttr.required, required !== null && required !== void 0 ? required : false); }
1428
+ set required(required) { this.fieldRequired = required !== null && required !== void 0 ? required : false; }
1505
1429
  get maxLength() { return (this._maxLength > 0) ? this._maxLength.toString() : ''; }
1506
1430
  set maxLength(requiredMaxLength) {
1507
1431
  if (typeof requiredMaxLength === 'string') {
1508
- this.setAttr(fldAttr.maxLength, parseInt(requiredMaxLength, 10));
1432
+ this._maxLength = parseInt(requiredMaxLength, 10);
1509
1433
  }
1510
1434
  else if (typeof requiredMaxLength === 'number') {
1511
- this.setAttr(fldAttr.maxLength, requiredMaxLength);
1435
+ this._maxLength = requiredMaxLength;
1512
1436
  }
1513
1437
  }
1514
1438
  get value() { return this.getValue(); }
@@ -1518,49 +1442,41 @@ class FieldDescriptor extends FormElement {
1518
1442
  this._editionPartial.next({ code: this.fieldCode, intrinsicValidation });
1519
1443
  }
1520
1444
  notifyEditionFinish() {
1521
- var _a, _b, _c, _d;
1445
+ var _a, _b;
1522
1446
  let intrinsicValidation = true;
1523
- const fieldDefaultFormat = (_a = FIELD_TYPES_FORMATS === null || FIELD_TYPES_FORMATS === void 0 ? void 0 : FIELD_TYPES_FORMATS[this.fieldType]) !== null && _a !== void 0 ? _a : null;
1447
+ const fieldDefaultFormat = (FIELD_TYPES_FORMATS === null || FIELD_TYPES_FORMATS === void 0 ? void 0 : FIELD_TYPES_FORMATS[this.fieldType])
1448
+ ? new RegExp(FIELD_TYPES_FORMATS === null || FIELD_TYPES_FORMATS === void 0 ? void 0 : FIELD_TYPES_FORMATS[this.fieldType]) : null;
1449
+ const fieldFormat = (this.fieldFormat) ? new RegExp(this.fieldFormat) : null;
1524
1450
  const fieldValue = this.getValue();
1525
- if (fieldValue && (fieldDefaultFormat || this.fieldFormat)) {
1526
- intrinsicValidation = ((_b = fieldDefaultFormat === null || fieldDefaultFormat === void 0 ? void 0 : fieldDefaultFormat.test(fieldValue)) !== null && _b !== void 0 ? _b : true)
1527
- && ((_d = (_c = this.fieldFormat) === null || _c === void 0 ? void 0 : _c.test(fieldValue)) !== null && _d !== void 0 ? _d : true);
1451
+ if (fieldValue && (fieldDefaultFormat || fieldFormat)) {
1452
+ intrinsicValidation = ((_a = fieldDefaultFormat === null || fieldDefaultFormat === void 0 ? void 0 : fieldDefaultFormat.test(fieldValue)) !== null && _a !== void 0 ? _a : true)
1453
+ && ((_b = fieldFormat === null || fieldFormat === void 0 ? void 0 : fieldFormat.test(fieldValue)) !== null && _b !== void 0 ? _b : true);
1528
1454
  if (!intrinsicValidation) {
1529
1455
  this.setError('99', this._intrinsicErrorMessage);
1530
1456
  }
1531
1457
  }
1532
1458
  this._editionFinish.next({ code: this.fieldCode, intrinsicValidation });
1533
1459
  }
1534
- setAttr(name, value) {
1535
- if (this[name]) {
1536
- this[name] = value;
1537
- }
1538
- if (MONITORED_ATTRIBUTES.includes(name)) {
1539
- this._attributeChange.next({ name, value });
1540
- }
1541
- }
1542
1460
  notifyEditionDetailRequest() {
1543
1461
  this._detailRequest.next(this.fieldCode);
1544
1462
  }
1545
- setVisibleLabel(visibleLabel) { this.setAttr(fldAttr.visibleLabel, visibleLabel); }
1546
- showLabel() { this.setVisibleLabel(true); }
1547
- hideLabel() { this.setVisibleLabel(false); }
1548
- setChanged(hasChanged) { this.setAttr(fldAttr.hasChanged, hasChanged); }
1549
- changed() { this.setChanged(true); }
1463
+ showLabel() { this.visibleLabel = true; }
1464
+ hideLabel() { this.visibleLabel = false; }
1465
+ changed() { this.hasChanged = true; }
1550
1466
  getRawValue() { return this._fieldValue; }
1551
- setLabel(label) { this.setAttr(fldAttr.title, label); }
1467
+ setLabel(label) { this.fieldTitle = label; }
1552
1468
  clean() { this.setValue(this.defaultValue || ''); }
1553
1469
  get backend() { return this.validateOnServer; }
1470
+ setVisibleLabel(visibleLabel) { this.visibleLabel = visibleLabel; }
1554
1471
  setEditable(editable = true) { (editable) ? this.enable() : this.disable(); }
1555
- hasError() { return this.errorCode !== '00'; }
1556
- setError(code, message, type = DEFAULT_ERROR_TYPE) {
1557
- this.setAttr(fldAttr.errorCode, code !== null && code !== void 0 ? code : '00');
1558
- this.setAttr(fldAttr.errorType, (this.errorCode === '00') ? '' : type);
1559
- this.setAttr(fldAttr.errorMessage, message !== null && message !== void 0 ? message : '');
1472
+ setError(code, message, type = 'error') {
1473
+ this.errorType = (code === '00') ? '' : type;
1474
+ this.errorCode = code;
1475
+ this.errorMessage = message;
1560
1476
  }
1561
1477
  getError() { return { type: this.errorType, code: this.errorCode, message: this.errorMessage }; }
1562
1478
  get error() { return this.getError(); }
1563
- set error(errorObj) { var _a; this.setError(errorObj.code, errorObj.message, (_a = errorObj.type) !== null && _a !== void 0 ? _a : DEFAULT_ERROR_TYPE); }
1479
+ set error(errorObj) { this.setError(errorObj.code, errorObj.message, errorObj.type); }
1564
1480
  getErrorCode() { return this.getError().code; }
1565
1481
  setErrorCode(code) { this.setError(code, this.errorMessage); }
1566
1482
  getErrorMessage() { return this.getError().message; }
@@ -1593,39 +1509,68 @@ class FieldDescriptor extends FormElement {
1593
1509
  }
1594
1510
  updateFromServer(fld) {
1595
1511
  var _a;
1596
- const fieldKeys = Object.keys(fld);
1597
- for (let index = 0; index < fieldKeys.length; index++) {
1598
- const attrName = fieldKeys[index];
1599
- const attrValue = fld[attrName];
1600
- (attrName === FIELD_VISIBLE) && this.setVisibility(attrValue);
1601
- (attrName === FIELD_LABEL_VISIBLE) && this.setVisibleLabel(fld.visibleLabel);
1602
- (attrName === FIELD_REQUIRED) && this.setAttr(fldAttr.required, (_a = fld.required) !== null && _a !== void 0 ? _a : false);
1603
- (attrName === FIELD_ERR_CODE) && this.setAttr(fldAttr.errorCode, fld.errorCode);
1604
- (attrName === FIELD_ERR_MSG) && this.setAttr(fldAttr.errorMessage, fld.errorMessage);
1605
- (attrName === FIELD_TOOLTIP) && this.setAttr(fldAttr.tooltipText, fld.tooltip);
1606
- (attrName === FIELD_INFO) && this.setAttr(fldAttr.info, fld.info);
1607
- (attrName === FIELD_EDITABLE) && this.setEditable(fld.editable);
1608
- (attrName === FIELD_TITLE) && this.setLabel(fld.fieldTitle.toString());
1609
- (attrName === FIELD_VALUE) && (this.setValue(fld._fieldValue) && this.setChanged(false));
1610
- (attrName === FIELD_OPTIONS) && this.setFieldOptions(fld.fieldOptions);
1611
- (attrName === FIELD_CAPTURE_TYPE) && this.setAttr(fldAttr.captureType, fld.captureType || 'INPUT');
1612
- (attrName === FIELD_TYPE) && this.setFieldType(fld.fieldTypeCode);
1613
- (attrName === FIELD_MAX_LENGTH) && this.setAttr(fldAttr.maxLength, fld.maxLength);
1512
+ if (FIELD_VISIBLE in fld) {
1513
+ this.setVisibility(fld.visible);
1514
+ }
1515
+ if (FIELD_LABEL_VISIBLE in fld) {
1516
+ this.setVisibleLabel(fld.visibleLabel);
1517
+ }
1518
+ if (FIELD_REQUIRED in fld) {
1519
+ this.fieldRequired = (_a = fld.required) !== null && _a !== void 0 ? _a : false;
1520
+ }
1521
+ if (FIELD_ERR_CODE in fld) {
1522
+ (this.errorCode = fld.errorCode);
1523
+ }
1524
+ if (FIELD_ERR_MSG in fld) {
1525
+ (this.errorMessage = fld.errorMessage);
1526
+ }
1527
+ if (FIELD_TOOLTIP in fld) {
1528
+ (this.tooltipText = fld.tooltip);
1529
+ }
1530
+ if (FIELD_INFO in fld) {
1531
+ (this.fieldInfo = fld.info);
1532
+ }
1533
+ if (FIELD_EDITABLE in fld) {
1534
+ this.setEditable(fld.editable);
1535
+ }
1536
+ if (FIELD_TITLE in fld) {
1537
+ this.setLabel(fld.fieldTitle.toString());
1538
+ }
1539
+ if (FIELD_VALUE in fld) {
1540
+ this.hasChanged = false;
1541
+ this.setValue(fld.fieldValue);
1542
+ }
1543
+ if (FIELD_OPTIONS in fld) {
1544
+ this.setFieldOptions(fld.fieldOptions);
1545
+ }
1546
+ if (FIELD_CAPTURE_TYPE in fld) {
1547
+ this.captureType = fld.captureType || 'INPUT';
1548
+ }
1549
+ if (FIELD_TYPE in fld) {
1550
+ this.setFieldType(fld.fieldTypeCode);
1551
+ }
1552
+ if (FIELD_MAX_LENGTH in fld) {
1553
+ this.maxLength = fld.maxLength;
1614
1554
  }
1615
1555
  }
1616
1556
  setFieldType(inputFieldType) {
1617
- this.setAttr(fldAttr.type, inputFieldType);
1557
+ this.fieldType = inputFieldType;
1558
+ /**
1559
+ * Se elimina la validación de que sea un tipo conocido
1560
+ * this.fieldType = (inputFieldType && FIELDTYPES.includes(inputFieldType))
1561
+ * ? inputFieldType : componentConstants.FIELDTYPE_TEXT;
1562
+ */
1618
1563
  }
1619
1564
  format() {
1620
1565
  if (this.fieldType === componentConstants.FIELDTYPE_CURRENCY) {
1621
- this.setAttr(fldAttr.value, formatCurrency(this._fieldValue));
1566
+ this._fieldValue = formatCurrency(this._fieldValue);
1622
1567
  }
1623
1568
  }
1624
1569
  setMinValue(minValue) {
1625
1570
  var _a, _b, _c;
1626
1571
  if (this.fieldType === componentConstants.FIELDTYPE_DATE
1627
1572
  && ((_a = this.widget) === null || _a === void 0 ? void 0 : _a.setMinValue)) {
1628
- this.setAttr(fldAttr.minValue, minValue);
1573
+ this._minValue = minValue;
1629
1574
  if (!minValue) {
1630
1575
  (_b = this.widget) === null || _b === void 0 ? void 0 : _b.setMinValue(false);
1631
1576
  }
@@ -1639,7 +1584,7 @@ class FieldDescriptor extends FormElement {
1639
1584
  var _a, _b, _c;
1640
1585
  if (this.fieldType === componentConstants.FIELDTYPE_DATE
1641
1586
  && ((_a = this.widget) === null || _a === void 0 ? void 0 : _a.setMaxValue)) {
1642
- this.setAttr(fldAttr.maxValue, maxValue);
1587
+ this._maxValue = maxValue;
1643
1588
  if (!maxValue) {
1644
1589
  (_b = this.widget) === null || _b === void 0 ? void 0 : _b.setMaxValue(false);
1645
1590
  }
@@ -1659,23 +1604,21 @@ class FieldDescriptor extends FormElement {
1659
1604
  || !Array.isArray(newOptions)) {
1660
1605
  return;
1661
1606
  }
1662
- let fieldOptions = newOptions.map(option => {
1607
+ const fieldOptions = newOptions.map(option => {
1663
1608
  if (option.text !== undefined && option.text !== null
1664
1609
  && option.value !== undefined && option.value !== null) {
1665
1610
  return { fieldOptionValue: option.text, fieldOptionId: option.value };
1666
1611
  }
1667
1612
  return Object.assign({}, option);
1668
1613
  });
1669
- fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
1614
+ this.fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
1670
1615
  && fieldOptions.length > 0) ? fieldOptions : [];
1671
- this.setAttr(fldAttr.options, fieldOptions);
1672
1616
  if (this.fieldType === componentConstants.FIELDTYPE_ARRAY && this.widget) {
1673
1617
  return (_a = this.widget) === null || _a === void 0 ? void 0 : _a.refereshContent();
1674
1618
  }
1675
1619
  if (this._fieldValue) {
1676
1620
  if (this.fieldType === componentConstants.FIELDTYPE_ARRAY && Array.isArray(this._fieldValue)) {
1677
- const fieldValue = (_b = this._fieldValue) === null || _b === void 0 ? void 0 : _b.filter(item => this.fieldOptions.find(opt => opt.fieldOptionId === item));
1678
- this.setAttr(fldAttr.value, fieldValue);
1621
+ this._fieldValue = (_b = this._fieldValue) === null || _b === void 0 ? void 0 : _b.filter(item => this.fieldOptions.find(opt => opt.fieldOptionId === item));
1679
1622
  }
1680
1623
  else {
1681
1624
  const valInOptions = this.fieldOptions
@@ -1695,7 +1638,7 @@ class FieldDescriptor extends FormElement {
1695
1638
  setValue(newValue, widgetUpdate = true) {
1696
1639
  var _a;
1697
1640
  if (typeof newValue === UNDEFINED || newValue === null) {
1698
- return true;
1641
+ return;
1699
1642
  }
1700
1643
  let newFinalValue;
1701
1644
  switch (this.fieldType) {
@@ -1735,10 +1678,9 @@ class FieldDescriptor extends FormElement {
1735
1678
  break;
1736
1679
  }
1737
1680
  if (this._fieldValue !== newFinalValue) {
1738
- this.setChanged(true);
1739
- this.setAttr(fldAttr.value, newFinalValue);
1681
+ this.hasChanged = true;
1682
+ this._fieldValue = newFinalValue;
1740
1683
  }
1741
- return true;
1742
1684
  }
1743
1685
  }
1744
1686
 
@@ -2108,8 +2050,8 @@ class FormStructureAndData {
2108
2050
  const fieldObject = this.getFieldObject(fieldCode);
2109
2051
  return (fieldObject) ? fieldObject.setValue(fieldValue) : null;
2110
2052
  }
2111
- setFieldError(code, message, type = 'error') {
2112
- const fieldObject = this.getFieldObject(code);
2053
+ setFieldError(fieldCode, code, message, type = 'error') {
2054
+ const fieldObject = this.getFieldObject(fieldCode);
2113
2055
  return (fieldObject) ? fieldObject.setError(code, message, type) : null;
2114
2056
  }
2115
2057
  setFieldIntrinsicErrorMessage(code, message) {
@@ -2496,7 +2438,7 @@ class BasicFormComponent {
2496
2438
  setFieldValue(fieldCode, fieldValue) { return this.formStructure.setFieldValue(fieldCode, fieldValue); }
2497
2439
  setFieldRequired(fieldCode, required) { return this.formStructure.setFieldRequired(fieldCode, required); }
2498
2440
  setFieldErrorMessage(fieldCode, errorMessage) { return this.formStructure.setFieldErrorMessage(fieldCode, errorMessage); }
2499
- setFieldError(code, message, type = 'error') { return this.formStructure.setFieldError(code, message, type); }
2441
+ setFieldError(fieldCode, code, message, type = 'error') { return this.formStructure.setFieldError(fieldCode, code, message, type); }
2500
2442
  setFieldIntrinsicErrorMessage(code, message) { return this.formStructure.setFieldIntrinsicErrorMessage(code, message); }
2501
2443
  setFieldOptions(fieldCode, optionsArray, idAttribute, nameAttribute) {
2502
2444
  return this.formStructure.setFieldOptions(fieldCode, optionsArray, idAttribute, nameAttribute);