tuain-ng-forms-lib 12.0.2 → 12.0.3

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.
@@ -54,230 +54,6 @@
54
54
  showLabel: [{ type: core.Input }]
55
55
  };
56
56
 
57
- var MONITORED_ATTRIBUTES = {
58
- _maxLength: 'maxLength',
59
- _onValidation: 'onValidation',
60
- _fieldValue: 'value',
61
- captureType: 'captureType',
62
- fieldTitle: 'title',
63
- fieldType: 'type',
64
- errorMessage: 'errorMessage',
65
- errorType: 'errorType',
66
- errorCode: 'errorCode',
67
- visibleLabel: 'visibleLabel',
68
- fieldRequired: 'required',
69
- fieldOptions: 'options',
70
- };
71
- var FieldComponent = /** @class */ (function () {
72
- function FieldComponent() {
73
- }
74
- FieldComponent.prototype.ngOnInit = function () {
75
- var _this = this;
76
- var _a;
77
- if (this.fieldObject) {
78
- this.formConfig = (_a = this.fieldObject) === null || _a === void 0 ? void 0 : _a._formConfig;
79
- // Atributos estáticos
80
- this.code = this.fieldObject.fieldCode;
81
- this.fieldInfo = this.fieldObject.fieldInfo;
82
- this.fieldAlignment = this.fieldObject.fieldAlignment;
83
- this.tooltipText = this.fieldObject.tooltipText;
84
- // Cargue inicial
85
- this.maxLength = this.fieldObject._maxLength;
86
- this.onValidation = this.fieldObject._onValidation;
87
- this.value = this.fieldObject._fieldValue;
88
- this.captureType = this.fieldObject.captureType;
89
- this.title = this.fieldObject.fieldTitle;
90
- this.type = this.fieldObject.fieldType;
91
- this.errorMessage = this.fieldObject.errorMessage;
92
- this.errorType = this.fieldObject.errorType;
93
- this.errorCode = this.fieldObject.errorCode;
94
- this.visibleLabel = this.fieldObject.visibleLabel;
95
- this.required = this.fieldObject.fieldRequired;
96
- this.options = this.fieldObject.fieldOptions;
97
- this.fieldObject.widget = this;
98
- // Atributos dinámicos
99
- this.fieldObject.attributeChange.subscribe(function (event) {
100
- var name = event.name, value = event.value;
101
- if (_this[MONITORED_ATTRIBUTES[name]]) {
102
- _this[MONITORED_ATTRIBUTES[name]] = value;
103
- }
104
- });
105
- }
106
- this.start();
107
- };
108
- FieldComponent.prototype.start = function () { };
109
- FieldComponent.prototype.focus = function () { };
110
- FieldComponent.prototype.onInputChange = function () {
111
- var _this = this;
112
- setTimeout(function () { return _this.fieldObject.notifyEditionPartial(); }, 50);
113
- };
114
- FieldComponent.prototype.onChangeContent = function () {
115
- var _this = this;
116
- setTimeout(function () { return _this.fieldObject.notifyEditionFinish(); }, 50);
117
- };
118
- FieldComponent.prototype.onShowInfo = function () {
119
- var _this = this;
120
- setTimeout(function () { return _this.fieldObject.notifyEditionDetailRequest(); }, 50);
121
- };
122
- FieldComponent.prototype.numberInputValidation = function (event) {
123
- var k = event.charCode;
124
- return (k > 47 && k < 58);
125
- };
126
- return FieldComponent;
127
- }());
128
- FieldComponent.decorators = [
129
- { type: core.Component, args: [{
130
- selector: 'lib-field',
131
- template: "<ng-content></ng-content>"
132
- },] }
133
- ];
134
- FieldComponent.propDecorators = {
135
- fieldObject: [{ type: core.Input }],
136
- disabled: [{ type: core.Input }]
137
- };
138
-
139
- var ElementComponent = /** @class */ (function () {
140
- function ElementComponent() {
141
- }
142
- ElementComponent.prototype.ngOnInit = function () {
143
- var _a;
144
- this.formConfig = (_a = this.formElement) === null || _a === void 0 ? void 0 : _a._formConfig;
145
- this.start();
146
- };
147
- ElementComponent.prototype.start = function () { };
148
- Object.defineProperty(ElementComponent.prototype, "visible", {
149
- get: function () {
150
- var _a, _b, _c, _d;
151
- var visible = (_b = (_a = this.formElement) === null || _a === void 0 ? void 0 : _a.visible) !== null && _b !== void 0 ? _b : true;
152
- return visible && ((_c = this.formElement) === null || _c === void 0 ? void 0 : _c.viewOnState((_d = this.formManager) === null || _d === void 0 ? void 0 : _d.currentState));
153
- },
154
- enumerable: false,
155
- configurable: true
156
- });
157
- Object.defineProperty(ElementComponent.prototype, "disabled", {
158
- get: function () {
159
- var _a, _b, _c, _d;
160
- var disabled = (_b = (_a = this.formElement) === null || _a === void 0 ? void 0 : _a.disabled) !== null && _b !== void 0 ? _b : false;
161
- return disabled || !((_c = this.formElement) === null || _c === void 0 ? void 0 : _c.enabledOnState((_d = this.formManager) === null || _d === void 0 ? void 0 : _d.currentState));
162
- },
163
- enumerable: false,
164
- configurable: true
165
- });
166
- return ElementComponent;
167
- }());
168
- ElementComponent.decorators = [
169
- { type: core.Component, args: [{
170
- selector: 'lib-element',
171
- template: "<ng-content></ng-content>"
172
- },] }
173
- ];
174
- ElementComponent.propDecorators = {
175
- formElement: [{ type: core.Input }],
176
- formManager: [{ type: core.Input }]
177
- };
178
-
179
- var FormErrorComponent = /** @class */ (function () {
180
- function FormErrorComponent() {
181
- }
182
- return FormErrorComponent;
183
- }());
184
- FormErrorComponent.decorators = [
185
- { type: core.Component, args: [{
186
- selector: 'lib-form-error',
187
- template: "<ng-content></ng-content>"
188
- },] }
189
- ];
190
- FormErrorComponent.propDecorators = {
191
- errorTitle: [{ type: core.Input }],
192
- errorMessage: [{ type: core.Input }],
193
- errorType: [{ type: core.Input }]
194
- };
195
-
196
- var FormHeaderComponent = /** @class */ (function () {
197
- function FormHeaderComponent() {
198
- this.goBackEvent = new core.EventEmitter();
199
- }
200
- FormHeaderComponent.prototype.goBackForm = function () {
201
- this.goBackEvent.emit();
202
- };
203
- return FormHeaderComponent;
204
- }());
205
- FormHeaderComponent.decorators = [
206
- { type: core.Component, args: [{
207
- selector: 'lib-form-header',
208
- template: "<ng-content></ng-content>"
209
- },] }
210
- ];
211
- FormHeaderComponent.propDecorators = {
212
- formManager: [{ type: core.Input }],
213
- goBackAction: [{ type: core.Input }],
214
- showTitle: [{ type: core.Input }],
215
- headerActions: [{ type: core.Input }],
216
- goBackEvent: [{ type: core.Output }]
217
- };
218
-
219
- var SectionComponent = /** @class */ (function () {
220
- function SectionComponent() {
221
- }
222
- SectionComponent.prototype.ngOnInit = function () {
223
- this.start();
224
- };
225
- SectionComponent.prototype.start = function () { };
226
- return SectionComponent;
227
- }());
228
- SectionComponent.decorators = [
229
- { type: core.Component, args: [{
230
- selector: 'lib-section',
231
- template: "<ng-content></ng-content>"
232
- },] }
233
- ];
234
- SectionComponent.propDecorators = {
235
- sectionObject: [{ type: core.Input }],
236
- formManager: [{ type: core.Input }]
237
- };
238
-
239
- var SubSectionComponent = /** @class */ (function () {
240
- function SubSectionComponent() {
241
- }
242
- SubSectionComponent.prototype.ngOnInit = function () {
243
- this.start();
244
- };
245
- SubSectionComponent.prototype.start = function () { };
246
- return SubSectionComponent;
247
- }());
248
- SubSectionComponent.decorators = [
249
- { type: core.Component, args: [{
250
- selector: 'lib-subsection',
251
- template: "<ng-content></ng-content>"
252
- },] }
253
- ];
254
- SubSectionComponent.propDecorators = {
255
- subSection: [{ type: core.Input }],
256
- showHeader: [{ type: core.Input }],
257
- formManager: [{ type: core.Input }]
258
- };
259
-
260
- var FieldSearch = /** @class */ (function () {
261
- function FieldSearch(filterDefinition) {
262
- this.fieldCode = filterDefinition.fieldCode;
263
- this.fieldAlias = filterDefinition.fieldAlias || filterDefinition.fieldCode;
264
- this.fieldTitle = filterDefinition.fieldTitle;
265
- this.fieldTypeCode = filterDefinition.fieldTypeCode;
266
- this.operators = filterDefinition.operators;
267
- this.alignment = filterDefinition.alignment;
268
- this.format = filterDefinition.format;
269
- }
270
- return FieldSearch;
271
- }());
272
- var Filter = /** @class */ (function () {
273
- function Filter() {
274
- this.filterModeSimple = true;
275
- this.advancedFilter = [];
276
- this.simpleFilterWords = [];
277
- }
278
- return Filter;
279
- }());
280
-
281
57
  /*! *****************************************************************************
282
58
  Copyright (c) Microsoft Corporation.
283
59
 
@@ -596,6 +372,204 @@
596
372
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
597
373
  }
598
374
 
375
+ var FieldComponent = /** @class */ (function () {
376
+ function FieldComponent() {
377
+ }
378
+ FieldComponent.prototype.ngOnInit = function () {
379
+ var _this = this;
380
+ var _a, _b;
381
+ if (this.fieldObject) {
382
+ this.formConfig = (_a = this.fieldObject) === null || _a === void 0 ? void 0 : _a._formConfig;
383
+ // Inicialización
384
+ var mapping = Object.entries(this.formConfig.componentFieldAttrMap);
385
+ for (var index = 0; index < mapping.length; index++) {
386
+ var _c = __read(mapping[index], 2), fieldAttr = _c[0], compAttr = _c[1];
387
+ this[compAttr.toString()] = (_b = this.fieldObject) === null || _b === void 0 ? void 0 : _b[fieldAttr.toString()];
388
+ }
389
+ // Subscripción a cambios en atributos
390
+ this.fieldObject.attributeChange.subscribe(function (event) {
391
+ var fieldAttr = event.name, value = event.value;
392
+ var compAttr = _this.formConfig.componentFieldAttrMap[fieldAttr];
393
+ _this.hasOwnProperty(compAttr) && (_this[compAttr] = value);
394
+ });
395
+ }
396
+ this.start();
397
+ };
398
+ FieldComponent.prototype.start = function () { };
399
+ FieldComponent.prototype.focus = function () { };
400
+ FieldComponent.prototype.onInputChange = function () {
401
+ var _this = this;
402
+ setTimeout(function () { return _this.fieldObject.notifyEditionPartial(); }, 50);
403
+ };
404
+ FieldComponent.prototype.onChangeContent = function () {
405
+ var _this = this;
406
+ setTimeout(function () { return _this.fieldObject.notifyEditionFinish(); }, 50);
407
+ };
408
+ FieldComponent.prototype.onShowInfo = function () {
409
+ var _this = this;
410
+ setTimeout(function () { return _this.fieldObject.notifyEditionDetailRequest(); }, 50);
411
+ };
412
+ FieldComponent.prototype.numberInputValidation = function (event) {
413
+ var k = event.charCode;
414
+ return (k > 47 && k < 58);
415
+ };
416
+ return FieldComponent;
417
+ }());
418
+ FieldComponent.decorators = [
419
+ { type: core.Component, args: [{
420
+ selector: 'lib-field',
421
+ template: "<ng-content></ng-content>"
422
+ },] }
423
+ ];
424
+ FieldComponent.propDecorators = {
425
+ fieldObject: [{ type: core.Input }],
426
+ disabled: [{ type: core.Input }]
427
+ };
428
+
429
+ var ElementComponent = /** @class */ (function () {
430
+ function ElementComponent() {
431
+ }
432
+ ElementComponent.prototype.ngOnInit = function () {
433
+ var _a;
434
+ this.formConfig = (_a = this.formElement) === null || _a === void 0 ? void 0 : _a._formConfig;
435
+ this.start();
436
+ };
437
+ ElementComponent.prototype.start = function () { };
438
+ Object.defineProperty(ElementComponent.prototype, "visible", {
439
+ get: function () {
440
+ var _a, _b, _c, _d;
441
+ var visible = (_b = (_a = this.formElement) === null || _a === void 0 ? void 0 : _a.visible) !== null && _b !== void 0 ? _b : true;
442
+ return visible && ((_c = this.formElement) === null || _c === void 0 ? void 0 : _c.viewOnState((_d = this.formManager) === null || _d === void 0 ? void 0 : _d.currentState));
443
+ },
444
+ enumerable: false,
445
+ configurable: true
446
+ });
447
+ Object.defineProperty(ElementComponent.prototype, "disabled", {
448
+ get: function () {
449
+ var _a, _b, _c, _d;
450
+ var disabled = (_b = (_a = this.formElement) === null || _a === void 0 ? void 0 : _a.disabled) !== null && _b !== void 0 ? _b : false;
451
+ return disabled || !((_c = this.formElement) === null || _c === void 0 ? void 0 : _c.enabledOnState((_d = this.formManager) === null || _d === void 0 ? void 0 : _d.currentState));
452
+ },
453
+ enumerable: false,
454
+ configurable: true
455
+ });
456
+ return ElementComponent;
457
+ }());
458
+ ElementComponent.decorators = [
459
+ { type: core.Component, args: [{
460
+ selector: 'lib-element',
461
+ template: "<ng-content></ng-content>"
462
+ },] }
463
+ ];
464
+ ElementComponent.propDecorators = {
465
+ formElement: [{ type: core.Input }],
466
+ formManager: [{ type: core.Input }]
467
+ };
468
+
469
+ var FormErrorComponent = /** @class */ (function () {
470
+ function FormErrorComponent() {
471
+ }
472
+ return FormErrorComponent;
473
+ }());
474
+ FormErrorComponent.decorators = [
475
+ { type: core.Component, args: [{
476
+ selector: 'lib-form-error',
477
+ template: "<ng-content></ng-content>"
478
+ },] }
479
+ ];
480
+ FormErrorComponent.propDecorators = {
481
+ errorTitle: [{ type: core.Input }],
482
+ errorMessage: [{ type: core.Input }],
483
+ errorType: [{ type: core.Input }]
484
+ };
485
+
486
+ var FormHeaderComponent = /** @class */ (function () {
487
+ function FormHeaderComponent() {
488
+ this.goBackEvent = new core.EventEmitter();
489
+ }
490
+ FormHeaderComponent.prototype.goBackForm = function () {
491
+ this.goBackEvent.emit();
492
+ };
493
+ return FormHeaderComponent;
494
+ }());
495
+ FormHeaderComponent.decorators = [
496
+ { type: core.Component, args: [{
497
+ selector: 'lib-form-header',
498
+ template: "<ng-content></ng-content>"
499
+ },] }
500
+ ];
501
+ FormHeaderComponent.propDecorators = {
502
+ formManager: [{ type: core.Input }],
503
+ goBackAction: [{ type: core.Input }],
504
+ showTitle: [{ type: core.Input }],
505
+ headerActions: [{ type: core.Input }],
506
+ goBackEvent: [{ type: core.Output }]
507
+ };
508
+
509
+ var SectionComponent = /** @class */ (function () {
510
+ function SectionComponent() {
511
+ }
512
+ SectionComponent.prototype.ngOnInit = function () {
513
+ this.start();
514
+ };
515
+ SectionComponent.prototype.start = function () { };
516
+ return SectionComponent;
517
+ }());
518
+ SectionComponent.decorators = [
519
+ { type: core.Component, args: [{
520
+ selector: 'lib-section',
521
+ template: "<ng-content></ng-content>"
522
+ },] }
523
+ ];
524
+ SectionComponent.propDecorators = {
525
+ sectionObject: [{ type: core.Input }],
526
+ formManager: [{ type: core.Input }]
527
+ };
528
+
529
+ var SubSectionComponent = /** @class */ (function () {
530
+ function SubSectionComponent() {
531
+ }
532
+ SubSectionComponent.prototype.ngOnInit = function () {
533
+ this.start();
534
+ };
535
+ SubSectionComponent.prototype.start = function () { };
536
+ return SubSectionComponent;
537
+ }());
538
+ SubSectionComponent.decorators = [
539
+ { type: core.Component, args: [{
540
+ selector: 'lib-subsection',
541
+ template: "<ng-content></ng-content>"
542
+ },] }
543
+ ];
544
+ SubSectionComponent.propDecorators = {
545
+ subSection: [{ type: core.Input }],
546
+ showHeader: [{ type: core.Input }],
547
+ formManager: [{ type: core.Input }]
548
+ };
549
+
550
+ var FieldSearch = /** @class */ (function () {
551
+ function FieldSearch(filterDefinition) {
552
+ this.fieldCode = filterDefinition.fieldCode;
553
+ this.fieldAlias = filterDefinition.fieldAlias || filterDefinition.fieldCode;
554
+ this.fieldTitle = filterDefinition.fieldTitle;
555
+ this.fieldTypeCode = filterDefinition.fieldTypeCode;
556
+ this.operators = filterDefinition.operators;
557
+ this.alignment = filterDefinition.alignment;
558
+ this.format = filterDefinition.format;
559
+ }
560
+ return FieldSearch;
561
+ }());
562
+ var Filter = /** @class */ (function () {
563
+ function Filter() {
564
+ this.filterModeSimple = true;
565
+ this.advancedFilter = [];
566
+ this.simpleFilterWords = [];
567
+ }
568
+ return Filter;
569
+ }());
570
+
571
+ var NO_ERROR = '00';
572
+ var HEADER$1 = 'HEADER';
599
573
  var elementTypes = {
600
574
  action: 'ACTION',
601
575
  field: 'FIELD',
@@ -1861,7 +1835,7 @@
1861
1835
  return RecordFormSection;
1862
1836
  }());
