tuain-ng-forms-lib 12.0.35 → 12.0.37

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.
@@ -394,35 +394,37 @@
394
394
  }
395
395
  FieldComponent.prototype.ngOnInit = function () {
396
396
  var _this = this;
397
- var _a, _b;
397
+ var _a, _b, _c;
398
398
  if (this.field) {
399
399
  this.formConfig = (_a = this.field) === null || _a === void 0 ? void 0 : _a._formConfig;
400
400
  // Inicialización
401
401
  var mapping = Object.entries(this.formConfig.componentFieldAttrMap);
402
402
  for (var index = 0; index < mapping.length; index++) {
403
- var _c = __read(mapping[index], 2), fieldAttr = _c[0], compAttr1 = _c[1];
403
+ var _d = __read(mapping[index], 2), fieldAttr1 = _d[0], compAttr1 = _d[1];
404
404
  var compAttr = compAttr1.toString();
405
- if (compAttr === VALUE) {
406
- this.updateValue();
407
- }
408
- else {
409
- this[compAttr] = (_b = this.field) === null || _b === void 0 ? void 0 : _b[fieldAttr.toString()];
410
- }
405
+ var fieldAttr = fieldAttr1.toString();
406
+ this.dafaultProcessFieldChange(compAttr, (_b = this.field) === null || _b === void 0 ? void 0 : _b[fieldAttr]);
407
+ this.processFieldChange(compAttr, (_c = this.field) === null || _c === void 0 ? void 0 : _c[fieldAttr]);
411
408
  }
412
409
  // Subscripción a cambios en atributos
413
410
  this.field.attributeChange.subscribe(function (event) {
414
411
  var fieldAttr = event.name, value = event.value;
415
412
  var compAttr = _this.formConfig.componentFieldAttrMap[fieldAttr];
416
- if (compAttr === VALUE) {
417
- _this.updateValue();
418
- }
419
- else {
420
- _this[compAttr] = value;
421
- }
413
+ _this.dafaultProcessFieldChange(compAttr, value);
414
+ _this.processFieldChange(compAttr, value);
422
415
  });
423
416
  }
424
417
  this.start();
425
418
  };
419
+ FieldComponent.prototype.dafaultProcessFieldChange = function (attribute, value) {
420
+ if (attribute === VALUE) {
421
+ this.updateValue();
422
+ }
423
+ else {
424
+ this[attribute] = value;
425
+ }
426
+ };
427
+ FieldComponent.prototype.processFieldChange = function (attribute, value) { };
426
428
  FieldComponent.prototype.start = function () { };
427
429
  FieldComponent.prototype.focus = function () { };
