@seniorsistemas/angular-components 14.7.1 → 14.8.0
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 +72 -29
- 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/esm2015/components/custom-fields/custom-fields.component.js +74 -30
- package/esm5/components/custom-fields/custom-fields.component.js +74 -30
- package/fesm2015/seniorsistemas-angular-components.js +72 -29
- package/fesm2015/seniorsistemas-angular-components.js.map +1 -1
- package/fesm5/seniorsistemas-angular-components.js +72 -29
- package/fesm5/seniorsistemas-angular-components.js.map +1 -1
- package/package.json +1 -1
- package/seniorsistemas-angular-components.metadata.json +1 -1
|
@@ -4817,6 +4817,21 @@ var CustomFieldsService = /** @class */ (function () {
|
|
|
4817
4817
|
return CustomFieldsService;
|
|
4818
4818
|
}());
|
|
4819
4819
|
|
|
4820
|
+
var CustomFieldType;
|
|
4821
|
+
(function (CustomFieldType) {
|
|
4822
|
+
CustomFieldType["String"] = "String";
|
|
4823
|
+
CustomFieldType["Boolean"] = "Boolean";
|
|
4824
|
+
CustomFieldType["Integer"] = "Integer";
|
|
4825
|
+
CustomFieldType["Double"] = "Double";
|
|
4826
|
+
CustomFieldType["Date"] = "Date";
|
|
4827
|
+
CustomFieldType["DateTime"] = "DateTime";
|
|
4828
|
+
CustomFieldType["Time"] = "Time";
|
|
4829
|
+
CustomFieldType["Money"] = "Money";
|
|
4830
|
+
CustomFieldType["Blob"] = "Blob";
|
|
4831
|
+
CustomFieldType["Binary"] = "Binary";
|
|
4832
|
+
CustomFieldType["Any"] = "Any";
|
|
4833
|
+
CustomFieldType["Enum"] = "Enum";
|
|
4834
|
+
})(CustomFieldType || (CustomFieldType = {}));
|
|
4820
4835
|
var moment$3 = moment_; // @HACK Necessary because of https://github.com/rollup/rollup/issues/670
|
|
4821
4836
|
var CustomFieldsComponent = /** @class */ (function () {
|
|
4822
4837
|
function CustomFieldsComponent(customFieldsService, localeService, sanitizer, translateService) {
|
|
@@ -4879,17 +4894,18 @@ var CustomFieldsComponent = /** @class */ (function () {
|
|
|
4879
4894
|
.subscribe(function (response) {
|
|
4880
4895
|
var _a = __read(response, 2), customFieldsResponse = _a[0], localeOptions = _a[1];
|
|
4881
4896
|
var defaults = {};
|
|
4882
|
-
defaults[
|
|
4883
|
-
defaults[
|
|
4884
|
-
defaults[
|
|
4885
|
-
defaults[
|
|
4886
|
-
defaults[
|
|
4887
|
-
defaults[
|
|
4888
|
-
defaults[
|
|
4889
|
-
defaults[
|
|
4890
|
-
defaults[
|
|
4891
|
-
defaults[
|
|
4892
|
-
defaults[
|
|
4897
|
+
defaults[CustomFieldType.String] = {};
|
|
4898
|
+
defaults[CustomFieldType.Boolean] = { defaultValue: false };
|
|
4899
|
+
defaults[CustomFieldType.Integer] = {};
|
|
4900
|
+
defaults[CustomFieldType.Double] = { defaultMask: "" };
|
|
4901
|
+
defaults[CustomFieldType.Money] = {};
|
|
4902
|
+
defaults[CustomFieldType.Date] = {};
|
|
4903
|
+
defaults[CustomFieldType.DateTime] = {};
|
|
4904
|
+
defaults[CustomFieldType.Time] = {};
|
|
4905
|
+
defaults[CustomFieldType.Blob] = {};
|
|
4906
|
+
defaults[CustomFieldType.Enum] = {};
|
|
4907
|
+
defaults[CustomFieldType.Binary] = {};
|
|
4908
|
+
defaults[CustomFieldType.Any] = {};
|
|
4893
4909
|
if (!customFieldsResponse || !customFieldsResponse.entity_)
|
|
4894
4910
|
return;
|
|
4895
4911
|
var _b = customFieldsResponse.entity_, active = _b.active, fields = _b.fields;
|
|
@@ -4899,16 +4915,23 @@ var CustomFieldsComponent = /** @class */ (function () {
|
|
|
4899
4915
|
.filter(function (field) { return field.customizable && field.customization && field.customization.active; })
|
|
4900
4916
|
.forEach(function (field) {
|
|
4901
4917
|
var formField = _this.getFormField(field, localeOptions);
|
|
4902
|
-
|
|
4918
|
+
var fieldType = field.type;
|
|
4919
|
+
if (field.type === CustomFieldType.Blob && _this.value && _this.value[formField.name])
|
|
4903
4920
|
_this.createBlobToFileUpload(formField);
|
|
4904
4921
|
var validationRegex = field.customization.validationRegex;
|
|
4905
|
-
var asIsTypes = [
|
|
4922
|
+
var asIsTypes = [
|
|
4923
|
+
CustomFieldType.Boolean,
|
|
4924
|
+
CustomFieldType.Money,
|
|
4925
|
+
CustomFieldType.Date,
|
|
4926
|
+
CustomFieldType.DateTime,
|
|
4927
|
+
CustomFieldType.Time
|
|
4928
|
+
];
|
|
4906
4929
|
var validators = [];
|
|
4907
|
-
if (validationRegex && asIsTypes.
|
|
4930
|
+
if (validationRegex && !asIsTypes.includes(fieldType))
|
|
4908
4931
|
validators.push(Validators.pattern(validationRegex));
|
|
4909
|
-
if (
|
|
4932
|
+
if (fieldType === CustomFieldType.Integer && !formField.mask)
|
|
4910
4933
|
validators.push(Validators.pattern(/^\-?\d*$/));
|
|
4911
|
-
var control = new FormControl({ value: defaults[
|
|
4934
|
+
var control = new FormControl({ value: defaults[fieldType].defaultValue, disabled: _this.formGroup.disabled }, validators);
|
|
4912
4935
|
control.markAsDirty({ onlySelf: true });
|
|
4913
4936
|
_this.formGroup.addControl(formField.name, control);
|
|
4914
4937
|
_this.fields.push(formField);
|
|
@@ -4993,17 +5016,13 @@ var CustomFieldsComponent = /** @class */ (function () {
|
|
|
4993
5016
|
var _this = this;
|
|
4994
5017
|
var parsedValues = {};
|
|
4995
5018
|
this.fields.forEach(function (field) {
|
|
4996
|
-
var type = field.type, name = field.name, mask = field.mask;
|
|
5019
|
+
var type = field.type, name = field.name, mask = field.mask, scale = field.scale;
|
|
4997
5020
|
var value = _this.formGroup.get(name).value;
|
|
4998
5021
|
if (value)
|
|
4999
5022
|
switch (type) {
|
|
5000
|
-
case FieldType.
|
|
5023
|
+
case FieldType.Number:
|
|
5001
5024
|
if (mask)
|
|
5002
|
-
value =
|
|
5003
|
-
break;
|
|
5004
|
-
case FieldType.Double:
|
|
5005
|
-
if (mask)
|
|
5006
|
-
value = parseFloat(value.replace(/\./g, "").replace(/,/g, "."));
|
|
5025
|
+
value = new BigNumber(value).toFixed(scale).toString();
|
|
5007
5026
|
break;
|
|
5008
5027
|
case FieldType.Date:
|
|
5009
5028
|
value = moment$3(value).format("YYYY-MM-DD");
|
|
@@ -5015,7 +5034,7 @@ var CustomFieldsComponent = /** @class */ (function () {
|
|
|
5015
5034
|
value = moment$3(value).format("HH:mm:ss");
|
|
5016
5035
|
break;
|
|
5017
5036
|
}
|
|
5018
|
-
if (value
|
|
5037
|
+
if (value !== null && !(new BigNumber(value).isNaN())) {
|
|
5019
5038
|
parsedValues[name] = value;
|
|
5020
5039
|
}
|
|
5021
5040
|
else if (_this.isTypeNumberOrEnum(type)) {
|
|
@@ -5027,22 +5046,46 @@ var CustomFieldsComponent = /** @class */ (function () {
|
|
|
5027
5046
|
return parsedValues;
|
|
5028
5047
|
};
|
|
5029
5048
|
CustomFieldsComponent.prototype.isTypeNumberOrEnum = function (type) {
|
|
5030
|
-
|
|
5049
|
+
var numberOrEnum = [
|
|
5050
|
+
FieldType.Number,
|
|
5051
|
+
FieldType.Enum
|
|
5052
|
+
];
|
|
5053
|
+
return numberOrEnum.includes(type);
|
|
5031
5054
|
};
|
|
5032
5055
|
CustomFieldsComponent.prototype.getFormField = function (field, localeOptions) {
|
|
5056
|
+
var _a, _b;
|
|
5033
5057
|
var parameters;
|
|
5034
5058
|
switch (field.type) {
|
|
5035
|
-
case
|
|
5059
|
+
case CustomFieldType.Blob:
|
|
5036
5060
|
parameters = this.getBlobParameters();
|
|
5037
5061
|
break;
|
|
5038
|
-
case
|
|
5062
|
+
case CustomFieldType.Boolean:
|
|
5039
5063
|
parameters = this.getBooleanParameters();
|
|
5040
5064
|
break;
|
|
5041
5065
|
case "Enumeration":
|
|
5042
|
-
case
|
|
5066
|
+
case CustomFieldType.Enum:
|
|
5043
5067
|
field.type = FieldType.Enum;
|
|
5044
5068
|
parameters = this.getEnumParameters(field);
|
|
5045
5069
|
break;
|
|
5070
|
+
case CustomFieldType.Money:
|
|
5071
|
+
parameters = {
|
|
5072
|
+
type: FieldType.Number,
|
|
5073
|
+
leftAddon: {
|
|
5074
|
+
label: (_b = (_a = localeOptions === null || localeOptions === void 0 ? void 0 : localeOptions.number) === null || _a === void 0 ? void 0 : _a.currencySymbol) !== null && _b !== void 0 ? _b : "R$",
|
|
5075
|
+
},
|
|
5076
|
+
};
|
|
5077
|
+
break;
|
|
5078
|
+
case CustomFieldType.Double:
|
|
5079
|
+
parameters = {
|
|
5080
|
+
type: FieldType.Number
|
|
5081
|
+
};
|
|
5082
|
+
break;
|
|
5083
|
+
case CustomFieldType.Integer:
|
|
5084
|
+
parameters = {
|
|
5085
|
+
type: FieldType.Number,
|
|
5086
|
+
scale: 0
|
|
5087
|
+
};
|
|
5088
|
+
break;
|
|
5046
5089
|
default:
|
|
5047
5090
|
parameters = {};
|
|
5048
5091
|
break;
|
|
@@ -5100,7 +5143,7 @@ var CustomFieldsComponent = /** @class */ (function () {
|
|
|
5100
5143
|
* com os fields inseridos e deletados.
|
|
5101
5144
|
*/
|
|
5102
5145
|
CustomFieldsComponent.prototype.createFieldCustomization = function (fields) {
|
|
5103
|
-
this.hasBlob = !!fields.filter(function (field) { return field.type ===
|
|
5146
|
+
this.hasBlob = !!fields.filter(function (field) { return field.type === CustomFieldType.Blob; }).length;
|
|
5104
5147
|
if (this.hasBlob) {
|
|
5105
5148
|
this.formGroup.addControl("fieldCustomization", new FormArray([
|
|
5106
5149
|
new FormGroup({
|