1863
1837
 
1864
- var HEADER$1 = 'HEADER';
1838
+ var HEADER = 'HEADER';
1865
1839
  var FormAction = /** @class */ (function (_super) {
1866
1840
  __extends(FormAction, _super);
1867
1841
  function FormAction(actionDefinition, formConfig) {
@@ -1874,7 +1848,7 @@
1874
1848
  _this.actionCode = actionDefinition.actionCode ? actionDefinition.actionCode.toString() : '';
1875
1849
  _this.actionName = actionDefinition.actionTitle;
1876
1850
  _this.iconName = actionDefinition.iconName || _this.actionCode;
1877
- _this.location = actionDefinition.position || HEADER$1;
1851
+ _this.location = actionDefinition.position || HEADER;
1878
1852
  _this.backend = (_a = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.serverAction) !== null && _a !== void 0 ? _a : false;
1879
1853
  _this.newState = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.newState;
1880
1854
  _this.customAttributes = (_b = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.customAttributes) !== null && _b !== void 0 ? _b : null;
@@ -2097,11 +2071,12 @@
2097
2071
  if (editable === void 0) { editable = true; }
2098
2072
  (editable) ? this.enable() : this.disable();
2099
2073
  };
2100
- FieldDescriptor.prototype.hasError = function () { return this.errorCode !== '00'; };
2074
+ FieldDescriptor.prototype.hasError = function () { return this.errorCode !== NO_ERROR; };
2075
+ FieldDescriptor.prototype.resetError = function () { (this.errorCode !== NO_ERROR) && this.setError(NO_ERROR, null); };
2101
2076
  FieldDescriptor.prototype.setError = function (code, message, type) {
2102
2077
  if (type === void 0) { type = DEFAULT_ERROR_TYPE; }
2103
- this.setAttr(fldAttr.errorCode, code !== null && code !== void 0 ? code : '00');
2104
- this.setAttr(fldAttr.errorType, (this.errorCode === '00') ? '' : type);
2078
+ this.setAttr(fldAttr.errorCode, code !== null && code !== void 0 ? code : NO_ERROR);
2079
+ this.setAttr(fldAttr.errorType, (this.errorCode === NO_ERROR) ? '' : type);
2105
2080
  this.setAttr(fldAttr.errorMessage, message !== null && message !== void 0 ? message : '');
2106
2081
  };
2107
2082
  FieldDescriptor.prototype.getError = function () { return { type: this.errorType, code: this.errorCode, message: this.errorMessage }; };
@@ -2301,8 +2276,6 @@
2301
2276
  return FieldDescriptor;
2302
2277
  }(FormElement));
