@esfaenza/forms-and-validations 11.2.75 → 11.2.78
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 +226 -48
- 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/base-form-control.js +2 -2
- package/esm2015/lib/forms/form-autocomplete/form-autocomplete.component.js +18 -7
- package/esm2015/lib/forms/form-multiselect/form-multiselect.component.js +11 -4
- 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 +216 -45
- package/fesm2015/esfaenza-forms-and-validations.js.map +1 -1
- package/lib/forms/form-autocomplete/form-autocomplete.component.d.ts +2 -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 = 3;
|
|
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 {
|
|
@@ -1663,7 +1812,7 @@ class BaseFormControl {
|
|
|
1663
1812
|
* un altro con lo stesso "name" ma magari resettato, Angular lo re-idraterebbe con i valori precedenti nonostante il modello fosse vuoto
|
|
1664
1813
|
*/
|
|
1665
1814
|
ngOnDestroy() {
|
|
1666
|
-
if (this.
|
|
1815
|
+
if (this.Form && this.validationControl && !!this.Form.getControl(this.validationControl))
|
|
1667
1816
|
this.Form.removeControl(this.validationControl);
|
|
1668
1817
|
}
|
|
1669
1818
|
/** Elabora i validatori iniettati e capisce se il valore è obbligatorio o meno */
|
|
@@ -2747,6 +2896,8 @@ class FormMultiSelectComponent extends BaseFormControl {
|
|
|
2747
2896
|
this.SelectLabel = "";
|
|
2748
2897
|
/** Permette al componente di gestire come modello non una lista di chiavi, ma una lista di KeyValue */
|
|
2749
2898
|
this.UseKeyValues = false;
|
|
2899
|
+
/** Indica al componente di emettere una lista di chiavi separate da virgola piuttosto che una lista vera e propria di chiavi/KeyValue */
|
|
2900
|
+
this.UseCommaSeparatedList = false;
|
|
2750
2901
|
/** Impostazioni del componente interno **angular2-multiselect** */
|
|
2751
2902
|
this.Settings = null;
|
|
2752
2903
|
// Default dei settings per evitare che siano mai nulli, altrimenti il cazzo di CuppaLab salta in araia che è veramente una bellezza
|
|
@@ -2799,6 +2950,8 @@ class FormMultiSelectComponent extends BaseFormControl {
|
|
|
2799
2950
|
writeValue(obj) {
|
|
2800
2951
|
this.TmpModel = obj;
|
|
2801
2952
|
let toPass = [];
|
|
2953
|
+
if (this.UseCommaSeparatedList && obj && !obj.length)
|
|
2954
|
+
obj = obj.split(',');
|
|
2802
2955
|
//Qui arrivano solo gli id, o {id: x, description: y} in caso sono in UseKeyValues,
|
|
2803
2956
|
//devo tirare fuori gli oggetti relativi e piazzarli come lista per il Model
|
|
2804
2957
|
if (obj && obj.length > 0) {
|
|
@@ -2816,10 +2969,12 @@ class FormMultiSelectComponent extends BaseFormControl {
|
|
|
2816
2969
|
/** @ignore Override per gestire input in uscita */
|
|
2817
2970
|
changed() {
|
|
2818
2971
|
let toEmit = null;
|
|
2819
|
-
if (!this.UseKeyValues)
|
|
2972
|
+
if (!this.UseKeyValues && !this.UseCommaSeparatedList)
|
|
2820
2973
|
toEmit = this.Model.map(m => m.id);
|
|
2821
|
-
else
|
|
2974
|
+
else if (this.UseKeyValues)
|
|
2822
2975
|
toEmit = this.Model.map(m => ({ id: m.id, description: m.itemName }));
|
|
2976
|
+
else if (this.UseCommaSeparatedList)
|
|
2977
|
+
toEmit = this.Model.map(m => m.id).join(',');
|
|
2823
2978
|
super.changed(toEmit);
|
|
2824
2979
|
super.finalized();
|
|
2825
2980
|
}
|
|
@@ -2846,7 +3001,8 @@ FormMultiSelectComponent.ctorParameters = () => [
|
|
|
2846
3001
|
];
|
|
2847
3002
|
FormMultiSelectComponent.propDecorators = {
|
|
2848
3003
|
SelectLabel: [{ type: Input }],
|
|
2849
|
-
UseKeyValues: [{ type: Input }]
|
|
3004
|
+
UseKeyValues: [{ type: Input }],
|
|
3005
|
+
UseCommaSeparatedList: [{ type: Input }]
|
|
2850
3006
|
};
|
|
2851
3007
|
|
|
2852
3008
|
// Angular
|
|
@@ -2919,6 +3075,8 @@ class FormAutocompleteComponent extends BaseFormControl {
|
|
|
2919
3075
|
this.RequiredPlaceholder = null;
|
|
2920
3076
|
/** Indica se i controlli devono essere effettuati tenendo conto del Case o meno. Vale solo qualora la **Source** fosse fornita */
|
|
2921
3077
|
this.CaseSensitive = false;
|
|
3078
|
+
/** Indica se usare la modalità multiselezione o no */
|
|
3079
|
+
this.Multi = false;
|
|
2922
3080
|
/**
|
|
2923
3081
|
* Indica se ignorare il prossimo evento writeValue che normalmente dovrebbe richiedere la nuova source. Serve per quando l'utente seleziona un elemento:
|
|
2924
3082
|
* Subito dopo partirebbe un altro evento modelChange che ricaricherebbe nuovamente la source
|
|
@@ -2943,7 +3101,8 @@ class FormAutocompleteComponent extends BaseFormControl {
|
|
|
2943
3101
|
});
|
|
2944
3102
|
return;
|
|
2945
3103
|
}
|
|
2946
|
-
this.
|
|
3104
|
+
if (!this.Multi)
|
|
3105
|
+
this.finalizeValue(value);
|
|
2947
3106
|
}
|
|
2948
3107
|
/**
|
|
2949
3108
|
* 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 +3126,10 @@ class FormAutocompleteComponent extends BaseFormControl {
|
|
|
2967
3126
|
if (t && t.length > 0) {
|
|
2968
3127
|
this.Source = t;
|
|
2969
3128
|
this.tryBindSourceDisplay();
|
|
2970
|
-
|
|
3129
|
+
if (!this.Multi)
|
|
3130
|
+
setTimeout(() => { this.finalizeValue(this.Model); });
|
|
3131
|
+
else
|
|
3132
|
+
this.cdr.markForCheck();
|
|
2971
3133
|
}
|
|
2972
3134
|
});
|
|
2973
3135
|
}
|
|
@@ -2982,7 +3144,8 @@ class FormAutocompleteComponent extends BaseFormControl {
|
|
|
2982
3144
|
return;
|
|
2983
3145
|
}
|
|
2984
3146
|
// Quando filtro la source, se non devo ignorare l'evento devo comunque assicurarmi di impostare il valore selezionato a null
|
|
2985
|
-
|
|
3147
|
+
if (!this.Multi)
|
|
3148
|
+
super.changed(null);
|
|
2986
3149
|
if (!event && this.MinChars == 0 && !this.SearchFunction) {
|
|
2987
3150
|
this.FilteredBoundSource = this.BoundSource;
|
|
2988
3151
|
return;
|
|
@@ -3038,7 +3201,10 @@ class FormAutocompleteComponent extends BaseFormControl {
|
|
|
3038
3201
|
}
|
|
3039
3202
|
/** @ignore Override che marca anche il prossimo evento di filterSource da ignorare */
|
|
3040
3203
|
changed(forcedValue = null, markForCheck = false) {
|
|
3041
|
-
this.
|
|
3204
|
+
if (!this.Multi)
|
|
3205
|
+
this.ignoreNextWriteValue = true;
|
|
3206
|
+
if (forcedValue == "" && this.Multi)
|
|
3207
|
+
this.Model = "";
|
|
3042
3208
|
super.changed(forcedValue, markForCheck);
|
|
3043
3209
|
}
|
|
3044
3210
|
/** @ignore */
|
|
@@ -3055,7 +3221,7 @@ class FormAutocompleteComponent extends BaseFormControl {
|
|
|
3055
3221
|
FormAutocompleteComponent.decorators = [
|
|
3056
3222
|
{ type: Component, args: [{
|
|
3057
3223
|
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>",
|
|
3224
|
+
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 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
3225
|
providers: [{ provide: LocalizationService, useClass: FormAutocompleteComponentLoc }],
|
|
3060
3226
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
3061
3227
|
},] }
|
|
@@ -3075,7 +3241,8 @@ FormAutocompleteComponent.propDecorators = {
|
|
|
3075
3241
|
SearchFunction: [{ type: Input }],
|
|
3076
3242
|
MinChars: [{ type: Input }],
|
|
3077
3243
|
RequiredPlaceholder: [{ type: Input }],
|
|
3078
|
-
CaseSensitive: [{ type: Input }]
|
|
3244
|
+
CaseSensitive: [{ type: Input }],
|
|
3245
|
+
Multi: [{ type: Input }]
|
|
3079
3246
|
};
|
|
3080
3247
|
|
|
3081
3248
|
// Angular
|
|
@@ -3208,6 +3375,7 @@ const COMPONENTS = [
|
|
|
3208
3375
|
FormMultiSelectComponent,
|
|
3209
3376
|
FormFileComponent,
|
|
3210
3377
|
ValidationAutocompleteComponent,
|
|
3378
|
+
ValidationAutocompleteMultiComponent,
|
|
3211
3379
|
FormAutocompleteComponent,
|
|
3212
3380
|
FormDateTimeComponent,
|
|
3213
3381
|
ValidationDateTimeComponent,
|
|
@@ -3221,6 +3389,9 @@ const MODULES = [
|
|
|
3221
3389
|
FormsModule,
|
|
3222
3390
|
LocalizationModule,
|
|
3223
3391
|
MatInputModule,
|
|
3392
|
+
MatChipsModule,
|
|
3393
|
+
MatIconModule,
|
|
3394
|
+
MatCheckboxModule,
|
|
3224
3395
|
MatDatepickerModule,
|
|
3225
3396
|
MatDayjsDateModule,
|
|
3226
3397
|
TooltipModule,
|
|
@@ -3265,5 +3436,5 @@ FormsAndValidationsModule.decorators = [
|
|
|
3265
3436
|
* Generated bundle index. Do not edit.
|
|
3266
3437
|
*/
|
|
3267
3438
|
|
|
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,
|
|
3439
|
+
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
3440
|
//# sourceMappingURL=esfaenza-forms-and-validations.js.map
|