@esfaenza/forms-and-validations 12.2.11 → 12.2.15
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/esfaenza-forms-and-validations.umd.js +64 -54
- package/bundles/esfaenza-forms-and-validations.umd.js.map +1 -1
- package/esfaenza-forms-and-validations.metadata.json +1 -1
- package/esm2015/lib/forms/base-form-control.js +27 -24
- package/esm2015/lib/forms/form-adaptive/form-adaptive.component.js +8 -3
- package/esm2015/lib/forms/form-select/form-select.component.js +30 -25
- package/fesm2015/esfaenza-forms-and-validations.js +63 -48
- package/fesm2015/esfaenza-forms-and-validations.js.map +1 -1
- package/lib/forms/form-adaptive/form-adaptive.component.d.ts +4 -0
- package/lib/forms/form-select/form-select.component.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1871,32 +1871,35 @@
|
|
|
1871
1871
|
if (this.Source.length == 0 && !this.FirstBind)
|
|
1872
1872
|
this.BoundSource = [];
|
|
1873
1873
|
this.FirstBind = false;
|
|
1874
|
+
// Cache locale per evitare di rifare dei regex.match ogni santa volta
|
|
1874
1875
|
if (this.Source.length > 0) {
|
|
1875
1876
|
this.BoundSource = [];
|
|
1876
|
-
|
|
1877
|
-
var
|
|
1878
|
-
var
|
|
1877
|
+
// Blocco per tirare fuori le condizioni scritte tipo --> :prop?(Roba con {prop})
|
|
1878
|
+
var iffedMatches = this.Display.match(/:([a-z]+)\?\(([^\(\)]+)\)/g);
|
|
1879
|
+
var bindCheckingGroups = [];
|
|
1880
|
+
if (iffedMatches) {
|
|
1881
|
+
iffedMatches.forEach(function (m) {
|
|
1882
|
+
// Stessa regex di sopra ma il tag "i" serve per tirare fuori i singoli capturing group e per qualche motivo
|
|
1883
|
+
// new RegExp(baseRegex, "g") non funziona quindi non ho potuto razionalizzarlo
|
|
1884
|
+
var groups = m.match(/:([a-z]+)\?\(([^\(\)]+)\)/i);
|
|
1885
|
+
bindCheckingGroups.push({ global: m, prop: groups[1], whenexists: groups[2] });
|
|
1886
|
+
});
|
|
1887
|
+
}
|
|
1888
|
+
// Blocco per tirare fuori le proprietà scritte tipo --> {prop}
|
|
1889
|
+
var bindProperties = [];
|
|
1890
|
+
var matches = this.Display.match(/{[a-z]+}/gi);
|
|
1891
|
+
if (matches)
|
|
1892
|
+
matches.forEach(function (m) { bindProperties.push({ global: m, prop: m.substring(1, m.length - 1) }); });
|
|
1893
|
+
// Blocco per generare la descrizione finale di un elemento
|
|
1879
1894
|
this.Source.forEach(function (s) {
|
|
1880
|
-
|
|
1881
|
-
var
|
|
1882
|
-
//
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
// altrimenti elimino il blocco completamente
|
|
1889
|
-
tmpDescription = tmpDescription.replace(m[0], s[groups[1]] ? groups[2] : "");
|
|
1890
|
-
}
|
|
1891
|
-
}
|
|
1892
|
-
var matches = tmpDescription.match(bindings_1);
|
|
1893
|
-
if (matches) {
|
|
1894
|
-
for (var i = 0; i < matches.length; i++) {
|
|
1895
|
-
var m = matches[i];
|
|
1896
|
-
tmpDescription = tmpDescription.replace(m, s[m.substring(1, m.length - 1)]);
|
|
1897
|
-
}
|
|
1898
|
-
}
|
|
1899
|
-
_this.BoundSource.push({ id: s[_this.IdField], description: tmpDescription });
|
|
1895
|
+
// Parto sempre dalla variabile di Display, poi sostituisco pezzo per pezzo
|
|
1896
|
+
var desc = _this.Display;
|
|
1897
|
+
// Taglio o mantengo le condizioni in base alla proprietà su cui fare check
|
|
1898
|
+
// Dopodiché scrivo tutte le proprietà
|
|
1899
|
+
bindCheckingGroups.forEach(function (t) { desc = desc.replace(t.global, (s[t.prop] != null && s[t.prop] != undefined) ? t.whenexists : ""); });
|
|
1900
|
+
bindProperties.forEach(function (t) { desc = desc.replace(t.global, s[t.prop]); });
|
|
1901
|
+
// Aggiungo alla BoundSource in formato standard KeyValue
|
|
1902
|
+
_this.BoundSource.push({ id: s[_this.IdField], description: desc });
|
|
1900
1903
|
});
|
|
1901
1904
|
}
|
|
1902
1905
|
};
|
|
@@ -2284,6 +2287,10 @@
|
|
|
2284
2287
|
* Utilizzata nel form-adapter per specificare la precisione degli input currencymap (Type: currency)
|
|
2285
2288
|
*/
|
|
2286
2289
|
_this.Precision = 2;
|
|
2290
|
+
/**
|
|
2291
|
+
* Allineamento della currency mask
|
|
2292
|
+
*/
|
|
2293
|
+
_this.Alignment = 'right';
|
|
2287
2294
|
/**
|
|
2288
2295
|
* Variabile interna che gestisce se effettuare il riallineamento dei dati o meno
|
|
2289
2296
|
*/
|
|
@@ -2392,7 +2399,7 @@
|
|
|
2392
2399
|
{ type: core.Component, args: [{
|
|
2393
2400
|
selector: "form-adaptive",
|
|
2394
2401
|
providers: [{ provide: localizations.LocalizationService, useClass: FormAdaptiveComponentLoc }],
|
|
2395
|
-
template: "<ng-container *ngIf=\"!FormLayout\">\r\n <ng-container *ngTemplateOutlet=\"controlTemplate\"></ng-container>\r\n</ng-container>\r\n\r\n<div *ngIf=\"FormLayout\" class=\"form-group row {{FormGroupClass}}\" [class.app-margin-bottom-0]=\"Last\">\r\n <label class=\"col-md-{{LabelColWidth}} m-t-5\">{{Label}}{{Required ? '*' : ''}}:</label>\r\n <div class=\"col-md-{{InputColWidth}}\">\r\n <ng-container *ngTemplateOutlet=\"controlTemplate\"></ng-container>\r\n </div>\r\n <div class=\"clearfix\"></div>\r\n</div>\r\n\r\n<ng-template #controlTemplate>\r\n <div *ngIf=\"!Type\" class=\"app-margin-top-5\">\r\n <em>{{TypeMissingMessage}}</em>\r\n </div>\r\n \r\n <!--Se currency-->\r\n <div *ngIf=\"Type == 'currency'\">\r\n <val-currency [forceInvalid]=\"ForcedError\"\r\n [CurrencyOptions]=\"{ prefix: '', thousands: '.', decimal: ',', precision: Precision, align:
|
|
2402
|
+
template: "<ng-container *ngIf=\"!FormLayout\">\r\n <ng-container *ngTemplateOutlet=\"controlTemplate\"></ng-container>\r\n</ng-container>\r\n\r\n<div *ngIf=\"FormLayout\" class=\"form-group row {{FormGroupClass}}\" [class.app-margin-bottom-0]=\"Last\">\r\n <label class=\"col-md-{{LabelColWidth}} m-t-5\">{{Label}}{{Required ? '*' : ''}}:</label>\r\n <div class=\"col-md-{{InputColWidth}}\">\r\n <ng-container *ngTemplateOutlet=\"controlTemplate\"></ng-container>\r\n </div>\r\n <div class=\"clearfix\"></div>\r\n</div>\r\n\r\n<ng-template #controlTemplate>\r\n <div *ngIf=\"!Type\" class=\"app-margin-top-5\">\r\n <em>{{TypeMissingMessage}}</em>\r\n </div>\r\n \r\n <!--Se currency-->\r\n <div *ngIf=\"Type == 'currency'\">\r\n <val-currency [forceInvalid]=\"ForcedError\"\r\n [CurrencyOptions]=\"{ prefix: '', thousands: '.', decimal: ',', precision: Precision, align: Alignment }\" [noValidate]=\"!Validation\"\r\n #validationControl=\"ngModel\" type=\"text\" [readonly]=\"Readonly\" [submitted]=\"Form?.submitted\" [required]=\"Required\" [(ngModel)]=\"Model\" name=\"{{GeneratedName}}\" autocomplete=\"off\" (inputChange)=\"changed();\"></val-currency>\r\n </div>\r\n <!--Se data-->\r\n <div *ngIf=\"Type == 'date'\">\r\n <val-date #validationControl=\"ngModel\" [forceInvalid]=\"ForcedError\" [noValidate]=\"!Validation\" [readonly]=\"Readonly\" [submitted]=\"Form?.submitted\" [required]=\"Required\" [(ngModel)]=\"Model\" name=\"{{GeneratedName}}\" autocomplete=\"off\" (inputChange)=\"changed();\"></val-date>\r\n </div>\r\n <!--Se stringa-->\r\n <div *ngIf=\"Type == 'string'\">\r\n <val-input #validationControl=\"ngModel\" [forceInvalid]=\"ForcedError\" [noValidate]=\"!Validation\" [readonly]=\"Readonly\" [submitted]=\"Form?.submitted\" type=\"text\" pattern=\"{{Pattern || ''}}\" [required]=\"Required\" [(ngModel)]=\"Model\" name=\"{{GeneratedName}}\" autocomplete=\"off\" (inputChange)=\"changed();\"></val-input>\r\n </div>\r\n <!--Se numero-->\r\n <div *ngIf=\"Type == 'float' || Type == 'number'\">\r\n <val-input #validationControl=\"ngModel\" [forceInvalid]=\"ForcedError\" [noValidate]=\"!Validation\" [readonly]=\"Readonly\" [submitted]=\"Form?.submitted\" type=\"text\" pattern=\"{{Pattern || '^([0-9]*[,])?[0-9]+$'}}\" [required]=\"Required\" [(ngModel)]=\"Model\" name=\"{{GeneratedName}}\" autocomplete=\"off\" (inputChange)=\"changed();\"></val-input>\r\n </div>\r\n <!--Se numero intero-->\r\n <div *ngIf=\"Type == 'int'\">\r\n <val-input #validationControl=\"ngModel\" [forceInvalid]=\"ForcedError\" [noValidate]=\"!Validation\" [readonly]=\"Readonly\" [submitted]=\"Form?.submitted\" type=\"text\" pattern=\"{{Pattern || '^[0-9]\\\\d*$'}}\" [required]=\"Required\" [(ngModel)]=\"Model\" name=\"{{GeneratedName}}\" autocomplete=\"off\" (inputChange)=\"changed();\"></val-input>\r\n </div>\r\n <!--Se boolean-->\r\n <div class=\"m-t-5\" *ngIf=\"Type == 'boolean'\">\r\n <input #validationControl=\"ngModel\" [readonly]=\"Readonly\" type=\"checkbox\" class=\"app-pointer\" [(ngModel)]=\"Model\" name=\"{{GeneratedName}}\" (ngModelChange)=\"changed();\" />\r\n </div>\r\n <!--Se enum-->\r\n <div *ngIf=\"Type == 'enum'\">\r\n <val-select #validationControl=\"ngModel\" [forceInvalid]=\"ForcedError\" [noValidate]=\"!Validation\" [readonly]=\"Readonly\" [submitted]=\"Form?.submitted\" [placeHolderValue]=\"''\" [placeholder]=\"('Select' | localize : lc) + '...'\" [required]=\"Required\" [(ngModel)]=\"Model\" (inputChange)=\"changed();\" name=\"{{GeneratedName}}\">\r\n <option *ngFor=\"let val of BoundSource\" [value]=\"val.id\">{{val.description}}</option>\r\n </val-select>\r\n </div>\r\n <!--Se autocomplete-->\r\n <div *ngIf=\"Type == 'autocomplete'\">\r\n <val-autocomplete #validationControl=\"ngModel\" [forceInvalid]=\"ForcedError\" [noValidate]=\"!Validation\" [readonly]=\"Readonly\" [submitted]=\"Form?.submitted\" [required]=\"Required\" [(ngModel)]=\"Model\" name=\"{{GeneratedName}}\" [Source]=\"BoundSource\" (inputChange)=\"changed();\"></val-autocomplete>\r\n </div>\r\n <!--Se date time-->\r\n <div *ngIf=\"Type == 'datetime'\">\r\n <val-datetime #validationControl=\"ngModel\" [forceInvalid]=\"ForcedError\" [noValidate]=\"!Validation\" [readonly]=\"Readonly\" [submitted]=\"Form?.submitted\" [required]=\"Required\" [(ngModel)]=\"Model\" name=\"{{GeneratedName}}\" autocomplete=\"off\" (inputChange)=\"changed();\"></val-datetime>\r\n </div>\r\n <!--Se time-->\r\n <div *ngIf=\"Type == 'time'\">\r\n <ngx-mat-timepicker name=\"val-time\" #elementRef #baseInput=\"ngModel\" [(ngModel)]=\"Model\" [disabled]=\"Readonly\"\r\n [showSpinners]=\"false\" [stepHour]=\"2\" [stepMinute]=\"5\" [stepSecond]=\"30\"\r\n [showSeconds]=\"true\" (ngModelChange)=\"changed()\" #validationControl=\"ngModel\">\r\n </ngx-mat-timepicker>\r\n </div>\r\n <!--Se file-->\r\n <div *ngIf=\"Type == 'file'\">\r\n <div class=\"input-group file-upload\">\r\n <input type=\"file\" (change)=\"fileChange()\" #fileInput class=\"file-upload-btn app-pointer\" [multiple]=\"null\"/>\r\n <input type=\"text\" [class.frm-padding-left-22]=\"AllowDownload && ModelFile.filename && ModelFile.fileb64\" class=\"form-control checking-field\" placeholder=\"{{'Select a file' | localize : lc}}...\" [(ngModel)]=\"ModelFile.filename\" name=\"dsfile\" #validationControl=\"ngModel\" [required]=\"Required\"/>\r\n \r\n <a class=\"fa fa-download app-pointer app-input-icon\" *ngIf=\"AllowDownload && ModelFile.filename && ModelFile.fileb64\" (click)=\"downloadAttachment()\"></a>\r\n <i class=\"fa fa-times delete-file\" (click)=\"fileChange(true)\" *ngIf=\"ModelFile.filename\"></i>\r\n <span class=\"input-group-btn\">\r\n <button class=\"btn btn-primary btn-file-upload\" type=\"button\"><i class=\"fa fa-upload\"></i></button>\r\n </span>\r\n </div>\r\n </div>\r\n</ng-template>",
|
|
2396
2403
|
changeDetection: core.ChangeDetectionStrategy.OnPush,
|
|
2397
2404
|
styles: [".frm-padding-left-22{padding-left:22px}"]
|
|
2398
2405
|
},] }
|
|
@@ -2414,7 +2421,8 @@
|
|
|
2414
2421
|
Pattern: [{ type: core.Input }],
|
|
2415
2422
|
inputEl: [{ type: core.ViewChild, args: ["fileInput", { static: false },] }],
|
|
2416
2423
|
AllowDownload: [{ type: core.Input }],
|
|
2417
|
-
Precision: [{ type: core.Input }]
|
|
2424
|
+
Precision: [{ type: core.Input }],
|
|
2425
|
+
Alignment: [{ type: core.Input }]
|
|
2418
2426
|
};
|
|
2419
2427
|
|
|
2420
2428
|
// Angular
|
|
@@ -2828,35 +2836,37 @@
|
|
|
2828
2836
|
* @ignore
|
|
2829
2837
|
*/
|
|
2830
2838
|
FormSelectComponent.prototype.ngOnChanges = function (changes) {
|
|
2831
|
-
var
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
}
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2839
|
+
var _this = this;
|
|
2840
|
+
var newSource = changes["Source"];
|
|
2841
|
+
var curr = newSource.currentValue;
|
|
2842
|
+
var prev = newSource.previousValue;
|
|
2843
|
+
// Se manca curr vuol dire che non ho un valore e posso ignorare (alla peggio deve arrivarmi un array vuoto)
|
|
2844
|
+
if (!curr)
|
|
2845
|
+
return;
|
|
2846
|
+
// Se manca prev vuol dire che è la prima assegnazione, lo considero un array vuoto e proseguo... ogni tanto viene chiamato una sola volta
|
|
2847
|
+
// ogni tanto viene chiamato due volte... è un pelo arbitrario ma vabbè
|
|
2848
|
+
if (!prev)
|
|
2849
|
+
prev = [];
|
|
2850
|
+
// Considero di aver ricevuto una nuova sorgente se:
|
|
2851
|
+
// 1: La sorgente nuova ha un numero di elementi diverso dalla sorgente vecchia
|
|
2852
|
+
// 2: Sia la sorgente nuova che vecchia hanno almeno un elemento e l'id del primo elemento della sorgente nuova è diverso dall'id del primo elemento della sorgente vecchia
|
|
2853
|
+
if (newSource && (curr.length != prev.length || (curr.length > 0 && curr[0][this.IdField] != prev[0][this.IdField]))) {
|
|
2854
|
+
/*
|
|
2855
|
+
* NGBUG:
|
|
2856
|
+
* Uso questo escamotage per distruggere il val-select e ricrearlo
|
|
2857
|
+
* Purtroppo una volta bindato a una sorgente, cambiargliela sotto significa mandare in palla material
|
|
2858
|
+
* che si mette a far floattare la label anche se il valore e' vuoto
|
|
2859
|
+
* Distruggendo il componente e ricreandolo material riparte da 0 e non da' problemi.
|
|
2860
|
+
* Ovviamente lo faccio solo quando ho una SelectLabel, altrimenti non ho problemi di floattamenti
|
|
2861
|
+
*/
|
|
2862
|
+
if (!this.FirstBind && this.SelectLabel) {
|
|
2863
|
+
this.BoundSource = null;
|
|
2864
|
+
setTimeout(function () { _this.tryBindSourceDisplay(); _this.cdr.detectChanges(); });
|
|
2865
|
+
}
|
|
2866
|
+
else
|
|
2867
|
+
this.tryBindSourceDisplay();
|
|
2868
|
+
this.cdr.markForCheck();
|
|
2869
|
+
}
|
|
2860
2870
|
};
|
|
2861
2871
|
/**
|
|
2862
2872
|
* @ignore
|