tuain-ng-forms-lib 0.12.20 → 0.12.30

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.
@@ -146,12 +146,41 @@
146
146
  ]
147
147
  };
148
148
 
149
+ var MONITORED_ATTRIBUTES$1 = {
150
+ _maxLength: 'maxLength',
151
+ _onValidation: '_onValidation',
152
+ _fieldValue: 'value',
153
+ captureType: 'captureType',
154
+ fieldTitle: 'fieldTitle',
155
+ fieldType: 'fieldType',
156
+ errorMessage: 'errorMessage',
157
+ errorType: 'errorType',
158
+ errorCode: 'errorCode',
159
+ visibleLabel: 'visibleLabel',
160
+ fieldRequired: 'fieldRequired',
161
+ fieldOptions: 'fieldOptions',
162
+ };
149
163
  var FieldComponent = /** @class */ (function () {
150
164
  function FieldComponent() {
151
165
  this.componentConstants = Object.assign({}, componentConstants);
152
166
  }
153
167
  FieldComponent.prototype.ngOnInit = function () {
154
- this.fieldObject.widget = this;
168
+ var _this = this;
169
+ if (this.fieldObject) {
170
+ // Atributos estáticos
171
+ this.fieldCode = this.fieldObject.fieldCode;
172
+ this.fieldInfo = this.fieldObject.fieldInfo;
173
+ this.fieldAlignment = this.fieldObject.fieldAlignment;
174
+ this.tooltipText = this.fieldObject.tooltipText;
175
+ this.fieldObject.widget = this;
176
+ // Atributos dinámicos
177
+ this.fieldObject.attributeChange.subscribe(function (event) {
178
+ var name = event.name, value = event.value;
179
+ if (_this[MONITORED_ATTRIBUTES$1[name]]) {
180
+ _this[MONITORED_ATTRIBUTES$1[name]] = value;
181
+ }
182
+ });
183
+ }
155
184
  this.start();
156
185
  };
157
186
  FieldComponent.prototype.start = function () { };
@@ -657,9 +686,9 @@
657
686
  this.setVisibility((_b = elementDefinition === null || elementDefinition === void 0 ? void 0 : elementDefinition.visible) !== null && _b !== void 0 ? _b : true);
658
687
  this.widget = null;
659
688
  }
660
- FormElement.prototype.isField = function () { return this.type === componentConstants.ELEMENTTYPE_FIELD; };
661
- FormElement.prototype.isAction = function () { return this.type === componentConstants.ELEMENTTYPE_ACTION; };
662
- FormElement.prototype.isTable = function () { return this.type === componentConstants.ELEMENTTYPE_TABLE; };
689
+ FormElement.prototype.isField = function () { return this.elementType === componentConstants.ELEMENTTYPE_FIELD; };
690
+ FormElement.prototype.isAction = function () { return this.elementType === componentConstants.ELEMENTTYPE_ACTION; };
691
+ FormElement.prototype.isTable = function () { return this.elementType === componentConstants.ELEMENTTYPE_TABLE; };
663
692
  FormElement.prototype.setVisibleStates = function (newStates) {
664
693
  var visibleStates = (!Array.isArray(newStates) && typeof newStates === 'string')
665
694
  ? newStates.split(',').map(function (state) { return state.trim(); }).filter(function (state) { return state.length > 0; })
@@ -986,7 +1015,7 @@
986
1015
  _this._tableColumnObj = {};
987
1016
  _this._actionsObj = {};
988
1017
  _this.allSelected = false;
989
- _this.type = componentConstants.ELEMENTTYPE_TABLE;
1018
+ _this.elementType = componentConstants.ELEMENTTYPE_TABLE;
990
1019
  _this.waiting = false;
991
1020
  _this.complexFilter = false;
992
1021
  _this.currentPage = 1;
@@ -1679,7 +1708,7 @@
1679
1708
  break;
1680
1709
  }
1681
1710
  if (elementObject) {
1682
- elementObject.type = type;
1711
+ elementObject.elementType = type;
1683
1712
  arrayToAdd.push(elementObject);
1684
1713
  this.subSectionElements.push(elementObject);
1685
1714
  this.elementsArray[code] = elementObject;
@@ -1889,7 +1918,7 @@
1889
1918
  _this = _super.call(this, actionDefinition) || this;
1890
1919
  _this._actionActivated = new rxjs.Subject();
1891
1920
  _this.inProgress = false;
1892
- _this.type = componentConstants.ELEMENTTYPE_ACTION;
1921
+ _this.elementType = componentConstants.ELEMENTTYPE_ACTION;
1893
1922
  _this.actionCode = actionDefinition.actionCode ? actionDefinition.actionCode.toString() : '';
1894
1923
  _this.actionName = actionDefinition.actionTitle;
1895
1924
  _this.iconName = actionDefinition.iconName || _this.actionCode;
@@ -1937,42 +1966,120 @@
1937
1966
  var FIELD_TOOLTIP = 'tooltipText';
1938
1967
  var FIELD_INFO = 'info';
1939
1968
  var FIELD_EDITABLE = 'editable';
1969
+ var FIELD_TYPES = {
1970
+ boolean: 'BOOLEAN',
1971
+ array: 'ARRAY',
1972
+ check: 'CHECK',
1973
+ date: 'DATE',
1974
+ daterange: 'DATERANGE',
1975
+ time: 'TIME',
1976
+ timerange: 'TIMERANGE',
1977
+ map: 'MAP',
1978
+ number: 'NUMBER',
1979
+ decimal: 'DECIMAL',
1980
+ currency: 'CURRENCY',
1981
+ select: 'SELECT',
1982
+ typeahead: 'TYPEAHEAD',
1983
+ text: 'TEXT',
1984
+ password: 'PASSWORD',
1985
+ label: 'LABEL',
1986
+ html: 'HTML',
1987
+ title: 'TITLE',
1988
+ message: 'MESSAGE',
1989
+ link: 'LINK',
1990
+ warning: 'WARNING',
1991
+ avatar: 'AVATAR',
1992
+ email: 'EMAIL',
1993
+ phone: 'PHONE',
1994
+ };
1995
+ var FIELD_TYPES_FORMATS = {
1996
+ EMAIL: new RegExp('^\\w+([\\.-]?\\w+)@\\w+([\\.-]?\\w+)(\\.\\w{2,3})+$'),
1997
+ };
1998
+ var INTRINSIC_ERROR_MESSAGES = {
1999
+ EMAIL: "El valor no corresponde a un correo v\u00E1lido",
2000
+ DEFAULT: "El valor no se ajusta al formato establecido",
2001
+ };
2002
+ var DEFAULT_ERROR_TYPE = 'error';
2003
+ var DEFAULT_CAPTURE_TYPE = 'INPUT';
2004
+ var DEFAULT_ALIGNMENT = 'left';
2005
+ var MONITORED_ATTRIBUTES = ['_maxLength', '_onValidation', 'captureType', 'fieldTitle', 'fieldType',
2006
+ 'errorMessage', 'errorType', 'errorCode', 'visibleLabel', 'fieldRequired', 'fieldOptions', '_fieldValue'];
1940
2007
  var STD_MAX_LENGTH = 50;
1941
2008
  var BIG_MAX_LENGTH = 500;
2009
+ var fldAttr = {
2010
+ validateOnServer: 'validateOnServer',
2011
+ value: '_fieldValue',
2012
+ minValue: '_minValue',
2013
+ maxValue: '_maxValue',
2014
+ maxLength: '_maxLength',
2015
+ onValidation: '_onValidation',
2016
+ intrinsicErrorMessage: '_intrinsicErrorMessage',
2017
+ code: 'fieldCode',
2018
+ info: 'fieldInfo',
2019
+ defaultValue: 'defaultValue',
2020
+ defaultEditable: 'defaultEditable',
2021
+ customAttributes: 'customAttributes',
2022
+ visibleLabel: 'visibleLabel',
2023
+ required: 'fieldRequired',
2024
+ hasChanged: 'hasChanged',
2025
+ outputOnly: 'outputOnly',
2026
+ captureType: 'captureType',
2027
+ title: 'fieldTitle',
2028
+ type: 'fieldType',
2029
+ alignment: 'fieldAlignment',
2030
+ format: 'fieldFormat',
2031
+ externalValue: 'externalValue',
2032
+ tooltipText: 'tooltipText',
2033
+ errorType: 'errorType',
2034
+ errorCode: 'errorCode',
2035
+ errorMessage: 'errorMessage',
2036
+ options: 'fieldOptions',
2037
+ };
1942
2038
  var FieldDescriptor = /** @class */ (function (_super) {
1943
2039
  __extends(FieldDescriptor, _super);
1944
2040
  function FieldDescriptor(inputFieldReceived) {
1945
2041
  var _this = this;
1946
- var _a, _b, _c, _d, _e, _f, _g;
2042
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1947
2043
  _this = _super.call(this, inputFieldReceived) || this;
1948
2044
  _this._editionFinish = new rxjs.Subject();
1949
2045
  _this._editionPartial = new rxjs.Subject();
1950
2046
  _this._detailRequest = new rxjs.Subject();
1951
- _this.type = componentConstants.ELEMENTTYPE_FIELD;
1952
- var fieldReceived = (inputFieldReceived) ? inputFieldReceived : {};
1953
- _this.setEditable((_a = fieldReceived === null || fieldReceived === void 0 ? void 0 : fieldReceived.editable) !== null && _a !== void 0 ? _a : true);
1954
- _this.fieldCode = fieldReceived.fieldCode;
1955
- _this.fieldTitle = fieldReceived.fieldTitle || _this.fieldCode;
1956
- _this.captureType = fieldReceived.captureType || 'INPUT';
1957
- _this.setFieldType(fieldReceived.fieldTypeCode);
1958
- _this.defaultValue = fieldReceived.defaultValue || null;
1959
- _this._maxLength = (_b = fieldReceived.maxLength) !== null && _b !== void 0 ? _b : (_this.captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
1960
- _this.setValue(fieldReceived.fieldValue || _this.defaultValue || '');
1961
- var defaultTypeAlignment = (tableFieldStyles[_this.fieldType] != null) ? tableFieldStyles[_this.fieldType]['text-align'] : 'left';
1962
- _this.fieldAlignment = (fieldReceived.alignment != null) ? fieldReceived.alignment.toLowerCase() : defaultTypeAlignment;
1963
- _this.fieldInfo = fieldReceived.info || '';
1964
- _this.fieldFormat = fieldReceived.format || '';
1965
- _this.validateOnServer = (_c = fieldReceived === null || fieldReceived === void 0 ? void 0 : fieldReceived.serverAction) !== null && _c !== void 0 ? _c : false;
1966
- _this.customAttributes = (_d = fieldReceived === null || fieldReceived === void 0 ? void 0 : fieldReceived.customAttributes) !== null && _d !== void 0 ? _d : null;
1967
- _this.setVisibility(fieldReceived.visible);
1968
- _this.visibleLabel = (_e = fieldReceived === null || fieldReceived === void 0 ? void 0 : fieldReceived.visibleLabel) !== null && _e !== void 0 ? _e : true;
1969
- _this.tooltipText = fieldReceived.tooltip || '';
1970
- _this.defaultEditable = _this.enabled;
1971
- _this.fieldRequired = (_f = fieldReceived === null || fieldReceived === void 0 ? void 0 : fieldReceived.required) !== null && _f !== void 0 ? _f : false;
1972
- _this.errorMessage = fieldReceived.errorMessage || '';
1973
- _this.errorCode = fieldReceived.errorCode || '00';
1974
- _this.outputOnly = (_g = fieldReceived === null || fieldReceived === void 0 ? void 0 : fieldReceived.outputOnly) !== null && _g !== void 0 ? _g : false;
1975
- _this.setFieldOptions(fieldReceived.fieldOptions);
2047
+ _this._attributeChange = new rxjs.Subject();
2048
+ _this.elementType = componentConstants.ELEMENTTYPE_FIELD;
2049
+ var fld = (inputFieldReceived) ? inputFieldReceived : {};
2050
+ _this.setAttr(fldAttr.code, fld.fieldCode);
2051
+ _this.setAttr(fldAttr.title, (_a = fld.fieldTitle) !== null && _a !== void 0 ? _a : _this.fieldCode);
2052
+ _this.setAttr(fldAttr.captureType, (_b = fld.captureType) !== null && _b !== void 0 ? _b : DEFAULT_CAPTURE_TYPE);
2053
+ _this.setAttr(fldAttr.defaultValue, (_c = fld.defaultValue) !== null && _c !== void 0 ? _c : null);
2054
+ var defaultTypeAlignment = (tableFieldStyles[_this.fieldType] != null)
2055
+ ? tableFieldStyles[_this.fieldType]['text-align'] : DEFAULT_ALIGNMENT;
2056
+ var fieldAlignment = (fld.alignment != null) ? fld.alignment.toLowerCase() : defaultTypeAlignment;
2057
+ _this.setAttr(fldAttr.alignment, fieldAlignment);
2058
+ _this.setAttr(fldAttr.info, fld.info || '');
2059
+ var fieldFormat;
2060
+ try {
2061
+ fieldFormat = (fld.format) ? new RegExp(fld.format) : null;
2062
+ }
2063
+ catch (e) {
2064
+ fieldFormat = null;
2065
+ }
2066
+ _this.setAttr(fldAttr.format, fieldFormat);
2067
+ _this.setAttr(fldAttr.validateOnServer, (_d = fld.serverAction) !== null && _d !== void 0 ? _d : false);
2068
+ _this.setAttr(fldAttr.customAttributes, (_e = fld.customAttributes) !== null && _e !== void 0 ? _e : {});
2069
+ _this.setAttr(fldAttr.tooltipText, fld.tooltip || '');
2070
+ _this.setAttr(fldAttr.defaultEditable, _this.enabled);
2071
+ _this.setAttr(fldAttr.required, (_f = fld.required) !== null && _f !== void 0 ? _f : false);
2072
+ _this.setError(fld.errorCode, fld.errorMessage, (_g = fld.errorType) !== null && _g !== void 0 ? _g : DEFAULT_ERROR_TYPE);
2073
+ _this.setAttr(fldAttr.outputOnly, (_h = fld.outputOnly) !== null && _h !== void 0 ? _h : false);
2074
+ var maxLength = (_j = fld.maxLength) !== null && _j !== void 0 ? _j : (_this.captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
2075
+ _this.setAttr(fldAttr.maxLength, maxLength);
2076
+ _this.setAttr(fldAttr.intrinsicErrorMessage, (_k = INTRINSIC_ERROR_MESSAGES[_this.fieldType]) !== null && _k !== void 0 ? _k : INTRINSIC_ERROR_MESSAGES.DEFAULT);
2077
+ _this.setFieldType(fld.fieldTypeCode);
2078
+ _this.setEditable((_l = fld.editable) !== null && _l !== void 0 ? _l : true);
2079
+ _this.setVisibleLabel((_m = fld.visibleLabel) !== null && _m !== void 0 ? _m : true);
2080
+ _this.setVisibility(fld.visible);
2081
+ _this.setFieldOptions(fld.fieldOptions);
2082
+ _this.setValue(fld.fieldValue || _this.defaultValue || '');
1976
2083
  return _this;
1977
2084
  }
1978
2085
  Object.defineProperty(FieldDescriptor.prototype, "name", {
@@ -1985,6 +2092,11 @@
1985
2092
  enumerable: false,
1986
2093
  configurable: true
1987
2094
  });
2095
+ Object.defineProperty(FieldDescriptor.prototype, "attributeChange", {
2096
+ get: function () { return this._attributeChange; },
2097
+ enumerable: false,
2098
+ configurable: true
2099
+ });
1988
2100
  Object.defineProperty(FieldDescriptor.prototype, "editionPartial", {
1989
2101
  get: function () { return this._editionPartial; },
1990
2102
  enumerable: false,
@@ -1995,6 +2107,18 @@
1995
2107
  enumerable: false,
1996
2108
  configurable: true
1997
2109
  });
2110
+ Object.defineProperty(FieldDescriptor.prototype, "validating", {
2111
+ get: function () { return this._onValidation; },
2112
+ set: function (isValidating) { this.setAttr(fldAttr.onValidation, isValidating); },
2113
+ enumerable: false,
2114
+ configurable: true
2115
+ });
2116
+ FieldDescriptor.prototype.setIntrinsicErrorMessage = function (message) { this.setAttr(fldAttr.intrinsicErrorMessage, message); };
2117
+ Object.defineProperty(FieldDescriptor.prototype, "intrinsicErrorMessage", {
2118
+ set: function (message) { this.setIntrinsicErrorMessage(message); },
2119
+ enumerable: false,
2120
+ configurable: true
2121
+ });
1998
2122
  Object.defineProperty(FieldDescriptor.prototype, "fieldValue", {
1999
2123
  get: function () { return this.getValue(); },
2000
2124
  enumerable: false,
@@ -2002,7 +2126,7 @@
2002
2126
  });
2003
2127
  Object.defineProperty(FieldDescriptor.prototype, "required", {
2004
2128
  get: function () { return this.fieldRequired; },
2005
- set: function (required) { this.fieldRequired = required !== null && required !== void 0 ? required : false; },
2129
+ set: function (required) { this.setAttr(fldAttr.required, required !== null && required !== void 0 ? required : false); },
2006
2130
  enumerable: false,
2007
2131
  configurable: true
2008
2132
  });
@@ -2010,10 +2134,10 @@
2010
2134
  get: function () { return (this._maxLength > 0) ? this._maxLength.toString() : ''; },
2011
2135
  set: function (requiredMaxLength) {
2012
2136
  if (typeof requiredMaxLength === 'string') {
2013
- this._maxLength = parseInt(requiredMaxLength, 10);
2137
+ this.setAttr(fldAttr.maxLength, parseInt(requiredMaxLength, 10));
2014
2138
  }
2015
2139
  else if (typeof requiredMaxLength === 'number') {
2016
- this._maxLength = requiredMaxLength;
2140
+ this.setAttr(fldAttr.maxLength, requiredMaxLength);
2017
2141
  }
2018
2142
  },
2019
2143
  enumerable: false,
@@ -2025,30 +2149,82 @@
2025
2149
  enumerable: false,
2026
2150
  configurable: true
2027
2151
  });
2028
- FieldDescriptor.prototype.notifyEditionPartial = function () { this._editionPartial.next(this.fieldCode); };
2029
- FieldDescriptor.prototype.notifyEditionFinish = function () { this._editionFinish.next(this.fieldCode); };
2030
- FieldDescriptor.prototype.notifyEditionDetailRequest = function () { this._detailRequest.next(this.fieldCode); };
2031
- FieldDescriptor.prototype.showLabel = function () { this.visibleLabel = true; };
2032
- FieldDescriptor.prototype.hideLabel = function () { this.visibleLabel = false; };
2033
- FieldDescriptor.prototype.changed = function () { this.hasChanged = true; };
2152
+ FieldDescriptor.prototype.notifyEditionPartial = function () {
2153
+ var intrinsicValidation = true;
2154
+ this._editionPartial.next({ code: this.fieldCode, intrinsicValidation: intrinsicValidation });
2155
+ };
2156
+ FieldDescriptor.prototype.notifyEditionFinish = function () {
2157
+ var _a, _b, _c, _d;
2158
+ var intrinsicValidation = true;
2159
+ var fieldDefaultFormat = (_a = FIELD_TYPES_FORMATS === null || FIELD_TYPES_FORMATS === void 0 ? void 0 : FIELD_TYPES_FORMATS[this.fieldType]) !== null && _a !== void 0 ? _a : null;
2160
+ var fieldValue = this.getValue();
2161
+ if (fieldValue && (fieldDefaultFormat || this.fieldFormat)) {
2162
+ intrinsicValidation = ((_b = fieldDefaultFormat === null || fieldDefaultFormat === void 0 ? void 0 : fieldDefaultFormat.test(fieldValue)) !== null && _b !== void 0 ? _b : true)
2163
+ && ((_d = (_c = this.fieldFormat) === null || _c === void 0 ? void 0 : _c.test(fieldValue)) !== null && _d !== void 0 ? _d : true);
2164
+ if (!intrinsicValidation) {
2165
+ this.setError('99', this._intrinsicErrorMessage);
2166
+ }
2167
+ }
2168
+ this._editionFinish.next({ code: this.fieldCode, intrinsicValidation: intrinsicValidation });
2169
+ };
2170
+ FieldDescriptor.prototype.setAttr = function (name, value) {
2171
+ if (this[name]) {
2172
+ this[name] = value;
2173
+ }
2174
+ if (MONITORED_ATTRIBUTES.includes(name)) {
2175
+ this._attributeChange.next({ name: name, value: value });
2176
+ }
2177
+ };
2178
+ FieldDescriptor.prototype.notifyEditionDetailRequest = function () {
2179
+ this._detailRequest.next(this.fieldCode);
2180
+ };
2181
+ FieldDescriptor.prototype.setVisibleLabel = function (visibleLabel) { this.setAttr(fldAttr.visibleLabel, visibleLabel); };
2182
+ FieldDescriptor.prototype.showLabel = function () { this.setVisibleLabel(true); };
2183
+ FieldDescriptor.prototype.hideLabel = function () { this.setVisibleLabel(false); };
2184
+ FieldDescriptor.prototype.setChanged = function (hasChanged) { this.setAttr(fldAttr.hasChanged, hasChanged); };
2185
+ FieldDescriptor.prototype.changed = function () { this.setChanged(true); };
2034
2186
  FieldDescriptor.prototype.getRawValue = function () { return this._fieldValue; };
2035
- FieldDescriptor.prototype.setLabel = function (label) { this.fieldTitle = label; };
2187
+ FieldDescriptor.prototype.setLabel = function (label) { this.setAttr(fldAttr.title, label); };
2036
2188
  FieldDescriptor.prototype.clean = function () { this.setValue(this.defaultValue || ''); };
2037
2189
  Object.defineProperty(FieldDescriptor.prototype, "backend", {
2038
2190
  get: function () { return this.validateOnServer; },
2039
2191
  enumerable: false,
2040
2192
  configurable: true
2041
2193
  });
2042
- FieldDescriptor.prototype.setVisibleLabel = function (visibleLabel) { this.visibleLabel = visibleLabel; };
2043
2194
  FieldDescriptor.prototype.setEditable = function (editable) {
2044
2195
  if (editable === void 0) { editable = true; }
2045
2196
  (editable) ? this.enable() : this.disable();
2046
2197
  };
2047
- FieldDescriptor.prototype.isEmpty = function () { return this.getValue() === '' || this.getValue() === undefined || this.getValue() === null; };
2048
- FieldDescriptor.prototype.getErrorCode = function () { return this.errorCode; };
2049
- FieldDescriptor.prototype.setErrorCode = function (code) { this.errorCode = code; };
2050
- FieldDescriptor.prototype.getErrorMessage = function () { return this.errorMessage; };
2051
- FieldDescriptor.prototype.setErrorMessage = function (msg) { this.errorMessage = msg; };
2198
+ FieldDescriptor.prototype.hasError = function () { return this.errorCode !== '00'; };
2199
+ FieldDescriptor.prototype.setError = function (code, message, type) {
2200
+ if (type === void 0) { type = DEFAULT_ERROR_TYPE; }
2201
+ this.setAttr(fldAttr.errorCode, code !== null && code !== void 0 ? code : '00');
2202
+ this.setAttr(fldAttr.errorType, (this.errorCode === '00') ? '' : type);
2203
+ this.setAttr(fldAttr.errorMessage, message !== null && message !== void 0 ? message : '');
2204
+ };
2205
+ FieldDescriptor.prototype.getError = function () { return { type: this.errorType, code: this.errorCode, message: this.errorMessage }; };
2206
+ Object.defineProperty(FieldDescriptor.prototype, "error", {
2207
+ get: function () { return this.getError(); },
2208
+ set: function (errorObj) { var _a; this.setError(errorObj.code, errorObj.message, (_a = errorObj.type) !== null && _a !== void 0 ? _a : DEFAULT_ERROR_TYPE); },
2209
+ enumerable: false,
2210
+ configurable: true
2211
+ });
2212
+ FieldDescriptor.prototype.getErrorCode = function () { return this.getError().code; };
2213
+ FieldDescriptor.prototype.setErrorCode = function (code) { this.setError(code, this.errorMessage); };
2214
+ FieldDescriptor.prototype.getErrorMessage = function () { return this.getError().message; };
2215
+ FieldDescriptor.prototype.setErrorMessage = function (msg) { this.setError(this.errorCode, msg); };
2216
+ FieldDescriptor.prototype.isEmpty = function () {
2217
+ var fieldCurrentValue = this.getValue();
2218
+ if (fieldCurrentValue === undefined || fieldCurrentValue === null) {
2219
+ return true;
2220
+ }
2221
+ if ((this.fieldType === FIELD_TYPES.array || this.fieldType === FIELD_TYPES.phone)
2222
+ && Array.isArray(fieldCurrentValue) && fieldCurrentValue.length === 0) {
2223
+ return true;
2224
+ }
2225
+ ;
2226
+ return fieldCurrentValue === '';
2227
+ };
2052
2228
  FieldDescriptor.prototype.getValue = function () {
2053
2229
  var _a;
2054
2230
  switch (this.fieldType) {
@@ -2065,68 +2241,39 @@
2065
2241
  };
2066
2242
  FieldDescriptor.prototype.updateFromServer = function (fld) {
2067
2243
  var _a;
2068
- if (FIELD_VISIBLE in fld) {
2069
- this.setVisibility(fld.visible);
2070
- }
2071
- if (FIELD_LABEL_VISIBLE in fld) {
2072
- this.setVisibleLabel(fld.visibleLabel);
2073
- }
2074
- if (FIELD_REQUIRED in fld) {
2075
- this.fieldRequired = (_a = fld.required) !== null && _a !== void 0 ? _a : false;
2076
- }
2077
- if (FIELD_ERR_CODE in fld) {
2078
- (this.errorCode = fld.errorCode);
2079
- }
2080
- if (FIELD_ERR_MSG in fld) {
2081
- (this.errorMessage = fld.errorMessage);
2082
- }
2083
- if (FIELD_TOOLTIP in fld) {
2084
- (this.tooltipText = fld.tooltip);
2085
- }
2086
- if (FIELD_INFO in fld) {
2087
- (this.fieldInfo = fld.info);
2088
- }
2089
- if (FIELD_EDITABLE in fld) {
2090
- this.setEditable(fld.editable);
2091
- }
2092
- if (FIELD_TITLE in fld) {
2093
- this.setLabel(fld.fieldTitle.toString());
2094
- }
2095
- if (FIELD_VALUE in fld) {
2096
- this.hasChanged = false;
2097
- this.setValue(fld.fieldValue);
2098
- }
2099
- if (FIELD_OPTIONS in fld) {
2100
- this.setFieldOptions(fld.fieldOptions);
2101
- }
2102
- if (FIELD_CAPTURE_TYPE in fld) {
2103
- this.captureType = fld.captureType || 'INPUT';
2104
- }
2105
- if (FIELD_TYPE in fld) {
2106
- this.setFieldType(fld.fieldTypeCode);
2107
- }
2108
- if (FIELD_MAX_LENGTH in fld) {
2109
- this.maxLength = fld.maxLength;
2244
+ var fieldKeys = Object.keys(fld);
2245
+ for (var index = 0; index < fieldKeys.length; index++) {
2246
+ var attrName = fieldKeys[index];
2247
+ var attrValue = fld[attrName];
2248
+ (attrName === FIELD_VISIBLE) && this.setVisibility(attrValue);
2249
+ (attrName === FIELD_LABEL_VISIBLE) && this.setVisibleLabel(fld.visibleLabel);
2250
+ (attrName === FIELD_REQUIRED) && this.setAttr(fldAttr.required, (_a = fld.required) !== null && _a !== void 0 ? _a : false);
2251
+ (attrName === FIELD_ERR_CODE) && this.setAttr(fldAttr.errorCode, fld.errorCode);
2252
+ (attrName === FIELD_ERR_MSG) && this.setAttr(fldAttr.errorMessage, fld.errorMessage);
2253
+ (attrName === FIELD_TOOLTIP) && this.setAttr(fldAttr.tooltipText, fld.tooltip);
2254
+ (attrName === FIELD_INFO) && this.setAttr(fldAttr.info, fld.info);
2255
+ (attrName === FIELD_EDITABLE) && this.setEditable(fld.editable);
2256
+ (attrName === FIELD_TITLE) && this.setLabel(fld.fieldTitle.toString());
2257
+ (attrName === FIELD_VALUE) && (this.setValue(fld._fieldValue) && this.setChanged(false));
2258
+ (attrName === FIELD_OPTIONS) && this.setFieldOptions(fld.fieldOptions);
2259
+ (attrName === FIELD_CAPTURE_TYPE) && this.setAttr(fldAttr.captureType, fld.captureType || 'INPUT');
2260
+ (attrName === FIELD_TYPE) && this.setFieldType(fld.fieldTypeCode);
2261
+ (attrName === FIELD_MAX_LENGTH) && this.setAttr(fldAttr.maxLength, fld.maxLength);
2110
2262
  }
2111
2263
  };
2112
2264
  FieldDescriptor.prototype.setFieldType = function (inputFieldType) {
2113
- this.fieldType = inputFieldType;
2114
- /**
2115
- * Se elimina la validación de que sea un tipo conocido
2116
- * this.fieldType = (inputFieldType && FIELDTYPES.includes(inputFieldType))
2117
- * ? inputFieldType : componentConstants.FIELDTYPE_TEXT;
2118
- */
2265
+ this.setAttr(fldAttr.type, inputFieldType);
2119
2266
  };
2120
2267
  FieldDescriptor.prototype.format = function () {
2121
2268
  if (this.fieldType === componentConstants.FIELDTYPE_CURRENCY) {
2122
- this._fieldValue = formatCurrency(this._fieldValue);
2269
+ this.setAttr(fldAttr.value, formatCurrency(this._fieldValue));
2123
2270
  }
2124
2271
  };
2125
2272
  FieldDescriptor.prototype.setMinValue = function (minValue) {
2126
2273
  var _a, _b, _c;
2127
2274
  if (this.fieldType === componentConstants.FIELDTYPE_DATE
2128
2275
  && ((_a = this.widget) === null || _a === void 0 ? void 0 : _a.setMinValue)) {
2129
- this._minValue = minValue;
2276
+ this.setAttr(fldAttr.minValue, minValue);
2130
2277
  if (!minValue) {
2131
2278
  (_b = this.widget) === null || _b === void 0 ? void 0 : _b.setMinValue(false);
2132
2279
  }
@@ -2140,7 +2287,7 @@
2140
2287
  var _a, _b, _c;
2141
2288
  if (this.fieldType === componentConstants.FIELDTYPE_DATE
2142
2289
  && ((_a = this.widget) === null || _a === void 0 ? void 0 : _a.setMaxValue)) {
2143
- this._maxValue = maxValue;
2290
+ this.setAttr(fldAttr.maxValue, maxValue);
2144
2291
  if (!maxValue) {
2145
2292
  (_b = this.widget) === null || _b === void 0 ? void 0 : _b.setMaxValue(false);
2146
2293
  }
@@ -2168,14 +2315,16 @@
2168
2315
  }
2169
2316
  return Object.assign({}, option);
2170
2317
  });
2171
- this.fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
2318
+ fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
2172
2319
  && fieldOptions.length > 0) ? fieldOptions : [];
2320
+ this.setAttr(fldAttr.options, fieldOptions);
2173
2321
  if (this.fieldType === componentConstants.FIELDTYPE_ARRAY && this.widget) {
2174
2322
  return (_a = this.widget) === null || _a === void 0 ? void 0 : _a.refereshContent();
2175
2323
  }
2176
2324
  if (this._fieldValue) {
2177
2325
  if (this.fieldType === componentConstants.FIELDTYPE_ARRAY && Array.isArray(this._fieldValue)) {
2178
- this._fieldValue = (_b = this._fieldValue) === null || _b === void 0 ? void 0 : _b.filter(function (item) { return _this.fieldOptions.find(function (opt) { return opt.fieldOptionId === item; }); });
2326
+ var fieldValue = (_b = this._fieldValue) === null || _b === void 0 ? void 0 : _b.filter(function (item) { return _this.fieldOptions.find(function (opt) { return opt.fieldOptionId === item; }); });
2327
+ this.setAttr(fldAttr.value, fieldValue);
2179
2328
  }
2180
2329
  else {
2181
2330
  var valInOptions = this.fieldOptions
@@ -2196,7 +2345,7 @@
2196
2345
  if (widgetUpdate === void 0) { widgetUpdate = true; }
2197
2346
  var _a;
2198
2347
  if (typeof newValue === UNDEFINED || newValue === null) {
2199
- return;
2348
+ return true;
2200
2349
  }
2201
2350
  var newFinalValue;
2202
2351
  switch (this.fieldType) {
@@ -2236,9 +2385,10 @@
2236
2385
  break;
2237
2386
  }
2238
2387
  if (this._fieldValue !== newFinalValue) {
2239
- this.hasChanged = true;
2240
- this._fieldValue = newFinalValue;
2388
+ this.setChanged(true);
2389
+ this.setAttr(fldAttr.value, newFinalValue);
2241
2390
  }
2391
+ return true;
2242
2392
  };
2243
2393
  return FieldDescriptor;
2244
2394
  }(FormElement));
@@ -2721,6 +2871,15 @@
2721
2871
  var fieldObject = this.getFieldObject(fieldCode);
2722
2872
  return (fieldObject) ? fieldObject.setValue(fieldValue) : null;
2723
2873
  };
2874
+ FormStructureAndData.prototype.setFieldError = function (code, message, type) {
2875
+ if (type === void 0) { type = 'error'; }
2876
+ var fieldObject = this.getFieldObject(code);
2877
+ return (fieldObject) ? fieldObject.setError(code, message, type) : null;
2878
+ };
2879
+ FormStructureAndData.prototype.setFieldIntrinsicErrorMessage = function (code, message) {
2880
+ var fieldObject = this.getFieldObject(code);
2881
+ return (fieldObject) ? fieldObject.setIntrinsicErrorMessage(message) : null;
2882
+ };
2724
2883
  FormStructureAndData.prototype.setFieldRequired = function (fieldCode, required) {
2725
2884
  var fieldObject = this.getFieldObject(fieldCode);
2726
2885
  return (fieldObject) ? fieldObject.required = required : null;
@@ -3223,6 +3382,11 @@
3223
3382
  BasicFormComponent.prototype.setFieldValue = function (fieldCode, fieldValue) { return this.formStructure.setFieldValue(fieldCode, fieldValue); };
3224
3383
  BasicFormComponent.prototype.setFieldRequired = function (fieldCode, required) { return this.formStructure.setFieldRequired(fieldCode, required); };
3225
3384
  BasicFormComponent.prototype.setFieldErrorMessage = function (fieldCode, errorMessage) { return this.formStructure.setFieldErrorMessage(fieldCode, errorMessage); };
3385
+ BasicFormComponent.prototype.setFieldError = function (code, message, type) {
3386
+ if (type === void 0) { type = 'error'; }
3387
+ return this.formStructure.setFieldError(code, message, type);
3388
+ };
3389
+ BasicFormComponent.prototype.setFieldIntrinsicErrorMessage = function (code, message) { return this.formStructure.setFieldIntrinsicErrorMessage(code, message); };
3226
3390
  BasicFormComponent.prototype.setFieldOptions = function (fieldCode, optionsArray, idAttribute, nameAttribute) {
3227
3391
  return this.formStructure.setFieldOptions(fieldCode, optionsArray, idAttribute, nameAttribute);
3228
3392
  };
@@ -3441,8 +3605,14 @@
3441
3605
  var formFields = this.formStructure.getFields();
3442
3606
  if (Array.isArray(formFields)) {
3443
3607
  formFields.forEach(function (field) {
3444
- field.editionFinish.subscribe(function (code) { return _this.startFieldValidation(code); });
3445
- field.editionPartial.subscribe(function (code) { return _this.startFieldInputValidation(code); });
3608
+ field.editionFinish.subscribe(function (event) {
3609
+ var code = event.code, intrinsicValidation = event.intrinsicValidation;
3610
+ _this.startFieldValidation(code, intrinsicValidation);
3611
+ });
3612
+ field.editionPartial.subscribe(function (event) {
3613
+ var code = event.code, intrinsicValidation = event.intrinsicValidation;
3614
+ _this.startFieldInputValidation(code, intrinsicValidation);
3615
+ });
3446
3616
  field.detailRequest.subscribe(function (code) { return _this.showFieldInfo(code); });
3447
3617
  });
3448
3618
  }
@@ -3909,7 +4079,8 @@
3909
4079
  _this.fieldValidationsFinish[fieldCode].push(callbackMethod);
3910
4080
  });
3911
4081
  };
3912
- BasicFormComponent.prototype.startFieldInputValidation = function (fieldCode) {
4082
+ BasicFormComponent.prototype.startFieldInputValidation = function (fieldCode, intrinsicValidation) {
4083
+ if (intrinsicValidation === void 0) { intrinsicValidation = true; }
3913
4084
  return __awaiter(this, void 0, void 0, function () {
3914
4085
  var fieldToValidate, validationCallbacks, clientValidationPromises, validationCallbacks_1, validationCallbacks_1_1, validationMethod, continueValidationPromise;
3915
4086
  var e_10, _g;
@@ -3948,7 +4119,8 @@
3948
4119
  });
3949
4120
  });
3950
4121
  };
