@esfaenza/forms-and-validations 11.2.77 → 11.2.80
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 +234 -49
- package/bundles/esfaenza-forms-and-validations.umd.js.map +1 -1
- package/esfaenza-forms-and-validations.d.ts +2 -1
- package/esfaenza-forms-and-validations.metadata.json +1 -1
- package/esm2015/esfaenza-forms-and-validations.js +3 -2
- package/esm2015/lib/forms/form-autocomplete/form-autocomplete.component.js +21 -7
- package/esm2015/lib/forms/form-multiselect/form-multiselect.component.js +11 -4
- package/esm2015/lib/forms/form-select/form-select.component.js +6 -3
- package/esm2015/lib/forms-and-validations.module.js +9 -1
- package/esm2015/lib/validations/base-validation.loc.js +2 -1
- package/esm2015/lib/validations/validation-autocomplete/validation-autocomplete.component.js +12 -34
- package/esm2015/lib/validations/validation-autocomplete-multi/validation-autocomplete-multi.component.js +175 -0
- package/fesm2015/esfaenza-forms-and-validations.js +223 -46
- package/fesm2015/esfaenza-forms-and-validations.js.map +1 -1
- package/lib/forms/form-autocomplete/form-autocomplete.component.d.ts +4 -0
- package/lib/forms/form-multiselect/form-multiselect.component.d.ts +3 -1
- package/lib/validations/validation-autocomplete/validation-autocomplete.component.d.ts +14 -42
- package/lib/validations/validation-autocomplete-multi/validation-autocomplete-multi.component.d.ts +78 -0
- package/package.json +1 -1
|
@@ -4,8 +4,11 @@ import { DayJsDateAdapter, MatDayjsDateModule } from '@esfaenza/material-dayjs-a
|
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
5
|
import { NG_VALIDATORS, RequiredValidator, NgControl, NG_VALUE_ACCESSOR, NG_ASYNC_VALIDATORS, FormsModule } from '@angular/forms';
|
|
6
6
|
import { MatDatepickerModule } from '@angular/material/datepicker';
|
|
7
|
-
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
|
7
|
+
import { MatAutocompleteTrigger, MatAutocompleteModule } from '@angular/material/autocomplete';
|
|
8
8
|
import { MatInputModule } from '@angular/material/input';
|
|
9
|
+
import { MatChipsModule } from '@angular/material/chips';
|
|
10
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
11
|
+
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
9
12
|
import { LocalizationService, LocalizationModule } from '@esfaenza/localizations';
|
|
10
13
|
import { CurrencyMaskModule } from '@esfaenza/ngx-currency-mask';
|
|
11
14
|
import { AngularMultiSelectModule } from 'angular2-multiselect-dropdown';
|
|
@@ -424,6 +427,7 @@ class BaseValidationLoc extends LocalizationService {
|
|
|
424
427
|
super(LOC_LOCALE !== null && LOC_LOCALE !== void 0 ? LOC_LOCALE : 'it-IT');
|
|
425
428
|
super.set("en->it", "Required Input", ["Input Richiesto"]);
|
|
426
429
|
super.set("en->it", "Invalid Input Format", ["Formato Input Invalido"]);
|
|
430
|
+
super.set("en->it", "Elements selected", ["Elementi selezionati"]);
|
|
427
431
|
}
|
|
428
432
|
}
|
|
429
433
|
BaseValidationLoc.decorators = [
|
|
@@ -1246,52 +1250,36 @@ ValidationDateTimeComponent.propDecorators = {
|
|
|
1246
1250
|
* Componente di validaizone per gli input di Autocompletamento
|
|
1247
1251
|
*/
|
|
1248
1252
|
class ValidationAutocompleteComponent extends BaseValidation {
|
|
1249
|
-
/**
|
|
1250
|
-
* @ignore
|
|
1251
|
-
*/
|
|
1253
|
+
/** @ignore */
|
|
1252
1254
|
constructor(_validators, _asyncValidators, injector, lc) {
|
|
1253
1255
|
super();
|
|
1254
1256
|
this._validators = _validators;
|
|
1255
1257
|
this._asyncValidators = _asyncValidators;
|
|
1256
1258
|
this.injector = injector;
|
|
1257
1259
|
this.lc = lc;
|
|
1258
|
-
/**
|
|
1259
|
-
* Sorgente da cui scegliere valori filtrata in base a quello che ha scritto l'utente
|
|
1260
|
-
*/
|
|
1260
|
+
/** Sorgente da cui scegliere valori filtrata in base a quello che ha scritto l'utente */
|
|
1261
1261
|
this.FilteredSource = [];
|
|
1262
|
-
/**
|
|
1263
|
-
* Contenuto della label Floattante Material-Style
|
|
1264
|
-
*/
|
|
1262
|
+
/** Contenuto della label Floattante Material-Style */
|
|
1265
1263
|
this.label = "";
|
|
1266
|
-
/**
|
|
1267
|
-
* Evento che indica l'opzione selezionata dal componente. Il valore finale della selezione dovrà essere questo
|
|
1268
|
-
*/
|
|
1264
|
+
/** Evento che indica l'opzione selezionata dal componente. Il valore finale della selezione dovrà essere questo */
|
|
1269
1265
|
this.optionChange = new EventEmitter();
|
|
1270
|
-
/**
|
|
1271
|
-
* @ignore
|
|
1272
|
-
*/
|
|
1266
|
+
/** @ignore */
|
|
1273
1267
|
this.onTouched = () => { }; //placeholder on touched function
|
|
1274
1268
|
}
|
|
1275
|
-
/**
|
|
1276
|
-
* @ignore
|
|
1277
|
-
*/
|
|
1269
|
+
/** @ignore */
|
|
1278
1270
|
ngOnInit() {
|
|
1279
1271
|
this.registerFocusRequest();
|
|
1280
1272
|
//controllo se è settato un required per decidere in maniera condizionale se utilizzare il validatore required nel componente interno
|
|
1281
1273
|
if (this._validators && !this.noValidate && this._validators.some(elem => elem instanceof RequiredValidator))
|
|
1282
1274
|
this.required = true;
|
|
1283
1275
|
}
|
|
1284
|
-
/**
|
|
1285
|
-
* @ignore
|
|
1286
|
-
*/
|
|
1276
|
+
/** @ignore */
|
|
1287
1277
|
ngOnDestroy() {
|
|
1288
1278
|
this.deregisterFocusRequest();
|
|
1289
1279
|
if (this.tooltipSubscription)
|
|
1290
1280
|
this.tooltipSubscription.unsubscribe();
|
|
1291
1281
|
}
|
|
1292
|
-
/**
|
|
1293
|
-
* @ignore
|
|
1294
|
-
*/
|
|
1282
|
+
/** @ignore */
|
|
1295
1283
|
ngAfterViewInit() {
|
|
1296
1284
|
this.postBinding();
|
|
1297
1285
|
}
|
|
@@ -1322,9 +1310,7 @@ class ValidationAutocompleteComponent extends BaseValidation {
|
|
|
1322
1310
|
};
|
|
1323
1311
|
}
|
|
1324
1312
|
}
|
|
1325
|
-
/**
|
|
1326
|
-
* @ignore
|
|
1327
|
-
*/
|
|
1313
|
+
/** @ignore */
|
|
1328
1314
|
writeValue(value) {
|
|
1329
1315
|
var val = value && this.FilteredSource ? this.FilteredSource.find(t => t.id == value) : null;
|
|
1330
1316
|
if (val)
|
|
@@ -1342,15 +1328,11 @@ class ValidationAutocompleteComponent extends BaseValidation {
|
|
|
1342
1328
|
this.inputChange.emit(toEmit);
|
|
1343
1329
|
this.onTouched();
|
|
1344
1330
|
}
|
|
1345
|
-
/**
|
|
1346
|
-
* @ignore
|
|
1347
|
-
*/
|
|
1331
|
+
/** @ignore */
|
|
1348
1332
|
registerOnChange(fn) {
|
|
1349
1333
|
this.propagateChange = fn;
|
|
1350
1334
|
}
|
|
1351
|
-
/**
|
|
1352
|
-
* @ignore
|
|
1353
|
-
*/
|
|
1335
|
+
/** @ignore */
|
|
1354
1336
|
registerOnTouched(fn) {
|
|
1355
1337
|
this.onTouched = fn;
|
|
1356
1338
|
}
|
|
@@ -1385,6 +1367,173 @@ ValidationAutocompleteComponent.propDecorators = {
|
|
|
1385
1367
|
optionChange: [{ type: Output }]
|
|
1386
1368
|
};
|
|
1387
1369
|
|
|
1370
|
+
// Angular
|
|
1371
|
+
/**
|
|
1372
|
+
* Componente di validaizone per gli input di Autocompletamento
|
|
1373
|
+
*/
|
|
1374
|
+
class ValidationAutocompleteMultiComponent extends BaseValidation {
|
|
1375
|
+
/** @ignore */
|
|
1376
|
+
constructor(_validators, _asyncValidators, injector, lc) {
|
|
1377
|
+
super();
|
|
1378
|
+
this._validators = _validators;
|
|
1379
|
+
this._asyncValidators = _asyncValidators;
|
|
1380
|
+
this.injector = injector;
|
|
1381
|
+
this.lc = lc;
|
|
1382
|
+
this.displayFn = () => '';
|
|
1383
|
+
/** Numero massimo di chip visualizzate */
|
|
1384
|
+
this.ChipThreshold = 10;
|
|
1385
|
+
/** Sorgente da cui scegliere valori filtrata in base a quello che ha scritto l'utente */
|
|
1386
|
+
this.FilteredSource = [];
|
|
1387
|
+
/** Contenuto della label Floattante Material-Style */
|
|
1388
|
+
this.label = "";
|
|
1389
|
+
/** Evento che indica l'opzione selezionata dal componente. Il valore finale della selezione dovrà essere questo */
|
|
1390
|
+
this.optionChange = new EventEmitter();
|
|
1391
|
+
/** Elementi selezionati */
|
|
1392
|
+
this.selectData = [];
|
|
1393
|
+
/** @ignore */
|
|
1394
|
+
this.onTouched = () => { }; //placeholder on touched function
|
|
1395
|
+
}
|
|
1396
|
+
/** @ignore */
|
|
1397
|
+
ngOnInit() {
|
|
1398
|
+
this.registerFocusRequest();
|
|
1399
|
+
//controllo se è settato un required per decidere in maniera condizionale se utilizzare il validatore required nel componente interno
|
|
1400
|
+
if (this._validators && !this.noValidate && this._validators.some(elem => elem instanceof RequiredValidator))
|
|
1401
|
+
this.required = true;
|
|
1402
|
+
}
|
|
1403
|
+
/** @ignore */
|
|
1404
|
+
ngOnDestroy() {
|
|
1405
|
+
this.deregisterFocusRequest();
|
|
1406
|
+
if (this.tooltipSubscription)
|
|
1407
|
+
this.tooltipSubscription.unsubscribe();
|
|
1408
|
+
}
|
|
1409
|
+
/** @ignore */
|
|
1410
|
+
ngAfterViewInit() {
|
|
1411
|
+
this.postBinding();
|
|
1412
|
+
}
|
|
1413
|
+
/** In caso arrivi una nuova sorgente devo reimpostare lo stato di selezione con quello attuale */
|
|
1414
|
+
ngOnChanges(changes) {
|
|
1415
|
+
let newSource = changes["FilteredSource"];
|
|
1416
|
+
if (!newSource || newSource.firstChange)
|
|
1417
|
+
return;
|
|
1418
|
+
for (let i = 0; i < this.FilteredSource.length; i++) {
|
|
1419
|
+
let item = this.FilteredSource[i];
|
|
1420
|
+
item.selected = this.selectData.find(t => t.id == item.id);
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
/**
|
|
1424
|
+
* Metodo che si occupa di collegare i validatori e la funzione di reset dal **ControlValueAccessor** rappresentato
|
|
1425
|
+
* da questo componente al **ControlValueAccessor** rappresentato dall'effettivo elemento di Input presente lato HTML
|
|
1426
|
+
*/
|
|
1427
|
+
postBinding() {
|
|
1428
|
+
this.CheckValidity();
|
|
1429
|
+
const ngControl = this.injector.get(NgControl, null);
|
|
1430
|
+
if (ngControl) {
|
|
1431
|
+
this.parentControl = ngControl.control;
|
|
1432
|
+
//se la variabile novalidate è true, elimino tutti i validatori eventualmente inseriti
|
|
1433
|
+
if (this.noValidate) {
|
|
1434
|
+
this.parentControl.clearValidators();
|
|
1435
|
+
this.parentControl.clearAsyncValidators();
|
|
1436
|
+
}
|
|
1437
|
+
else {
|
|
1438
|
+
this.baseInput.control.setAsyncValidators(this._asyncValidators);
|
|
1439
|
+
this.baseInput.control.setValidators(this._validators);
|
|
1440
|
+
}
|
|
1441
|
+
//faccio in modo che se chiamo il reset del controllo (o della form) dall'esterno si resetti anche il controllo nativo
|
|
1442
|
+
const origFunc = this.parentControl.reset;
|
|
1443
|
+
this.parentControl.reset = () => {
|
|
1444
|
+
origFunc.apply(this.parentControl);
|
|
1445
|
+
this.baseInput.control.reset();
|
|
1446
|
+
this.tooltip.hide();
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
/** @ignore */
|
|
1451
|
+
writeValue(value, finalValue = false) {
|
|
1452
|
+
var val = value && this.FilteredSource ? this.FilteredSource.find(t => t.id == value) : null;
|
|
1453
|
+
if (finalValue)
|
|
1454
|
+
this.optionChange.emit(value);
|
|
1455
|
+
this.propagateChange(val ? val.id : value);
|
|
1456
|
+
this.value = val ? val.description : value;
|
|
1457
|
+
}
|
|
1458
|
+
/**
|
|
1459
|
+
* L'emit della modifica al valore viene gestito su un evento custom (**inputChange**) come workaround al malfunzionamento dell'**ngModelChange** nativo
|
|
1460
|
+
*
|
|
1461
|
+
* @param {any} toEmit valore da propagare all'esterno
|
|
1462
|
+
*/
|
|
1463
|
+
onModelChange(toEmit, finalValue = false) {
|
|
1464
|
+
this.writeValue(toEmit, finalValue);
|
|
1465
|
+
if (!finalValue)
|
|
1466
|
+
this.inputChange.emit(toEmit);
|
|
1467
|
+
this.onTouched();
|
|
1468
|
+
}
|
|
1469
|
+
/** @ignore */
|
|
1470
|
+
registerOnChange(fn) {
|
|
1471
|
+
this.propagateChange = fn;
|
|
1472
|
+
}
|
|
1473
|
+
/** @ignore */
|
|
1474
|
+
registerOnTouched(fn) {
|
|
1475
|
+
this.onTouched = fn;
|
|
1476
|
+
}
|
|
1477
|
+
/** Rimuove un elemento selezionato */
|
|
1478
|
+
removeChip(data) {
|
|
1479
|
+
if (!data) {
|
|
1480
|
+
this.selectData = [];
|
|
1481
|
+
this.FilteredSource.forEach(data => data.selected = false);
|
|
1482
|
+
this.onModelChange(this.selectData.map(t => t.id).join(','), true);
|
|
1483
|
+
this.onFinalize();
|
|
1484
|
+
}
|
|
1485
|
+
else
|
|
1486
|
+
this.toggleSelection(data);
|
|
1487
|
+
}
|
|
1488
|
+
;
|
|
1489
|
+
/** Seleziona o deseleziona un oggetto */
|
|
1490
|
+
toggleSelection(data) {
|
|
1491
|
+
data.selected = !data.selected;
|
|
1492
|
+
if (data.selected === true) {
|
|
1493
|
+
this.selectData.push(data);
|
|
1494
|
+
}
|
|
1495
|
+
else {
|
|
1496
|
+
const i = this.selectData.findIndex(value => value.id === data.id);
|
|
1497
|
+
this.selectData.splice(i, 1);
|
|
1498
|
+
}
|
|
1499
|
+
this.value = null;
|
|
1500
|
+
this.onModelChange(this.selectData.map(t => t.id).join(','), true);
|
|
1501
|
+
this.onFinalize();
|
|
1502
|
+
}
|
|
1503
|
+
;
|
|
1504
|
+
}
|
|
1505
|
+
ValidationAutocompleteMultiComponent.decorators = [
|
|
1506
|
+
{ type: Component, args: [{
|
|
1507
|
+
selector: "val-autocomplete-multi",
|
|
1508
|
+
template: "<mat-form-field appearance=\"{{FieldAppearence}}\" class=\"mat-full-width mat-no-border-top\" [style.width.px]=\"widthPx\">\r\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\r\n <mat-chip-list #chipList>\r\n <ng-container *ngIf=\"selectData.length < ChipThreshold\" >\r\n <mat-chip *ngFor=\"let select of selectData\" class=\"cardinal-colors\" (click)=\"!(readonly || disabled) && removeChip(select)\">\r\n {{ select.description }}\r\n <mat-icon class=\"mat-chip-remove\">cancel</mat-icon>\r\n </mat-chip>\r\n </ng-container>\r\n\r\n <mat-chip *ngIf=\"selectData.length >= ChipThreshold\" class=\"cardinal-colors\" (click)=\"!(readonly || disabled) && removeChip(null)\">\r\n {{ selectData.length }} {{ 'Elements selected' | localize: lc }}\r\n <mat-icon class=\"mat-chip-remove\">cancel</mat-icon>\r\n </mat-chip>\r\n \r\n <input matInput\r\n [matChipInputFor]=\"chipList\"\r\n #htmlInput\r\n #baseInput='ngModel'\r\n type=\"text\"\r\n triggers=\"\"\r\n placement=\"top\"\r\n [placeholder]=\"placeholder\"\r\n [matAutocomplete]=\"auto\"\r\n name=\"val-input\"\r\n id=\"{{id}}\"\r\n [(ngModel)]=\"value\"\r\n [tooltip]=\"tolTemplate\"\r\n [disabled]=\"readonly || disabled\"\r\n (ngModelChange)=\"onModelChange($event)\"\r\n (click)=\"onFocus($event)\"\r\n (focus)=\"checkTooltip();\"\r\n (blur)=\"closeTooltip();\">\r\n </mat-chip-list>\r\n\r\n <mat-autocomplete #auto=\"matAutocomplete\" [displayWith]=\"displayFn\">\r\n <mat-option *ngFor=\"let data of FilteredSource\">\r\n <div (click)=\"toggleSelection(data); $event.stopPropagation()\">\r\n <mat-checkbox [checked]=\"data.selected\" (change)=\"toggleSelection(data);\" (click)=\"$event.stopPropagation()\">\r\n {{ data.description }}\r\n </mat-checkbox>\r\n </div>\r\n </mat-option>\r\n </mat-autocomplete>\r\n</mat-form-field>\r\n\r\n<ng-template #tolTemplate>\r\n <div (click)=\"closeTooltip()\">\r\n <span>{{validationFailed}}</span>\r\n </div>\r\n</ng-template>",
|
|
1509
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1510
|
+
providers: [
|
|
1511
|
+
{ provide: LocalizationService, useClass: BaseValidationLoc },
|
|
1512
|
+
{
|
|
1513
|
+
provide: NG_VALUE_ACCESSOR,
|
|
1514
|
+
useExisting: forwardRef(() => ValidationAutocompleteMultiComponent),
|
|
1515
|
+
multi: true
|
|
1516
|
+
}
|
|
1517
|
+
],
|
|
1518
|
+
encapsulation: ViewEncapsulation.None,
|
|
1519
|
+
styles: [".tooltip-inner{background-color:#842a30;font-size:12px;width:-webkit-max-content;width:-moz-max-content;width:max-content}.tooltip{margin:auto auto auto 20%!important}.tooltip-inner{background-color:#842a30!important;color:#fff}.tooltip.top .tooltip-arrow,.tooltip.top .tooltip-arrow:before{border-top-color:#842a30}.close-button{position:absolute;right:0;top:-.2em;float:right;font-size:16px;font-weight:700;color:inherit;text-shadow:0 1px 0 #fff;opacity:.5}.close-button:focus,.close-button:hover{text-decoration:none;cursor:pointer;opacity:.75}"]
|
|
1520
|
+
},] }
|
|
1521
|
+
];
|
|
1522
|
+
ValidationAutocompleteMultiComponent.ctorParameters = () => [
|
|
1523
|
+
{ type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_VALIDATORS,] }] },
|
|
1524
|
+
{ type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_ASYNC_VALIDATORS,] }] },
|
|
1525
|
+
{ type: Injector },
|
|
1526
|
+
{ type: LocalizationService }
|
|
1527
|
+
];
|
|
1528
|
+
ValidationAutocompleteMultiComponent.propDecorators = {
|
|
1529
|
+
ChipThreshold: [{ type: Input }],
|
|
1530
|
+
FilteredSource: [{ type: Input }],
|
|
1531
|
+
value: [{ type: Input }],
|
|
1532
|
+
label: [{ type: Input }],
|
|
1533
|
+
optionChange: [{ type: Output }],
|
|
1534
|
+
autoTrigger: [{ type: ViewChild, args: [MatAutocompleteTrigger,] }]
|
|
1535
|
+
};
|
|
1536
|
+
|
|
1388
1537
|
// Angular
|
|
1389
1538
|
/** Componente base da cui tutti i componenti Form implementano */
|
|
1390
1539
|
class BaseFormControl {
|
|
@@ -2634,7 +2783,9 @@ class FormSelectComponent extends BaseFormControl {
|
|
|
2634
2783
|
this.detatchPreviousAndRetatchNext((afterStuff) => {
|
|
2635
2784
|
this.BoundSource = null;
|
|
2636
2785
|
setTimeout(() => {
|
|
2786
|
+
var _a;
|
|
2637
2787
|
this.tryBindSourceDisplay();
|
|
2788
|
+
this.EvaluatedModel = this.BoundSource && this.BoundSource.length > 0 ? (_a = this.BoundSource.find(t => t.id == this.Model)) === null || _a === void 0 ? void 0 : _a.description : "";
|
|
2638
2789
|
this.cdr.detectChanges();
|
|
2639
2790
|
setTimeout(() => { afterStuff(); });
|
|
2640
2791
|
});
|
|
@@ -2642,7 +2793,9 @@ class FormSelectComponent extends BaseFormControl {
|
|
|
2642
2793
|
}
|
|
2643
2794
|
else
|
|
2644
2795
|
this.detatchPreviousAndRetatchNext((afterStuff) => {
|
|
2796
|
+
var _a;
|
|
2645
2797
|
this.tryBindSourceDisplay();
|
|
2798
|
+
this.EvaluatedModel = this.BoundSource && this.BoundSource.length > 0 ? (_a = this.BoundSource.find(t => t.id == this.Model)) === null || _a === void 0 ? void 0 : _a.description : "";
|
|
2646
2799
|
this.cdr.detectChanges();
|
|
2647
2800
|
setTimeout(() => { afterStuff(); });
|
|
2648
2801
|
});
|
|
@@ -2670,8 +2823,7 @@ class FormSelectComponent extends BaseFormControl {
|
|
|
2670
2823
|
/** @ignore */
|
|
2671
2824
|
writeValue(obj) {
|
|
2672
2825
|
var _a;
|
|
2673
|
-
|
|
2674
|
-
this.EvaluatedModel = (_a = this.BoundSource.find(t => t.id == obj)) === null || _a === void 0 ? void 0 : _a.description;
|
|
2826
|
+
this.EvaluatedModel = this.BoundSource && this.BoundSource.length > 0 ? (_a = this.BoundSource.find(t => t.id == this.Model)) === null || _a === void 0 ? void 0 : _a.description : "";
|
|
2675
2827
|
super.writeValue(obj);
|
|
2676
2828
|
}
|
|
2677
2829
|
/** @ignore */
|
|
@@ -2747,6 +2899,8 @@ class FormMultiSelectComponent extends BaseFormControl {
|
|
|
2747
2899
|
this.SelectLabel = "";
|
|
2748
2900
|
/** Permette al componente di gestire come modello non una lista di chiavi, ma una lista di KeyValue */
|
|
2749
2901
|
this.UseKeyValues = false;
|
|
2902
|
+
/** Indica al componente di emettere una lista di chiavi separate da virgola piuttosto che una lista vera e propria di chiavi/KeyValue */
|
|
2903
|
+
this.UseCommaSeparatedList = false;
|
|
2750
2904
|
/** Impostazioni del componente interno **angular2-multiselect** */
|
|
2751
2905
|
this.Settings = null;
|
|
2752
2906
|
// Default dei settings per evitare che siano mai nulli, altrimenti il cazzo di CuppaLab salta in araia che è veramente una bellezza
|
|
@@ -2799,6 +2953,8 @@ class FormMultiSelectComponent extends BaseFormControl {
|
|
|
2799
2953
|
writeValue(obj) {
|
|
2800
2954
|
this.TmpModel = obj;
|
|
2801
2955
|
let toPass = [];
|
|
2956
|
+
if (this.UseCommaSeparatedList && obj && !obj.length)
|
|
2957
|
+
obj = obj.split(',');
|
|
2802
2958
|
//Qui arrivano solo gli id, o {id: x, description: y} in caso sono in UseKeyValues,
|
|
2803
2959
|
//devo tirare fuori gli oggetti relativi e piazzarli come lista per il Model
|
|
2804
2960
|
if (obj && obj.length > 0) {
|
|
@@ -2816,10 +2972,12 @@ class FormMultiSelectComponent extends BaseFormControl {
|
|
|
2816
2972
|
/** @ignore Override per gestire input in uscita */
|
|
2817
2973
|
changed() {
|
|
2818
2974
|
let toEmit = null;
|
|
2819
|
-
if (!this.UseKeyValues)
|
|
2975
|
+
if (!this.UseKeyValues && !this.UseCommaSeparatedList)
|
|
2820
2976
|
toEmit = this.Model.map(m => m.id);
|
|
2821
|
-
else
|
|
2977
|
+
else if (this.UseKeyValues)
|
|
2822
2978
|
toEmit = this.Model.map(m => ({ id: m.id, description: m.itemName }));
|
|
2979
|
+
else if (this.UseCommaSeparatedList)
|
|
2980
|
+
toEmit = this.Model.map(m => m.id).join(',');
|
|
2823
2981
|
super.changed(toEmit);
|
|
2824
2982
|
super.finalized();
|
|
2825
2983
|
}
|
|
@@ -2846,7 +3004,8 @@ FormMultiSelectComponent.ctorParameters = () => [
|
|
|
2846
3004
|
];
|
|
2847
3005
|
FormMultiSelectComponent.propDecorators = {
|
|
2848
3006
|
SelectLabel: [{ type: Input }],
|
|
2849
|
-
UseKeyValues: [{ type: Input }]
|
|
3007
|
+
UseKeyValues: [{ type: Input }],
|
|
3008
|
+
UseCommaSeparatedList: [{ type: Input }]
|
|
2850
3009
|
};
|
|
2851
3010
|
|
|
2852
3011
|
// Angular
|
|
@@ -2919,6 +3078,10 @@ class FormAutocompleteComponent extends BaseFormControl {
|
|
|
2919
3078
|
this.RequiredPlaceholder = null;
|
|
2920
3079
|
/** Indica se i controlli devono essere effettuati tenendo conto del Case o meno. Vale solo qualora la **Source** fosse fornita */
|
|
2921
3080
|
this.CaseSensitive = false;
|
|
3081
|
+
/** Indica se usare la modalità multiselezione o no */
|
|
3082
|
+
this.Multi = false;
|
|
3083
|
+
/** Indica se usare la modalità multiselezione o no */
|
|
3084
|
+
this.MultiElementsThreshold = 10;
|
|
2922
3085
|
/**
|
|
2923
3086
|
* Indica se ignorare il prossimo evento writeValue che normalmente dovrebbe richiedere la nuova source. Serve per quando l'utente seleziona un elemento:
|
|
2924
3087
|
* Subito dopo partirebbe un altro evento modelChange che ricaricherebbe nuovamente la source
|
|
@@ -2943,7 +3106,8 @@ class FormAutocompleteComponent extends BaseFormControl {
|
|
|
2943
3106
|
});
|
|
2944
3107
|
return;
|
|
2945
3108
|
}
|
|
2946
|
-
this.
|
|
3109
|
+
if (!this.Multi)
|
|
3110
|
+
this.finalizeValue(value);
|
|
2947
3111
|
}
|
|
2948
3112
|
/**
|
|
2949
3113
|
* Dato un valore verifica se può restituire le informazioni trovate in **Source** con id uguale a **value** o se deve restituire il valore in se
|
|
@@ -2967,7 +3131,10 @@ class FormAutocompleteComponent extends BaseFormControl {
|
|
|
2967
3131
|
if (t && t.length > 0) {
|
|
2968
3132
|
this.Source = t;
|
|
2969
3133
|
this.tryBindSourceDisplay();
|
|
2970
|
-
|
|
3134
|
+
if (!this.Multi)
|
|
3135
|
+
setTimeout(() => { this.finalizeValue(this.Model); });
|
|
3136
|
+
else
|
|
3137
|
+
this.cdr.markForCheck();
|
|
2971
3138
|
}
|
|
2972
3139
|
});
|
|
2973
3140
|
}
|
|
@@ -2982,7 +3149,8 @@ class FormAutocompleteComponent extends BaseFormControl {
|
|
|
2982
3149
|
return;
|
|
2983
3150
|
}
|
|
2984
3151
|
// Quando filtro la source, se non devo ignorare l'evento devo comunque assicurarmi di impostare il valore selezionato a null
|
|
2985
|
-
|
|
3152
|
+
if (!this.Multi)
|
|
3153
|
+
super.changed(null);
|
|
2986
3154
|
if (!event && this.MinChars == 0 && !this.SearchFunction) {
|
|
2987
3155
|
this.FilteredBoundSource = this.BoundSource;
|
|
2988
3156
|
return;
|
|
@@ -3038,7 +3206,10 @@ class FormAutocompleteComponent extends BaseFormControl {
|
|
|
3038
3206
|
}
|
|
3039
3207
|
/** @ignore Override che marca anche il prossimo evento di filterSource da ignorare */
|
|
3040
3208
|
changed(forcedValue = null, markForCheck = false) {
|
|
3041
|
-
this.
|
|
3209
|
+
if (!this.Multi)
|
|
3210
|
+
this.ignoreNextWriteValue = true;
|
|
3211
|
+
if (forcedValue == "" && this.Multi)
|
|
3212
|
+
this.Model = "";
|
|
3042
3213
|
super.changed(forcedValue, markForCheck);
|
|
3043
3214
|
}
|
|
3044
3215
|
/** @ignore */
|
|
@@ -3055,7 +3226,7 @@ class FormAutocompleteComponent extends BaseFormControl {
|
|
|
3055
3226
|
FormAutocompleteComponent.decorators = [
|
|
3056
3227
|
{ type: Component, args: [{
|
|
3057
3228
|
selector: "form-autocomplete",
|
|
3058
|
-
template: "<ng-container *ngIf=\"!FormLayout\">\r\n <ng-container *ngIf=\"DisplayMode && !DisplayModeTemplate\">{{ EvaluatedModel }}</ng-container>\r\n <ng-container *ngIf=\"DisplayMode && DisplayModeTemplate\"><ng-container *ngTemplateOutlet=\"DisplayModeTemplate, context: { $implicit: EvaluatedModel }\"></ng-container></ng-container>\r\n <div [hidden]=\"DisplayMode\"><ng-container *ngTemplateOutlet=\"controlTemplate\"></ng-container></div>\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}}\" [class.app-bold]=\"DisplayMode\" [class.m-t-5]=\"!DisplayMode\">{{Label}}{{Required && !DisplayMode ? '*' : ''}}:</label>\r\n <div class=\"col-md-{{InputColWidth}}\">\r\n <ng-container *ngIf=\"DisplayMode && !DisplayModeTemplate\">{{ EvaluatedModel }}</ng-container>\r\n <ng-container *ngIf=\"DisplayMode && DisplayModeTemplate\"><ng-container *ngTemplateOutlet=\"DisplayModeTemplate, context: { $implicit: EvaluatedModel }\"></ng-container></ng-container>\r\n <div [hidden]=\"DisplayMode\"><ng-container *ngTemplateOutlet=\"controlTemplate\"></ng-container></div>\r\n </div>\r\n <div class=\"clearfix\"></div>\r\n</div>\r\n\r\n<ng-template #controlTemplate>\r\n <val-autocomplete [FocusSubject]=\"FocusSubject\" [FieldAppearence]=\"FieldAppearence\" [noValidate]=\"!Validation\"\r\n [submitted]=\"Form?.submitted\"\r\n [forceInvalid]=\"ForcedError\"\r\n [readonly]=\"Readonly\"\r\n [label]=\"SelectLabel\"\r\n type=\"text\"\r\n [ngModel]=\"Model\"\r\n (ngModelChange)=\"Model = $event; evaluateIdResearch()\"\r\n [id]=\"GeneratedName\"\r\n name=\"{{GeneratedName}}\"\r\n #validationControl=\"ngModel\"\r\n (inputChange)=\"filterSource($event);\"\r\n (inputFocus)=\"focused($event);\"\r\n (inputFinalized)=\"finalized()\"\r\n (optionChange)=\"changed($event);\"\r\n [placeholder]=\"Required ? ((RequiredPlaceholder != null ? RequiredPlaceholder : ('Select' | localize : lc) + '...')) : Placeholder\"\r\n [validationFailed]=\"FailedValidationMessage\"\r\n [FilteredSource]=\"FilteredBoundSource\"\r\n >\r\n </val-autocomplete>\r\n</ng-template>",
|
|
3229
|
+
template: "<ng-container *ngIf=\"!FormLayout\">\r\n <ng-container *ngIf=\"DisplayMode && !DisplayModeTemplate\">{{ EvaluatedModel }}</ng-container>\r\n <ng-container *ngIf=\"DisplayMode && DisplayModeTemplate\"><ng-container *ngTemplateOutlet=\"DisplayModeTemplate, context: { $implicit: EvaluatedModel }\"></ng-container></ng-container>\r\n <div [hidden]=\"DisplayMode\"><ng-container *ngTemplateOutlet=\"controlTemplate\"></ng-container></div>\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}}\" [class.app-bold]=\"DisplayMode\" [class.m-t-5]=\"!DisplayMode\">{{Label}}{{Required && !DisplayMode ? '*' : ''}}:</label>\r\n <div class=\"col-md-{{InputColWidth}}\">\r\n <ng-container *ngIf=\"DisplayMode && !DisplayModeTemplate\">{{ EvaluatedModel }}</ng-container>\r\n <ng-container *ngIf=\"DisplayMode && DisplayModeTemplate\"><ng-container *ngTemplateOutlet=\"DisplayModeTemplate, context: { $implicit: EvaluatedModel }\"></ng-container></ng-container>\r\n <div [hidden]=\"DisplayMode\"><ng-container *ngTemplateOutlet=\"controlTemplate\"></ng-container></div>\r\n </div>\r\n <div class=\"clearfix\"></div>\r\n</div>\r\n\r\n<ng-template #controlTemplate>\r\n <val-autocomplete *ngIf=\"!Multi\" [FocusSubject]=\"FocusSubject\" [FieldAppearence]=\"FieldAppearence\" [noValidate]=\"!Validation\"\r\n [submitted]=\"Form?.submitted\"\r\n [forceInvalid]=\"ForcedError\"\r\n [readonly]=\"Readonly\"\r\n [label]=\"SelectLabel\"\r\n type=\"text\"\r\n [ngModel]=\"Model\"\r\n (ngModelChange)=\"Model = $event; evaluateIdResearch()\"\r\n [id]=\"GeneratedName\"\r\n name=\"{{GeneratedName}}\"\r\n #validationControl=\"ngModel\"\r\n (inputChange)=\"filterSource($event);\"\r\n (inputFocus)=\"focused($event);\"\r\n (inputFinalized)=\"finalized()\"\r\n (optionChange)=\"changed($event);\"\r\n [placeholder]=\"Required ? ((RequiredPlaceholder != null ? RequiredPlaceholder : ('Select' | localize : lc) + '...')) : Placeholder\"\r\n [validationFailed]=\"FailedValidationMessage\"\r\n [FilteredSource]=\"FilteredBoundSource\">\r\n </val-autocomplete>\r\n\r\n <val-autocomplete-multi *ngIf=\"Multi\" [FocusSubject]=\"FocusSubject\" [FieldAppearence]=\"FieldAppearence\" [noValidate]=\"!Validation\"\r\n [submitted]=\"Form?.submitted\"\r\n [forceInvalid]=\"ForcedError\"\r\n [readonly]=\"Readonly\"\r\n [label]=\"SelectLabel\"\r\n [ChipThreshold]=\"MultiElementsThreshold\"\r\n type=\"text\"\r\n [ngModel]=\"Model\"\r\n (ngModelChange)=\"Model = $event; evaluateIdResearch()\"\r\n [id]=\"GeneratedName\"\r\n name=\"{{GeneratedName}}\"\r\n #validationControl=\"ngModel\"\r\n (inputChange)=\"filterSource($event);\"\r\n (inputFocus)=\"focused($event);\"\r\n (inputFinalized)=\"finalized()\"\r\n (optionChange)=\"changed($event);\"\r\n [placeholder]=\"Required ? ((RequiredPlaceholder != null ? RequiredPlaceholder : ('Select' | localize : lc) + '...')) : Placeholder\"\r\n [validationFailed]=\"FailedValidationMessage\"\r\n [FilteredSource]=\"FilteredBoundSource\">\r\n\r\n </val-autocomplete-multi>\r\n</ng-template>",
|
|
3059
3230
|
providers: [{ provide: LocalizationService, useClass: FormAutocompleteComponentLoc }],
|
|
3060
3231
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
3061
3232
|
},] }
|
|
@@ -3075,7 +3246,9 @@ FormAutocompleteComponent.propDecorators = {
|
|
|
3075
3246
|
SearchFunction: [{ type: Input }],
|
|
3076
3247
|
MinChars: [{ type: Input }],
|
|
3077
3248
|
RequiredPlaceholder: [{ type: Input }],
|
|
3078
|
-
CaseSensitive: [{ type: Input }]
|
|
3249
|
+
CaseSensitive: [{ type: Input }],
|
|
3250
|
+
Multi: [{ type: Input }],
|
|
3251
|
+
MultiElementsThreshold: [{ type: Input }]
|
|
3079
3252
|
};
|
|
3080
3253
|
|
|
3081
3254
|
// Angular
|
|
@@ -3208,6 +3381,7 @@ const COMPONENTS = [
|
|
|
3208
3381
|
FormMultiSelectComponent,
|
|
3209
3382
|
FormFileComponent,
|
|
3210
3383
|
ValidationAutocompleteComponent,
|
|
3384
|
+
ValidationAutocompleteMultiComponent,
|
|
3211
3385
|
FormAutocompleteComponent,
|
|
3212
3386
|
FormDateTimeComponent,
|
|
3213
3387
|
ValidationDateTimeComponent,
|
|
@@ -3221,6 +3395,9 @@ const MODULES = [
|
|
|
3221
3395
|
FormsModule,
|
|
3222
3396
|
LocalizationModule,
|
|
3223
3397
|
MatInputModule,
|
|
3398
|
+
MatChipsModule,
|
|
3399
|
+
MatIconModule,
|
|
3400
|
+
MatCheckboxModule,
|
|
3224
3401
|
MatDatepickerModule,
|
|
3225
3402
|
MatDayjsDateModule,
|
|
3226
3403
|
TooltipModule,
|
|
@@ -3265,5 +3442,5 @@ FormsAndValidationsModule.decorators = [
|
|
|
3265
3442
|
* Generated bundle index. Do not edit.
|
|
3266
3443
|
*/
|
|
3267
3444
|
|
|
3268
|
-
export { AppFile, FormAdaptiveComponent, FormAutocompleteComponent, FormCheckboxComponent, FormDateComponent, FormDateTimeComponent, FormEmptyComponent, FormErrorComponent, FormFileComponent, FormInfoComponent, FormInputComponent, FormSelectComponent, FormTemplateComponent, FormTextareaComponent, FormTimeComponent, FormsAndValidationsModule, FormsAndValidationsModuleConfig, NgxExpandedDayJsDateAdapter, ValidationAutocompleteComponent, ValidationCurrencyComponent, ValidationDateComponent, ValidationDateTimeComponent, ValidationInputComponent, ValidationSelectComponent, ValidationTextAreaComponent, BaseValidation as ɵa, BaseValidationLoc as ɵb, FAV_LOCALE as ɵc, ACO_CUSTOMKEY as ɵd, FAV_DEBUG_MODE as ɵe, CustomRequiredDirective as ɵf, BaseFormControl as ɵg, FormSelectComponentLoc as ɵh, FormAdaptiveComponentLoc as ɵi, FormMultiSelectComponent as ɵj, FormMultiSelectComponentLoc as ɵk, FormFileComponentLoc as ɵl,
|
|
3445
|
+
export { AppFile, FormAdaptiveComponent, FormAutocompleteComponent, FormCheckboxComponent, FormDateComponent, FormDateTimeComponent, FormEmptyComponent, FormErrorComponent, FormFileComponent, FormInfoComponent, FormInputComponent, FormSelectComponent, FormTemplateComponent, FormTextareaComponent, FormTimeComponent, FormsAndValidationsModule, FormsAndValidationsModuleConfig, NgxExpandedDayJsDateAdapter, ValidationAutocompleteComponent, ValidationCurrencyComponent, ValidationDateComponent, ValidationDateTimeComponent, ValidationInputComponent, ValidationSelectComponent, ValidationTextAreaComponent, BaseValidation as ɵa, BaseValidationLoc as ɵb, FAV_LOCALE as ɵc, ACO_CUSTOMKEY as ɵd, FAV_DEBUG_MODE as ɵe, CustomRequiredDirective as ɵf, BaseFormControl as ɵg, FormSelectComponentLoc as ɵh, FormAdaptiveComponentLoc as ɵi, FormMultiSelectComponent as ɵj, FormMultiSelectComponentLoc as ɵk, FormFileComponentLoc as ɵl, ValidationAutocompleteMultiComponent as ɵm, FormAutocompleteComponentLoc as ɵn };
|
|
3269
3446
|
//# sourceMappingURL=esfaenza-forms-and-validations.js.map
|