428
430
  FieldComponent.prototype.updateObject = function () {
@@ -1952,40 +1954,26 @@
1952
1954
  FieldDescriptor.prototype.setFieldType = function (inputFieldType) {
1953
1955
  this.setAttr(fldAttr.type, inputFieldType);
1954
1956
  };
1955
- FieldDescriptor.prototype.setMinValue = function (minValue) {
1956
- var _a, _b, _c;
1957
- if (this.fieldType === this._formConfig.fieldTypes.date
1958
- && ((_a = this.widget) === null || _a === void 0 ? void 0 : _a.setMinValue)) {
1959
- this.setAttr(fldAttr.minValue, minValue);
1960
- if (!minValue) {
1961
- (_b = this.widget) === null || _b === void 0 ? void 0 : _b.setMinValue(false);
1962
- }
1963
- else {
1964
- var minDate = new Date(minValue);
1965
- (_c = this.widget) === null || _c === void 0 ? void 0 : _c.setMinValue(minDate);
1966
- }
1957
+ FieldDescriptor.prototype.setMinValue = function (inputMinValue) {
1958
+ var minValue = inputMinValue;
1959
+ if (this.fieldType === this._formConfig.fieldTypes.date) {
1960
+ minValue = new Date(minValue);
1967
1961
  }
1962
+ this.setAttr(fldAttr.minValue, minValue);
1968
1963
  };
1969
- FieldDescriptor.prototype.setMaxValue = function (maxValue) {
1970
- var _a, _b, _c;
1971
- if (this.fieldType === this._formConfig.fieldTypes.date
1972
- && ((_a = this.widget) === null || _a === void 0 ? void 0 : _a.setMaxValue)) {
1973
- this.setAttr(fldAttr.maxValue, maxValue);
1974
- if (!maxValue) {
1975
- (_b = this.widget) === null || _b === void 0 ? void 0 : _b.setMaxValue(false);
1976
- }
1977
- else {
1978
- var maxDate = new Date(maxValue);
1979
- (_c = this.widget) === null || _c === void 0 ? void 0 : _c.setMaxValue(maxDate);
1980
- }
1964
+ FieldDescriptor.prototype.setMaxValue = function (inputMaxValue) {
1965
+ var maxValue = inputMaxValue;
1966
+ if (this.fieldType === this._formConfig.fieldTypes.date) {
1967
+ maxValue = new Date(maxValue);
1981
1968
  }
1969
+ this.setAttr(fldAttr.maxValue, maxValue);
1982
1970
  };
1983
1971
  FieldDescriptor.prototype.getFieldOptions = function () {
1984
1972
  return JSON.parse(JSON.stringify(this.fieldOptions));
1985
1973
  };
1986
1974
  FieldDescriptor.prototype.setFieldOptions = function (newOptions) {
1987
1975
  var _this = this;
1988
- var _a, _b, _c, _d;
1976
+ var _a;
1989
1977
  if ((this.captureType !== 'LIST' && this.captureType !== 'RADIO')
1990
1978
  || typeof newOptions === UNDEFINED || !newOptions
1991
1979
  || !Array.isArray(newOptions)) {
@@ -2001,12 +1989,9 @@
2001
1989
  fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
2002
1990
  && fieldOptions.length > 0) ? fieldOptions : [];
2003
1991
  this.setAttr(fldAttr.options, fieldOptions);
2004
- if (this.fieldType === this._formConfig.fieldTypes.array && this.widget) {
2005
- return (_a = this.widget) === null || _a === void 0 ? void 0 : _a.refereshContent();
2006
- }
2007
1992
  if (this._value) {
2008
1993
  if (this.fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._value)) {
2009
- var fieldValue = (_b = this._value) === null || _b === void 0 ? void 0 : _b.filter(function (item) { return _this.fieldOptions.find(function (opt) { return opt.fieldOptionId === item; }); });
1994
+ var fieldValue = (_a = this._value) === null || _a === void 0 ? void 0 : _a.filter(function (item) { return _this.fieldOptions.find(function (opt) { return opt.fieldOptionId === item; }); });
2010
1995
  this.setAttr(fldAttr.value, fieldValue);
2011
1996
  }
2012
1997
  else {
@@ -2019,57 +2004,41 @@
2019
2004
  }
2020
2005
  if (this.fieldRequired && this.fieldOptions.length === 1) {
2021
2006
  this.setValue(this.fieldOptions[0].fieldOptionId);
2022
- if ((_c = this.widget) === null || _c === void 0 ? void 0 : _c.onChangeContent) {
2023
- (_d = this.widget) === null || _d === void 0 ? void 0 : _d.onChangeContent();
2024
- }
2025
2007
  }
2026
2008
  };
2027
2009
  FieldDescriptor.prototype.setValue = function (newValue, widgetUpdate) {
2028
2010
  if (widgetUpdate === void 0) { widgetUpdate = true; }
2029
- var _a;
2030
2011
  if (typeof newValue === UNDEFINED || newValue === null) {
2031
2012
  return true;
2032
2013
  }
2033
2014
  var newFinalValue;
2034
- switch (this.fieldType) {
2035
- case 'BOOLEAN':
2036
- newFinalValue = !!newValue;
2037
- break;
2038
- case this._formConfig.fieldTypes.boolean:
2039
- newFinalValue = !!newValue;
2040
- break;
2041
- case this._formConfig.fieldTypes.check:
2042
- newFinalValue = !!newValue;
2043
- break;
2044
- case this._formConfig.fieldTypes.array:
2045
- if (newValue === null || newValue === '') {
2046
- newFinalValue = [];
2047
- }
2048
- else if (!Array.isArray(newValue)) {
2049
- if (typeof (newValue) !== 'string') {
2050
- newValue = newValue.toString();
2051
- }
2052
- newFinalValue = newValue.split(',');
2053
- }
2054
- else {
2055
- newFinalValue = newValue;
2056
- }
2057
- break;
2058
- case this._formConfig.fieldTypes.map:
2059
- newFinalValue = newValue;
2060
- if (newFinalValue && this.widget && widgetUpdate) {
2061
- var latitude = parseFloat(newFinalValue[0]);
2062
- var longitude = parseFloat(newFinalValue[1]);
2063
- (_a = this.widget) === null || _a === void 0 ? void 0 : _a.setLocation(latitude, longitude);
2064
- }
2065
- break;
2066
- default:
2015
+ if (this.fieldType === this._formConfig.fieldTypes.boolean
2016
+ || this.fieldType === this._formConfig.fieldTypes.check) {
2017
+ newFinalValue = yn__default['default'](newValue);
2018
+ }
2019
+ else if (this.fieldType === this._formConfig.fieldTypes.array
2020
+ || this.fieldType === this._formConfig.fieldTypes.map) {
2021
+ if (newValue === null || newValue === '') {
2022
+ newFinalValue = [];
2023
+ }
2024
+ else if (Array.isArray(newValue)) {
2067
2025
  newFinalValue = newValue;
2068
- break;
2026
+ }
2027
+ else {
2028
+ newFinalValue = newValue.toString().split(',');
2029
+ }
2030
+ }
2031
+ else {
2032
+ newFinalValue = newValue;
2069
2033
  }
2070
2034
  if (this._value !== newFinalValue) {
2071
2035
  this.setChanged(true);
2072
- this.setAttr(fldAttr.value, newFinalValue);
2036
+ if (widgetUpdate) {
2037
+ this.setAttr(fldAttr.value, newFinalValue);
2038
+ }
2039
+ else {
2040
+ this._value = newFinalValue;
2041
+ }
2073
2042
  }
2074
2043
  return true;
2075
2044
  };