2303
2278
 
2304
- var HEADER = 'HEADER';
2305
- var NO_ERROR = '00';
2306
2279
  var FormStructureAndData = /** @class */ (function () {
2307
2280
  function FormStructureAndData(definitionReceived, formConfig) {
2308
2281
  var e_1, _d, e_2, _e, e_3, _f, e_4, _g;
@@ -2551,7 +2524,7 @@
2551
2524
  return this._actions;
2552
2525
  };
2553
2526
  FormStructureAndData.prototype.getHeaderActions = function () {
2554
- return this._actions.filter(function (actionItem) { return actionItem.location === HEADER; });
2527
+ return this._actions.filter(function (actionItem) { return actionItem.location === HEADER$1; });
2555
2528
  };
2556
2529
  FormStructureAndData.prototype.getFieldObject = function (elementId) {
2557
2530
  return (this._fieldsObj && elementId && this._fieldsObj[elementId])
@@ -3622,7 +3595,7 @@
3622
3595
  this.errorDetail = recordResponse.errorDetail;
3623
3596
  };
3624
3597
  BasicFormComponent.prototype.errorOccured = function () {
3625
- return (this.errorCode !== '00');
3598
+ return (this.errorCode !== NO_ERROR);
3626
3599
  };
3627
3600
  BasicFormComponent.prototype.changeState = function (state) { return this.formStructure.changeState(state); };
3628
3601
  BasicFormComponent.prototype.changeFormMode = function (state) { return this.changeState(state); };
@@ -3643,7 +3616,7 @@
3643
3616
  formData: this.formStructure.getPayload(),
3644
3617
  immutableData: this.formStructure.immutableData,
3645
3618
  };
3646
- this.errorCode = '00';
3619
+ this.errorCode = NO_ERROR;
3647
3620
  this.errorMessage = '';
3648
3621
  this.errorDetail = '';
3649
3622
  this.inServerProcess = true;
@@ -3994,8 +3967,7 @@
3994
3967
  if (!fieldToValidate) {
3995
3968
  return [2 /*return*/, false];
3996
3969
  }
3997
- fieldToValidate.setErrorMessage('');
3998
- fieldToValidate.setErrorCode('00');
3970
+ fieldToValidate.resetError();
3999
3971
  validationCallbacks = this.fieldInputValidation[fieldCode];
4000
3972
  if (!validationCallbacks) return [3 /*break*/, 2];
4001
3973
  clientValidationPromises = [];
@@ -4034,8 +4006,7 @@
4034
4006
  if (!fieldToValidate || !intrinsicValidation) {
4035
4007
  return [2 /*return*/];
4036
4008
  }
4037
- fieldToValidate.setErrorMessage('');
4038
- fieldToValidate.setErrorCode('00');
4009
+ fieldToValidate.resetError();
4039
4010
  validationCallbacks = this.fieldValidationsStart[fieldCode];
4040
4011
  if (!validationCallbacks) return [3 /*break*/, 2];
4041
4012
  clientValidationPromises = [];