@esfaenza/forms-and-validations 11.2.72 → 11.2.75

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.
@@ -1941,7 +1941,7 @@
1941
1941
  });
1942
1942
  // Post trybind se c'è un modello associato ricalcolo l'**EvaluatedModel**
1943
1943
  if (this.Model)
1944
- this.EvaluatedModel = (_a = this.BoundSource.find(function (t) { return t.id == _this.Model; })) === null || _a === void 0 ? void 0 : _a.description;
1944
+ (_a = this.BoundSource.find(function (t) { return t.id == _this.Model; })) === null || _a === void 0 ? void 0 : _a.description;
1945
1945
  }
1946
1946
  };
1947
1947
  /** Valuta il contenuto della variabile BindCheckingGroups */
@@ -2265,6 +2265,8 @@
2265
2265
  if (clear) {
2266
2266
  model.filename = "";
2267
2267
  ne.value = "";
2268
+ model.fileb64 = "";
2269
+ model.nativefiles = [];
2268
2270
  }
2269
2271
  else {
2270
2272
  for (var i = 0; i < ne.files.length; i++)
@@ -2537,6 +2539,7 @@
2537
2539
  _this.tryBindSourceDisplay();
2538
2540
  // In questo caso è già filtrata dalla SearchFunction
2539
2541
  _this.FilteredBoundSource = _this.BoundSource;
2542
+ _this.removeFilteredSourceOnDescriptionSelection();
2540
2543
  _this.cdr.markForCheck();
2541
2544
  });
2542
2545
  }, 400);
@@ -2545,10 +2548,19 @@
2545
2548
  this.throttla("filtersource", function () {
2546
2549
  // In questo caso devo filtrare io in memoria
2547
2550
  _this.FilteredBoundSource = _this.BoundSource.filter(function (t) { return (_this.CaseSensitive && t.description.includes(event)) || (!_this.CaseSensitive && t.description.toLowerCase().includes(event.toLowerCase())); });
2551
+ _this.removeFilteredSourceOnDescriptionSelection();
2548
2552
  _this.cdr.markForCheck();
2549
2553
  }, 100);
2550
2554
  }
2551
2555
  };
2556
+ /** @ignore */
2557
+ FormAdaptiveComponent.prototype.removeFilteredSourceOnDescriptionSelection = function () {
2558
+ if (this.FilteredBoundSource.length == 1 && (this.FilteredBoundSource[0].description === this.Model)) {
2559
+ this.Model = this.BoundSource[0].id;
2560
+ this.EvaluatedModel = this.BoundSource[0].description;
2561
+ this.FilteredBoundSource = [];
2562
+ }
2563
+ };
2552
2564
  /** Metodo richiamato quando viene modificato il modello del campo di input */
2553
2565
  FormAdaptiveComponent.prototype.changed = function () {
2554
2566
  var toEmit = this.getModelToEmit();
@@ -3381,6 +3393,22 @@
3381
3393
  this.Model = val ? val.description : value;
3382
3394
  this.EvaluatedModel = this.Model;
3383
3395
  };
3396
+ /**
3397
+ * Quando viene scritto un nuovo valore bisogna controllare se per botta di culo fosse un id, in tal caso dev'essere rieffettuato il bind
3398
+ * per mostrare solo la descrizione nell'autocomplete
3399
+ */
3400
+ FormAutocompleteComponent.prototype.evaluateIdResearch = function () {
3401
+ var _this = this;
3402
+ if (!this.Model)
3403
+ return;
3404
+ this.SearchFunction(this.Model, true).subscribe(function (t) {
3405
+ if (t && t.length > 0) {
3406
+ _this.Source = t;
3407
+ _this.tryBindSourceDisplay();
3408
+ setTimeout(function () { _this.finalizeValue(_this.Model); });
3409
+ }
3410
+ });
3411
+ };
3384
3412
  /**
3385
3413
  * Evento di filtro della sorgente dati in base all'input utente
3386
3414
  *
@@ -3411,6 +3439,7 @@
3411
3439
  _this.tryBindSourceDisplay();
3412
3440
  // In questo caso è già filtrata dalla SearchFunction
3413
3441
  _this.FilteredBoundSource = _this.BoundSource;
3442
+ _this.removeFilteredSourceOnDescriptionSelection();
3414
3443
  _this.cdr.markForCheck();
3415
3444
  });
3416
3445
  }, 400);
@@ -3419,11 +3448,20 @@
3419
3448
  this.throttla("filtersource", function () {
3420
3449
  // In questo caso devo filtrare io in memoria
3421
3450
  _this.FilteredBoundSource = _this.BoundSource.filter(function (t) { return (_this.CaseSensitive && t.description.includes(event)) || (!_this.CaseSensitive && t.description.toLowerCase().includes(event.toLowerCase())); });
3451
+ _this.removeFilteredSourceOnDescriptionSelection();
3422
3452
  _this.cdr.markForCheck();
3423
3453
  }, 100);
3424
3454
  }
3425
3455
  };
3426
3456
  /** @ignore */
3457
+ FormAutocompleteComponent.prototype.removeFilteredSourceOnDescriptionSelection = function () {
3458
+ if (this.FilteredBoundSource.length == 1 && (this.FilteredBoundSource[0].description === this.Model)) {
3459
+ this.Model = this.BoundSource[0].id;
3460
+ this.EvaluatedModel = this.BoundSource[0].description;
3461
+ this.FilteredBoundSource = [];
3462
+ }
3463
+ };
3464
+ /** @ignore */
3427
3465
  FormAutocompleteComponent.prototype.ngOnChanges = function (changes) {
3428
3466
  var _a;
3429
3467
  var newSource = changes["Source"];
@@ -3460,7 +3498,7 @@
3460
3498
  FormAutocompleteComponent.decorators = [
3461
3499
  { type: core.Component, args: [{
3462
3500
  selector: "form-autocomplete",
3463
- 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 [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>",
3501
+ 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>",
3464
3502
  providers: [{ provide: localizations.LocalizationService, useClass: FormAutocompleteComponentLoc }],
3465
3503
  changeDetection: core.ChangeDetectionStrategy.OnPush
3466
3504
  },] }