@seniorsistemas/angular-components 17.10.4 → 17.10.5

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.
@@ -11714,6 +11714,7 @@ var CustomFieldType;
11714
11714
  CustomFieldType["Any"] = "Any";
11715
11715
  CustomFieldType["Enum"] = "Enum";
11716
11716
  })(CustomFieldType || (CustomFieldType = {}));
11717
+
11717
11718
  var moment$5 = moment_; // @HACK Necessary because of https://github.com/rollup/rollup/issues/670
11718
11719
  var CustomFieldsComponent = /** @class */ (function () {
11719
11720
  function CustomFieldsComponent(customFieldsService, localeService, sanitizer, translateService, controlContainer) {
@@ -11747,81 +11748,14 @@ var CustomFieldsComponent = /** @class */ (function () {
11747
11748
  configurable: true
11748
11749
  });
11749
11750
  CustomFieldsComponent.prototype.ngOnInit = function () {
11750
- var _this = this;
11751
- if (!this.domain)
11752
- throw new Error("You need to specify the custom-fields domain!");
11753
- if (!this.service)
11754
- throw new Error("You need to specify the custom-fields service!");
11755
- if (!this.entity)
11756
- throw new Error("You need to specify the custom-fields entity!");
11757
- this.formGroup = new FormGroup({});
11758
- var observables = [this.getCustomFields(), this.localeService.get()];
11759
- forkJoin(observables)
11760
- .pipe(takeUntil(this.ngUsubscribe), finalize(function () {
11761
- var _a;
11762
- _this.formGroup.markAsPristine();
11763
- (_a = _this.parentControl) === null || _a === void 0 ? void 0 : _a.markAsPristine();
11764
- if (_this.ready$)
11765
- _this.ready$.next(true);
11766
- }))
11767
- .subscribe(function (response) {
11768
- var _a = __read(response, 2), customFieldsResponse = _a[0], localeOptions = _a[1];
11769
- var defaults = {};
11770
- defaults[CustomFieldType.String] = {};
11771
- defaults[CustomFieldType.Boolean] = { defaultValue: false };
11772
- defaults[CustomFieldType.Integer] = {};
11773
- defaults[CustomFieldType.Double] = { defaultMask: "" };
11774
- defaults[CustomFieldType.Money] = {};
11775
- defaults[CustomFieldType.Date] = {};
11776
- defaults[CustomFieldType.DateTime] = {};
11777
- defaults[CustomFieldType.LocalDateTime] = {};
11778
- defaults[CustomFieldType.Time] = {};
11779
- defaults[CustomFieldType.Blob] = {};
11780
- defaults[CustomFieldType.Enum] = {};
11781
- defaults[CustomFieldType.Binary] = {};
11782
- defaults[CustomFieldType.Any] = {};
11783
- if (!customFieldsResponse || !customFieldsResponse.entity_)
11784
- return;
11785
- var _b = customFieldsResponse.entity_, active = _b.active, fields = _b.fields;
11786
- if (!active)
11787
- return;
11788
- fields
11789
- .filter(function (field) { return field.customizable && field.customization && field.customization.active; })
11790
- .forEach(function (field) {
11791
- var _a;
11792
- var formField = _this.getFormField(field, localeOptions);
11793
- var fieldType = field.type;
11794
- if (field.type === CustomFieldType.Blob && _this.value && _this.value[formField.name])
11795
- _this.createBlobToFileUpload(formField);
11796
- var validationRegex = field.customization.validationRegex;
11797
- var asIsTypes = [
11798
- CustomFieldType.Boolean,
11799
- CustomFieldType.Money,
11800
- CustomFieldType.Date,
11801
- CustomFieldType.DateTime,
11802
- CustomFieldType.LocalDateTime,
11803
- CustomFieldType.Time,
11804
- ];
11805
- var validators = [];
11806
- if (validationRegex && !asIsTypes.includes(fieldType))
11807
- validators.push(Validators.pattern(validationRegex));
11808
- if (fieldType === CustomFieldType.Integer && !formField.mask)
11809
- validators.push(Validators.pattern(/^\-?\d*$/));
11810
- if ((_a = formField.required) === null || _a === void 0 ? void 0 : _a.call(formField)) {
11811
- validators.push(Validators.required);
11812
- }
11813
- var control = new FormControl({ value: defaults[fieldType].defaultValue, disabled: _this.formGroup.disabled }, validators);
11814
- _this.formGroup.addControl(formField.name, control);
11815
- _this.fields.push(formField);
11816
- });
11817
- _this.createFieldCustomization(fields);
11818
- _this.formGroup.patchValue(_this.parseValuesForFields(_this.value));
11819
- _this.ready = true;
11820
- });
11751
+ this._validateInputs();
11752
+ this._createForm();
11821
11753
  this.addDisplayTimeInfoSignToFields();
11822
11754
  };
11823
11755
  CustomFieldsComponent.prototype.ngAfterViewInit = function () {
11756
+ var _this = this;
11824
11757
  this.enableOrDisableFields(this.disableFields);
11758
+ this.formGroup.valueChanges.subscribe(function () { var _a; return (_a = _this.onChange) === null || _a === void 0 ? void 0 : _a.call(_this, _this.parseFieldsValues()); });
11825
11759
  };
11826
11760
  CustomFieldsComponent.prototype.ngOnChanges = function (changes) {
11827
11761
  if (changes.disableFields) {
@@ -11833,9 +11767,7 @@ var CustomFieldsComponent = /** @class */ (function () {
11833
11767
  this.ngUsubscribe.complete();
11834
11768
  };
11835
11769
  CustomFieldsComponent.prototype.registerOnChange = function (fn) {
11836
- var _this = this;
11837
11770
  this.onChange = fn;
11838
- this.formGroup.valueChanges.subscribe(function () { return _this.onChange(_this.parseFieldsValues()); });
11839
11771
  };
11840
11772
  CustomFieldsComponent.prototype.registerOnTouched = function (fn) {
11841
11773
  this.onTouched = fn;
@@ -11874,6 +11806,9 @@ var CustomFieldsComponent = /** @class */ (function () {
11874
11806
  });
11875
11807
  return errors;
11876
11808
  };
11809
+ CustomFieldsComponent.prototype.cleanFields = function () {
11810
+ this.formGroup.reset();
11811
+ };
11877
11812
  CustomFieldsComponent.prototype.enableOrDisableFields = function (disabled) {
11878
11813
  var e_1, _a;
11879
11814
  if (!this.formGroup) {
@@ -11893,8 +11828,80 @@ var CustomFieldsComponent = /** @class */ (function () {
11893
11828
  finally { if (e_1) throw e_1.error; }
11894
11829
  }
11895
11830
  };
11896
- CustomFieldsComponent.prototype.cleanFields = function () {
11897
- this.formGroup.reset();
11831
+ CustomFieldsComponent.prototype._validateInputs = function () {
11832
+ if (!this.domain)
11833
+ throw new Error("You need to specify the custom-fields domain!");
11834
+ if (!this.service)
11835
+ throw new Error("You need to specify the custom-fields service!");
11836
+ if (!this.entity)
11837
+ throw new Error("You need to specify the custom-fields entity!");
11838
+ };
11839
+ CustomFieldsComponent.prototype._createForm = function () {
11840
+ var _this = this;
11841
+ this.formGroup = new FormGroup({});
11842
+ var observables = [this.getCustomFields(), this.localeService.get()];
11843
+ forkJoin(observables)
11844
+ .pipe(takeUntil(this.ngUsubscribe), finalize(function () {
11845
+ var _a;
11846
+ _this.formGroup.markAsPristine();
11847
+ (_a = _this.parentControl) === null || _a === void 0 ? void 0 : _a.markAsPristine();
11848
+ if (_this.ready$)
11849
+ _this.ready$.next(true);
11850
+ }))
11851
+ .subscribe(function (response) {
11852
+ var _a = __read(response, 2), customFieldsResponse = _a[0], localeOptions = _a[1];
11853
+ var defaults = {};
11854
+ defaults[CustomFieldType.String] = {};
11855
+ defaults[CustomFieldType.Boolean] = { defaultValue: false };
11856
+ defaults[CustomFieldType.Integer] = {};
11857
+ defaults[CustomFieldType.Double] = { defaultMask: "" };
11858
+ defaults[CustomFieldType.Money] = {};
11859
+ defaults[CustomFieldType.Date] = {};
11860
+ defaults[CustomFieldType.DateTime] = {};
11861
+ defaults[CustomFieldType.LocalDateTime] = {};
11862
+ defaults[CustomFieldType.Time] = {};
11863
+ defaults[CustomFieldType.Blob] = {};
11864
+ defaults[CustomFieldType.Enum] = {};
11865
+ defaults[CustomFieldType.Binary] = {};
11866
+ defaults[CustomFieldType.Any] = {};
11867
+ if (!customFieldsResponse || !customFieldsResponse.entity_)
11868
+ return;
11869
+ var _b = customFieldsResponse.entity_, active = _b.active, fields = _b.fields;
11870
+ if (!active)
11871
+ return;
11872
+ fields
11873
+ .filter(function (field) { return field.customizable && field.customization && field.customization.active; })
11874
+ .forEach(function (field) {
11875
+ var _a;
11876
+ var formField = _this.getFormField(field, localeOptions);
11877
+ var fieldType = field.type;
11878
+ if (field.type === CustomFieldType.Blob && _this.value && _this.value[formField.name])
11879
+ _this.createBlobToFileUpload(formField);
11880
+ var validationRegex = field.customization.validationRegex;
11881
+ var asIsTypes = [
11882
+ CustomFieldType.Boolean,
11883
+ CustomFieldType.Money,
11884
+ CustomFieldType.Date,
11885
+ CustomFieldType.DateTime,
11886
+ CustomFieldType.LocalDateTime,
11887
+ CustomFieldType.Time,
11888
+ ];
11889
+ var validators = [];
11890
+ if (validationRegex && !asIsTypes.includes(fieldType))
11891
+ validators.push(Validators.pattern(validationRegex));
11892
+ if (fieldType === CustomFieldType.Integer && !formField.mask)
11893
+ validators.push(Validators.pattern(/^\-?\d*$/));
11894
+ if ((_a = formField.required) === null || _a === void 0 ? void 0 : _a.call(formField)) {
11895
+ validators.push(Validators.required);
11896
+ }
11897
+ var control = new FormControl({ value: defaults[fieldType].defaultValue, disabled: _this.formGroup.disabled }, validators);
11898
+ _this.formGroup.addControl(formField.name, control);
11899
+ _this.fields.push(formField);
11900
+ });
11901
+ _this.createFieldCustomization(fields);
11902
+ _this.formGroup.patchValue(_this.parseValuesForFields(_this.value));
11903
+ _this.ready = true;
11904
+ });
11898
11905
  };
11899
11906
  CustomFieldsComponent.prototype.parseValuesForFields = function (values) {
11900
11907
  var parsedValues = __assign({}, values);