@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
|
@@ -5000,6 +5000,21 @@
|
|
|
5000
5000
|
return CustomFieldsService;
|
|
5001
5001
|
}());
|
|
5002
5002
|
|
|
5003
|
+
var CustomFieldType;
|
|
5004
|
+
(function (CustomFieldType) {
|
|
5005
|
+
CustomFieldType["String"] = "String";
|
|
5006
|
+
CustomFieldType["Boolean"] = "Boolean";
|
|
5007
|
+
CustomFieldType["Integer"] = "Integer";
|
|
5008
|
+
CustomFieldType["Double"] = "Double";
|
|
5009
|
+
CustomFieldType["Date"] = "Date";
|
|
5010
|
+
CustomFieldType["DateTime"] = "DateTime";
|
|
5011
|
+
CustomFieldType["Time"] = "Time";
|
|
5012
|
+
CustomFieldType["Money"] = "Money";
|
|
5013
|
+
CustomFieldType["Blob"] = "Blob";
|
|
5014
|
+
CustomFieldType["Binary"] = "Binary";
|
|
5015
|
+
CustomFieldType["Any"] = "Any";
|
|
5016
|
+
CustomFieldType["Enum"] = "Enum";
|
|
5017
|
+
})(CustomFieldType || (CustomFieldType = {}));
|
|
5003
5018
|
var moment$3 = moment_; // @HACK Necessary because of https://github.com/rollup/rollup/issues/670
|
|
5004
5019
|
var CustomFieldsComponent = /** @class */ (function () {
|
|
5005
5020
|
function CustomFieldsComponent(customFieldsService, localeService, sanitizer, translateService) {
|
|
@@ -5062,17 +5077,18 @@
|
|
|
5062
5077
|
.subscribe(function (response) {
|
|
5063
5078
|
var _a = __read(response, 2), customFieldsResponse = _a[0], localeOptions = _a[1];
|
|
5064
5079
|
var defaults = {};
|
|
5065
|
-
defaults[
|
|
5066
|
-
defaults[
|
|
5067
|
-
defaults[
|
|
5068
|
-
defaults[
|
|
5069
|
-
defaults[
|
|
5070
|
-
defaults[
|
|
5071
|
-
defaults[
|
|
5072
|
-
defaults[
|
|
5073
|
-
defaults[
|
|
5074
|
-
defaults[
|
|
5075
|
-
defaults[
|
|
5080
|
+
defaults[CustomFieldType.String] = {};
|
|
5081
|
+
defaults[CustomFieldType.Boolean] = { defaultValue: false };
|
|
5082
|
+
defaults[CustomFieldType.Integer] = {};
|
|
5083
|
+
defaults[CustomFieldType.Double] = { defaultMask: "" };
|
|
5084
|
+
defaults[CustomFieldType.Money] = {};
|
|
5085
|
+
defaults[CustomFieldType.Date] = {};
|
|
5086
|
+
defaults[CustomFieldType.DateTime] = {};
|
|
5087
|
+
defaults[CustomFieldType.Time] = {};
|
|
5088
|
+
defaults[CustomFieldType.Blob] = {};
|
|
5089
|
+
defaults[CustomFieldType.Enum] = {};
|
|
5090
|
+
defaults[CustomFieldType.Binary] = {};
|
|
5091
|
+
defaults[CustomFieldType.Any] = {};
|
|
5076
5092
|
if (!customFieldsResponse || !customFieldsResponse.entity_)
|
|
5077
5093
|
return;
|
|
5078
5094
|
var _b = customFieldsResponse.entity_, active = _b.active, fields = _b.fields;
|
|
@@ -5082,16 +5098,23 @@
|
|
|
5082
5098
|
.filter(function (field) { return field.customizable && field.customization && field.customization.active; })
|
|
5083
5099
|
.forEach(function (field) {
|
|
5084
5100
|
var formField = _this.getFormField(field, localeOptions);
|
|
5085
|
-
|
|
5101
|
+
var fieldType = field.type;
|
|
5102
|
+
if (field.type === CustomFieldType.Blob && _this.value && _this.value[formField.name])
|
|
5086
5103
|
_this.createBlobToFileUpload(formField);
|
|
5087
5104
|
var validationRegex = field.customization.validationRegex;
|
|
5088
|
-
var asIsTypes = [
|
|
5105
|
+
var asIsTypes = [
|
|
5106
|
+
CustomFieldType.Boolean,
|
|
5107
|
+
CustomFieldType.Money,
|
|
5108
|
+
CustomFieldType.Date,
|
|
5109
|
+
CustomFieldType.DateTime,
|
|
5110
|
+
CustomFieldType.Time
|
|
5111
|
+
];
|
|
5089
5112
|
var validators = [];
|
|
5090
|
-
if (validationRegex && asIsTypes.
|
|
5113
|
+
if (validationRegex && !asIsTypes.includes(fieldType))
|
|
5091
5114
|
validators.push(forms.Validators.pattern(validationRegex));
|
|
5092
|
-
if (
|
|
5115
|
+
if (fieldType === CustomFieldType.Integer && !formField.mask)
|
|
5093
5116
|
validators.push(forms.Validators.pattern(/^\-?\d*$/));
|
|
5094
|
-
var control = new forms.FormControl({ value: defaults[
|
|
5117
|
+
var control = new forms.FormControl({ value: defaults[fieldType].defaultValue, disabled: _this.formGroup.disabled }, validators);
|
|
5095
5118
|
control.markAsDirty({ onlySelf: true });
|
|
5096
5119
|
_this.formGroup.addControl(formField.name, control);
|
|
5097
5120
|
_this.fields.push(formField);
|
|
@@ -5176,17 +5199,13 @@
|
|
|
5176
5199
|
var _this = this;
|
|
5177
5200
|
var parsedValues = {};
|
|
5178
5201
|
this.fields.forEach(function (field) {
|
|
5179
|
-
var type = field.type, name = field.name, mask = field.mask;
|
|
5202
|
+
var type = field.type, name = field.name, mask = field.mask, scale = field.scale;
|
|
5180
5203
|
var value = _this.formGroup.get(name).value;
|
|
5181
5204
|
if (value)
|
|
5182
5205
|
switch (type) {
|
|
5183
|
-
case exports.FieldType.
|
|
5206
|
+
case exports.FieldType.Number:
|
|
5184
5207
|
if (mask)
|
|
5185
|
-
value =
|
|
5186
|
-
break;
|
|
5187
|
-
case exports.FieldType.Double:
|
|
5188
|
-
if (mask)
|
|
5189
|
-
value = parseFloat(value.replace(/\./g, "").replace(/,/g, "."));
|
|
5208
|
+
value = new BigNumber__default(value).toFixed(scale).toString();
|
|
5190
5209
|
break;
|
|
5191
5210
|
case exports.FieldType.Date:
|
|
5192
5211
|
value = moment$3(value).format("YYYY-MM-DD");
|
|
@@ -5198,7 +5217,7 @@
|
|
|
5198
5217
|
value = moment$3(value).format("HH:mm:ss");
|
|
5199
5218
|
break;
|
|
5200
5219
|
}
|
|
5201
|
-
if (value
|
|
5220
|
+
if (value !== null && !(new BigNumber__default(value).isNaN())) {
|
|
5202
5221
|
parsedValues[name] = value;
|
|
5203
5222
|
}
|
|
5204
5223
|
else if (_this.isTypeNumberOrEnum(type)) {
|
|
@@ -5210,22 +5229,46 @@
|
|
|
5210
5229
|
return parsedValues;
|
|
5211
5230
|
};
|
|
5212
5231
|
CustomFieldsComponent.prototype.isTypeNumberOrEnum = function (type) {
|
|
5213
|
-
|
|
5232
|
+
var numberOrEnum = [
|
|
5233
|
+
exports.FieldType.Number,
|
|
5234
|
+
exports.FieldType.Enum
|
|
5235
|
+
];
|
|
5236
|
+
return numberOrEnum.includes(type);
|
|
5214
5237
|
};
|
|
5215
5238
|
CustomFieldsComponent.prototype.getFormField = function (field, localeOptions) {
|
|
5239
|
+
var _a, _b;
|
|
5216
5240
|
var parameters;
|
|
5217
5241
|
switch (field.type) {
|
|
5218
|
-
case
|
|
5242
|
+
case CustomFieldType.Blob:
|
|
5219
5243
|
parameters = this.getBlobParameters();
|
|
5220
5244
|
break;
|
|
5221
|
-
case
|
|
5245
|
+
case CustomFieldType.Boolean:
|
|
5222
5246
|
parameters = this.getBooleanParameters();
|
|
5223
5247
|
break;
|
|
5224
5248
|
case "Enumeration":
|
|
5225
|
-
case
|
|
5249
|
+
case CustomFieldType.Enum:
|
|
5226
5250
|
field.type = exports.FieldType.Enum;
|
|
5227
5251
|
parameters = this.getEnumParameters(field);
|
|
5228
5252
|
break;
|
|
5253
|
+
case CustomFieldType.Money:
|
|
5254
|
+
parameters = {
|
|
5255
|
+
type: exports.FieldType.Number,
|
|
5256
|
+
leftAddon: {
|
|
5257
|
+
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$",
|
|
5258
|
+
},
|
|
5259
|
+
};
|
|
5260
|
+
break;
|
|
5261
|
+
case CustomFieldType.Double:
|
|
5262
|
+
parameters = {
|
|
5263
|
+
type: exports.FieldType.Number
|
|
5264
|
+
};
|
|
5265
|
+
break;
|
|
5266
|
+
case CustomFieldType.Integer:
|
|
5267
|
+
parameters = {
|
|
5268
|
+
type: exports.FieldType.Number,
|
|
5269
|
+
scale: 0
|
|
5270
|
+
};
|
|
5271
|
+
break;
|
|
5229
5272
|
default:
|
|
5230
5273
|
parameters = {};
|
|
5231
5274
|
break;
|
|
@@ -5283,7 +5326,7 @@
|
|
|
5283
5326
|
* com os fields inseridos e deletados.
|
|
5284
5327
|
*/
|
|
5285
5328
|
CustomFieldsComponent.prototype.createFieldCustomization = function (fields) {
|
|
5286
|
-
this.hasBlob = !!fields.filter(function (field) { return field.type ===
|
|
5329
|
+
this.hasBlob = !!fields.filter(function (field) { return field.type === CustomFieldType.Blob; }).length;
|
|
5287
5330
|
if (this.hasBlob) {
|
|
5288
5331
|
this.formGroup.addControl("fieldCustomization", new forms.FormArray([
|
|
5289
5332
|
new forms.FormGroup({
|