tuain-ng-forms-lib 12.0.37 → 12.0.42

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.
@@ -60,10 +60,11 @@ ActionComponent.propDecorators = {
60
60
  showLabel: [{ type: Input }]
61
61
  };
62
62
 
63
- const VALUE = '';
63
+ const VALUE = 'value';
64
+ const FOCUS = 'focus';
64
65
  class FieldComponent {
65
66
  ngOnInit() {
66
- var _a, _b, _c;
67
+ var _a, _b;
67
68
  if (this.field) {
68
69
  this.formConfig = (_a = this.field) === null || _a === void 0 ? void 0 : _a._formConfig;
69
70
  // Inicialización
@@ -72,8 +73,9 @@ class FieldComponent {
72
73
  const [fieldAttr1, compAttr1] = mapping[index];
73
74
  const compAttr = compAttr1.toString();
74
75
  const fieldAttr = fieldAttr1.toString();
75
- this.dafaultProcessFieldChange(compAttr, (_b = this.field) === null || _b === void 0 ? void 0 : _b[fieldAttr]);
76
- this.processFieldChange(compAttr, (_c = this.field) === null || _c === void 0 ? void 0 : _c[fieldAttr]);
76
+ const attributeValue = (_b = this.field) === null || _b === void 0 ? void 0 : _b[fieldAttr];
77
+ this.dafaultProcessFieldChange(compAttr, attributeValue);
78
+ this.processFieldChange(compAttr, attributeValue);
77
79
  }
78
80
  // Subscripción a cambios en atributos
79
81
  this.field.attributeChange.subscribe(event => {
@@ -89,6 +91,9 @@ class FieldComponent {
89
91
  if (attribute === VALUE) {
90
92
  this.updateValue();
91
93
  }
94
+ else if (attribute === FOCUS) {
95
+ this.focus();
96
+ }
92
97
  else {
93
98
  this[attribute] = value;
94
99
  }
@@ -296,7 +301,6 @@ class FormElement {
296
301
  this._visibleForced = false;
297
302
  this.disabled = (_a = elementDefinition === null || elementDefinition === void 0 ? void 0 : elementDefinition.disabled) !== null && _a !== void 0 ? _a : false;
298
303
  this.setVisibility((_b = elementDefinition === null || elementDefinition === void 0 ? void 0 : elementDefinition.visible) !== null && _b !== void 0 ? _b : true);
299
- this.widget = null;
300
304
  this.customAttributes = (_c = elementDefinition === null || elementDefinition === void 0 ? void 0 : elementDefinition.customAttributes) !== null && _c !== void 0 ? _c : {};
301
305
  }
302
306
  getCustomAttribute(name) { var _a, _b; return (_b = (_a = this.customAttributes) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : null; }
@@ -526,9 +530,9 @@ class RecordTable extends FormElement {
526
530
  this._selectionActionTrigger = new Subject();
527
531
  this._getDataTrigger = new Subject();
528
532
  this._attributeChange = new Subject();
529
- this.tableRecordObj = {};
530
533
  this._tableColumnObj = {};
531
534
  this._actionsObj = {};
535
+ this.tableRecordObj = {};
532
536
  this.allSelected = false;
533
537
  this.elementType = elementTypes.table;
534
538
  this.waiting = false;
@@ -997,7 +1001,6 @@ class LibTableComponent {
997
1001
  this.tableFieldStyles = this.formConfig.tableFieldStyles;
998
1002
  this.selectable = this.table.selectable;
999
1003
  this.hasActions = this.table.hasActions;
1000
- this.table.widget = this;
1001
1004
  this.inlineActions = this.table.getActions(this.formConfig.tableActions.inline);
1002
1005
  this.globalActions = this.table.getActions(this.formConfig.tableActions.global);
1003
1006
  this.selectionActions = this.table.getActions(this.formConfig.tableActions.selection);
@@ -1153,6 +1156,7 @@ const fldAttr = {
1153
1156
  maxValue: '_maxValue',
1154
1157
  maxLength: '_maxLength',
1155
1158
  onValidation: '_onValidation',
1159
+ focus: 'focus',
1156
1160
  intrinsicErrorMessage: '_intrinsicErrorMessage',
1157
1161
  code: 'fieldCode',
1158
1162
  info: 'fieldInfo',
@@ -1225,6 +1229,7 @@ class FieldDescriptor extends FormElement {
1225
1229
  get info() { return this.fieldInfo; }
1226
1230
  get validating() { return this._onValidation; }
1227
1231
  set validating(isValidating) { this.setAttr(fldAttr.onValidation, isValidating); }
1232
+ focus() { this.setAttr(fldAttr.focus, true); }
1228
1233
  setIntrinsicErrorMessage(message) { this.setAttr(fldAttr.intrinsicErrorMessage, message); }
1229
1234
  set intrinsicErrorMessage(message) { this.setIntrinsicErrorMessage(message); }
1230
1235
  get fieldValue() { return this.getValue(); }
@@ -1259,6 +1264,14 @@ class FieldDescriptor extends FormElement {
1259
1264
  this.setError('99', this._intrinsicErrorMessage);
1260
1265
  }
1261
1266
  }
1267
+ if (intrinsicValidation && fieldValue && this._minValue && fieldValue < this._minValue) {
1268
+ intrinsicValidation = false;
1269
+ this.setError('99', 'Campo con valor inferior al mínimo');
1270
+ }
1271
+ if (intrinsicValidation && fieldValue && this._maxValue && fieldValue > this._maxValue) {
1272
+ intrinsicValidation = false;
1273
+ this.setError('99', 'Campo con valor superior al máximo');
1274
+ }
1262
1275
  this._editionFinish.next({ code: this.fieldCode, intrinsicValidation });
1263
1276
  }
1264
1277
  setAttr(name, value) {
@@ -1313,6 +1326,10 @@ class FieldDescriptor extends FormElement {
1313
1326
  }
1314
1327
  return this._value;
1315
1328
  }
1329
+ getOptionText() {
1330
+ var _a, _b;
1331
+ return (_b = (_a = this.fieldOptions.find(item => item.fieldOptionId === this._value)) === null || _a === void 0 ? void 0 : _a.fieldOptionValue) !== null && _b !== void 0 ? _b : null;
1332
+ }
1316
1333
  updateFromServer(fld) {
1317
1334
  var _a;
1318
1335
  const fieldKeys = Object.keys(fld);
@@ -1776,6 +1793,7 @@ class FormStructureAndData {
1776
1793
  enableField(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.enable(); }
1777
1794
  disableField(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.disable(); }
1778
1795
  getFieldValue(code) { var _a; return (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.getValue(); }
1796
+ getFieldOptionText(code) { var _a; return (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.getOptionText(); }
1779
1797
  getFieldOptions(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.getFieldOptions(); }
1780
1798
  setFieldValue(code, value) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.setValue(value); }
1781
1799
  setFieldError(code, message, type = 'error') { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.setError(code, message, type); }
@@ -2157,90 +2175,28 @@ class BasicFormComponent {
2157
2175
  this.cleanStart();
2158
2176
  this.customPreProcessing();
2159
2177
  }
2160
- getTitle() {
2161
- var _a;
2162
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getTitle();
2163
- }
2164
- setTitle(title) {
2165
- var _a;
2166
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setTitle(title);
2167
- }
2168
- cleanData() {
2169
- var _a;
2170
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.cleanData();
2171
- }
2172
- getCurrentState() {
2173
- var _a;
2174
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getCurrentState();
2175
- }
2176
- supportState(state) {
2177
- var _a;
2178
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.supportState(state);
2179
- }
2180
- changeState(state) {
2181
- var _a;
2182
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.changeState(state);
2183
- }
2184
- getStates() {
2185
- var _a;
2186
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.states;
2187
- }
2188
- getImmutableElement(name) {
2189
- var _a;
2190
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getImmutableElement(name);
2191
- }
2192
- getExtraInfo(name) {
2193
- var _a;
2194
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getExtraInfo(name);
2195
- }
2196
- getFields() {
2197
- var _a;
2198
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFields();
2199
- }
2200
- getFieldNames() {
2201
- var _a;
2202
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldNames();
2203
- }
2204
- getField(code) {
2205
- var _a;
2206
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getField(code);
2207
- }
2208
- enableField(code) {
2209
- var _a;
2210
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.enableField(code);
2211
- }
2212
- disableField(code) {
2213
- var _a;
2214
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.disableField(code);
2215
- }
2216
- getFieldValue(code) {
2217
- var _a;
2218
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldValue(code);
2219
- }
2220
- getFieldsValues(codes) {
2221
- var _a;
2222
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldsValues(codes);
2223
- }
2224
- getFieldOptions(code) {
2225
- var _a;
2226
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldOptions(code);
2227
- }
2228
- setFieldValue(code, value) {
2229
- var _a;
2230
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldValue(code, value);
2231
- }
2232
- setFieldRequired(code, required) {
2233
- var _a;
2234
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldRequired(code, required);
2235
- }
2236
- setFieldErrorMessage(code, errorMessage) {
2237
- var _a;
2238
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldErrorMessage(code, errorMessage);
2239
- }
2240
- setFieldError(code, message, type) {
2241
- var _a;
2242
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldError(code, message, type);
2243
- }
2178
+ getTitle() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getTitle(); }
2179
+ setTitle(title) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setTitle(title); }
2180
+ cleanData() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.cleanData(); }
2181
+ getCurrentState() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getCurrentState(); }
2182
+ supportState(state) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.supportState(state); }
2183
+ changeState(state) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.changeState(state); }
2184
+ getStates() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.states; }
2185
+ getImmutableElement(name) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getImmutableElement(name); }
2186
+ getExtraInfo(name) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getExtraInfo(name); }
2187
+ getFields() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFields(); }
2188
+ getFieldNames() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldNames(); }
2189
+ getField(code) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getField(code); }
2190
+ enableField(code) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.enableField(code); }
2191
+ disableField(code) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.disableField(code); }
2192
+ getFieldValue(code) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldValue(code); }
2193
+ getFieldOptionText(code) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldOptionText(code); }
2194
+ getFieldsValues(codes) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldsValues(codes); }
2195
+ getFieldOptions(code) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldOptions(code); }
2196
+ setFieldValue(code, value) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldValue(code, value); }
2197
+ setFieldRequired(code, required) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldRequired(code, required); }
2198
+ setFieldErrorMessage(code, errorMessage) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldErrorMessage(code, errorMessage); }
2199
+ setFieldError(code, message, type) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldError(code, message, type); }
2244
2200
  setFieldIntrinsicErrorMessage(code, message) {
2245
2201
  var _a;
2246
2202
  return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldIntrinsicErrorMessage(code, message);
@@ -3507,11 +3463,8 @@ class BasicFormComponent {
3507
3463
  this.tagFieldsWithError(requiredEmptyFields, null, this.formConfig.formStandardErrors.requiredField);
3508
3464
  for (const fieldCode of requiredEmptyFields) {
3509
3465
  const requiredEmptyField = this.getField(fieldCode);
3510
- if (requiredEmptyField && requiredEmptyField.widget
3511
- && requiredEmptyField.widget.focus) {
3512
- requiredEmptyField.widget.focus();
3513
- break;
3514
- }
3466
+ requiredEmptyField === null || requiredEmptyField === void 0 ? void 0 : requiredEmptyField.focus();
3467
+ break;
3515
3468
  }
3516
3469
  }
3517
3470
  const validationIssueFields = this.getFieldsWithValidationIssues(null, sectionCode);
@@ -3520,11 +3473,8 @@ class BasicFormComponent {
3520
3473
  this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
3521
3474
  for (const fieldCode of validationIssueFields) {
3522
3475
  const validationIssueField = this.getField(fieldCode);
3523
- if (validationIssueField && validationIssueField.widget
3524
- && validationIssueField.widget.focus) {
3525
- validationIssueField.widget.focus();
3526
- break;
3527
- }
3476
+ validationIssueField.focus();
3477
+ break;
3528
3478
  }
3529
3479
  }
3530
3480
  return validationError;