tuain-ng-forms-lib 0.12.21 → 0.12.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/tuain-ng-forms-lib.umd.js +181 -117
- package/bundles/tuain-ng-forms-lib.umd.js.map +1 -1
- package/esm2015/lib/classes/forms/action.js +2 -2
- package/esm2015/lib/classes/forms/element.js +4 -4
- package/esm2015/lib/classes/forms/field.js +143 -112
- package/esm2015/lib/classes/forms/subsection.js +2 -2
- package/esm2015/lib/classes/forms/table/table.js +2 -2
- package/esm2015/lib/components/elements/field.component.js +30 -2
- package/fesm2015/tuain-ng-forms-lib.js +177 -118
- package/fesm2015/tuain-ng-forms-lib.js.map +1 -1
- package/lib/classes/forms/element.d.ts +1 -1
- package/lib/classes/forms/field.d.ts +18 -13
- package/lib/components/elements/field.component.d.ts +16 -0
- package/package.json +1 -1
- package/tuain-ng-forms-lib.metadata.json +1 -1
|
@@ -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
|
-
|
|
168
|
+
var _this = this;
|
|
169
|
+
if (this.fieldObject) {
|
|
170
|
+
// Atributos estáticos
|
|
171
|
+
this.code = 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.
|
|
661
|
-
FormElement.prototype.isAction = function () { return this.
|
|
662
|
-
FormElement.prototype.isTable = function () { return this.
|
|
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.
|
|
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.
|
|
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.
|
|
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,9 +1966,8 @@
|
|
|
1937
1966
|
var FIELD_TOOLTIP = 'tooltipText';
|
|
1938
1967
|
var FIELD_INFO = 'info';
|
|
1939
1968
|
var FIELD_EDITABLE = 'editable';
|
|
1940
|
-
var EMAIL_FORMAT = '^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$';
|
|
1941
|
-
// Norbey ".+@([\da-z\.-]+)\.([a-z\.]{2,6})"
|
|
1942
1969
|
var FIELD_TYPES = {
|
|
1970
|
+
boolean: 'BOOLEAN',
|
|
1943
1971
|
array: 'ARRAY',
|
|
1944
1972
|
check: 'CHECK',
|
|
1945
1973
|
date: 'DATE',
|
|
@@ -1964,45 +1992,94 @@
|
|
|
1964
1992
|
email: 'EMAIL',
|
|
1965
1993
|
phone: 'PHONE',
|
|
1966
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'];
|
|
1967
2007
|
var STD_MAX_LENGTH = 50;
|
|
1968
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
|
+
};
|
|
1969
2038
|
var FieldDescriptor = /** @class */ (function (_super) {
|
|
1970
2039
|
__extends(FieldDescriptor, _super);
|
|
1971
2040
|
function FieldDescriptor(inputFieldReceived) {
|
|
1972
2041
|
var _this = this;
|
|
1973
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2042
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1974
2043
|
_this = _super.call(this, inputFieldReceived) || this;
|
|
1975
2044
|
_this._editionFinish = new rxjs.Subject();
|
|
1976
2045
|
_this._editionPartial = new rxjs.Subject();
|
|
1977
2046
|
_this._detailRequest = new rxjs.Subject();
|
|
1978
|
-
_this.
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
_this.
|
|
1982
|
-
_this.
|
|
1983
|
-
_this.captureType =
|
|
1984
|
-
_this.
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
_this.
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
_this.
|
|
1998
|
-
_this.
|
|
1999
|
-
_this.
|
|
2000
|
-
_this.
|
|
2001
|
-
_this.
|
|
2002
|
-
_this.
|
|
2003
|
-
_this.
|
|
2004
|
-
|
|
2005
|
-
|
|
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 || '');
|
|
2006
2083
|
return _this;
|
|
2007
2084
|
}
|
|
2008
2085
|
Object.defineProperty(FieldDescriptor.prototype, "name", {
|
|
@@ -2015,6 +2092,11 @@
|
|
|
2015
2092
|
enumerable: false,
|
|
2016
2093
|
configurable: true
|
|
2017
2094
|
});
|
|
2095
|
+
Object.defineProperty(FieldDescriptor.prototype, "attributeChange", {
|
|
2096
|
+
get: function () { return this._attributeChange; },
|
|
2097
|
+
enumerable: false,
|
|
2098
|
+
configurable: true
|
|
2099
|
+
});
|
|
2018
2100
|
Object.defineProperty(FieldDescriptor.prototype, "editionPartial", {
|
|
2019
2101
|
get: function () { return this._editionPartial; },
|
|
2020
2102
|
enumerable: false,
|
|
@@ -2027,11 +2109,11 @@
|
|
|
2027
2109
|
});
|
|
2028
2110
|
Object.defineProperty(FieldDescriptor.prototype, "validating", {
|
|
2029
2111
|
get: function () { return this._onValidation; },
|
|
2030
|
-
set: function (isValidating) { this.
|
|
2112
|
+
set: function (isValidating) { this.setAttr(fldAttr.onValidation, isValidating); },
|
|
2031
2113
|
enumerable: false,
|
|
2032
2114
|
configurable: true
|
|
2033
2115
|
});
|
|
2034
|
-
FieldDescriptor.prototype.setIntrinsicErrorMessage = function (message) { this.
|
|
2116
|
+
FieldDescriptor.prototype.setIntrinsicErrorMessage = function (message) { this.setAttr(fldAttr.intrinsicErrorMessage, message); };
|
|
2035
2117
|
Object.defineProperty(FieldDescriptor.prototype, "intrinsicErrorMessage", {
|
|
2036
2118
|
set: function (message) { this.setIntrinsicErrorMessage(message); },
|
|
2037
2119
|
enumerable: false,
|
|
@@ -2044,7 +2126,7 @@
|
|
|
2044
2126
|
});
|
|
2045
2127
|
Object.defineProperty(FieldDescriptor.prototype, "required", {
|
|
2046
2128
|
get: function () { return this.fieldRequired; },
|
|
2047
|
-
set: function (required) { this.
|
|
2129
|
+
set: function (required) { this.setAttr(fldAttr.required, required !== null && required !== void 0 ? required : false); },
|
|
2048
2130
|
enumerable: false,
|
|
2049
2131
|
configurable: true
|
|
2050
2132
|
});
|
|
@@ -2052,10 +2134,10 @@
|
|
|
2052
2134
|
get: function () { return (this._maxLength > 0) ? this._maxLength.toString() : ''; },
|
|
2053
2135
|
set: function (requiredMaxLength) {
|
|
2054
2136
|
if (typeof requiredMaxLength === 'string') {
|
|
2055
|
-
this.
|
|
2137
|
+
this.setAttr(fldAttr.maxLength, parseInt(requiredMaxLength, 10));
|
|
2056
2138
|
}
|
|
2057
2139
|
else if (typeof requiredMaxLength === 'number') {
|
|
2058
|
-
this.
|
|
2140
|
+
this.setAttr(fldAttr.maxLength, requiredMaxLength);
|
|
2059
2141
|
}
|
|
2060
2142
|
},
|
|
2061
2143
|
enumerable: false,
|
|
@@ -2072,50 +2154,58 @@
|
|
|
2072
2154
|
this._editionPartial.next({ code: this.fieldCode, intrinsicValidation: intrinsicValidation });
|
|
2073
2155
|
};
|
|
2074
2156
|
FieldDescriptor.prototype.notifyEditionFinish = function () {
|
|
2157
|
+
var _a, _b, _c, _d;
|
|
2075
2158
|
var intrinsicValidation = true;
|
|
2076
|
-
var
|
|
2077
|
-
var fieldFormat = new RegExp(fieldExpression);
|
|
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;
|
|
2078
2160
|
var fieldValue = this.getValue();
|
|
2079
|
-
if (fieldValue && fieldFormat) {
|
|
2080
|
-
intrinsicValidation =
|
|
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);
|
|
2081
2164
|
if (!intrinsicValidation) {
|
|
2082
|
-
|
|
2083
|
-
? "El valor de " + this.fieldTitle + " no corresponde a un correo v\u00E1lido"
|
|
2084
|
-
: "El valor de " + this.fieldTitle + " no se ajusta al formato establecido";
|
|
2085
|
-
this.setError('99', message);
|
|
2165
|
+
this.setError('99', this._intrinsicErrorMessage);
|
|
2086
2166
|
}
|
|
2087
2167
|
}
|
|
2088
2168
|
this._editionFinish.next({ code: this.fieldCode, intrinsicValidation: intrinsicValidation });
|
|
2089
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
|
+
};
|
|
2090
2178
|
FieldDescriptor.prototype.notifyEditionDetailRequest = function () {
|
|
2091
2179
|
this._detailRequest.next(this.fieldCode);
|
|
2092
2180
|
};
|
|
2093
|
-
FieldDescriptor.prototype.
|
|
2094
|
-
FieldDescriptor.prototype.
|
|
2095
|
-
FieldDescriptor.prototype.
|
|
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); };
|
|
2096
2186
|
FieldDescriptor.prototype.getRawValue = function () { return this._fieldValue; };
|
|
2097
|
-
FieldDescriptor.prototype.setLabel = function (label) { this.
|
|
2187
|
+
FieldDescriptor.prototype.setLabel = function (label) { this.setAttr(fldAttr.title, label); };
|
|
2098
2188
|
FieldDescriptor.prototype.clean = function () { this.setValue(this.defaultValue || ''); };
|
|
2099
2189
|
Object.defineProperty(FieldDescriptor.prototype, "backend", {
|
|
2100
2190
|
get: function () { return this.validateOnServer; },
|
|
2101
2191
|
enumerable: false,
|
|
2102
2192
|
configurable: true
|
|
2103
2193
|
});
|
|
2104
|
-
FieldDescriptor.prototype.setVisibleLabel = function (visibleLabel) { this.visibleLabel = visibleLabel; };
|
|
2105
2194
|
FieldDescriptor.prototype.setEditable = function (editable) {
|
|
2106
2195
|
if (editable === void 0) { editable = true; }
|
|
2107
2196
|
(editable) ? this.enable() : this.disable();
|
|
2108
2197
|
};
|
|
2198
|
+
FieldDescriptor.prototype.hasError = function () { return this.errorCode !== '00'; };
|
|
2109
2199
|
FieldDescriptor.prototype.setError = function (code, message, type) {
|
|
2110
|
-
if (type === void 0) { type =
|
|
2111
|
-
this.
|
|
2112
|
-
this.errorCode
|
|
2113
|
-
this.errorMessage
|
|
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 : '');
|
|
2114
2204
|
};
|
|
2115
2205
|
FieldDescriptor.prototype.getError = function () { return { type: this.errorType, code: this.errorCode, message: this.errorMessage }; };
|
|
2116
2206
|
Object.defineProperty(FieldDescriptor.prototype, "error", {
|
|
2117
2207
|
get: function () { return this.getError(); },
|
|
2118
|
-
set: function (errorObj) { this.setError(errorObj.code, errorObj.message, errorObj.type); },
|
|
2208
|
+
set: function (errorObj) { var _a; this.setError(errorObj.code, errorObj.message, (_a = errorObj.type) !== null && _a !== void 0 ? _a : DEFAULT_ERROR_TYPE); },
|
|
2119
2209
|
enumerable: false,
|
|
2120
2210
|
configurable: true
|
|
2121
2211
|
});
|
|
@@ -2151,68 +2241,39 @@
|
|
|
2151
2241
|
};
|
|
2152
2242
|
FieldDescriptor.prototype.updateFromServer = function (fld) {
|
|
2153
2243
|
var _a;
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
this.
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
(this.
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
(this.
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
(this.
|
|
2171
|
-
|
|
2172
|
-
if (FIELD_INFO in fld) {
|
|
2173
|
-
(this.fieldInfo = fld.info);
|
|
2174
|
-
}
|
|
2175
|
-
if (FIELD_EDITABLE in fld) {
|
|
2176
|
-
this.setEditable(fld.editable);
|
|
2177
|
-
}
|
|
2178
|
-
if (FIELD_TITLE in fld) {
|
|
2179
|
-
this.setLabel(fld.fieldTitle.toString());
|
|
2180
|
-
}
|
|
2181
|
-
if (FIELD_VALUE in fld) {
|
|
2182
|
-
this.hasChanged = false;
|
|
2183
|
-
this.setValue(fld.fieldValue);
|
|
2184
|
-
}
|
|
2185
|
-
if (FIELD_OPTIONS in fld) {
|
|
2186
|
-
this.setFieldOptions(fld.fieldOptions);
|
|
2187
|
-
}
|
|
2188
|
-
if (FIELD_CAPTURE_TYPE in fld) {
|
|
2189
|
-
this.captureType = fld.captureType || 'INPUT';
|
|
2190
|
-
}
|
|
2191
|
-
if (FIELD_TYPE in fld) {
|
|
2192
|
-
this.setFieldType(fld.fieldTypeCode);
|
|
2193
|
-
}
|
|
2194
|
-
if (FIELD_MAX_LENGTH in fld) {
|
|
2195
|
-
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);
|
|
2196
2262
|
}
|
|
2197
2263
|
};
|
|
2198
2264
|
FieldDescriptor.prototype.setFieldType = function (inputFieldType) {
|
|
2199
|
-
this.
|
|
2200
|
-
/**
|
|
2201
|
-
* Se elimina la validación de que sea un tipo conocido
|
|
2202
|
-
* this.fieldType = (inputFieldType && FIELDTYPES.includes(inputFieldType))
|
|
2203
|
-
* ? inputFieldType : componentConstants.FIELDTYPE_TEXT;
|
|
2204
|
-
*/
|
|
2265
|
+
this.setAttr(fldAttr.type, inputFieldType);
|
|
2205
2266
|
};
|
|
2206
2267
|
FieldDescriptor.prototype.format = function () {
|
|
2207
2268
|
if (this.fieldType === componentConstants.FIELDTYPE_CURRENCY) {
|
|
2208
|
-
this.
|
|
2269
|
+
this.setAttr(fldAttr.value, formatCurrency(this._fieldValue));
|
|
2209
2270
|
}
|
|
2210
2271
|
};
|
|
2211
2272
|
FieldDescriptor.prototype.setMinValue = function (minValue) {
|
|
2212
2273
|
var _a, _b, _c;
|
|
2213
2274
|
if (this.fieldType === componentConstants.FIELDTYPE_DATE
|
|
2214
2275
|
&& ((_a = this.widget) === null || _a === void 0 ? void 0 : _a.setMinValue)) {
|
|
2215
|
-
this.
|
|
2276
|
+
this.setAttr(fldAttr.minValue, minValue);
|
|
2216
2277
|
if (!minValue) {
|
|
2217
2278
|
(_b = this.widget) === null || _b === void 0 ? void 0 : _b.setMinValue(false);
|
|
2218
2279
|
}
|
|
@@ -2226,7 +2287,7 @@
|
|
|
2226
2287
|
var _a, _b, _c;
|
|
2227
2288
|
if (this.fieldType === componentConstants.FIELDTYPE_DATE
|
|
2228
2289
|
&& ((_a = this.widget) === null || _a === void 0 ? void 0 : _a.setMaxValue)) {
|
|
2229
|
-
this.
|
|
2290
|
+
this.setAttr(fldAttr.maxValue, maxValue);
|
|
2230
2291
|
if (!maxValue) {
|
|
2231
2292
|
(_b = this.widget) === null || _b === void 0 ? void 0 : _b.setMaxValue(false);
|
|
2232
2293
|
}
|
|
@@ -2254,14 +2315,16 @@
|
|
|
2254
2315
|
}
|
|
2255
2316
|
return Object.assign({}, option);
|
|
2256
2317
|
});
|
|
2257
|
-
|
|
2318
|
+
fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
|
|
2258
2319
|
&& fieldOptions.length > 0) ? fieldOptions : [];
|
|
2320
|
+
this.setAttr(fldAttr.options, fieldOptions);
|
|
2259
2321
|
if (this.fieldType === componentConstants.FIELDTYPE_ARRAY && this.widget) {
|
|
2260
2322
|
return (_a = this.widget) === null || _a === void 0 ? void 0 : _a.refereshContent();
|
|
2261
2323
|
}
|
|
2262
2324
|
if (this._fieldValue) {
|
|
2263
2325
|
if (this.fieldType === componentConstants.FIELDTYPE_ARRAY && Array.isArray(this._fieldValue)) {
|
|
2264
|
-
|
|
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);
|
|
2265
2328
|
}
|
|
2266
2329
|
else {
|
|
2267
2330
|
var valInOptions = this.fieldOptions
|
|
@@ -2282,7 +2345,7 @@
|
|
|
2282
2345
|
if (widgetUpdate === void 0) { widgetUpdate = true; }
|
|
2283
2346
|
var _a;
|
|
2284
2347
|
if (typeof newValue === UNDEFINED || newValue === null) {
|
|
2285
|
-
return;
|
|
2348
|
+
return true;
|
|
2286
2349
|
}
|
|
2287
2350
|
var newFinalValue;
|
|
2288
2351
|
switch (this.fieldType) {
|
|
@@ -2322,9 +2385,10 @@
|
|
|
2322
2385
|
break;
|
|
2323
2386
|
}
|
|
2324
2387
|
if (this._fieldValue !== newFinalValue) {
|
|
2325
|
-
this.
|
|
2326
|
-
this.
|
|
2388
|
+
this.setChanged(true);
|
|
2389
|
+
this.setAttr(fldAttr.value, newFinalValue);
|
|
2327
2390
|
}
|
|
2391
|
+
return true;
|
|
2328
2392
|
};
|
|
2329
2393
|
return FieldDescriptor;
|
|
2330
2394
|
}(FormElement));
|