3951
- BasicFormComponent.prototype.startFieldValidation = function (fieldCode) {
4122
+ BasicFormComponent.prototype.startFieldValidation = function (fieldCode, intrinsicValidation) {
4123
+ if (intrinsicValidation === void 0) { intrinsicValidation = true; }
3952
4124
  return __awaiter(this, void 0, void 0, function () {
3953
4125
  var fieldToValidate, validationCallbacks, clientValidationPromises, validationCallbacks_2, validationCallbacks_2_1, validationMethod, clientValidationPromise, clientValidationResults, continueValidation;
3954
4126
  var e_11, _g;
@@ -3956,7 +4128,7 @@
3956
4128
  switch (_h.label) {
3957
4129
  case 0:
3958
4130
  fieldToValidate = this.getField(fieldCode);
3959
- if (!fieldToValidate) {
4131
+ if (!fieldToValidate || !intrinsicValidation) {
3960
4132
  return [2 /*return*/];
3961
4133
  }
3962
4134
  fieldToValidate.setErrorMessage('');
@@ -4004,6 +4176,7 @@
4004
4176
  finish = true;
4005
4177
  validationResult = null;
4006
4178
  if (!fieldObj.backend) return [3 /*break*/, 2];
4179
+ fieldObj.validating = true;
4007
4180
  return [4 /*yield*/, this
4008
4181
  .requestFormAction(componentConstants.FORMACTION_VALIDATE, fieldObj.fieldCode)];
4009
4182
  case 1:
@@ -4021,7 +4194,9 @@
4021
4194
  fieldObj.setErrorMessage(this.errorMessage);
4022
4195
  this.displayValidationServerError();
4023
4196
  _g.label = 5;
4024
- case 5: return [2 /*return*/];
4197
+ case 5:
4198
+ fieldObj.validating = false;
4199
+ return [2 /*return*/];
4025
4200
  }
4026
4201
  });
4027
4202
  });