@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.
- package/bundles/seniorsistemas-angular-components.umd.js +82 -75
- package/bundles/seniorsistemas-angular-components.umd.js.map +1 -1
- package/bundles/seniorsistemas-angular-components.umd.min.js +1 -1
- package/bundles/seniorsistemas-angular-components.umd.min.js.map +1 -1
- package/components/custom-fields/custom-fields.component.d.ts +8 -6
- package/components/custom-fields/models/custom-field-type.d.ts +15 -0
- package/esm2015/components/custom-fields/custom-fields.component.js +74 -83
- package/esm2015/components/custom-fields/models/custom-field-type.js +17 -0
- package/esm5/components/custom-fields/custom-fields.component.js +85 -94
- package/esm5/components/custom-fields/models/custom-field-type.js +17 -0
- package/fesm2015/seniorsistemas-angular-components.js +72 -65
- package/fesm2015/seniorsistemas-angular-components.js.map +1 -1
- package/fesm5/seniorsistemas-angular-components.js +82 -75
- package/fesm5/seniorsistemas-angular-components.js.map +1 -1
- package/package.json +1 -1
- package/seniorsistemas-angular-components.metadata.json +1 -1
|
@@ -11860,6 +11860,7 @@
|
|
|
11860
11860
|
CustomFieldType["Any"] = "Any";
|
|
11861
11861
|
CustomFieldType["Enum"] = "Enum";
|
|
11862
11862
|
})(CustomFieldType || (CustomFieldType = {}));
|
|
11863
|
+
|
|
11863
11864
|
var moment$5 = moment_; // @HACK Necessary because of https://github.com/rollup/rollup/issues/670
|
|
11864
11865
|
var CustomFieldsComponent = /** @class */ (function () {
|
|
11865
11866
|
function CustomFieldsComponent(customFieldsService, localeService, sanitizer, translateService, controlContainer) {
|
|
@@ -11893,81 +11894,14 @@
|
|
|
11893
11894
|
configurable: true
|
|
11894
11895
|
});
|
|
11895
11896
|
CustomFieldsComponent.prototype.ngOnInit = function () {
|
|
11896
|
-
|
|
11897
|
-
|
|
11898
|
-
throw new Error("You need to specify the custom-fields domain!");
|
|
11899
|
-
if (!this.service)
|
|
11900
|
-
throw new Error("You need to specify the custom-fields service!");
|
|
11901
|
-
if (!this.entity)
|
|
11902
|
-
throw new Error("You need to specify the custom-fields entity!");
|
|
11903
|
-
this.formGroup = new forms.FormGroup({});
|
|
11904
|
-
var observables = [this.getCustomFields(), this.localeService.get()];
|
|
11905
|
-
rxjs.forkJoin(observables)
|
|
11906
|
-
.pipe(operators.takeUntil(this.ngUsubscribe), operators.finalize(function () {
|
|
11907
|
-
var _a;
|
|
11908
|
-
_this.formGroup.markAsPristine();
|
|
11909
|
-
(_a = _this.parentControl) === null || _a === void 0 ? void 0 : _a.markAsPristine();
|
|
11910
|
-
if (_this.ready$)
|
|
11911
|
-
_this.ready$.next(true);
|
|
11912
|
-
}))
|
|
11913
|
-
.subscribe(function (response) {
|
|
11914
|
-
var _a = __read(response, 2), customFieldsResponse = _a[0], localeOptions = _a[1];
|
|
11915
|
-
var defaults = {};
|
|
11916
|
-
defaults[CustomFieldType.String] = {};
|
|
11917
|
-
defaults[CustomFieldType.Boolean] = { defaultValue: false };
|
|
11918
|
-
defaults[CustomFieldType.Integer] = {};
|
|
11919
|
-
defaults[CustomFieldType.Double] = { defaultMask: "" };
|
|
11920
|
-
defaults[CustomFieldType.Money] = {};
|
|
11921
|
-
defaults[CustomFieldType.Date] = {};
|
|
11922
|
-
defaults[CustomFieldType.DateTime] = {};
|
|
11923
|
-
defaults[CustomFieldType.LocalDateTime] = {};
|
|
11924
|
-
defaults[CustomFieldType.Time] = {};
|
|
11925
|
-
defaults[CustomFieldType.Blob] = {};
|
|
11926
|
-
defaults[CustomFieldType.Enum] = {};
|
|
11927
|
-
defaults[CustomFieldType.Binary] = {};
|
|
11928
|
-
defaults[CustomFieldType.Any] = {};
|
|
11929
|
-
if (!customFieldsResponse || !customFieldsResponse.entity_)
|
|
11930
|
-
return;
|
|
11931
|
-
var _b = customFieldsResponse.entity_, active = _b.active, fields = _b.fields;
|
|
11932
|
-
if (!active)
|
|
11933
|
-
return;
|
|
11934
|
-
fields
|
|
11935
|
-
.filter(function (field) { return field.customizable && field.customization && field.customization.active; })
|
|
11936
|
-
.forEach(function (field) {
|
|
11937
|
-
var _a;
|
|
11938
|
-
var formField = _this.getFormField(field, localeOptions);
|
|
11939
|
-
var fieldType = field.type;
|
|
11940
|
-
if (field.type === CustomFieldType.Blob && _this.value && _this.value[formField.name])
|
|
11941
|
-
_this.createBlobToFileUpload(formField);
|
|
11942
|
-
var validationRegex = field.customization.validationRegex;
|
|
11943
|
-
var asIsTypes = [
|
|
11944
|
-
CustomFieldType.Boolean,
|
|
11945
|
-
CustomFieldType.Money,
|
|
11946
|
-
CustomFieldType.Date,
|
|
11947
|
-
CustomFieldType.DateTime,
|
|
11948
|
-
CustomFieldType.LocalDateTime,
|
|
11949
|
-
CustomFieldType.Time,
|
|
11950
|
-
];
|
|
11951
|
-
var validators = [];
|
|
11952
|
-
if (validationRegex && !asIsTypes.includes(fieldType))
|
|
11953
|
-
validators.push(forms.Validators.pattern(validationRegex));
|
|
11954
|
-
if (fieldType === CustomFieldType.Integer && !formField.mask)
|
|
11955
|
-
validators.push(forms.Validators.pattern(/^\-?\d*$/));
|
|
11956
|
-
if ((_a = formField.required) === null || _a === void 0 ? void 0 : _a.call(formField)) {
|
|
11957
|
-
validators.push(forms.Validators.required);
|
|
11958
|
-
}
|
|
11959
|
-
var control = new forms.FormControl({ value: defaults[fieldType].defaultValue, disabled: _this.formGroup.disabled }, validators);
|
|
11960
|
-
_this.formGroup.addControl(formField.name, control);
|
|
11961
|
-
_this.fields.push(formField);
|
|
11962
|
-
});
|
|
11963
|
-
_this.createFieldCustomization(fields);
|
|
11964
|
-
_this.formGroup.patchValue(_this.parseValuesForFields(_this.value));
|
|
11965
|
-
_this.ready = true;
|
|
11966
|
-
});
|
|
11897
|
+
this._validateInputs();
|
|
11898
|
+
this._createForm();
|
|
11967
11899
|
this.addDisplayTimeInfoSignToFields();
|
|
11968
11900
|
};
|
|
11969
11901
|
CustomFieldsComponent.prototype.ngAfterViewInit = function () {
|
|
11902
|
+
var _this = this;
|
|
11970
11903
|
this.enableOrDisableFields(this.disableFields);
|
|
11904
|
+
this.formGroup.valueChanges.subscribe(function () { var _a; return (_a = _this.onChange) === null || _a === void 0 ? void 0 : _a.call(_this, _this.parseFieldsValues()); });
|
|
11971
11905
|
};
|
|
11972
11906
|
CustomFieldsComponent.prototype.ngOnChanges = function (changes) {
|
|
11973
11907
|
if (changes.disableFields) {
|
|
@@ -11979,9 +11913,7 @@
|
|
|
11979
11913
|
this.ngUsubscribe.complete();
|
|
11980
11914
|
};
|
|
11981
11915
|
CustomFieldsComponent.prototype.registerOnChange = function (fn) {
|
|
11982
|
-
var _this = this;
|
|
11983
11916
|
this.onChange = fn;
|
|
11984
|
-
this.formGroup.valueChanges.subscribe(function () { return _this.onChange(_this.parseFieldsValues()); });
|
|
11985
11917
|
};
|
|
11986
11918
|
CustomFieldsComponent.prototype.registerOnTouched = function (fn) {
|
|
11987
11919
|
this.onTouched = fn;
|
|
@@ -12020,6 +11952,9 @@
|
|
|
12020
11952
|
});
|
|
12021
11953
|
return errors;
|
|
12022
11954
|
};
|
|
11955
|
+
CustomFieldsComponent.prototype.cleanFields = function () {
|
|
11956
|
+
this.formGroup.reset();
|
|
11957
|
+
};
|
|
12023
11958
|
CustomFieldsComponent.prototype.enableOrDisableFields = function (disabled) {
|
|
12024
11959
|
var e_1, _a;
|
|
12025
11960
|
if (!this.formGroup) {
|
|
@@ -12039,8 +11974,80 @@
|
|
|
12039
11974
|
finally { if (e_1) throw e_1.error; }
|
|
12040
11975
|
}
|
|
12041
11976
|
};
|
|
12042
|
-
CustomFieldsComponent.prototype.
|
|
12043
|
-
this.
|
|
11977
|
+
CustomFieldsComponent.prototype._validateInputs = function () {
|
|
11978
|
+
if (!this.domain)
|
|
11979
|
+
throw new Error("You need to specify the custom-fields domain!");
|
|
11980
|
+
if (!this.service)
|
|
11981
|
+
throw new Error("You need to specify the custom-fields service!");
|
|
11982
|
+
if (!this.entity)
|
|
11983
|
+
throw new Error("You need to specify the custom-fields entity!");
|
|
11984
|
+
};
|
|
11985
|
+
CustomFieldsComponent.prototype._createForm = function () {
|
|
11986
|
+
var _this = this;
|
|
11987
|
+
this.formGroup = new forms.FormGroup({});
|
|
11988
|
+
var observables = [this.getCustomFields(), this.localeService.get()];
|
|
11989
|
+
rxjs.forkJoin(observables)
|
|
11990
|
+
.pipe(operators.takeUntil(this.ngUsubscribe), operators.finalize(function () {
|
|
11991
|
+
var _a;
|
|
11992
|
+
_this.formGroup.markAsPristine();
|
|
11993
|
+
(_a = _this.parentControl) === null || _a === void 0 ? void 0 : _a.markAsPristine();
|
|
11994
|
+
if (_this.ready$)
|
|
11995
|
+
_this.ready$.next(true);
|
|
11996
|
+
}))
|
|
11997
|
+
.subscribe(function (response) {
|
|
11998
|
+
var _a = __read(response, 2), customFieldsResponse = _a[0], localeOptions = _a[1];
|
|
11999
|
+
var defaults = {};
|
|
12000
|
+
defaults[CustomFieldType.String] = {};
|
|
12001
|
+
defaults[CustomFieldType.Boolean] = { defaultValue: false };
|
|
12002
|
+
defaults[CustomFieldType.Integer] = {};
|
|
12003
|
+
defaults[CustomFieldType.Double] = { defaultMask: "" };
|
|
12004
|
+
defaults[CustomFieldType.Money] = {};
|
|
12005
|
+
defaults[CustomFieldType.Date] = {};
|
|
12006
|
+
defaults[CustomFieldType.DateTime] = {};
|
|
12007
|
+
defaults[CustomFieldType.LocalDateTime] = {};
|
|
12008
|
+
defaults[CustomFieldType.Time] = {};
|
|
12009
|
+
defaults[CustomFieldType.Blob] = {};
|
|
12010
|
+
defaults[CustomFieldType.Enum] = {};
|
|
12011
|
+
defaults[CustomFieldType.Binary] = {};
|
|
12012
|
+
defaults[CustomFieldType.Any] = {};
|
|
12013
|
+
if (!customFieldsResponse || !customFieldsResponse.entity_)
|
|
12014
|
+
return;
|
|
12015
|
+
var _b = customFieldsResponse.entity_, active = _b.active, fields = _b.fields;
|
|
12016
|
+
if (!active)
|
|
12017
|
+
return;
|
|
12018
|
+
fields
|
|
12019
|
+
.filter(function (field) { return field.customizable && field.customization && field.customization.active; })
|
|
12020
|
+
.forEach(function (field) {
|
|
12021
|
+
var _a;
|
|
12022
|
+
var formField = _this.getFormField(field, localeOptions);
|
|
12023
|
+
var fieldType = field.type;
|
|
12024
|
+
if (field.type === CustomFieldType.Blob && _this.value && _this.value[formField.name])
|
|
12025
|
+
_this.createBlobToFileUpload(formField);
|
|
12026
|
+
var validationRegex = field.customization.validationRegex;
|
|
12027
|
+
var asIsTypes = [
|
|
12028
|
+
CustomFieldType.Boolean,
|
|
12029
|
+
CustomFieldType.Money,
|
|
12030
|
+
CustomFieldType.Date,
|
|
12031
|
+
CustomFieldType.DateTime,
|
|
12032
|
+
CustomFieldType.LocalDateTime,
|
|
12033
|
+
CustomFieldType.Time,
|
|
12034
|
+
];
|
|
12035
|
+
var validators = [];
|
|
12036
|
+
if (validationRegex && !asIsTypes.includes(fieldType))
|
|
12037
|
+
validators.push(forms.Validators.pattern(validationRegex));
|
|
12038
|
+
if (fieldType === CustomFieldType.Integer && !formField.mask)
|
|
12039
|
+
validators.push(forms.Validators.pattern(/^\-?\d*$/));
|
|
12040
|
+
if ((_a = formField.required) === null || _a === void 0 ? void 0 : _a.call(formField)) {
|
|
12041
|
+
validators.push(forms.Validators.required);
|
|
12042
|
+
}
|
|
12043
|
+
var control = new forms.FormControl({ value: defaults[fieldType].defaultValue, disabled: _this.formGroup.disabled }, validators);
|
|
12044
|
+
_this.formGroup.addControl(formField.name, control);
|
|
12045
|
+
_this.fields.push(formField);
|
|
12046
|
+
});
|
|
12047
|
+
_this.createFieldCustomization(fields);
|
|
12048
|
+
_this.formGroup.patchValue(_this.parseValuesForFields(_this.value));
|
|
12049
|
+
_this.ready = true;
|
|
12050
|
+
});
|
|
12044
12051
|
};
|
|
12045
12052
|
CustomFieldsComponent.prototype.parseValuesForFields = function (values) {
|
|
12046
12053
|
var parsedValues = __assign({}, values);
|