@esfaenza/forms-and-validations 12.2.28 → 13.1.3

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.
Files changed (118) hide show
  1. package/esfaenza-forms-and-validations.d.ts +1 -12
  2. package/esm2020/esfaenza-forms-and-validations.mjs +5 -0
  3. package/esm2020/lib/forms/base-form-control.mjs +482 -0
  4. package/esm2020/lib/forms/form-adaptive/form-adaptive.component.loc.mjs +28 -0
  5. package/esm2020/lib/forms/form-adaptive/form-adaptive.component.mjs +294 -0
  6. package/esm2020/lib/forms/form-autocomplete/form-autocomplete.component.loc.mjs +26 -0
  7. package/esm2020/lib/forms/form-autocomplete/form-autocomplete.component.mjs +200 -0
  8. package/esm2020/lib/forms/form-checkbox/form-checkbox.component.mjs +52 -0
  9. package/esm2020/lib/forms/form-date/form-date.component.mjs +59 -0
  10. package/esm2020/lib/forms/form-datetime/form-datetime.component.mjs +59 -0
  11. package/esm2020/lib/forms/form-empty/form-empty.component.mjs +36 -0
  12. package/esm2020/lib/forms/form-error/form-error.component.mjs +52 -0
  13. package/esm2020/lib/forms/form-file/form-file.component.loc.mjs +28 -0
  14. package/esm2020/lib/forms/form-file/form-file.component.mjs +119 -0
  15. package/esm2020/lib/forms/form-info/form-info.component.mjs +52 -0
  16. package/esm2020/lib/forms/form-input/form-input.component.mjs +93 -0
  17. package/esm2020/lib/forms/form-multiselect/form-multiselect.component.loc.mjs +29 -0
  18. package/esm2020/lib/forms/form-multiselect/form-multiselect.component.mjs +159 -0
  19. package/esm2020/lib/forms/form-select/form-select.component.loc.mjs +26 -0
  20. package/esm2020/lib/forms/form-select/form-select.component.mjs +129 -0
  21. package/esm2020/lib/forms/form-template/form-template.component.mjs +71 -0
  22. package/esm2020/lib/forms/form-textarea/form-textarea.component.mjs +54 -0
  23. package/esm2020/lib/forms/form-time/form-time.component.mjs +131 -0
  24. package/esm2020/lib/forms-and-validations.module.mjs +203 -0
  25. package/{esm2015/lib/models/AppFile.js → esm2020/lib/models/AppFile.mjs} +0 -0
  26. package/{esm2015/lib/models/FormsAndValidationsModuleConfig.js → esm2020/lib/models/FormsAndValidationsModuleConfig.mjs} +0 -0
  27. package/esm2020/lib/models/dayjs-adapter/dayjs-date-adapter.mjs +89 -0
  28. package/{esm2015/lib/tokens.js → esm2020/lib/tokens.mjs} +0 -0
  29. package/esm2020/lib/validations/base-validation.loc.mjs +28 -0
  30. package/esm2020/lib/validations/base-validation.mjs +232 -0
  31. package/esm2020/lib/validations/customValidators/CustomRequiredDirective.mjs +41 -0
  32. package/esm2020/lib/validations/validation-autocomplete/validation-autocomplete.component.mjs +168 -0
  33. package/esm2020/lib/validations/validation-currency/validation-currency.component.mjs +61 -0
  34. package/esm2020/lib/validations/validation-date/validation-date.component.mjs +177 -0
  35. package/esm2020/lib/validations/validation-datetime/validation-datetime.component.mjs +206 -0
  36. package/esm2020/lib/validations/validation-input/validation-input.component.mjs +207 -0
  37. package/esm2020/lib/validations/validation-select/validation-select.component.mjs +184 -0
  38. package/esm2020/lib/validations/validation-text-area/validation-text-area.component.mjs +64 -0
  39. package/esm2020/public-api.mjs +35 -0
  40. package/fesm2015/esfaenza-forms-and-validations.mjs +3620 -0
  41. package/fesm2015/esfaenza-forms-and-validations.mjs.map +1 -0
  42. package/fesm2020/esfaenza-forms-and-validations.mjs +3562 -0
  43. package/fesm2020/esfaenza-forms-and-validations.mjs.map +1 -0
  44. package/lib/forms/base-form-control.d.ts +3 -0
  45. package/lib/forms/form-adaptive/form-adaptive.component.d.ts +3 -0
  46. package/lib/forms/form-adaptive/form-adaptive.component.loc.d.ts +3 -0
  47. package/lib/forms/form-autocomplete/form-autocomplete.component.d.ts +3 -0
  48. package/lib/forms/form-autocomplete/form-autocomplete.component.loc.d.ts +3 -0
  49. package/lib/forms/form-checkbox/form-checkbox.component.d.ts +3 -0
  50. package/lib/forms/form-date/form-date.component.d.ts +3 -0
  51. package/lib/forms/form-datetime/form-datetime.component.d.ts +3 -0
  52. package/lib/forms/form-empty/form-empty.component.d.ts +3 -0
  53. package/lib/forms/form-error/form-error.component.d.ts +3 -0
  54. package/lib/forms/form-file/form-file.component.d.ts +3 -0
  55. package/lib/forms/form-file/form-file.component.loc.d.ts +3 -0
  56. package/lib/forms/form-info/form-info.component.d.ts +3 -0
  57. package/lib/forms/form-input/form-input.component.d.ts +3 -0
  58. package/lib/forms/form-multiselect/form-multiselect.component.d.ts +4 -0
  59. package/lib/forms/form-multiselect/form-multiselect.component.loc.d.ts +3 -0
  60. package/lib/forms/form-select/form-select.component.d.ts +3 -0
  61. package/lib/forms/form-select/form-select.component.loc.d.ts +3 -0
  62. package/lib/forms/form-template/form-template.component.d.ts +3 -0
  63. package/lib/forms/form-textarea/form-textarea.component.d.ts +3 -0
  64. package/lib/forms/form-time/form-time.component.d.ts +3 -0
  65. package/lib/forms-and-validations.module.d.ts +38 -0
  66. package/lib/models/dayjs-adapter/dayjs-date-adapter.d.ts +3 -0
  67. package/lib/validations/base-validation.d.ts +3 -0
  68. package/lib/validations/base-validation.loc.d.ts +3 -0
  69. package/lib/validations/customValidators/CustomRequiredDirective.d.ts +3 -0
  70. package/lib/validations/validation-autocomplete/validation-autocomplete.component.d.ts +3 -0
  71. package/lib/validations/validation-currency/validation-currency.component.d.ts +3 -0
  72. package/lib/validations/validation-date/validation-date.component.d.ts +3 -0
  73. package/lib/validations/validation-datetime/validation-datetime.component.d.ts +3 -0
  74. package/lib/validations/validation-input/validation-input.component.d.ts +3 -0
  75. package/lib/validations/validation-select/validation-select.component.d.ts +3 -0
  76. package/lib/validations/validation-text-area/validation-text-area.component.d.ts +3 -0
  77. package/package.json +31 -19
  78. package/public-api.d.ts +2 -0
  79. package/bundles/esfaenza-forms-and-validations.umd.js +0 -3753
  80. package/bundles/esfaenza-forms-and-validations.umd.js.map +0 -1
  81. package/esfaenza-forms-and-validations.metadata.json +0 -1
  82. package/esm2015/esfaenza-forms-and-validations.js +0 -17
  83. package/esm2015/lib/forms/base-form-control.js +0 -460
  84. package/esm2015/lib/forms/form-adaptive/form-adaptive.component.js +0 -277
  85. package/esm2015/lib/forms/form-adaptive/form-adaptive.component.loc.js +0 -23
  86. package/esm2015/lib/forms/form-autocomplete/form-autocomplete.component.js +0 -187
  87. package/esm2015/lib/forms/form-autocomplete/form-autocomplete.component.loc.js +0 -21
  88. package/esm2015/lib/forms/form-checkbox/form-checkbox.component.js +0 -41
  89. package/esm2015/lib/forms/form-date/form-date.component.js +0 -49
  90. package/esm2015/lib/forms/form-datetime/form-datetime.component.js +0 -49
  91. package/esm2015/lib/forms/form-empty/form-empty.component.js +0 -34
  92. package/esm2015/lib/forms/form-error/form-error.component.js +0 -49
  93. package/esm2015/lib/forms/form-file/form-file.component.js +0 -109
  94. package/esm2015/lib/forms/form-file/form-file.component.loc.js +0 -23
  95. package/esm2015/lib/forms/form-info/form-info.component.js +0 -49
  96. package/esm2015/lib/forms/form-input/form-input.component.js +0 -76
  97. package/esm2015/lib/forms/form-multiselect/form-multiselect.component.js +0 -153
  98. package/esm2015/lib/forms/form-multiselect/form-multiselect.component.loc.js +0 -24
  99. package/esm2015/lib/forms/form-select/form-select.component.js +0 -114
  100. package/esm2015/lib/forms/form-select/form-select.component.loc.js +0 -21
  101. package/esm2015/lib/forms/form-template/form-template.component.js +0 -64
  102. package/esm2015/lib/forms/form-textarea/form-textarea.component.js +0 -44
  103. package/esm2015/lib/forms/form-time/form-time.component.js +0 -117
  104. package/esm2015/lib/forms-and-validations.module.js +0 -144
  105. package/esm2015/lib/models/dayjs-adapter/dayjs-date-adapter.js +0 -86
  106. package/esm2015/lib/validations/base-validation.js +0 -208
  107. package/esm2015/lib/validations/base-validation.loc.js +0 -23
  108. package/esm2015/lib/validations/customValidators/CustomRequiredDirective.js +0 -35
  109. package/esm2015/lib/validations/validation-autocomplete/validation-autocomplete.component.js +0 -151
  110. package/esm2015/lib/validations/validation-currency/validation-currency.component.js +0 -48
  111. package/esm2015/lib/validations/validation-date/validation-date.component.js +0 -165
  112. package/esm2015/lib/validations/validation-datetime/validation-datetime.component.js +0 -193
  113. package/esm2015/lib/validations/validation-input/validation-input.component.js +0 -186
  114. package/esm2015/lib/validations/validation-select/validation-select.component.js +0 -166
  115. package/esm2015/lib/validations/validation-text-area/validation-text-area.component.js +0 -52
  116. package/esm2015/public-api.js +0 -32
  117. package/fesm2015/esfaenza-forms-and-validations.js +0 -3261
  118. package/fesm2015/esfaenza-forms-and-validations.js.map +0 -1
@@ -1,3261 +0,0 @@
1
- import { InjectionToken, Directive, Input, Injectable, Inject, EventEmitter, ViewChild, Output, Optional, Component, ViewEncapsulation, ChangeDetectionStrategy, forwardRef, Injector, ChangeDetectorRef, ContentChild, Self, Host, NgModule } from '@angular/core';
2
- import { CommonModule } from '@angular/common';
3
- import { NG_VALIDATORS, RequiredValidator, NgControl, NG_VALUE_ACCESSOR, NG_ASYNC_VALIDATORS, FormsModule } from '@angular/forms';
4
- import { MatDatepickerModule } from '@angular/material/datepicker';
5
- import { MatAutocompleteModule } from '@angular/material/autocomplete';
6
- import { MatInputModule } from '@angular/material/input';
7
- import { MAT_DATE_LOCALE, MAT_DATE_FORMATS } from '@angular/material/core';
8
- import { LocalizationService, LocalizationModule } from '@esfaenza/localizations';
9
- import { DayJsDateAdapter, MatDayjsDateModule } from '@esfaenza/material-dayjs-adapter';
10
- import { CurrencyMaskModule } from '@esfaenza/ngx-currency-mask';
11
- import { AngularMultiSelectModule } from 'angular2-multiselect-dropdown';
12
- import { NgxMatDateAdapter, NgxMatDatetimePickerModule, NgxMatTimepickerModule, NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker';
13
- import { TooltipDirective, TooltipModule } from 'ngx-bootstrap/tooltip';
14
- import { DateService, UtilityService } from '@esfaenza/extensions';
15
- import { AccessControlService, ComponentContext } from '@esfaenza/access-control';
16
- import { __awaiter } from 'tslib';
17
-
18
- /**
19
- * Classe che identifica un file
20
- */
21
- class AppFile {
22
- /**
23
- * @ignore
24
- */
25
- constructor() {
26
- this.filename = "";
27
- this.fileb64 = "";
28
- this.nativefiles = [];
29
- }
30
- }
31
-
32
- /**
33
- * Classe di configurazione del modulo
34
- */
35
- class FormsAndValidationsModuleConfig {
36
- }
37
-
38
- /**
39
- * Token che indica la lingua da utilizzare, sono supportate "it-IT" ed "en-US"
40
- */
41
- const FAV_LOCALE = new InjectionToken('FAV_LOCALE');
42
- /**
43
- * Chiave che indica il prefisso dei Contesti Applicativi per permettere l'abilitazione/disabilitazione di input in maniera contestuale
44
- */
45
- const ACO_CUSTOMKEY = new InjectionToken('ACO_CUSTOMKEY');
46
-
47
- // Angular
48
- /**
49
- * Direttiva utilizzata per validazioni "required" custom, in modo da poter dire che anche se c'è un valore selezionato, ma quel valore lo considero null
50
- * allora la validazione fallisce. Attualmente usato nell'unico punto sensato: validation-select
51
- */
52
- class CustomRequiredDirective {
53
- constructor() {
54
- /**
55
- * Lista di valori che vengono considerati "vuoti" seppur presenti
56
- */
57
- this.NullValues = [];
58
- }
59
- /**
60
- * @ignore
61
- */
62
- validate(c) {
63
- // Controllo solo per custom required a true, altrimenti qualsiasi valore mi va bene
64
- if (this.customRequired != "true")
65
- return null;
66
- return !c.value || this.NullValues.includes(c.value) ? { required: true } : null;
67
- }
68
- }
69
- CustomRequiredDirective.decorators = [
70
- { type: Directive, args: [{
71
- selector: '[customRequired]',
72
- providers: [{ provide: NG_VALIDATORS, useExisting: CustomRequiredDirective, multi: true }]
73
- },] }
74
- ];
75
- CustomRequiredDirective.propDecorators = {
76
- NullValues: [{ type: Input, args: ["CustomNullValues",] }],
77
- customRequired: [{ type: Input, args: ['customRequired',] }]
78
- };
79
-
80
- //Angular
81
- /**
82
- * Espansione dell'adapter di default di DayJs già utilizzato per i bind base su Material.
83
- *
84
- * Questa versione serve unicamente per i controlli **datetime-picker**, ma dato che io l'adapter già lo avevo lato **esfaenza/material-dayjs-adapter**
85
- * qui devo semplicemente aggiungere le funzioni non presenti nella mia implementazione che servono al **datetime-picker**
86
- */
87
- class NgxExpandedDayJsDateAdapter extends DayJsDateAdapter {
88
- /**
89
- * @ignore
90
- */
91
- constructor(dateLocale) {
92
- super(dateLocale);
93
- }
94
- // Espando il mio DayJsDateAdapter con i metodi extra del NgxMatDateAdapter che servono per il material timepicker
95
- // Non potendo fare "extends" da due classi mi tocca tenerlo così senza type safety....
96
- /**
97
- * Identifica se due date hanno lo stesso orario
98
- *
99
- * @param {DayJs} a Primo elemento del controllo
100
- * @param {DayJs} b Secondo elemento del controllo
101
- * @returns **true** se hanno lo stess orario, **false** altrimenti
102
- */
103
- isSameTime(a, b) {
104
- if (a == null || b == null)
105
- return true;
106
- return this.getHour(a) === this.getHour(b)
107
- && this.getMinute(a) === this.getMinute(b)
108
- && this.getSecond(a) === this.getSecond(b);
109
- }
110
- /**
111
- * Copia dell'orario da una data all'altra, Modifica direttamente l'oggetto **toDate**
112
- *
113
- * @param {DayJs} toDate Data in cui copiare l'orario
114
- * @param {DayJs} fromDate Data da cui copiare l'orario
115
- */
116
- copyTime(toDate, fromDate) {
117
- this.setHour(toDate, this.getHour(fromDate));
118
- this.setMinute(toDate, this.getMinute(fromDate));
119
- this.setSecond(toDate, this.getSecond(fromDate));
120
- }
121
- /**
122
- * Mette a confronto due date
123
- * @param {Dayjs} first Prima data da confrontare
124
- * @param {Dayjs} second Seconda data da confrontare
125
- * @param {boolean} showSeconds Indica se considerare anche i secondi, di default no
126
- * @returns {number} 0 se le due date sono uguali, un numero minore di 0 se la prima data è precedente alla seconda e un numero maggiore di 0 altrimenti
127
- */
128
- compareDateWithTime(first, second, showSeconds) {
129
- let res = super.compareDate(first, second) ||
130
- this.getHour(first) - this.getHour(second) ||
131
- this.getMinute(first) - this.getMinute(second);
132
- if (showSeconds)
133
- res = res || this.getSecond(first) - this.getSecond(second);
134
- return res;
135
- }
136
- /**
137
- * Assegna a una data i valori di ore, minuti e secondi di default.
138
- *
139
- * Se non specificati vengono assegnati degli '0'
140
- *
141
- * @param {DayJs} date Data a cui assegnare i valori di default
142
- * @param {number[]} defaultTime Valori di default per ore, minuti e secondi, considerati 0 se non presenti
143
- */
144
- setTimeByDefaultValues(date, defaultTime) {
145
- if (!Array.isArray(defaultTime)) {
146
- throw Error('@Input DefaultTime should be an array');
147
- }
148
- this.setHour(date, defaultTime[0] || 0);
149
- this.setMinute(date, defaultTime[1] || 0);
150
- this.setSecond(date, defaultTime[2] || 0);
151
- }
152
- }
153
- NgxExpandedDayJsDateAdapter.decorators = [
154
- { type: Injectable }
155
- ];
156
- NgxExpandedDayJsDateAdapter.ctorParameters = () => [
157
- { type: String, decorators: [{ type: Inject, args: [MAT_DATE_LOCALE,] }] }
158
- ];
159
-
160
- // Angular
161
- /**
162
- * Classe astratta base che contiene le logiche / proprietà in comune a tutti i validatori
163
- *
164
- * Nota bene: I tooltip rallentano tantissimo la pagina perché il tizio che ha fatto ngx bootstrap non è capace
165
- */
166
- class BaseValidation {
167
- constructor() {
168
- /**
169
- * Variabile per tenere in memoria il fatto che il componente è forzato a invalido o no
170
- */
171
- this._forceInvalid = false;
172
- /**
173
- * Indica se il valore è obbligatorio o opzionale
174
- */
175
- this.required = false;
176
- /**
177
- * Indica se di default deve valutare il messaggio di errore in base al validatore che fallisce.
178
- *
179
- * Se fallisce il required validator scriverà che l'input è obbligatorio, se invece fallisce
180
- * un eventuale pattern validator scriverà che il formato dell'input è invalido
181
- */
182
- this.InferErrorMessages = true;
183
- /**
184
- * Messaggio da mostrare se la validazione fallisce.
185
- *
186
- * Se questo è valorizzato, il messaggio non viene valutato in automatico nonstante **InferErrorMessages** sia **true**
187
- */
188
- this.validationFailed = "";
189
- /**
190
- * Indica se il componente è in sola lettura
191
- */
192
- this.readonly = false;
193
- /**
194
- * Indica le dimensioni del componente
195
- */
196
- this.widthPx = null;
197
- /**
198
- * Indica se il componente è disabilitato o no (più o meno stesso concetto del readonly)
199
- */
200
- this.disabled = false;
201
- /**
202
- * Eventuale placeholder da mostrare al posto del valore quando il valore è nullo / vuoto
203
- */
204
- this.placeholder = "";
205
- /**
206
- * Classi da applicare al componente
207
- */
208
- this.class = "";
209
- /**
210
- * Stili da applicare al componente
211
- */
212
- this.style = "";
213
- /**
214
- * Pattern di validazione dell'input
215
- */
216
- this.pattern = "";
217
- /**
218
- * Indica di non validare il componente
219
- */
220
- this.noValidate = false;
221
- /**
222
- * Indica se abilitare o meno l'autocompletamento di default del browser
223
- */
224
- this.autocomplete = "off";
225
- /**
226
- * Evento che sostituisce l'ngModelChange facendolo funzionare in maniera un po' più consistente
227
- */
228
- this.inputChange = new EventEmitter();
229
- /**
230
- * @ignore
231
- */
232
- this.propagateChange = (_) => { };
233
- }
234
- /**
235
- * Query che raccoglie il tooltip in maniera dinamica (ad ogni change detection)
236
- *
237
- * @param {TooltipDirective} comp Elemento HTML a cui è applicata la direttiva del tooltip
238
- */
239
- set tooltip_static(comp) {
240
- if (comp) {
241
- this.tooltip = comp;
242
- }
243
- }
244
- ;
245
- /**
246
- * Query che raccoglie l'input o direttiva che contiene il valore in maniera dinamica (ad ogni change detection)
247
- *
248
- * @param {NgModel} comp Elemento HTML associato al ngModel del componente
249
- */
250
- set baseInput_static(comp) {
251
- if (comp) {
252
- this.baseInput = comp;
253
- }
254
- }
255
- ;
256
- /**
257
- * Imposta il componente come "submitted" scatenandone le validazioni ed eventualmente la visualizzazione del tooltip di errore
258
- *
259
- * @param {boolean} val **true** se si vuole impostare questo controllo come submitted, **false** altrimenti
260
- */
261
- set submitted(val) {
262
- this._submitted = val;
263
- if (!this.baseInput)
264
- return;
265
- if (val)
266
- this.baseInput.control.markAsTouched();
267
- if (this.baseInput.control.status === "INVALID" && val)
268
- this.showTooltipWithMessage();
269
- else
270
- this.tooltip.hide();
271
- }
272
- /**
273
- * Imposta il componente come "invalid" a prescindere dai validatori
274
- */
275
- set forceInvalid(val) {
276
- this._forceInvalid = val;
277
- if (val)
278
- setTimeout(() => this.baseInput.control.setErrors({ forcedtoinvalid: true }));
279
- else
280
- setTimeout(() => {
281
- this.baseInput.control.setErrors({ forcedtoinvalid: null });
282
- this.baseInput.control.updateValueAndValidity();
283
- });
284
- }
285
- /**
286
- * Helper che controlla se il tooltip deve essere mostrato o meno,
287
- * richiamato direttamente dall'HTML dei componenti
288
- */
289
- checkTooltip() {
290
- if ((this.baseInput.invalid && this.baseInput.touched))
291
- this.showTooltipWithMessage();
292
- }
293
- /**
294
- * Helper che calcola il messaggio da mostrare nel tooltip che andrà ad aprire
295
- */
296
- showTooltipWithMessage() {
297
- this.validationFailed = this.validationFailed ? this.validationFailed : this.InferErrorMessages ? this.inferMessage() : "";
298
- if (this.validationFailed)
299
- this.tooltip.show();
300
- }
301
- /**
302
- * Calcola il messaggio da mostrare in base al valore.
303
- *
304
- * Entrare in questa funzione significa che lo stato di validazione è fallito, per questo si comporta semplicemente in maniera esclusiva, e cioè:
305
- *
306
- * 1) Se ero required e sono senza valore --> Input richiesto
307
- *
308
- * 2) Altrimenti se ho un valore --> Di sicuro il formato è errato
309
- */
310
- inferMessage() {
311
- if (this.required && !this.baseInput.value)
312
- return this.lc.loc("Required Input");
313
- if (this.baseInput.value)
314
- return this.lc.loc("Invalid Input Format");
315
- }
316
- /**
317
- * Forza la chiusura del tooltip
318
- */
319
- closeTooltip() {
320
- this.tooltip.hide();
321
- }
322
- /**
323
- * Controlla se il controllo è valido e in caso lo sia chiude il tooltip
324
- */
325
- CheckValidity() {
326
- if (!this.baseInput.statusChanges)
327
- return;
328
- this.baseInput.statusChanges.subscribe(event => {
329
- if (event === "VALID")
330
- this.tooltip.hide();
331
- });
332
- }
333
- /**
334
- * @ignore
335
- */
336
- setDisabledState(isDisabled) {
337
- isDisabled ? this.baseInput.control.disable() : this.baseInput.control.enable();
338
- this.readonly = isDisabled;
339
- }
340
- }
341
- BaseValidation.decorators = [
342
- { type: Directive }
343
- ];
344
- BaseValidation.propDecorators = {
345
- tooltip: [{ type: ViewChild, args: [TooltipDirective, { static: false },] }],
346
- tooltip_static: [{ type: ViewChild, args: [TooltipDirective, { static: true },] }],
347
- baseInput: [{ type: ViewChild, args: ["baseInput", { static: false },] }],
348
- baseInput_static: [{ type: ViewChild, args: ["baseInput", { static: true },] }],
349
- InferErrorMessages: [{ type: Input }],
350
- validationFailed: [{ type: Input }],
351
- readonly: [{ type: Input }],
352
- widthPx: [{ type: Input }],
353
- disabled: [{ type: Input }],
354
- placeholder: [{ type: Input }],
355
- class: [{ type: Input }],
356
- style: [{ type: Input }],
357
- pattern: [{ type: Input }],
358
- noValidate: [{ type: Input }],
359
- autocomplete: [{ type: Input }],
360
- inputChange: [{ type: Output }],
361
- submitted: [{ type: Input, args: ["submitted",] }],
362
- forceInvalid: [{ type: Input }]
363
- };
364
-
365
- /**
366
- * Classe di localizzazione in comune con tutti i Componenti di validazione
367
- */
368
- class BaseValidationLoc extends LocalizationService {
369
- /**
370
- * @ignore
371
- */
372
- constructor(LOC_LOCALE) {
373
- super(LOC_LOCALE !== null && LOC_LOCALE !== void 0 ? LOC_LOCALE : 'it-IT');
374
- super.set("en->it", "Required Input", ["Input Richiesto"]);
375
- super.set("en->it", "Invalid Input Format", ["Formato Input Invalido"]);
376
- }
377
- }
378
- BaseValidationLoc.decorators = [
379
- { type: Injectable }
380
- ];
381
- BaseValidationLoc.ctorParameters = () => [
382
- { type: String, decorators: [{ type: Optional }, { type: Inject, args: [FAV_LOCALE,] }] }
383
- ];
384
-
385
- // Angular
386
- /**
387
- * Componente di validaizone per gli input a selezione singola
388
- */
389
- class ValidationSelectComponent extends BaseValidation {
390
- /**
391
- * @ignore
392
- */
393
- constructor(_validators, _asyncValidators, injector, cdr, lc) {
394
- super();
395
- this._validators = _validators;
396
- this._asyncValidators = _asyncValidators;
397
- this.injector = injector;
398
- this.cdr = cdr;
399
- this.lc = lc;
400
- /**
401
- * valore del campo vuoto della select
402
- */
403
- this.emptyFieldValue = "-2";
404
- /**
405
- * Valore del placeholder
406
- */
407
- this.placeHolderValue = "-1";
408
- /**
409
- * Per i componenti non obbligatori indica se fornire un "valore vuoto"
410
- */
411
- this.emptyValue = true;
412
- /**
413
- * Indica se mostrare o nascondere il simboletto di validazione (Tic verde o Croce rossa)
414
- */
415
- this.showValidationSymbol = true;
416
- /**
417
- * Contenuto della label Floattante Material-Style
418
- */
419
- this.label = "";
420
- /**
421
- * Evento richiamato quando si perde il focus sull'input di inserimento
422
- */
423
- this.onBlur = new EventEmitter();
424
- /**
425
- * @ignore
426
- */
427
- this.onTouched = () => { }; //placeholder on touched function
428
- }
429
- /**
430
- * @ignore
431
- */
432
- ngOnInit() {
433
- //controllo se è settato un required per decidere in maniera condizionale se utilizzare il validatore required nel componente interno
434
- //Lo imposto ANCHE se sono in situazione di noValidate perché comporta eventuali modifiche grafiche che potrebbero servirmi, ma comunque non va a d aggiungere
435
- //validatori o cose strane, quindi GG
436
- if (this._validators && this._validators.some(elem => elem instanceof RequiredValidator && elem.required))
437
- this.required = true;
438
- }
439
- /**
440
- * @ignore
441
- */
442
- ngOnDestroy() {
443
- if (this.tooltipSubscription)
444
- this.tooltipSubscription.unsubscribe();
445
- }
446
- /**
447
- * @ignore
448
- */
449
- ngAfterViewInit() {
450
- this.postBinding();
451
- }
452
- /**
453
- * Metodo che si occupa di collegare i validatori e la funzione di reset dal **ControlValueAccessor** rappresentato
454
- * da questo componente al **ControlValueAccessor** rappresentato dall'effettivo elemento di Input presente lato HTML
455
- */
456
- postBinding() {
457
- // Eredito i validatori
458
- if (!this.noValidate) {
459
- this.baseInput.control.setAsyncValidators(this._asyncValidators);
460
- this.baseInput.control.setValidators(this._validators);
461
- }
462
- this.CheckValidity();
463
- const ngControl = this.injector.get(NgControl, null);
464
- if (ngControl) {
465
- this.parentControl = ngControl.control;
466
- // se la variabile novalidate è true, elimino tutti i validatori eventualmente inseriti
467
- if (this.noValidate) {
468
- this.parentControl.clearValidators();
469
- this.parentControl.clearAsyncValidators();
470
- }
471
- // faccio in modo che se chiamo il reset del controllo (o della form) dall'esterno si resetti anche il controllo nativo
472
- const origFunc = this.parentControl.reset;
473
- this.parentControl.reset = () => {
474
- origFunc.apply(this.parentControl);
475
- this.baseInput.control.reset();
476
- this.tooltip.hide();
477
- };
478
- }
479
- }
480
- /**
481
- * @ignore
482
- */
483
- writeValue(value) {
484
- this.value = value;
485
- this.propagateChange(value);
486
- this.cdr.markForCheck();
487
- }
488
- /**
489
- * L'emit della modifica al valore viene gestito su un evento custom (**inputChange**) come workaround al malfunzionamento dell'**ngModelChange** nativo
490
- *
491
- * @param {any} toEmit valore da propagare all'esterno
492
- */
493
- onModelChange(toEmit) {
494
- this.writeValue(toEmit);
495
- this.inputChange.emit(toEmit);
496
- this.onTouched();
497
- }
498
- /**
499
- * @ignore
500
- */
501
- registerOnChange(fn) {
502
- this.propagateChange = fn;
503
- }
504
- /**
505
- * @ignore
506
- */
507
- registerOnTouched(fn) {
508
- this.onTouched = fn;
509
- }
510
- }
511
- ValidationSelectComponent.decorators = [
512
- { type: Component, args: [{
513
- selector: "val-select",
514
- template: "<mat-form-field appearance=\"outline\" class=\"mat-full-width mat-no-border-top mat-height-fixed\" [style.width.px]=\"widthPx\">\r\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\r\n <select matNativeControl\r\n #baseInput=\"ngModel\"\r\n name=\"val-select\"\r\n class=\"form-control\"\r\n triggers=\"\"\r\n placement=\"top\"\r\n [customRequired]=\"required ? 'true' : 'false'\"\r\n [CustomNullValues]=\"[placeHolderValue,emptyFieldValue]\"\r\n [(ngModel)]=\"value\"\r\n [tooltip]=\"tolTemplate\"\r\n [class.checking-combo]=\"!noValidate\"\r\n [class.app-option-placeholder]=\"baseInput.value === placeHolderValue\"\r\n [class.no-bg-img]=\"!showValidationSymbol\"\r\n [disabled]=\"readonly\"\r\n (focus)=\"checkTooltip()\"\r\n (blur)=\"closeTooltip(); onBlur.emit(true);\"\r\n (ngModelChange)=\"onModelChange($event)\">\r\n\r\n <option *ngIf=\"placeholder\" [value]=\"placeHolderValue\" disabled selected hidden>{{placeholder}}</option>\r\n <option *ngIf=\"required == false && emptyValue\" [value]=\"emptyFieldValue\"></option>\r\n <ng-content></ng-content>\r\n </select>\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>",
515
- encapsulation: ViewEncapsulation.None,
516
- changeDetection: ChangeDetectionStrategy.OnPush,
517
- providers: [
518
- { provide: LocalizationService, useClass: BaseValidationLoc },
519
- {
520
- provide: NG_VALUE_ACCESSOR,
521
- useExisting: forwardRef(() => ValidationSelectComponent),
522
- multi: true
523
- }
524
- ],
525
- styles: [".tooltip-inner{background-color:#842a30;color:#fff;font-size:12px;width:max-content}.tooltip{margin:auto auto auto 20%!important}.tooltip-inner{background-color:#842a30!important;color:#fff}.tooltip.top .tooltip-arrow:before,.tooltip.top .tooltip-arrow{border-top-color:#842a30}.close-button{position:absolute;right:0em;top:-.2em;float:right;font-size:16px;font-weight:bold;color:inherit;text-shadow:0 1px 0 #fff;opacity:.5}.close-button:hover,.close-button:focus{text-decoration:none;cursor:pointer;opacity:.75}\n"]
526
- },] }
527
- ];
528
- ValidationSelectComponent.ctorParameters = () => [
529
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_VALIDATORS,] }] },
530
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_ASYNC_VALIDATORS,] }] },
531
- { type: Injector },
532
- { type: ChangeDetectorRef },
533
- { type: LocalizationService }
534
- ];
535
- ValidationSelectComponent.propDecorators = {
536
- emptyFieldValue: [{ type: Input }],
537
- placeHolderValue: [{ type: Input }],
538
- emptyValue: [{ type: Input }],
539
- showValidationSymbol: [{ type: Input }],
540
- label: [{ type: Input }],
541
- onBlur: [{ type: Output }]
542
- };
543
-
544
- // Angular
545
- /**
546
- * Componente di validaizone per gli input di tipo data
547
- */
548
- class ValidationDateComponent extends BaseValidation {
549
- /**
550
- * @ignore
551
- */
552
- constructor(cdr, _validators, _asyncValidators, injector, lc, dateExts) {
553
- super();
554
- this.cdr = cdr;
555
- this._validators = _validators;
556
- this._asyncValidators = _asyncValidators;
557
- this.injector = injector;
558
- this.lc = lc;
559
- this.dateExts = dateExts;
560
- /**
561
- * Utilizza il Date di Javascript come modello in uscita. Il modello in entrata verrà comunque ricondotto a un DayJs
562
- */
563
- this.useJsDates = false;
564
- /**
565
- * @ignore
566
- */
567
- this.onTouched = () => { };
568
- }
569
- /**
570
- * @ignore
571
- */
572
- ngOnInit() {
573
- //controllo se è settato un required per decidere in maniera condizionale se utilizzare il validatore required nel componente interno
574
- if (this._validators && !this.noValidate && this._validators.some(elem => elem instanceof RequiredValidator))
575
- this.required = true;
576
- this._format = this.lc.token("getSmallDateDisplayFormat");
577
- }
578
- /**
579
- * @ignore
580
- */
581
- ngAfterViewInit() {
582
- this.postBinding();
583
- }
584
- /**
585
- * Metodo che si occupa di collegare i validatori e la funzione di reset dal **ControlValueAccessor** rappresentato
586
- * da questo componente al **ControlValueAccessor** rappresentato dall'effettivo elemento di Input presente lato HTML
587
- */
588
- postBinding() {
589
- this.CheckValidity();
590
- const ngControl = this.injector.get(NgControl, null);
591
- if (ngControl) {
592
- this.parentControl = ngControl.control;
593
- if (this.noValidate) {
594
- this.parentControl.clearValidators();
595
- this.parentControl.clearAsyncValidators();
596
- }
597
- else {
598
- this.baseInput.control.setAsyncValidators(this._asyncValidators);
599
- this.baseInput.control.setValidators(this._validators);
600
- }
601
- // //faccio in modo che se chiamo il reset del controllo (o della form) dall'esterno si resetti anche il controllo nativo
602
- //faccio in modo che se chiamo il reset del controllo (o della form) dall'esterno si resetti anche il controllo nativo
603
- const origFunc = this.parentControl.reset;
604
- this.parentControl.reset = () => {
605
- origFunc.apply(this.parentControl);
606
- this.baseInput.control.reset();
607
- this.tooltip.hide();
608
- };
609
- }
610
- }
611
- /**
612
- * @ignore
613
- */
614
- writeValue(value) {
615
- if (!value) {
616
- this.value = null;
617
- if (this.baseInput)
618
- this.baseInput.reset();
619
- }
620
- else {
621
- var date = null;
622
- if (this.useJsDates) {
623
- date = this.dateExts.getDateConvertion(value);
624
- if (date) {
625
- this.propagateChange(date.toDate());
626
- this.inputChange.emit(date.toDate());
627
- }
628
- }
629
- else
630
- date = dayjs(value, this.lc.token("getSmallDateFormat"));
631
- this.value = date;
632
- }
633
- this.cdr.markForCheck();
634
- }
635
- /**
636
- * Metodo che si occupa di, eventualmente, aggiustare il valore da propagare ed emetterlo
637
- *
638
- * L'emit della modifica al valore viene gestito su un evento custom (**inputChange**) come workaround al malfunzionamento dell'**ngModelChange** nativo
639
- *
640
- * @param {any} toEmit valore da propagare all'esterno
641
- */
642
- outputValue(toEmit) {
643
- let value = toEmit.value;
644
- let propagateValue;
645
- if (!value)
646
- propagateValue = null;
647
- else if (!this.useJsDates)
648
- propagateValue = value.format(this.lc.token("getSmallDateFormat"));
649
- else {
650
- if (value && value.isValid())
651
- propagateValue = value.hour(0).minute(0).second(0).toDate();
652
- else
653
- propagateValue = null;
654
- }
655
- this.propagateChange(propagateValue);
656
- this.inputChange.emit(propagateValue);
657
- this.onTouched();
658
- }
659
- /**
660
- * @ignore
661
- */
662
- registerOnChange(fn) {
663
- this.propagateChange = fn;
664
- }
665
- /**
666
- * @ignore
667
- */
668
- registerOnTouched(fn) {
669
- this.onTouched = fn;
670
- }
671
- }
672
- ValidationDateComponent.decorators = [
673
- { type: Component, args: [{
674
- selector: "val-date",
675
- template: "<mat-form-field appearance=\"outline\" class=\"mat-full-width mat-no-border-top mat-height-fixed\" [style.width.px]=\"widthPx\">\r\n <mat-label *ngIf=\"placeholder\">{{placeholder}}</mat-label>\r\n <input matInput\r\n [matDatepicker]=\"datepicker\"\r\n #baseInput=\"ngModel\"\r\n type=\"text\"\r\n triggers=\"\"\r\n placement=\"top\"\r\n name=\"val-date\"\r\n class=\"form-control {{class}}\"\r\n autocomplete=\"{{autocomplete}}\"\r\n [(ngModel)]=\"value\"\r\n [class.checking-field]=\"!noValidate\"\r\n [tooltip]=\"tolTemplate\"\r\n [placeholder]=\"placeholder ? '' : _format\"\r\n [disabled]=\"readonly || disabled\"\r\n [isDisabled]=\"readonly || disabled\"\r\n (dateChange)=\"outputValue($event)\" />\r\n <mat-datepicker-toggle matSuffix [for]=\"datepicker\"></mat-datepicker-toggle>\r\n <mat-datepicker #datepicker></mat-datepicker>\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>",
676
- encapsulation: ViewEncapsulation.None,
677
- changeDetection: ChangeDetectionStrategy.OnPush,
678
- providers: [
679
- { provide: LocalizationService, useClass: BaseValidationLoc },
680
- {
681
- provide: NG_VALUE_ACCESSOR,
682
- useExisting: forwardRef(() => ValidationDateComponent),
683
- multi: true
684
- }
685
- ],
686
- styles: [".tooltip-inner{background-color:#842a30;color:#fff;font-size:12px;width:max-content}.tooltip{margin:auto auto auto 20%!important}.tooltip-inner{background-color:#842a30!important;color:#fff}.tooltip.top .tooltip-arrow:before,.tooltip.top .tooltip-arrow{border-top-color:#842a30}.close-button{position:absolute;right:0em;top:-.2em;float:right;font-size:16px;font-weight:bold;color:inherit;text-shadow:0 1px 0 #fff;opacity:.5}.close-button:hover,.close-button:focus{text-decoration:none;cursor:pointer;opacity:.75}\n"]
687
- },] }
688
- ];
689
- ValidationDateComponent.ctorParameters = () => [
690
- { type: ChangeDetectorRef },
691
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_VALIDATORS,] }] },
692
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_ASYNC_VALIDATORS,] }] },
693
- { type: Injector },
694
- { type: LocalizationService },
695
- { type: DateService }
696
- ];
697
- ValidationDateComponent.propDecorators = {
698
- useJsDates: [{ type: Input }]
699
- };
700
-
701
- // Angular
702
- /**
703
- * Componente di validaizone per gli input a semplice casella di testo
704
- */
705
- class ValidationInputComponent extends BaseValidation {
706
- /**
707
- * @ignore
708
- */
709
- constructor(cdr, _validators, _asyncValidators, injector, lc) {
710
- super();
711
- this.cdr = cdr;
712
- this._validators = _validators;
713
- this._asyncValidators = _asyncValidators;
714
- this.injector = injector;
715
- this.lc = lc;
716
- /**
717
- * Indica se questo Comopnente deve rappresentare un oggetto di Input di tipo "Password"
718
- */
719
- this.Password = false;
720
- /**
721
- * Indica se deve mostrare un indicazione di warning nel suffisso
722
- */
723
- this.showWarning = false;
724
- /**
725
- * Classe del warning eventualmente modificabile.
726
- *
727
- * Default: "fa fa-warning"
728
- */
729
- this.warningClass = "fa fa-warning";
730
- /**
731
- * Identifica se il testo di un componente di tipo "password" dev'essere visualizzato o meno
732
- */
733
- this.passShown = false;
734
- /**
735
- * Tipo del componente, può essere "text" o "password" e viene impostato automaticamente dall'Input **Password**
736
- */
737
- this.type = "text";
738
- /**
739
- * Indicazione se il componente ha o meno un suffisso.
740
- *
741
- * Valorizzato a **true** solo se viene trovata una proiezione su **suffix_internal** o se l'Input **showWarning** viene impostato a **true**
742
- */
743
- this.HasSuffix = false;
744
- /**
745
- * Indicazione se il componente ha o meno un prefisso.
746
- *
747
- * Valorizzato a **true** solo se viene trovata una proiezione su **prefix_internal**
748
- */
749
- this.HasPrefix = false;
750
- /**
751
- * @ignore
752
- */
753
- this.onTouched = () => { };
754
- }
755
- /**
756
- * @ignore
757
- */
758
- ngOnInit() {
759
- //controllo se è settato un required per decidere in maniera condizionale se utilizzare il validatore required nel componente interno
760
- if (this._validators && !this.noValidate && this._validators.some(elem => elem instanceof RequiredValidator))
761
- this.required = true;
762
- if (this.Password)
763
- this.type = "password";
764
- }
765
- /**
766
- * @ignore
767
- */
768
- ngOnDestroy() {
769
- if (this.tooltipSubscription)
770
- this.tooltipSubscription.unsubscribe();
771
- }
772
- /**
773
- * @ignore
774
- */
775
- ngAfterViewInit() {
776
- this.HasSuffix = !!this.suffix_internal || this.showWarning;
777
- this.HasPrefix = !!this.prefix_internal;
778
- this.postBinding();
779
- }
780
- /**
781
- * @ignore
782
- */
783
- ngOnChanges(changes) {
784
- const newShowWarnings = changes["showWarning"];
785
- if (newShowWarnings)
786
- this.HasSuffix = !!this.suffix_internal || this.showWarning;
787
- }
788
- /**
789
- * Metodo che si occupa di collegare i validatori e la funzione di reset dal **ControlValueAccessor** rappresentato
790
- * da questo componente al **ControlValueAccessor** rappresentato dall'effettivo elemento di Input presente lato HTML
791
- */
792
- postBinding() {
793
- this.CheckValidity();
794
- const ngControl = this.injector.get(NgControl, null);
795
- if (ngControl) {
796
- this.parentControl = ngControl.control;
797
- // Se la variabile novalidate è true, elimino tutti i validatori eventualmente inseriti
798
- if (this.noValidate) {
799
- this.parentControl.clearValidators();
800
- this.parentControl.clearAsyncValidators();
801
- }
802
- else {
803
- this.baseInput.control.setAsyncValidators(this._asyncValidators);
804
- this.baseInput.control.setValidators(this._validators);
805
- }
806
- // Faccio in modo che se chiamo il reset del controllo (o della form) dall'esterno si resetti anche il controllo nativo
807
- const origFunc = this.parentControl.reset;
808
- this.parentControl.reset = () => {
809
- origFunc.apply(this.parentControl);
810
- this.baseInput.control.reset();
811
- this.tooltip.hide();
812
- };
813
- }
814
- }
815
- /**
816
- * @ignore
817
- */
818
- writeValue(value) {
819
- this.value = value;
820
- this.propagateChange(value);
821
- this.cdr.markForCheck();
822
- }
823
- /**
824
- * L'emit della modifica al valore viene gestito su un evento custom (**inputChange**) come workaround al malfunzionamento dell'**ngModelChange** nativo
825
- *
826
- * @param {any} toEmit valore da propagare all'esterno
827
- */
828
- onModelChange(toEmit) {
829
- this.writeValue(toEmit);
830
- this.inputChange.emit(toEmit);
831
- this.onTouched();
832
- }
833
- /**
834
- * @ignore
835
- */
836
- registerOnChange(fn) {
837
- this.propagateChange = fn;
838
- }
839
- /**
840
- * @ignore
841
- */
842
- registerOnTouched(fn) {
843
- this.onTouched = fn;
844
- }
845
- }
846
- ValidationInputComponent.decorators = [
847
- { type: Component, args: [{
848
- selector: "val-input",
849
- template: "<mat-form-field appearance=\"outline\" class=\"mat-full-width mat-no-border-top mat-height-fixed\" [style.width.px]=\"widthPx\">\r\n <mat-label [class.app-margin-left-25]=\"HasPrefix\" *ngIf=\"placeholder\">{{placeholder}}</mat-label>\r\n <ng-container *ngIf=\"HasPrefix\">\r\n <ng-container *ngTemplateOutlet=\"prefix_internal\"></ng-container>\r\n </ng-container>\r\n\r\n <input matInput\r\n #baseInput='ngModel'\r\n type=\"{{type}}\"\r\n triggers=\"\"\r\n placement=\"top\"\r\n autocomplete=\"{{autocomplete}}\"\r\n name=\"val-input\"\r\n class=\"form-control {{class}}\"\r\n [class.app-margin-left-25]=\"HasPrefix\"\r\n [class.mat-input-with-suffix]=\"HasSuffix || Password || showWarning\"\r\n [(ngModel)]=\"value\"\r\n [class.checking-field]=\"!noValidate && !showWarning\"\r\n [tooltip]=\"tolTemplate\"\r\n [disabled]=\"readonly || disabled\"\r\n (ngModelChange)=\"onModelChange($event)\"\r\n (focus)=\"checkTooltip();\"\r\n (blur)=\"closeTooltip();\">\r\n <ng-container *ngIf=\"HasSuffix || Password || showWarning\">\r\n <ng-container *ngIf=\"!Password && !showWarning\">\r\n <ng-container *ngTemplateOutlet=\"suffix_internal\"></ng-container>\r\n </ng-container>\r\n\r\n <span class=\"form-input-suffix\" *ngIf=\"Password || showWarning\">\r\n <ng-container *ngIf=\"Password\" matSuffix>\r\n <a *ngIf=\"passShown\" class=\"fa fa-eye-slash app-fs-16 app-pointer\" (click)=\"type = 'password'; passShown = !passShown; $event.preventDefault()\"></a>\r\n <a *ngIf=\"!passShown\" class=\"fa fa-eye app-fs-16 app-pointer\" (click)=\"type = 'text'; passShown = !passShown; $event.preventDefault()\"></a>\r\n </ng-container>\r\n <ng-container *ngIf=\"showWarning\" matSuffix>\r\n <span title=\"{{warningTitle}}\" class=\"{{warningClass}} text-warning app-fs-16\"></span>\r\n </ng-container>\r\n </span>\r\n </ng-container>\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>",
850
- changeDetection: ChangeDetectionStrategy.OnPush,
851
- providers: [
852
- { provide: LocalizationService, useClass: BaseValidationLoc },
853
- {
854
- provide: NG_VALUE_ACCESSOR,
855
- useExisting: forwardRef(() => ValidationInputComponent),
856
- multi: true
857
- }
858
- ],
859
- encapsulation: ViewEncapsulation.None,
860
- styles: [".tooltip-inner{background-color:#842a30;color:#fff;font-size:12px;width:max-content}.tooltip{margin:auto auto auto 20%!important}.tooltip-inner{background-color:#842a30!important;color:#fff}.tooltip.top .tooltip-arrow:before,.tooltip.top .tooltip-arrow{border-top-color:#842a30}.close-button{position:absolute;right:0em;top:-.2em;float:right;font-size:16px;font-weight:bold;color:inherit;text-shadow:0 1px 0 #fff;opacity:.5}.close-button:hover,.close-button:focus{text-decoration:none;cursor:pointer;opacity:.75}\n"]
861
- },] }
862
- ];
863
- ValidationInputComponent.ctorParameters = () => [
864
- { type: ChangeDetectorRef },
865
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_VALIDATORS,] }] },
866
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_ASYNC_VALIDATORS,] }] },
867
- { type: Injector },
868
- { type: LocalizationService }
869
- ];
870
- ValidationInputComponent.propDecorators = {
871
- Password: [{ type: Input }],
872
- showWarning: [{ type: Input }],
873
- warningTitle: [{ type: Input }],
874
- warningClass: [{ type: Input }],
875
- value: [{ type: Input, args: ["value",] }],
876
- suffix_internal: [{ type: ContentChild, args: ["suffix_internal", { static: false },] }],
877
- prefix_internal: [{ type: ContentChild, args: ["prefix_internal", { static: false },] }]
878
- };
879
-
880
- // Angular
881
- /**
882
- * Componente di validaizone per gli input con maschera di inserimento numerica
883
- */
884
- class ValidationCurrencyComponent extends ValidationInputComponent {
885
- /**
886
- * @ignore
887
- */
888
- constructor(cdr, validators, asyncValidators, injector, lc) {
889
- super(cdr, validators, asyncValidators, injector, lc);
890
- this.lc = lc;
891
- }
892
- }
893
- ValidationCurrencyComponent.decorators = [
894
- { type: Component, args: [{
895
- selector: "val-currency",
896
- template: "<mat-form-field appearance=\"outline\" class=\"mat-full-width mat-no-border-top mat-height-fixed\" [style.width.px]=\"widthPx\">\r\n <mat-label *ngIf=\"placeholder\">{{placeholder}}</mat-label>\r\n <input #baseInput='ngModel'\r\n currencyMask\r\n matInput\r\n [readonly]=\"readonly\"\r\n [options]='CurrencyOptions'\r\n [(ngModel)]=\"value\"\r\n name=\"val-input\"\r\n (focus)=\"checkTooltip()\"\r\n (blur)=\"closeTooltip()\"\r\n class=\"form-control {{class}}\"\r\n [class.checking-field]=\"!noValidate\"\r\n (ngModelChange)=\"onModelChange($event)\"\r\n type=\"{{type}}\"\r\n [tooltip]=\"tolTemplate\"\r\n triggers=\"\"\r\n placement=\"top\"\r\n autocomplete=\"{{autocomplete}}\" />\r\n</mat-form-field>\r\n\r\n<ng-template #tolTemplate>\r\n <div>\r\n <span class=\"close-button pull-right\" (click)=\"closeTooltip()\" aria-label=\"Close\">\r\n <span aria-hidden=\"true\">&times;</span>\r\n </span>\r\n <span>{{validationFailed}}</span>\r\n </div>\r\n</ng-template>",
897
- changeDetection: ChangeDetectionStrategy.OnPush,
898
- providers: [
899
- { provide: LocalizationService, useClass: BaseValidationLoc },
900
- {
901
- provide: NG_VALUE_ACCESSOR,
902
- useExisting: forwardRef(() => ValidationCurrencyComponent),
903
- multi: true
904
- }
905
- ],
906
- encapsulation: ViewEncapsulation.None,
907
- styles: [".tooltip-inner{background-color:#842a30;color:#fff;font-size:12px;width:max-content}.tooltip{margin:auto auto auto 20%!important}.tooltip-inner{background-color:#842a30!important;color:#fff}.tooltip.top .tooltip-arrow:before,.tooltip.top .tooltip-arrow{border-top-color:#842a30}.close-button{position:absolute;right:0em;top:-.2em;float:right;font-size:16px;font-weight:bold;color:inherit;text-shadow:0 1px 0 #fff;opacity:.5}.close-button:hover,.close-button:focus{text-decoration:none;cursor:pointer;opacity:.75}\n", "val-currency .mat-form-field-wrapper .form-control.checking-field.ng-touched{padding-right:25px;margin-left:-25px}\n"]
908
- },] }
909
- ];
910
- ValidationCurrencyComponent.ctorParameters = () => [
911
- { type: ChangeDetectorRef },
912
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_VALIDATORS,] }] },
913
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_ASYNC_VALIDATORS,] }] },
914
- { type: Injector },
915
- { type: LocalizationService }
916
- ];
917
- ValidationCurrencyComponent.propDecorators = {
918
- CurrencyOptions: [{ type: Input }]
919
- };
920
-
921
- // Angular
922
- /**
923
- * Componente di validaizone per gli input ad area di testo
924
- */
925
- class ValidationTextAreaComponent extends ValidationInputComponent {
926
- /**
927
- * @ignore
928
- */
929
- constructor(cdr, validators, asyncValidators, injector, lc) {
930
- super(cdr, validators, asyncValidators, injector, lc);
931
- this.lc = lc;
932
- /**
933
- * Righe da mostrare di default per l'area di inserimento
934
- */
935
- this.rows = 2;
936
- }
937
- }
938
- ValidationTextAreaComponent.decorators = [
939
- { type: Component, args: [{
940
- selector: "val-textarea",
941
- template: "<mat-form-field appearance=\"outline\" class=\"mat-full-width mat-full-height mat-no-border-top mat-height-auto\">\r\n <mat-label *ngIf=\"placeholder\">{{placeholder}}</mat-label>\r\n <textarea #baseInput=\"ngModel\"\r\n matInput\r\n [(ngModel)]=\"value\"\r\n name=\"val-textarea\"\r\n triggers=\"\"\r\n class=\"app-no-resize form-control {{class}}\"\r\n [class.checking-field]=\"!noValidate\"\r\n rows=\"{{rows}}\"\r\n [tooltip]=\"tolTemplate\"\r\n placement=\"top\"\r\n (focus)=\"checkTooltip()\"\r\n (blur)=\"closeTooltip()\"\r\n (ngModelChange)=\"onModelChange($event)\">\r\n </textarea>\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>",
942
- providers: [
943
- { provide: LocalizationService, useClass: BaseValidationLoc },
944
- {
945
- provide: NG_VALUE_ACCESSOR,
946
- useExisting: forwardRef(() => ValidationTextAreaComponent),
947
- multi: true
948
- }
949
- ],
950
- encapsulation: ViewEncapsulation.None,
951
- changeDetection: ChangeDetectionStrategy.OnPush,
952
- styles: [".tooltip-inner{background-color:#842a30;color:#fff;font-size:12px;width:max-content}.tooltip{margin:auto auto auto 20%!important}.tooltip-inner{background-color:#842a30!important;color:#fff}.tooltip.top .tooltip-arrow:before,.tooltip.top .tooltip-arrow{border-top-color:#842a30}.close-button{position:absolute;right:0em;top:-.2em;float:right;font-size:16px;font-weight:bold;color:inherit;text-shadow:0 1px 0 #fff;opacity:.5}.close-button:hover,.close-button:focus{text-decoration:none;cursor:pointer;opacity:.75}\n"]
953
- },] }
954
- ];
955
- ValidationTextAreaComponent.ctorParameters = () => [
956
- { type: ChangeDetectorRef },
957
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_VALIDATORS,] }] },
958
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_ASYNC_VALIDATORS,] }] },
959
- { type: Injector },
960
- { type: LocalizationService }
961
- ];
962
- ValidationTextAreaComponent.propDecorators = {
963
- rows: [{ type: Input }]
964
- };
965
-
966
- // Angular
967
- /**
968
- * Componente di validaizone per gli input di tipo data-ora
969
- */
970
- class ValidationDateTimeComponent extends BaseValidation {
971
- /**
972
- * @ignore
973
- */
974
- constructor(cdr, _validators, _asyncValidators, injector, lc, dateExts) {
975
- super();
976
- this.cdr = cdr;
977
- this._validators = _validators;
978
- this._asyncValidators = _asyncValidators;
979
- this.injector = injector;
980
- this.lc = lc;
981
- this.dateExts = dateExts;
982
- /**
983
- * Proprietà dell'elemento di selezione dell'orario. Mostra o nasconde gli spinner
984
- *
985
- * Attualemnte non bindata ed utilizzata solo a livello di default ma non si sa mai
986
- */
987
- this.showSpinners = true;
988
- /**
989
- * Proprietà dell'elemento di selezione dell'orario. Mostra o nasconde i secondi
990
- *
991
- * Attualemnte non bindata ed utilizzata solo a livello di default ma non si sa mai
992
- */
993
- this.showSeconds = true;
994
- /**
995
- * Proprietà dell'elemento di selezione dell'orario. Imposta l'incremento/decremento minimo per le ore
996
- *
997
- * Attualemnte non bindata ed utilizzata solo a livello di default ma non si sa mai
998
- */
999
- this.stepHour = 1;
1000
- /**
1001
- * Proprietà dell'elemento di selezione dell'orario. Imposta l'incremento/decremento minimo per i minuti
1002
- *
1003
- * Attualemnte non bindata ed utilizzata solo a livello di default ma non si sa mai
1004
- */
1005
- this.stepMinute = 1;
1006
- /**
1007
- * Proprietà dell'elemento di selezione dell'orario. Imposta l'incremento/decremento minimo per i secondi
1008
- *
1009
- * Attualemnte non bindata ed utilizzata solo a livello di default ma non si sa mai
1010
- */
1011
- this.stepSecond = 1;
1012
- /**
1013
- * Utilizza il Date di Javascript come modello in uscita. Il modello in entrata verrà comunque ricondotto a un DayJs
1014
- */
1015
- this.useJsDates = false;
1016
- /**
1017
- * @ignore
1018
- */
1019
- this.onTouched = () => { };
1020
- }
1021
- /**
1022
- * @ignore
1023
- */
1024
- ngOnInit() {
1025
- // Controllo se è settato un required per decidere in maniera condizionale se utilizzare il validatore required nel componente interno
1026
- if (this._validators && !this.noValidate && this._validators.some(elem => elem instanceof RequiredValidator))
1027
- this.required = true;
1028
- this._format = this.lc.token("getSmallDateDisplayFormat");
1029
- }
1030
- /**
1031
- * @ignore
1032
- */
1033
- ngAfterViewInit() {
1034
- this.postBinding();
1035
- }
1036
- /**
1037
- * Metodo che si occupa di collegare i validatori e la funzione di reset dal **ControlValueAccessor** rappresentato
1038
- * da questo componente al **ControlValueAccessor** rappresentato dall'effettivo elemento di Input presente lato HTML
1039
- */
1040
- postBinding() {
1041
- this.CheckValidity();
1042
- const ngControl = this.injector.get(NgControl, null);
1043
- if (ngControl) {
1044
- this.parentControl = ngControl.control;
1045
- // Se la variabile novalidate è true, elimino tutti i validatori eventualmente inseriti
1046
- if (this.noValidate) {
1047
- this.parentControl.clearValidators();
1048
- this.parentControl.clearAsyncValidators();
1049
- }
1050
- else {
1051
- this.baseInput.control.setAsyncValidators(this._asyncValidators);
1052
- this.baseInput.control.setValidators(this._validators);
1053
- }
1054
- // Faccio in modo che se chiamo il reset del controllo (o della form) dall'esterno si resetti anche il controllo nativo
1055
- const origFunc = this.parentControl.reset;
1056
- this.parentControl.reset = () => {
1057
- origFunc.apply(this.parentControl);
1058
- this.baseInput.control.reset();
1059
- this.tooltip.hide();
1060
- };
1061
- }
1062
- }
1063
- /**
1064
- * @ignore
1065
- */
1066
- writeValue(value) {
1067
- if (!value) {
1068
- this.value = null;
1069
- if (this.baseInput)
1070
- this.baseInput.reset();
1071
- }
1072
- else {
1073
- var date = null;
1074
- if (this.useJsDates) {
1075
- date = this.dateExts.getDateConvertion(value);
1076
- this.propagateChange(date);
1077
- this.inputChange.emit(date);
1078
- }
1079
- else
1080
- date = dayjs(value, this.lc.token("getSmallDateFormat") + " HH:mm:ss");
1081
- this.value = date;
1082
- }
1083
- this.cdr.markForCheck();
1084
- }
1085
- /**
1086
- * Metodo che si occupa di, eventualmente, aggiustare il valore da propagare ed emetterlo
1087
- *
1088
- * L'emit della modifica al valore viene gestito su un evento custom (**inputChange**) come workaround al malfunzionamento dell'**ngModelChange** nativo
1089
- *
1090
- * @param {any} toEmit valore da propagare all'esterno
1091
- */
1092
- outputValue(toEmit) {
1093
- let value = toEmit.value;
1094
- let propagateValue;
1095
- if (!value)
1096
- propagateValue = null;
1097
- else if (!this.useJsDates)
1098
- propagateValue = value.format(this.lc.token("getSmallDateFormat") + " HH:mm:ss");
1099
- else {
1100
- if (value && value.isValid())
1101
- propagateValue = value.toDate();
1102
- else
1103
- propagateValue = null;
1104
- }
1105
- this.propagateChange(propagateValue);
1106
- this.inputChange.emit(propagateValue);
1107
- this.onTouched();
1108
- }
1109
- /**
1110
- * @ignore
1111
- */
1112
- registerOnChange(fn) {
1113
- this.propagateChange = fn;
1114
- }
1115
- /**
1116
- * @ignore
1117
- */
1118
- registerOnTouched(fn) {
1119
- this.onTouched = fn;
1120
- }
1121
- }
1122
- ValidationDateTimeComponent.decorators = [
1123
- { type: Component, args: [{
1124
- selector: "val-datetime",
1125
- template: "<mat-form-field appearance=\"outline\" class=\"mat-full-width mat-no-border-top mat-height-fixed\" [style.width.px]=\"widthPx\">\r\n <mat-label *ngIf=\"placeholder\">{{placeholder}}</mat-label>\r\n\r\n <input matInput \r\n [ngxMatDatetimePicker]=\"datepicker\" \r\n #baseInput=\"ngModel\"\r\n type=\"text\"\r\n triggers=\"\"\r\n placement=\"top\"\r\n name=\"val-date\"\r\n class=\"form-control {{class}}\"\r\n autocomplete=\"{{autocomplete}}\"\r\n [(ngModel)]=\"value\"\r\n [class.checking-field]=\"!noValidate\"\r\n [tooltip]=\"tolTemplate\"\r\n [placeholder]=\"placeholder ? '' : _format\"\r\n [disabled]=\"readonly || disabled\"\r\n [isDisabled]=\"readonly || disabled\"\r\n (dateChange)=\"outputValue($event)\"/>\r\n\r\n <mat-datepicker-toggle matSuffix [for]=\"datepicker\"></mat-datepicker-toggle>\r\n\r\n <ngx-mat-datetime-picker #datepicker \r\n [showSpinners]=\"showSpinners\" \r\n [showSeconds]=\"showSeconds\" \r\n [stepHour]=\"stepHour\" \r\n [stepMinute]=\"stepMinute\" \r\n [stepSecond]=\"stepSecond\" \r\n [touchUi]=\"false\" \r\n [color]=\"'primary'\">\r\n </ngx-mat-datetime-picker>\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>",
1126
- encapsulation: ViewEncapsulation.None,
1127
- changeDetection: ChangeDetectionStrategy.OnPush,
1128
- providers: [
1129
- { provide: LocalizationService, useClass: BaseValidationLoc },
1130
- {
1131
- provide: NG_VALUE_ACCESSOR,
1132
- useExisting: forwardRef(() => ValidationDateTimeComponent),
1133
- multi: true
1134
- }
1135
- ],
1136
- styles: [".tooltip-inner{background-color:#842a30;color:#fff;font-size:12px;width:max-content}.tooltip{margin:auto auto auto 20%!important}.tooltip-inner{background-color:#842a30!important;color:#fff}.tooltip.top .tooltip-arrow:before,.tooltip.top .tooltip-arrow{border-top-color:#842a30}.close-button{position:absolute;right:0em;top:-.2em;float:right;font-size:16px;font-weight:bold;color:inherit;text-shadow:0 1px 0 #fff;opacity:.5}.close-button:hover,.close-button:focus{text-decoration:none;cursor:pointer;opacity:.75}\n"]
1137
- },] }
1138
- ];
1139
- ValidationDateTimeComponent.ctorParameters = () => [
1140
- { type: ChangeDetectorRef },
1141
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_VALIDATORS,] }] },
1142
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_ASYNC_VALIDATORS,] }] },
1143
- { type: Injector },
1144
- { type: LocalizationService },
1145
- { type: DateService }
1146
- ];
1147
- ValidationDateTimeComponent.propDecorators = {
1148
- useJsDates: [{ type: Input }]
1149
- };
1150
-
1151
- // Angular
1152
- /**
1153
- * Componente di validaizone per gli input di Autocompletamento
1154
- */
1155
- class ValidationAutocompleteComponent extends BaseValidation {
1156
- /**
1157
- * @ignore
1158
- */
1159
- constructor(_validators, _asyncValidators, injector, lc, cdr) {
1160
- super();
1161
- this._validators = _validators;
1162
- this._asyncValidators = _asyncValidators;
1163
- this.injector = injector;
1164
- this.lc = lc;
1165
- this.cdr = cdr;
1166
- /**
1167
- * Sorgente da cui scegliere valori filtrata in base a quello che ha scritto l'utente
1168
- */
1169
- this.FilteredSource = [];
1170
- /**
1171
- * Contenuto della label Floattante Material-Style
1172
- */
1173
- this.label = "";
1174
- /**
1175
- * Evento che indica l'opzione selezionata dal componente. Il valore finale della selezione dovrà essere questo
1176
- */
1177
- this.optionChange = new EventEmitter();
1178
- /**
1179
- * @ignore
1180
- */
1181
- this.onTouched = () => { }; //placeholder on touched function
1182
- }
1183
- /**
1184
- * @ignore
1185
- */
1186
- ngOnInit() {
1187
- //controllo se è settato un required per decidere in maniera condizionale se utilizzare il validatore required nel componente interno
1188
- if (this._validators && !this.noValidate && this._validators.some(elem => elem instanceof RequiredValidator))
1189
- this.required = true;
1190
- }
1191
- /**
1192
- * @ignore
1193
- */
1194
- ngOnDestroy() {
1195
- if (this.tooltipSubscription)
1196
- this.tooltipSubscription.unsubscribe();
1197
- }
1198
- /**
1199
- * @ignore
1200
- */
1201
- ngAfterViewInit() {
1202
- this.postBinding();
1203
- }
1204
- /**
1205
- * Metodo che si occupa di collegare i validatori e la funzione di reset dal **ControlValueAccessor** rappresentato
1206
- * da questo componente al **ControlValueAccessor** rappresentato dall'effettivo elemento di Input presente lato HTML
1207
- */
1208
- postBinding() {
1209
- this.CheckValidity();
1210
- const ngControl = this.injector.get(NgControl, null);
1211
- if (ngControl) {
1212
- this.parentControl = ngControl.control;
1213
- //se la variabile novalidate è true, elimino tutti i validatori eventualmente inseriti
1214
- if (this.noValidate) {
1215
- this.parentControl.clearValidators();
1216
- this.parentControl.clearAsyncValidators();
1217
- }
1218
- else {
1219
- this.baseInput.control.setAsyncValidators(this._asyncValidators);
1220
- this.baseInput.control.setValidators(this._validators);
1221
- }
1222
- //faccio in modo che se chiamo il reset del controllo (o della form) dall'esterno si resetti anche il controllo nativo
1223
- const origFunc = this.parentControl.reset;
1224
- this.parentControl.reset = () => {
1225
- origFunc.apply(this.parentControl);
1226
- this.baseInput.control.reset();
1227
- this.tooltip.hide();
1228
- };
1229
- }
1230
- }
1231
- /**
1232
- * @ignore
1233
- */
1234
- writeValue(value) {
1235
- var val = value && this.FilteredSource ? this.FilteredSource.find(t => t.id == value) : null;
1236
- if (val)
1237
- this.optionChange.emit(val.id);
1238
- this.propagateChange(val ? val.id : value);
1239
- this.value = val ? val.description : value;
1240
- }
1241
- /**
1242
- * L'emit della modifica al valore viene gestito su un evento custom (**inputChange**) come workaround al malfunzionamento dell'**ngModelChange** nativo
1243
- *
1244
- * @param {any} toEmit valore da propagare all'esterno
1245
- */
1246
- onModelChange(toEmit) {
1247
- this.writeValue(toEmit);
1248
- this.inputChange.emit(toEmit);
1249
- this.onTouched();
1250
- }
1251
- /**
1252
- * @ignore
1253
- */
1254
- registerOnChange(fn) {
1255
- this.propagateChange = fn;
1256
- }
1257
- /**
1258
- * @ignore
1259
- */
1260
- registerOnTouched(fn) {
1261
- this.onTouched = fn;
1262
- }
1263
- }
1264
- ValidationAutocompleteComponent.decorators = [
1265
- { type: Component, args: [{
1266
- selector: "val-autocomplete",
1267
- template: "<mat-form-field appearance=\"outline\" class=\"mat-full-width mat-no-border-top mat-height-fixed\" [style.width.px]=\"widthPx\">\r\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\r\n <input matInput\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 class=\"form-control {{class}}\"\r\n [(ngModel)]=\"value\"\r\n [class.checking-field]=\"!noValidate\"\r\n [tooltip]=\"tolTemplate\"\r\n [disabled]=\"readonly || disabled\"\r\n (ngModelChange)=\"onModelChange($event)\"\r\n (focus)=\"checkTooltip();\"\r\n (blur)=\"closeTooltip();\">\r\n <mat-autocomplete autoActiveFirstOption #auto=\"matAutocomplete\">\r\n <mat-option *ngFor=\"let option of FilteredSource\" [value]=\"option.id\">\r\n {{option.description}}\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>",
1268
- changeDetection: ChangeDetectionStrategy.OnPush,
1269
- providers: [
1270
- { provide: LocalizationService, useClass: BaseValidationLoc },
1271
- {
1272
- provide: NG_VALUE_ACCESSOR,
1273
- useExisting: forwardRef(() => ValidationAutocompleteComponent),
1274
- multi: true
1275
- }
1276
- ],
1277
- encapsulation: ViewEncapsulation.None,
1278
- styles: [".tooltip-inner{background-color:#842a30;color:#fff;font-size:12px;width:max-content}.tooltip{margin:auto auto auto 20%!important}.tooltip-inner{background-color:#842a30!important;color:#fff}.tooltip.top .tooltip-arrow:before,.tooltip.top .tooltip-arrow{border-top-color:#842a30}.close-button{position:absolute;right:0em;top:-.2em;float:right;font-size:16px;font-weight:bold;color:inherit;text-shadow:0 1px 0 #fff;opacity:.5}.close-button:hover,.close-button:focus{text-decoration:none;cursor:pointer;opacity:.75}\n"]
1279
- },] }
1280
- ];
1281
- ValidationAutocompleteComponent.ctorParameters = () => [
1282
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_VALIDATORS,] }] },
1283
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_ASYNC_VALIDATORS,] }] },
1284
- { type: Injector },
1285
- { type: LocalizationService },
1286
- { type: ChangeDetectorRef }
1287
- ];
1288
- ValidationAutocompleteComponent.propDecorators = {
1289
- FilteredSource: [{ type: Input }],
1290
- value: [{ type: Input }],
1291
- label: [{ type: Input }],
1292
- optionChange: [{ type: Output }]
1293
- };
1294
-
1295
- // Angular
1296
- /**
1297
- * Componente base da cui tutti i componenti Form implementano
1298
- */
1299
- class BaseFormControl {
1300
- /**
1301
- * Costruttore
1302
- *
1303
- * @ignore
1304
- */
1305
- constructor(cdr, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY, nativeInput = false) {
1306
- this.cdr = cdr;
1307
- this.ngControl = ngControl;
1308
- this._validators = _validators;
1309
- this.ac = ac;
1310
- this.AppContext = AppContext;
1311
- this.ACO_CUSTOMKEY = ACO_CUSTOMKEY;
1312
- this.nativeInput = nativeInput;
1313
- /**
1314
- * https://github.com/angular/angular/issues/14988
1315
- * TL:DR; Il primo valore passato al writeValue è nullo perché quando i cagnacci fanno new FormControl()
1316
- * scrivono un writeValue nullo... quindi al primo binding salto l'inizializzazione se ho la coppia null-firstBind
1317
- * poi mettendo firstBind a false di lì in poi funziono come devo. Vista la casistica evito essenzialmente metà detectChanges
1318
- */
1319
- this.firstBind = true;
1320
- /**
1321
- * Indica se il campo è obbligatorio i opzionale
1322
- */
1323
- this.Required = false;
1324
- /**
1325
- * Indica se il Form che contiene questo campo è già stato registrato
1326
- */
1327
- this.formHasBennBound = false;
1328
- /**
1329
- * Indica se questo campo è staccato dal Form, ad esempio nel caso sia in un ng-template proiettato nel form.
1330
- *
1331
- * In quel caso la variabile **Form** del componente dev'essere valorizzata
1332
- */
1333
- this.detatchedFromform = false;
1334
- /**
1335
- * @ignore
1336
- */
1337
- this.propagateChange = (_) => { };
1338
- /**
1339
- * @ignore
1340
- */
1341
- this.onTouched = () => { };
1342
- /**
1343
- * @ignore Vedi getter e setter
1344
- */
1345
- this._readonly = false;
1346
- /**
1347
- * Qualora ci fosse un contesto collegato questa variabile identifica se Sono l'Owner o meno.
1348
- *
1349
- * Se non lo sono, il campo risulterà in sola lettura
1350
- */
1351
- this.AppContextOwnership = true;
1352
- /**
1353
- * Utilizza o meno il Layout di un form (Label con input di fianco), se false mostra solo l'input
1354
- */
1355
- this.FormLayout = true;
1356
- /**
1357
- * Attiva o disattiva la validazione per questo componente
1358
- */
1359
- this.Validation = true;
1360
- /**
1361
- * Placeholder per quando l'input è vuoto
1362
- */
1363
- this.Placeholder = "";
1364
- /**
1365
- * Classe extra per il form-group in cui viene wrappato l'input
1366
- */
1367
- this.FormGroupClass = "";
1368
- /**
1369
- * Messaggio da mostrare quando la validazione fallisce per questo componente. Di default viene proposta dalla libreria
1370
- */
1371
- this.FailedValidationMessage = "";
1372
- /**
1373
- * Input che forza l'invalidità del componente
1374
- */
1375
- this.ForcedError = false;
1376
- /**
1377
- * Mostra un testo a sinistra dell'input (FormLayout permettendo)
1378
- */
1379
- this.Label = "";
1380
- /**
1381
- * col-md-X per la label
1382
- */
1383
- this.LabelColWidth = 4;
1384
- /**
1385
- * col-md-X per l'input
1386
- */
1387
- this.InputColWidth = 8;
1388
- /**
1389
- * Indica se è l'ultimo componente di un form (serve per rimuovere il margine finale)
1390
- */
1391
- this.Last = false;
1392
- /**
1393
- * Associa il componente Form a questo input
1394
- */
1395
- this.Form = null;
1396
- /**
1397
- * Nome della proprietà che contiene l'Id degli oggetti bindati nella **Source**
1398
- */
1399
- this.IdField = 'id';
1400
- /**
1401
- * Espressione simil-Angular per cambiare il testo dei componenti che scelgono il proprio modello da una **Source**
1402
- *
1403
- * Il funzionamento è identico al binder di angular, solo con una graffa invece che 2.
1404
- * È inoltre possibile aggiungere pezzi di descrizione in maniera condizionale con la sintassi **:prop?(Prop vale {prop})**
1405
- */
1406
- this.Display = '{description}';
1407
- /**
1408
- * Risultato dell'unione fra le informazioni degli oggetti in **Source** e le impostazioni specificate nell'Input **Display**
1409
- */
1410
- this.BoundSource = [];
1411
- /**
1412
- * Indica se è il primo Bind della Source
1413
- */
1414
- this.SourceFirstBind = true;
1415
- /**
1416
- * Evento chiamato alla modifica del valore collegato a questo campo
1417
- */
1418
- this.inputChange = new EventEmitter();
1419
- /**
1420
- * Cache delle condizioni scritte tipo :prop?(Roba con {prop})
1421
- */
1422
- this.BindCheckingGroups = [];
1423
- /**
1424
- * Cache delle proprietà scritte tipo --> {prop}
1425
- */
1426
- this.BindProperties = [];
1427
- if (ngControl == null) {
1428
- if (!this.handleNullNgControl())
1429
- console.error("ngControl nullo per qualche motivo! Il 90% delle funzionalità di questo input saranno disabilitate");
1430
- return;
1431
- }
1432
- //Se mi arriva l'injectable del contesto posso capire se questo campo deve essere in readonly o no, solo se ho già inizializzato i controller custom dell'access control
1433
- if (this.AppContext && this.AppContext.name && this.ACO_CUSTOMKEY && this.ac && this.ac.InitializedCustom) {
1434
- this.AppContextOwnership = !this.ac.has(this.ACO_CUSTOMKEY + ":" + this.AppContext.name);
1435
- this._readonly = !this.AppContextOwnership;
1436
- }
1437
- ngControl.valueAccessor = this;
1438
- //Se ho già un parent impostato vuol dire che sotto al tag <form> ho direttamente un tag <form-*>..
1439
- //.. quindi posso impostare direttamente il riferimento del Form da usare in HTML per il submitted
1440
- //Se non c'è vuol dire che dentro al tag <form> c'è uno splendido <ng-container *ngTemplateOutlet="template; context: ....">..
1441
- //.. il quale a sua volta contiene il controllo <form-*> quindi avrò il form nell'input "Form"
1442
- if (ngControl._parent)
1443
- this.Form = ngControl._parent;
1444
- else
1445
- this.detatchedFromform = true;
1446
- //Questa serve per impostare me stesso come si deve, il validatore invece lo passo al validation-input quando viene settato il validationControl
1447
- if (this.ngControl) {
1448
- //Per tutti i validatori: rigenero la funzione di validazione. Per qualche motivo a volte ho validatori senza...
1449
- //... questo è un workaround per essere sicuro di averla sempre.
1450
- //Solo i validatori con parametri hanno bisogno della _createValidator (es. "maxlength" che ha 1 parametro), quindi no validatori tipo "required"
1451
- if (this._validators) {
1452
- this._validators.forEach(v => {
1453
- if (v._createValidator)
1454
- v._createValidator();
1455
- });
1456
- }
1457
- this.ngControl.control.setValidators(this._validators);
1458
- this.ngControl.control.updateValueAndValidity();
1459
- }
1460
- }
1461
- /**
1462
- * Ottiene il valore della variabile **_readonly**
1463
- *
1464
- * @returns {boolean} **true** se sola lettura, **false** altrimenti
1465
- */
1466
- get Readonly() { return this._readonly; }
1467
- /**
1468
- * Imposta il valore della variabile **_readonly** gestendo anche il Contesto applicativo
1469
- *
1470
- * @param {boolean} value Valore da impostare
1471
- */
1472
- set Readonly(value) {
1473
- if (this.AppContextOwnership)
1474
- this._readonly = value;
1475
- }
1476
- /**
1477
- * Permette di settare in una volta solo gli input LabelColWidth e InputColWidth, basta scriverlo con la sintassi "X Y"
1478
- *
1479
- * @param {string} input Input nel formato "X Y"
1480
- */
1481
- set LabelInputRatio(input) {
1482
- var ratio = input.split(/\s/);
1483
- this.LabelColWidth = parseInt(ratio[0]);
1484
- this.InputColWidth = parseInt(ratio[1]);
1485
- }
1486
- /**
1487
- * Query sull'elemento 'validationControl' che funziona in ambiente statico
1488
- *
1489
- * @param {NgModel} comp Elemento HTML marcato con "#validationControl"
1490
- */
1491
- set _validationControl(comp) { this.registerValComp(comp); }
1492
- /**
1493
- * Query sull'elemento 'validationControl' che funziona in ambiente dinamico
1494
- *
1495
- * @param {NgModel} comp Elemento HTML marcato con "#validationControl"
1496
- */
1497
- set validationControl_static(comp) { this.registerValComp(comp); }
1498
- ;
1499
- /**
1500
- * Effettua il Bind/Parse delle varie **Source** unendo le informazioni specificate in **Display**
1501
- *
1502
- * Eventualmente rieffettua un bind al modello in base al valore della variabile **RebindModelAfterSource**
1503
- */
1504
- tryBindSourceDisplay() {
1505
- if (!this.Source)
1506
- return;
1507
- if (this.Source.length == 0 && !this.SourceFirstBind)
1508
- this.BoundSource = [];
1509
- this.SourceFirstBind = false;
1510
- // Cache locale per evitare di rifare dei regex.match ogni santa volta
1511
- if (this.Source.length > 0) {
1512
- this.BoundSource = [];
1513
- if (this.BindCheckingGroups.length == 0)
1514
- this.evaluateBindCheckingGroups();
1515
- if (this.BindProperties.length == 0)
1516
- this.evaluateBindProperties();
1517
- // Blocco per generare la descrizione finale di un elemento
1518
- this.Source.forEach(s => {
1519
- // Aggiungo alla BoundSource in formato standard KeyValue
1520
- this.BoundSource.push(this.transformSourceItem(s));
1521
- });
1522
- }
1523
- }
1524
- /**
1525
- * Valuta il contenuto della variabile BindCheckingGroups
1526
- */
1527
- evaluateBindCheckingGroups() {
1528
- // Blocco per tirare fuori le condizioni scritte tipo --> :prop?(Roba con {prop})
1529
- var iffedMatches = this.Display.match(/:([a-z]+)\?\(([^\(\)]+)\)/g);
1530
- if (iffedMatches) {
1531
- iffedMatches.forEach(m => {
1532
- // Stessa regex di sopra ma il tag "i" serve per tirare fuori i singoli capturing group e per qualche motivo
1533
- // new RegExp(baseRegex, "g") non funziona quindi non ho potuto razionalizzarlo
1534
- let groups = m.match(/:([a-z]+)\?\(([^\(\)]+)\)/i);
1535
- this.BindCheckingGroups.push({ global: m, prop: groups[1], whenexists: groups[2] });
1536
- });
1537
- }
1538
- }
1539
- /**
1540
- * Valuta il contenuto della variabile BindProperties
1541
- */
1542
- evaluateBindProperties() {
1543
- // Blocco per tirare fuori le proprietà scritte tipo --> {prop}
1544
- var matches = this.Display.match(/{[a-z]+}/gi);
1545
- if (matches)
1546
- matches.forEach(m => { this.BindProperties.push({ global: m, prop: m.substring(1, m.length - 1) }); });
1547
- }
1548
- /**
1549
- * Trasforma un oggetto della Source alla sua versione "nuova" basandosi sulle informazioni su gruppi e proprietà
1550
- *
1551
- * @param {any} item Oggetto da trasformare
1552
- *
1553
- * @returns {{id: string, description: string}} Oggetto finale trasformato
1554
- */
1555
- transformSourceItem(s) {
1556
- // Parto sempre dalla variabile di Display, poi sostituisco pezzo per pezzo
1557
- let desc = this.Display;
1558
- // Taglio o mantengo le condizioni in base alla proprietà su cui fare check
1559
- // Dopodiché scrivo tutte le proprietà
1560
- for (let i = 0; i < this.BindCheckingGroups.length; i++) {
1561
- let t = this.BindCheckingGroups[i];
1562
- desc = desc.replace(t.global, (s[t.prop] != null && s[t.prop] != undefined) ? t.whenexists : "");
1563
- }
1564
- for (let i = 0; i < this.BindProperties.length; i++) {
1565
- let t = this.BindProperties[i];
1566
- desc = desc.replace(t.global, s[t.prop]);
1567
- }
1568
- return { id: s[this.IdField], description: desc };
1569
- }
1570
- /**
1571
- * Indica se il comopnente in questione è in grado di gestire ngControl nulli.
1572
- * Di default è **false**
1573
- *
1574
- * @returns {boolean} **true** se gestisco ngControl nulli, **false** altrimenti
1575
- */
1576
- handleNullNgControl() {
1577
- return false;
1578
- }
1579
- /**
1580
- * @ignore
1581
- */
1582
- ngOnInit() {
1583
- // A volte nell'ngOnInit non ci passa quindi lo metto sia qui sia nell'afterviewinit, penso che valga per i componenti di terze parti
1584
- // che si collegano per i cazzi loro al form ecc, quindi la parte sopra non serve... BOH
1585
- this.checkRequiredValidator();
1586
- //Il nome non c'è se metto standalone : true
1587
- //Dato che anche il controllo esterno viene considerato come componente del form, non posso basarmi solo sul nome ma devo aggiungere un tag. In questo caso "_internal"
1588
- // ATTENZIONE: QUALSIASI SIA IL MOTIVO, SE STO COSO VIENE SPOSTATO DALL ngOnInit NON FUNZIONA PIU NULLA
1589
- if (this.ngControl.name)
1590
- this.GeneratedName = this.ngControl.name.toString() + "_internal";
1591
- // ATTENZIONE: QUALSIASI SIA IL MOTIVO, SE STO COSO VIENE SPOSTATO DALL ngOnInit NON FUNZIONA PIU NULLA
1592
- if (this.Form) {
1593
- if (!this.formHasBennBound && this.validationControl) {
1594
- this.Form.addControl(this.validationControl);
1595
- this.formHasBennBound = true;
1596
- }
1597
- // Quando un form viene submittato la variabile Form.submitted viene assegnata all'input [submitted] del val-control
1598
- // Essendo che però la CD è OnPush per dire ad Angular che l'Input è cambiato e permettere i sideffects di assegnare [submitted]
1599
- // devo attaccarmi al submit attuale del form e prima di eseguirlo devo marcare il componente per il check
1600
- let origFunc = this.Form.onSubmit;
1601
- var formOutsideRef = this.Form;
1602
- this.Form.onSubmit = (ev) => {
1603
- this.cdr.markForCheck();
1604
- return origFunc.apply(formOutsideRef);
1605
- };
1606
- }
1607
- }
1608
- /**
1609
- * Elabora i validatori iniettati e capisce se il valore è obbligatorio o meno
1610
- */
1611
- checkRequiredValidator() {
1612
- // controllo se è settato un required per decidere in maniera condizionale se utilizzare il validatore required nel componente interno
1613
- // Lo faccio qui e non in un eventuale ngOnInit o costruttore perché ngOnInit non sempre viene chiamato e da costruttore il validatore non ha ancora il valore giusto
1614
- if (this._validators && this._validators.some(elem => elem instanceof RequiredValidator && elem.required))
1615
- this.Required = true;
1616
- }
1617
- /**
1618
- * @ignore
1619
- */
1620
- ngAfterViewInit() {
1621
- if (!this.ngControl)
1622
- return;
1623
- this.checkRequiredValidator();
1624
- }
1625
- /**
1626
- * Helper che collega la funzione di reset del controllo form al controllo di validazione sottostante
1627
- */
1628
- bindResetFunction() {
1629
- //faccio in modo che se chiamo il reset del controllo (o della form) dall'esterno si resetti anche il controllo nativo
1630
- const origFunc = this.ngControl.control.__original_reset__ || this.ngControl.control.reset;
1631
- var ngControl_outsideReference = this.ngControl.control;
1632
- var validationControl_outsideReference = this.validationControl.control;
1633
- this.ngControl.control.reset = () => {
1634
- origFunc.apply(ngControl_outsideReference);
1635
- validationControl_outsideReference.reset();
1636
- };
1637
- //Per consentire richiami multipli di questa funzione prendendo sempre la fiunzione di reset base
1638
- this.ngControl.control.__original_reset__ = origFunc;
1639
- }
1640
- /**
1641
- * @ignore
1642
- */
1643
- writeValue(obj) {
1644
- if (obj == null && this.firstBind) {
1645
- this.firstBind = false;
1646
- return;
1647
- }
1648
- this.Model = obj;
1649
- //Per svegliare Angular. Il valore che entra potrebbe essere valido/non valido e questo lo binda a tutto, form compreso
1650
- if (this.ngControl)
1651
- this.ngControl.control.updateValueAndValidity();
1652
- if (this.Model)
1653
- this.onNotNullValueSet();
1654
- // markForCheck non va bene in quanto arrivano possibilmente 2 update su un solo ciclo di stack
1655
- // setTime*ut che wrappa tutto non va bene sennò spamma delle change detection a suon di interval che rallentano tantissimo l'app
1656
- this.cdr.detectChanges();
1657
- }
1658
- /**
1659
- * @ignore
1660
- */
1661
- registerOnChange(fn) {
1662
- this.propagateChange = fn;
1663
- }
1664
- /**
1665
- * @ignore
1666
- */
1667
- registerOnTouched(fn) {
1668
- this.onTouched = fn;
1669
- }
1670
- /**
1671
- * Registra internamente il componente di validazione, ne imposta i validatori e collega il Form, se presente
1672
- *
1673
- * @param {NgModel} comp Elemento HTML marcato con "#validationControl"
1674
- */
1675
- registerValComp(comp) {
1676
- if (comp) {
1677
- // È arrivato un nuovo validationContorl (succede solo nel form-select quando cambia la source da 0 elementi / null ad N elementi, quindi al massimo una volta)
1678
- if (this.validationControl && this.Form)
1679
- this.Form.removeControl(this.validationControl);
1680
- this.validationControl = comp;
1681
- //Questa serve per passare avanti i validatori
1682
- this.validationControl.control.setValidators(this._validators);
1683
- //Se sono staccato dal Form (vuol dire che sono ad esempio dentro un ng-template) aggiungo il controllo al Form passato come input (context del template)
1684
- if (this.detatchedFromform && this.Form && !this.formHasBennBound) {
1685
- this.Form.addControl(this.validationControl);
1686
- this.formHasBennBound = true;
1687
- }
1688
- if (this.ngControl)
1689
- this.bindResetFunction();
1690
- //I val-roba questo lo fanno automaticamente dentro... gli altri no (es. semplice input checkbox)
1691
- this.updateValidityForNativeInput();
1692
- }
1693
- }
1694
- /**
1695
- * Aggiorna il valore e la validità dell'input sottostante. Non viene chiamato per input nativi come le checkbox
1696
- *
1697
- * @param {boolean} forcedValue Forza l'aggiornamento anche se non è un input nativo (input nativo = checkbox, ad esempio)
1698
- */
1699
- updateValidityForNativeInput(forcedValue = false) {
1700
- if (forcedValue || this.nativeInput)
1701
- this.validationControl.control.updateValueAndValidity();
1702
- }
1703
- /**
1704
- * @ignore
1705
- * Classico "spara fuori". Mantengo lo stesso nome dell'evento dei <val-*> (inputChange) per retrocompatibilità.
1706
- *
1707
- * Non posso tenerlo protected altrimenti posso eseguirlo solo dal .ts e non dall' .html
1708
- */
1709
- changed(forcedValue = null, markForCheck = false) {
1710
- this.propagateChange(forcedValue == null ? this.Model : forcedValue);
1711
- this.inputChange.emit(forcedValue == null ? this.Model : forcedValue);
1712
- if (markForCheck)
1713
- this.cdr.markForCheck();
1714
- }
1715
- }
1716
- BaseFormControl.decorators = [
1717
- { type: Directive }
1718
- ];
1719
- BaseFormControl.ctorParameters = () => [
1720
- { type: ChangeDetectorRef },
1721
- { type: NgControl },
1722
- { type: Array },
1723
- { type: AccessControlService, decorators: [{ type: Optional }] },
1724
- { type: ComponentContext, decorators: [{ type: Optional }] },
1725
- { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ACO_CUSTOMKEY,] }] },
1726
- { type: Boolean }
1727
- ];
1728
- BaseFormControl.propDecorators = {
1729
- FormLayout: [{ type: Input }],
1730
- Validation: [{ type: Input }],
1731
- Placeholder: [{ type: Input }],
1732
- FormGroupClass: [{ type: Input }],
1733
- FailedValidationMessage: [{ type: Input }],
1734
- ForcedError: [{ type: Input }],
1735
- Label: [{ type: Input }],
1736
- LabelColWidth: [{ type: Input }],
1737
- InputColWidth: [{ type: Input }],
1738
- Last: [{ type: Input }],
1739
- Form: [{ type: Input }],
1740
- Source: [{ type: Input }],
1741
- IdField: [{ type: Input }],
1742
- Display: [{ type: Input }],
1743
- Readonly: [{ type: Input }],
1744
- LabelInputRatio: [{ type: Input }],
1745
- _validationControl: [{ type: ViewChild, args: ["validationControl", { static: false },] }],
1746
- validationControl_static: [{ type: ViewChild, args: ["validationControl", { static: true },] }],
1747
- inputChange: [{ type: Output }]
1748
- };
1749
-
1750
- /**
1751
- * Classe di localizzazione per il componente **FormFileComponent**
1752
- */
1753
- class FormFileComponentLoc extends LocalizationService {
1754
- /**
1755
- * @ignore
1756
- */
1757
- constructor(LOC_LOCALE) {
1758
- super(LOC_LOCALE !== null && LOC_LOCALE !== void 0 ? LOC_LOCALE : 'it-IT');
1759
- super.set("en->it", "Select a file", ["Seleziona un file"]);
1760
- super.set("en->it", "Files Selected", ["File Selezionati"]);
1761
- }
1762
- }
1763
- FormFileComponentLoc.decorators = [
1764
- { type: Injectable }
1765
- ];
1766
- FormFileComponentLoc.ctorParameters = () => [
1767
- { type: String, decorators: [{ type: Optional }, { type: Inject, args: [FAV_LOCALE,] }] }
1768
- ];
1769
-
1770
- // Angular
1771
- /**
1772
- * Componente che permette all'utente di caricare/scaricare un file all'interno di un campo Input
1773
- */
1774
- class FormFileComponent extends BaseFormControl {
1775
- /**
1776
- * Costruttore
1777
- *
1778
- * @ignore
1779
- */
1780
- constructor(cdr, utiExts, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY, lc) {
1781
- super(cdr, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY);
1782
- this.utiExts = utiExts;
1783
- this.lc = lc;
1784
- /**
1785
- * Permette di caricare file multipli
1786
- */
1787
- this.Multiple = false;
1788
- /**
1789
- * Permette di scaricare l'eventuale file selezionato
1790
- */
1791
- this.AllowDownload = true;
1792
- //Per questo componente non posso permettermi che il modello sia nullo
1793
- this.Model = new AppFile();
1794
- }
1795
- /**
1796
- * @ignore
1797
- */
1798
- writeValue(obj) {
1799
- var model = obj == null ? new AppFile() : obj;
1800
- super.writeValue(model);
1801
- if (obj == null)
1802
- this.changed();
1803
- }
1804
- /**
1805
- * Helper per gestire la modifica del file attualmente bindato
1806
- *
1807
- * @param {boolean} clear Indica se bisogna svuotare l'input o meno
1808
- */
1809
- fileChange(clear = false) {
1810
- let files = [];
1811
- let model = this.Model;
1812
- let ne = this.inputEl.nativeElement;
1813
- if (clear) {
1814
- model.filename = "";
1815
- ne.value = "";
1816
- }
1817
- else {
1818
- for (let i = 0; i < ne.files.length; i++)
1819
- files.push(ne.files.item(i));
1820
- if (ne.files.length == 1)
1821
- model.filename = ne.files[0].name;
1822
- if (ne.files.length > 1)
1823
- model.filename = ne.files.length + " " + this.lc.loc("Files Selected");
1824
- model.nativefiles = files;
1825
- model.fileb64 = null;
1826
- }
1827
- this.changed(null, true);
1828
- }
1829
- /**
1830
- * Permette di scaricare l'eventuale file selezionato
1831
- */
1832
- downloadAttachment() {
1833
- let model = this.Model;
1834
- this.utiExts.saveFile(model.fileb64, model.filename);
1835
- }
1836
- /**
1837
- * @ignore
1838
- */
1839
- onNotNullValueSet() { }
1840
- }
1841
- FormFileComponent.decorators = [
1842
- { type: Component, args: [{
1843
- selector: "form-file",
1844
- providers: [{ provide: LocalizationService, useClass: FormFileComponentLoc }],
1845
- 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 class=\"input-group file-upload\">\r\n <input type=\"file\" (change)=\"fileChange()\" #fileInput class=\"file-upload-btn app-pointer\" [multiple]=\"Multiple ? true : null\" />\r\n <input type=\"text\" [class.frm-padding-left-22]=\"AllowDownload && Model.filename && Model.fileb64\" class=\"form-control checking-field\" placeholder=\"{{'Select a file' | localize : lc}}...\" [(ngModel)]=\"Model.filename\" name=\"dsfile\" #validationControl=\"ngModel\" [required]=\"Required ? true : null\" />\r\n\r\n <a class=\"fa fa-download app-pointer app-input-icon\" *ngIf=\"AllowDownload && Model.filename && Model.fileb64\" (click)=\"downloadAttachment()\"></a>\r\n <i class=\"fa fa-times delete-file\" (click)=\"fileChange(true)\" *ngIf=\"Model.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</ng-template>",
1846
- changeDetection: ChangeDetectionStrategy.OnPush,
1847
- styles: [".frm-padding-left-22{padding-left:22px}\n"]
1848
- },] }
1849
- ];
1850
- FormFileComponent.ctorParameters = () => [
1851
- { type: ChangeDetectorRef },
1852
- { type: UtilityService },
1853
- { type: NgControl, decorators: [{ type: Optional }, { type: Self }] },
1854
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_VALIDATORS,] }] },
1855
- { type: AccessControlService, decorators: [{ type: Optional }] },
1856
- { type: ComponentContext, decorators: [{ type: Optional }] },
1857
- { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ACO_CUSTOMKEY,] }] },
1858
- { type: LocalizationService }
1859
- ];
1860
- FormFileComponent.propDecorators = {
1861
- Multiple: [{ type: Input }],
1862
- AllowDownload: [{ type: Input }],
1863
- inputEl: [{ type: ViewChild, args: ["fileInput", { static: false },] }]
1864
- };
1865
-
1866
- // Angular
1867
- /**
1868
- * Componente che dà all'utente la possibilità di selezionare una data insieme ad un orario
1869
- */
1870
- class FormDateTimeComponent extends BaseFormControl {
1871
- /**
1872
- * Costruttore
1873
- *
1874
- * @ignore
1875
- */
1876
- constructor(cdr, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY) {
1877
- super(cdr, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY);
1878
- /**
1879
- * Utilizza il Date di Javascript come modello in uscita. Il modello in entrata verrà comunque ricondotto a un DayJs
1880
- */
1881
- this.JsDates = false;
1882
- }
1883
- /**
1884
- * @ignore
1885
- */
1886
- onNotNullValueSet() { }
1887
- }
1888
- FormDateTimeComponent.decorators = [
1889
- { type: Component, args: [{
1890
- selector: "form-datetime",
1891
- 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 <val-datetime [noValidate]=\"!Validation\"\r\n [submitted]=\"Form?.submitted\"\r\n [forceInvalid]=\"ForcedError\"\r\n [readonly]=\"Readonly\"\r\n [class]=\"Readonly ? 'app-bg-lightgrey' : ''\"\r\n [useJsDates]=\"JsDates\"\r\n [(ngModel)]=\"Model\"\r\n name=\"{{GeneratedName}}\"\r\n #validationControl=\"ngModel\"\r\n (inputChange)=\"changed();\"\r\n [placeholder]=\"Placeholder\"\r\n [validationFailed]=\"FailedValidationMessage\">\r\n </val-datetime>\r\n</ng-template>",
1892
- changeDetection: ChangeDetectionStrategy.OnPush
1893
- },] }
1894
- ];
1895
- FormDateTimeComponent.ctorParameters = () => [
1896
- { type: ChangeDetectorRef },
1897
- { type: NgControl, decorators: [{ type: Optional }, { type: Self }] },
1898
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_VALIDATORS,] }] },
1899
- { type: AccessControlService, decorators: [{ type: Optional }] },
1900
- { type: ComponentContext, decorators: [{ type: Optional }] },
1901
- { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ACO_CUSTOMKEY,] }] }
1902
- ];
1903
- FormDateTimeComponent.propDecorators = {
1904
- JsDates: [{ type: Input }]
1905
- };
1906
-
1907
- /**
1908
- * Classe di localizzazione per il componente **FormAdaptiveComponent**
1909
- */
1910
- class FormAdaptiveComponentLoc extends LocalizationService {
1911
- /**
1912
- * @ignore
1913
- */
1914
- constructor(LOC_LOCALE) {
1915
- super(LOC_LOCALE !== null && LOC_LOCALE !== void 0 ? LOC_LOCALE : 'it-IT');
1916
- super.set("en->it", "Select a file", ["Seleziona un file"]);
1917
- super.set("en->it", "Files Selected", ["File Selezionati"]);
1918
- }
1919
- }
1920
- FormAdaptiveComponentLoc.decorators = [
1921
- { type: Injectable }
1922
- ];
1923
- FormAdaptiveComponentLoc.ctorParameters = () => [
1924
- { type: String, decorators: [{ type: Optional }, { type: Inject, args: [FAV_LOCALE,] }] }
1925
- ];
1926
-
1927
- /**
1928
- * Componente in grado di assumere la forma di un qualsiasi altro componente form in base al tipo specificato. Utile per la creazione di form dinamici
1929
- */
1930
- class FormAdaptiveComponent extends BaseFormControl {
1931
- /**
1932
- * Costruttore
1933
- *
1934
- * @ignore
1935
- */
1936
- constructor(cdr, utiExts, dateAdapter, lc, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY) {
1937
- super(cdr, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY);
1938
- this.utiExts = utiExts;
1939
- this.dateAdapter = dateAdapter;
1940
- this.lc = lc;
1941
- /**
1942
- * Permette di scaricare l'eventuale file presente qualora il **Type** di questo componente fosse **file**
1943
- */
1944
- this.AllowDownload = true;
1945
- /**
1946
- * Utilizzata nel form-adapter per specificare la precisione degli input currencymap (Type: currency)
1947
- */
1948
- this.Precision = 2;
1949
- /**
1950
- * Allineamento della currency mask
1951
- */
1952
- this.Alignment = 'right';
1953
- /**
1954
- * Funzione di ricerca che verrà chiamata dal componente
1955
- */
1956
- this.SearchFunction = null;
1957
- /**
1958
- * Numero minimo di caratteri con cui cercare
1959
- */
1960
- this.MinChars = 3;
1961
- /**
1962
- * Indica se i controlli devono essere effettuati tenendo conto del Case o meno. Vale solo qualora la **Source** fosse fornita
1963
- */
1964
- this.CaseSensitive = false;
1965
- /**
1966
- * Variabile interna che gestisce se effettuare il riallineamento dei dati o meno
1967
- */
1968
- this.alignValues = false;
1969
- /**
1970
- * Indica se ignorare il prossimo evento writeValue che normalmente dovrebbe richiedere la nuova source. Serve per quando l'utente seleziona un elemento:
1971
- * Subito dopo partirebbe un altro evento modelChange che ricaricherebbe nuovamente la source
1972
- */
1973
- this.ignoreNextWriteValue = false;
1974
- /**
1975
- * Cache della sorgente originale POST binding, in modo da poter fare filtri in locale qualora la **SearchFunction** non fosse definita e la **Source** fosse assegnata
1976
- */
1977
- this.FilteredBoundSource = [];
1978
- //******************** Funzione di throttling per non spammare richieste in caso di animazioni attivate
1979
- //TODO: spostarla in un metodo di utilità (esfaenza/extensions)
1980
- /** @ignore */
1981
- this.executionTimers = {};
1982
- this.ModelFile = new AppFile();
1983
- }
1984
- /**
1985
- * @ignore
1986
- */
1987
- ngOnChanges(changes) {
1988
- var _a;
1989
- return __awaiter(this, void 0, void 0, function* () {
1990
- const newSource = changes["Source"];
1991
- const newType = changes["Type"];
1992
- if (newSource) {
1993
- this.tryBindSourceDisplay();
1994
- // Prima assegnazione se cambia la source sotto (quindi se viene bindata direttamente da HTML)
1995
- if (this.Type == "autocomplete" && (((_a = this.Model) === null || _a === void 0 ? void 0 : _a.length) || 0) >= this.MinChars && !this.SearchFunction)
1996
- this.FilteredBoundSource = this.BoundSource;
1997
- else
1998
- this.FilteredBoundSource = [];
1999
- this.cdr.markForCheck();
2000
- }
2001
- if (newType && this.Model)
2002
- this.writeValue(this.Model);
2003
- });
2004
- }
2005
- /**
2006
- * @ignore
2007
- */
2008
- writeValue(obj) {
2009
- this.alignValues = false;
2010
- if (!this.Type)
2011
- this.Type = "string";
2012
- if ((this.Type == "float" || this.Type == "number") && obj)
2013
- obj = obj.toString().replace(".", ",");
2014
- // Per sicurezza riallineo i valori
2015
- if (this.Type == "boolean") {
2016
- obj = obj ? (obj === true || obj.toLowerCase() == "true") : false;
2017
- this.alignValues = true;
2018
- }
2019
- if (this.Type == "time") {
2020
- const [hours, minutes, seconds] = (obj || "0:0:0").split(":");
2021
- obj = dayjs().hour(hours !== null && hours !== void 0 ? hours : 0).minute(minutes !== null && minutes !== void 0 ? minutes : 0).second(seconds !== null && seconds !== void 0 ? seconds : 0);
2022
- }
2023
- if (this.Type == "file")
2024
- obj = this.ModelFile;
2025
- if (this.Type == "autocomplete") {
2026
- if (this.SearchFunction) {
2027
- this.SearchFunction(obj, true).subscribe(t => {
2028
- this.Source = t;
2029
- this.tryBindSourceDisplay();
2030
- setTimeout(() => { this.finalizeValue(obj); });
2031
- });
2032
- return;
2033
- }
2034
- else
2035
- this.finalizeValue(obj);
2036
- }
2037
- super.writeValue(obj);
2038
- if (this.alignValues) {
2039
- this.changed();
2040
- this.cdr.markForCheck();
2041
- }
2042
- }
2043
- /**
2044
- * 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
2045
- *
2046
- * @param {any} value Valore scritto nell'input di testo
2047
- */
2048
- finalizeValue(value) {
2049
- var val = this.Source.find(t => t.id == value);
2050
- this.propagateChange(val ? val.id : value);
2051
- this.Model = val ? val.description : value;
2052
- }
2053
- /**
2054
- * Evento di filtro della sorgente dati in base all'input utente
2055
- *
2056
- * @param {string} event Input utente
2057
- */
2058
- filterSource(event) {
2059
- if (this.ignoreNextWriteValue) {
2060
- this.ignoreNextWriteValue = false;
2061
- return;
2062
- }
2063
- // Quando filtro la source, se non devo ignorare l'evento devo comunque assicurarmi di impostare il valore selezionato a null
2064
- super.changed("");
2065
- if (!event && this.MinChars == 0 && !this.SearchFunction) {
2066
- this.FilteredBoundSource = this.BoundSource;
2067
- return;
2068
- }
2069
- if (!event || event.length < this.MinChars) {
2070
- this.FilteredBoundSource = [];
2071
- return;
2072
- }
2073
- if (!this.SearchFunction && (!this.Source || this.Source.length == 0))
2074
- throw "Impossibile filtrare gli elementi senza una funzione di ricerca che restituisca una lista di { id: string, description: string }";
2075
- if (this.SearchFunction) {
2076
- this.throttla("filtersource", () => {
2077
- this.SearchFunction(event, false).subscribe(t => {
2078
- this.Source = t;
2079
- this.tryBindSourceDisplay();
2080
- // In questo caso è già filtrata dalla SearchFunction
2081
- this.FilteredBoundSource = this.BoundSource;
2082
- this.cdr.markForCheck();
2083
- });
2084
- }, 400);
2085
- }
2086
- else {
2087
- this.throttla("filtersource", () => {
2088
- // In questo caso devo filtrare io in memoria
2089
- this.FilteredBoundSource = this.BoundSource.filter(t => (this.CaseSensitive && t.description.includes(event)) || (!this.CaseSensitive && t.description.toLowerCase().includes(event.toLowerCase())));
2090
- this.cdr.markForCheck();
2091
- }, 100);
2092
- }
2093
- }
2094
- /**
2095
- * Metodo richiamato quando viene modificato il modello del campo di input
2096
- */
2097
- changed() {
2098
- var toEmit = this.Model ? JSON.parse(JSON.stringify(this.Model)) : null;
2099
- if ((this.Type == "float" || this.Type == "number") && toEmit)
2100
- toEmit = toEmit.replace(".", "").replace(",", ".");
2101
- if (this.Type == "boolean")
2102
- toEmit = toEmit ? true : false;
2103
- if (this.Type == "time") {
2104
- var toEmit = this.dateAdapter.clone(this.Model);
2105
- toEmit = toEmit.format("HH:mm:ss");
2106
- }
2107
- if (this.Type == "autocomplete")
2108
- this.ignoreNextWriteValue = true;
2109
- super.changed(toEmit);
2110
- }
2111
- /**
2112
- * Helper per gestire la modifica del file attualmente bindato. Ovviamente funziona solo qualora il **Type** fosse **file**
2113
- *
2114
- * @param {boolean} clear Indica se bisogna svuotare l'input o meno
2115
- */
2116
- fileChange(clear = false) {
2117
- let files = [];
2118
- let model = this.Model;
2119
- let ne = this.inputEl.nativeElement;
2120
- if (clear) {
2121
- model.filename = "";
2122
- ne.value = "";
2123
- }
2124
- else {
2125
- for (let i = 0; i < ne.files.length; i++)
2126
- files.push(ne.files.item(i));
2127
- if (ne.files.length == 1)
2128
- model.filename = ne.files[0].name;
2129
- if (ne.files.length > 1)
2130
- model.filename = ne.files.length + " " + this.lc.loc("Files Selected");
2131
- model.nativefiles = files;
2132
- model.fileb64 = null;
2133
- }
2134
- this.changed();
2135
- }
2136
- /**
2137
- * Permette di scaricare il file collegato all'evetnuale file input rappresentato da questo componente
2138
- */
2139
- downloadAttachment() {
2140
- let model = this.Model;
2141
- this.utiExts.saveFile(model.fileb64, model.filename);
2142
- }
2143
- /**
2144
- * @ignore
2145
- */
2146
- onNotNullValueSet() { }
2147
- /** @ignore */
2148
- throttla(id, func, throttleTime) {
2149
- //Se ho la funzione che vuole eseguire ripulisco quel timeout
2150
- if (this.executionTimers[id])
2151
- clearTimeout(this.executionTimers[id]);
2152
- //Ricreo il timeout per eseguire quella funzione dopo throttleTime millisecondi
2153
- this.executionTimers[id] = setTimeout(() => { func(); this.executionTimers[id] = null; }, throttleTime);
2154
- }
2155
- }
2156
- FormAdaptiveComponent.decorators = [
2157
- { type: Component, args: [{
2158
- selector: "form-adaptive",
2159
- providers: [{ provide: LocalizationService, useClass: FormAdaptiveComponentLoc }],
2160
- 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]=\"Required ? ('Select' | localize : lc) + '...' : Placeholder\" [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\" [placeholder]=\"Required ? ('Select' | localize : lc) + '...' : Placeholder\" [(ngModel)]=\"Model\" name=\"{{GeneratedName}}\" [FilteredSource]=\"FilteredBoundSource\" (inputChange)=\"filterSource($event); 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>",
2161
- changeDetection: ChangeDetectionStrategy.OnPush,
2162
- styles: [".frm-padding-left-22{padding-left:22px}\n"]
2163
- },] }
2164
- ];
2165
- FormAdaptiveComponent.ctorParameters = () => [
2166
- { type: ChangeDetectorRef },
2167
- { type: UtilityService },
2168
- { type: NgxMatDateAdapter },
2169
- { type: LocalizationService },
2170
- { type: NgControl, decorators: [{ type: Optional }, { type: Self }] },
2171
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_VALIDATORS,] }] },
2172
- { type: AccessControlService },
2173
- { type: ComponentContext, decorators: [{ type: Optional }] },
2174
- { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ACO_CUSTOMKEY,] }] }
2175
- ];
2176
- FormAdaptiveComponent.propDecorators = {
2177
- Type: [{ type: Input }],
2178
- TypeMissingMessage: [{ type: Input }],
2179
- Pattern: [{ type: Input }],
2180
- inputEl: [{ type: ViewChild, args: ["fileInput", { static: false },] }],
2181
- AllowDownload: [{ type: Input }],
2182
- Precision: [{ type: Input }],
2183
- Alignment: [{ type: Input }],
2184
- SearchFunction: [{ type: Input }],
2185
- MinChars: [{ type: Input }],
2186
- CaseSensitive: [{ type: Input }]
2187
- };
2188
-
2189
- // Angular
2190
- /**
2191
- * Componente placeholder per la creazione dei form che rappresenta un blocchetto vuoto,
2192
- * al posto del quale possono poi comparire dei componenti form senza incasinare la grafica
2193
- */
2194
- class FormEmptyComponent {
2195
- constructor() {
2196
- /**
2197
- * Indica se è l'ultimo componente di un form (serve per rimuovere il margine finale)
2198
- */
2199
- this.Last = false;
2200
- /**
2201
- * Classe extra per il form-group in cui viene wrappato l'input finto
2202
- */
2203
- this.FormGroupClass = "";
2204
- /**
2205
- * Valore placeholder da mostrare
2206
- */
2207
- this.PlaceholderModel = "Placeholder";
2208
- }
2209
- }
2210
- FormEmptyComponent.decorators = [
2211
- { type: Component, args: [{
2212
- selector: "form-empty",
2213
- template: "<div class=\"form-group row app-hidden-view {{FormGroupClass}}\" [class.app-margin-bottom-0]=\"Last\">\r\n <label class=\"col-md-4 m-t-5\">Placeholder:</label>\r\n <div class=\"col-md-8\">\r\n <val-input type=\"text\" [(ngModel)]=\"PlaceholderModel\" [ngModelOptions]=\"{standalone: true}\"></val-input>\r\n </div>\r\n <div class=\"clearfix\"></div>\r\n</div>",
2214
- changeDetection: ChangeDetectionStrategy.OnPush
2215
- },] }
2216
- ];
2217
- FormEmptyComponent.propDecorators = {
2218
- Last: [{ type: Input }],
2219
- FormGroupClass: [{ type: Input }]
2220
- };
2221
-
2222
- // Angular
2223
- /**
2224
- * Componente da utilizzare quando l'implementazione dell'input non è disponibile nella libreria,
2225
- * fornisce la struttura standard di un form-component ma l'input vero e proprio viene proiettato dall'esterno
2226
- */
2227
- class FormTemplateComponent {
2228
- constructor() {
2229
- /**
2230
- * Indica se l'input è obbligatorio o no
2231
- */
2232
- this.Required = false;
2233
- /**
2234
- * Mostra un testo a sinistra dell'input, **FormLayout** permettendo
2235
- */
2236
- this.Label = "";
2237
- /**
2238
- * Utilizza o meno il Layout di un form (Label con input di fianco), se false mostra solo l'input
2239
- */
2240
- this.FormLayout = true;
2241
- /**
2242
- * col-md-X per la label
2243
- */
2244
- this.LabelColWidth = 4;
2245
- /**
2246
- * col-md-X per l'input
2247
- */
2248
- this.InputColWidth = 8;
2249
- /**
2250
- * Indica se è l'ultimo componente di un form (serve per rimuovere il margine finale)
2251
- */
2252
- this.Last = false;
2253
- /**
2254
- * Classe extra per il form-group in cui viene wrappato l'input
2255
- */
2256
- this.FormGroupClass = "";
2257
- }
2258
- /**
2259
- * Permette di settare in una volta solo gli input LabelColWidth e InputColWidth, basta scriverlo con la sintassi "X Y"
2260
- */
2261
- set LabelInputRatio(input) {
2262
- var ratio = input.split(/\s/);
2263
- this.LabelColWidth = parseInt(ratio[0]);
2264
- this.InputColWidth = parseInt(ratio[1]);
2265
- }
2266
- }
2267
- FormTemplateComponent.decorators = [
2268
- { type: Component, args: [{
2269
- selector: "form-template",
2270
- template: "<ng-container *ngIf=\"!FormLayout\">\r\n <ng-content></ng-content>\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-content></ng-content>\r\n </div>\r\n <div class=\"clearfix\"></div>\r\n</div>",
2271
- changeDetection: ChangeDetectionStrategy.OnPush
2272
- },] }
2273
- ];
2274
- FormTemplateComponent.propDecorators = {
2275
- Required: [{ type: Input }],
2276
- Label: [{ type: Input }],
2277
- FormLayout: [{ type: Input }],
2278
- LabelColWidth: [{ type: Input }],
2279
- InputColWidth: [{ type: Input }],
2280
- Last: [{ type: Input }],
2281
- FormGroupClass: [{ type: Input }],
2282
- LabelInputRatio: [{ type: Input }]
2283
- };
2284
-
2285
- // Angular
2286
- /**
2287
- * Componente placeholder per la creazione dei form che rappresenta un blocchetto di erorre,
2288
- * al posto del quale possono poi comparire dei componenti form senza incasinare la grafica
2289
- */
2290
- class FormErrorComponent {
2291
- constructor() {
2292
- /**
2293
- * col-md-X per la label (Che in questoc aso è vuota)
2294
- */
2295
- this.LabelColWidth = 4;
2296
- /**
2297
- * col-md-X per l'input (che in questo caso contiene il messaggio d'errore proiettato nell'HTML)
2298
- */
2299
- this.InputColWidth = 8;
2300
- /**
2301
- * Indica se è l'ultimo componente di un form (serve per rimuovere il margine finale)
2302
- */
2303
- this.Last = false;
2304
- /**
2305
- * Classe extra per il form-group in cui viene wrappato l'input
2306
- */
2307
- this.FormGroupClass = "";
2308
- }
2309
- /**
2310
- * Permette di settare in una volta solo gli input LabelColWidth e InputColWidth, basta scriverlo con la sintassi "X Y"
2311
- */
2312
- set LabelInputRatio(input) {
2313
- var ratio = input.split(/\s/);
2314
- this.LabelColWidth = parseInt(ratio[0]);
2315
- this.InputColWidth = parseInt(ratio[1]);
2316
- }
2317
- }
2318
- FormErrorComponent.decorators = [
2319
- { type: Component, args: [{
2320
- selector: "form-error",
2321
- template: "<div class=\"form-group row {{FormGroupClass}}\" [class.app-margin-bottom-0]=\"Last\">\r\n <label class=\"app-hidden-view col-md-{{LabelColWidth}} m-t-5\"></label>\r\n <span class=\"help-block text-danger col-md-{{InputColWidth}}\">\r\n <ng-content></ng-content>\r\n </span>\r\n <div class=\"clearfix\"></div>\r\n</div>",
2322
- changeDetection: ChangeDetectionStrategy.OnPush
2323
- },] }
2324
- ];
2325
- FormErrorComponent.propDecorators = {
2326
- LabelColWidth: [{ type: Input }],
2327
- InputColWidth: [{ type: Input }],
2328
- Last: [{ type: Input }],
2329
- FormGroupClass: [{ type: Input }],
2330
- LabelInputRatio: [{ type: Input }]
2331
- };
2332
-
2333
- // Angular
2334
- /**
2335
- * Componente placeholder per la creazione dei form che rappresenta un blocchetto di informazioni,
2336
- * al posto del quale possono poi comparire dei componenti form senza incasinare la grafica
2337
- */
2338
- class FormInfoComponent {
2339
- constructor() {
2340
- /**
2341
- * col-md-X per la label (Che in questoc aso è vuota)
2342
- */
2343
- this.LabelColWidth = 4;
2344
- /**
2345
- * col-md-X per l'input (che in questo caso contiene il messaggio d'errore proiettato nell'HTML)
2346
- */
2347
- this.InputColWidth = 8;
2348
- /**
2349
- * Indica se è l'ultimo componente di un form (serve per rimuovere il margine finale)
2350
- */
2351
- this.Last = false;
2352
- /**
2353
- * Classe extra per il form-group in cui viene wrappato l'input
2354
- */
2355
- this.FormGroupClass = "";
2356
- }
2357
- /**
2358
- * Permette di settare in una volta solo gli input LabelColWidth e InputColWidth, basta scriverlo con la sintassi "X Y"
2359
- */
2360
- set LabelInputRatio(input) {
2361
- var ratio = input.split(/\s/);
2362
- this.LabelColWidth = parseInt(ratio[0]);
2363
- this.InputColWidth = parseInt(ratio[1]);
2364
- }
2365
- }
2366
- FormInfoComponent.decorators = [
2367
- { type: Component, args: [{
2368
- selector: "form-info",
2369
- template: "<div class=\"form-group row {{FormGroupClass}}\" [class.app-margin-bottom-0]=\"Last\">\r\n <label class=\"app-hidden-view col-md-{{LabelColWidth}} m-t-5\"></label>\r\n <span class=\"help-block col-md-{{InputColWidth}}\">\r\n <ng-content></ng-content>\r\n </span>\r\n <div class=\"clearfix\"></div>\r\n</div>",
2370
- changeDetection: ChangeDetectionStrategy.OnPush
2371
- },] }
2372
- ];
2373
- FormInfoComponent.propDecorators = {
2374
- LabelColWidth: [{ type: Input }],
2375
- InputColWidth: [{ type: Input }],
2376
- Last: [{ type: Input }],
2377
- FormGroupClass: [{ type: Input }],
2378
- LabelInputRatio: [{ type: Input }]
2379
- };
2380
-
2381
- // Angular
2382
- /**
2383
- * Componente rappresentante una checkbox
2384
- */
2385
- class FormCheckboxComponent extends BaseFormControl {
2386
- /**
2387
- * Costruttore
2388
- *
2389
- * @ignore
2390
- */
2391
- constructor(cdr, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY) {
2392
- super(cdr, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY, true);
2393
- }
2394
- /**
2395
- * @ignore
2396
- */
2397
- onNotNullValueSet() { }
2398
- }
2399
- FormCheckboxComponent.decorators = [
2400
- { type: Component, args: [{
2401
- selector: "form-checkbox",
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}} m-t-5\">\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 <input class=\"app-pointer\" [disabled]=\"Readonly ? true : null\" type=\"checkbox\" [(ngModel)]=\"Model\" name=\"{{GeneratedName}}\" #validationControl=\"ngModel\" (ngModelChange)=\"changed();\" />\r\n</ng-template>",
2403
- changeDetection: ChangeDetectionStrategy.OnPush
2404
- },] }
2405
- ];
2406
- FormCheckboxComponent.ctorParameters = () => [
2407
- { type: ChangeDetectorRef },
2408
- { type: NgControl, decorators: [{ type: Optional }, { type: Self }] },
2409
- { type: Array, decorators: [{ type: Optional }, { type: Host }, { type: Inject, args: [NG_VALIDATORS,] }] },
2410
- { type: AccessControlService },
2411
- { type: ComponentContext, decorators: [{ type: Optional }] },
2412
- { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ACO_CUSTOMKEY,] }] }
2413
- ];
2414
-
2415
- // Angular
2416
- /**
2417
- * Componente che dà all'utente la possibilità di selezionare una data
2418
- */
2419
- class FormDateComponent extends BaseFormControl {
2420
- /**
2421
- * Costruttore
2422
- *
2423
- * @ignore
2424
- */
2425
- constructor(cdr, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY) {
2426
- super(cdr, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY);
2427
- /**
2428
- * Utilizza il Date di Javascript come modello in uscita. Il modello in entrata verrà comunque ricondotto a un DayJs
2429
- */
2430
- this.JsDates = false;
2431
- }
2432
- /**
2433
- * @ignore
2434
- */
2435
- onNotNullValueSet() { }
2436
- }
2437
- FormDateComponent.decorators = [
2438
- { type: Component, args: [{
2439
- selector: "form-date",
2440
- 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 <val-date [noValidate]=\"!Validation\"\r\n [submitted]=\"Form?.submitted\"\r\n [forceInvalid]=\"ForcedError\"\r\n [readonly]=\"Readonly\"\r\n [class]=\"Readonly ? 'app-bg-lightgrey' : ''\"\r\n [useJsDates]=\"JsDates\"\r\n [(ngModel)]=\"Model\"\r\n name=\"{{GeneratedName}}\"\r\n #validationControl=\"ngModel\"\r\n (inputChange)=\"changed();\"\r\n [placeholder]=\"Placeholder\"\r\n [validationFailed]=\"FailedValidationMessage\">\r\n </val-date>\r\n</ng-template>",
2441
- changeDetection: ChangeDetectionStrategy.OnPush
2442
- },] }
2443
- ];
2444
- FormDateComponent.ctorParameters = () => [
2445
- { type: ChangeDetectorRef },
2446
- { type: NgControl, decorators: [{ type: Optional }, { type: Self }] },
2447
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_VALIDATORS,] }] },
2448
- { type: AccessControlService, decorators: [{ type: Optional }] },
2449
- { type: ComponentContext, decorators: [{ type: Optional }] },
2450
- { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ACO_CUSTOMKEY,] }] }
2451
- ];
2452
- FormDateComponent.propDecorators = {
2453
- JsDates: [{ type: Input }]
2454
- };
2455
-
2456
- // Angular
2457
- /**
2458
- * Semplice componente di Input testuale, con eventuale prefisso/suffisso
2459
- */
2460
- class FormInputComponent extends BaseFormControl {
2461
- /**
2462
- * Costruttore
2463
- *
2464
- * @ignore
2465
- */
2466
- constructor(cdr, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY) {
2467
- super(cdr, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY);
2468
- /**
2469
- * Indica se l'input relativo è di tipo Password
2470
- */
2471
- this.Password = false;
2472
- /**
2473
- * Delegato per l'esecuzione di un'operazione al click del suffisso
2474
- */
2475
- this.onSuffixAction = new EventEmitter();
2476
- /**
2477
- * Delegato per l'esecuzione di un'operazione al click del prefisso
2478
- */
2479
- this.onPrefixAction = new EventEmitter();
2480
- /**
2481
- * Indica la presenza o meno di un suffisso, si basa sulla "truthiness" della proiezione **suffix**
2482
- */
2483
- this.HasSuffix = false;
2484
- /**
2485
- * Indica la presenza o meno di un prefisso, si basa sulla "truthiness" della proiezione **prefix**
2486
- */
2487
- this.HasPrefix = false;
2488
- }
2489
- /**
2490
- * @ignore
2491
- */
2492
- ngAfterContentInit() {
2493
- this.HasSuffix = !!this.suffix;
2494
- this.HasPrefix = !!this.prefix;
2495
- }
2496
- /**
2497
- * @ignore
2498
- */
2499
- onNotNullValueSet() { }
2500
- }
2501
- FormInputComponent.decorators = [
2502
- { type: Component, args: [{
2503
- selector: "form-input",
2504
- 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 <val-input [noValidate]=\"!Validation\"\r\n [submitted]=\"Form?.submitted\"\r\n [readonly]=\"Readonly\"\r\n [forceInvalid]=\"ForcedError\"\r\n type=\"text\"\r\n [(ngModel)]=\"Model\"\r\n name=\"{{GeneratedName}}\"\r\n autocomplete=\"off\"\r\n #validationControl=\"ngModel\"\r\n (inputChange)=\"changed();\"\r\n [placeholder]=\"Placeholder\"\r\n [validationFailed]=\"FailedValidationMessage\"\r\n [Password]=\"Password\">\r\n <ng-container *ngIf=\"HasSuffix\">\r\n <ng-template #suffix_internal>\r\n <button type=\"button\" class=\"mat-button mat-icon-button mat-button-base mat-icon-button-override mat-icon-button-override-suffix\"\r\n matSuffix (click)=\"onSuffixAction.emit(); $event.stopPropagation(); $event.preventDefault();\">\r\n <ng-container *ngTemplateOutlet=\"suffix\"></ng-container>\r\n </button>\r\n </ng-template>\r\n </ng-container>\r\n <ng-container *ngIf=\"HasPrefix\">\r\n <ng-template #prefix_internal>\r\n <button type=\"button\" class=\"mat-button mat-icon-button mat-button-base mat-icon-button-override mat-icon-button-override-prefix\"\r\n matPrefix (click)=\"onPrefixAction.emit(); $event.stopPropagation(); $event.preventDefault();\">\r\n <ng-container *ngTemplateOutlet=\"prefix\"></ng-container>\r\n </button>\r\n </ng-template>\r\n </ng-container>\r\n </val-input>\r\n</ng-template>",
2505
- changeDetection: ChangeDetectionStrategy.OnPush
2506
- },] }
2507
- ];
2508
- FormInputComponent.ctorParameters = () => [
2509
- { type: ChangeDetectorRef },
2510
- { type: NgControl, decorators: [{ type: Optional }, { type: Self }] },
2511
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_VALIDATORS,] }] },
2512
- { type: AccessControlService, decorators: [{ type: Optional }] },
2513
- { type: ComponentContext, decorators: [{ type: Optional }] },
2514
- { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ACO_CUSTOMKEY,] }] }
2515
- ];
2516
- FormInputComponent.propDecorators = {
2517
- Password: [{ type: Input }],
2518
- onSuffixAction: [{ type: Output }],
2519
- onPrefixAction: [{ type: Output }],
2520
- suffix: [{ type: ContentChild, args: ["suffix", { static: false },] }],
2521
- prefix: [{ type: ContentChild, args: ["prefix", { static: false },] }]
2522
- };
2523
-
2524
- /**
2525
- * Classe di localizzazione per il componente **FormSelectComponent**
2526
- */
2527
- class FormSelectComponentLoc extends LocalizationService {
2528
- /**
2529
- * @ignore
2530
- */
2531
- constructor(LOC_LOCALE) {
2532
- super(LOC_LOCALE !== null && LOC_LOCALE !== void 0 ? LOC_LOCALE : 'it-IT');
2533
- }
2534
- }
2535
- FormSelectComponentLoc.decorators = [
2536
- { type: Injectable }
2537
- ];
2538
- FormSelectComponentLoc.ctorParameters = () => [
2539
- { type: String, decorators: [{ type: Optional }, { type: Inject, args: [FAV_LOCALE,] }] }
2540
- ];
2541
-
2542
- // Angular
2543
- /**
2544
- * Componente che permette di selezionare un valore da una lista di valori disponibili
2545
- */
2546
- class FormSelectComponent extends BaseFormControl {
2547
- /**
2548
- * Costruttore
2549
- *
2550
- * @ignore
2551
- */
2552
- constructor(cdr, lc, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY) {
2553
- super(cdr, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY);
2554
- this.lc = lc;
2555
- /**
2556
- * Permette di specificare il testo della Label flottante material-style
2557
- */
2558
- this.SelectLabel = "";
2559
- /**
2560
- * Permette al componente di considerare questo valore come "valore placeholder"
2561
- *
2562
- * Si consiglia di mantenere il default
2563
- */
2564
- this.PlaceholderValue = '';
2565
- /**
2566
- * Override del placeholder per select requried
2567
- */
2568
- this.RequiredPlaceholder = null;
2569
- /**
2570
- * Permette al componente di considerare questo valore come "valore vuoto"
2571
- *
2572
- * Si consiglia di mantenere il default
2573
- */
2574
- this.EmptyFieldValue = '-2';
2575
- /**
2576
- * Se **true** rimuove il simbolino di validazione (croce rossa o tick verde)
2577
- */
2578
- this.ShowValidationSymbol = true;
2579
- }
2580
- /**
2581
- * @ignore
2582
- */
2583
- ngOnChanges(changes) {
2584
- let newSource = changes["Source"];
2585
- if (!newSource)
2586
- return;
2587
- let curr = newSource.currentValue;
2588
- let prev = newSource.previousValue;
2589
- // Se manca curr vuol dire che non ho un valore e posso ignorare (alla peggio deve arrivarmi un array vuoto)
2590
- if (!curr)
2591
- return;
2592
- // Se manca prev vuol dire che è la prima assegnazione, lo considero un array vuoto e proseguo... ogni tanto viene chiamato una sola volta
2593
- // ogni tanto viene chiamato due volte... è un pelo arbitrario ma vabbè
2594
- if (!prev)
2595
- prev = [];
2596
- // Considero di aver ricevuto una nuova sorgente se:
2597
- // 1: La sorgente nuova ha un numero di elementi diverso dalla sorgente vecchia
2598
- // 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
2599
- if (newSource && (curr.length != prev.length || (curr.length > 0 && curr[0][this.IdField] != prev[0][this.IdField]))) {
2600
- /*
2601
- * NGBUG:
2602
- * Uso questo escamotage per distruggere il val-select e ricrearlo
2603
- * Purtroppo una volta bindato a una sorgente, cambiargliela sotto significa mandare in palla material
2604
- * che si mette a far floattare la label anche se il valore e' vuoto
2605
- * Distruggendo il componente e ricreandolo material riparte da 0 e non da' problemi.
2606
- * Ovviamente lo faccio solo quando ho una SelectLabel, altrimenti non ho problemi di floattamenti
2607
- */
2608
- if (!this.SourceFirstBind && this.SelectLabel) {
2609
- this.BoundSource = null;
2610
- setTimeout(() => { this.tryBindSourceDisplay(); this.cdr.detectChanges(); });
2611
- }
2612
- else
2613
- this.tryBindSourceDisplay();
2614
- this.cdr.markForCheck();
2615
- }
2616
- }
2617
- /**
2618
- * @ignore
2619
- */
2620
- onNotNullValueSet() { }
2621
- }
2622
- FormSelectComponent.decorators = [
2623
- { type: Component, args: [{
2624
- selector: "form-select",
2625
- providers: [{ provide: LocalizationService, useClass: FormSelectComponentLoc }],
2626
- template: "<ng-container *ngIf=\"!FormLayout\">\r\n <ng-container *ngTemplateOutlet=\"controlTemplate\"></ng-container>\r\n</ng-container>\r\n\r\n<div *ngIf=\"FormLayout && BoundSource\" 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\r\n <!-- Select vuota per quando non ho Sorgenti dati da cui selezionare. Uguale identica alla piena ma senza option\r\n Purtroppo devono essere due componenti distinti perch\u00E9 una select una volta creata non riesce pi\u00F9 ad adattarsi ai cambi di options -->\r\n <val-select *ngIf=\"!BoundSource || BoundSource.length == 0\"\r\n [required]=\"Required ? 'required' : null\"\r\n [noValidate]=\"!Validation\"\r\n [readonly]=\"Readonly\"\r\n [forceInvalid]=\"ForcedError\"\r\n [label]=\"SelectLabel\"\r\n [validationFailed]=\"FailedValidationMessage\"\r\n [placeholder]=\"Required ? ((RequiredPlaceholder != null ? RequiredPlaceholder : ('Select' | localize : lc) + '...')) : Placeholder\"\r\n [placeHolderValue]=\"PlaceholderValue\"\r\n [submitted]=\"Form?.submitted\"\r\n [emptyFieldValue]=\"Required || Placeholder || SelectLabel ? EmptyFieldValue : ''\"\r\n [(ngModel)]=\"Model\"\r\n [showValidationSymbol]=\"ShowValidationSymbol\"\r\n name=\"{{GeneratedName}}\"\r\n (inputChange)=\"Model = $event == EmptyFieldValue ? (Required? PlaceholderValue : '') : $event; changed();\"\r\n #validationControl=\"ngModel\">\r\n </val-select>\r\n\r\n <!-- Select vera e propria per quando arrivano i dati -->\r\n <val-select *ngIf=\"BoundSource && BoundSource.length > 0\"\r\n [required]=\"Required ? 'required' : null\"\r\n [noValidate]=\"!Validation\"\r\n [readonly]=\"Readonly\"\r\n [forceInvalid]=\"ForcedError\"\r\n [label]=\"SelectLabel\"\r\n [validationFailed]=\"FailedValidationMessage\"\r\n [showValidationSymbol]=\"ShowValidationSymbol\"\r\n [placeholder]=\"Required ? ((RequiredPlaceholder != null ? RequiredPlaceholder : ('Select' | localize : lc) + '...')) : Placeholder\"\r\n [placeHolderValue]=\"PlaceholderValue\"\r\n [submitted]=\"Form?.submitted\"\r\n [emptyFieldValue]=\"Required || Placeholder || SelectLabel ? EmptyFieldValue : ''\"\r\n [(ngModel)]=\"Model\"\r\n name=\"{{GeneratedName}}\"\r\n (inputChange)=\"Model = $event == EmptyFieldValue ? (Required? PlaceholderValue : '') : $event; changed();\"\r\n #validationControl=\"ngModel\">\r\n <option *ngFor=\"let obj of BoundSource\" [value]=\"obj.id\">{{obj.description}}</option>\r\n </val-select>\r\n</ng-template>",
2627
- changeDetection: ChangeDetectionStrategy.OnPush
2628
- },] }
2629
- ];
2630
- FormSelectComponent.ctorParameters = () => [
2631
- { type: ChangeDetectorRef },
2632
- { type: LocalizationService },
2633
- { type: NgControl, decorators: [{ type: Optional }, { type: Self }] },
2634
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_VALIDATORS,] }] },
2635
- { type: AccessControlService, decorators: [{ type: Optional }] },
2636
- { type: ComponentContext, decorators: [{ type: Optional }] },
2637
- { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ACO_CUSTOMKEY,] }] }
2638
- ];
2639
- FormSelectComponent.propDecorators = {
2640
- SelectLabel: [{ type: Input }],
2641
- PlaceholderValue: [{ type: Input }],
2642
- RequiredPlaceholder: [{ type: Input }],
2643
- EmptyFieldValue: [{ type: Input }],
2644
- ShowValidationSymbol: [{ type: Input }]
2645
- };
2646
-
2647
- /**
2648
- * Classe di localizzazione per il componente **FormMultiSelectComponent**
2649
- */
2650
- class FormMultiSelectComponentLoc extends LocalizationService {
2651
- /**
2652
- * @ignore
2653
- */
2654
- constructor(LOC_LOCALE) {
2655
- super(LOC_LOCALE !== null && LOC_LOCALE !== void 0 ? LOC_LOCALE : 'it-IT');
2656
- super.set("en->it", "Select everything", ["Seleziona tutto"]);
2657
- super.set("en->it", "Deselect everything", ["Deseleziona tutto"]);
2658
- super.set("en->it", "Select one or more values...", ["Seleziona uno o più valori..."]);
2659
- }
2660
- }
2661
- FormMultiSelectComponentLoc.decorators = [
2662
- { type: Injectable }
2663
- ];
2664
- FormMultiSelectComponentLoc.ctorParameters = () => [
2665
- { type: String, decorators: [{ type: Optional }, { type: Inject, args: [FAV_LOCALE,] }] }
2666
- ];
2667
-
2668
- /**
2669
- * Componente che permette di effettuare una selezione multipla fra gli oggetti passati nell'Input **Source**
2670
- *
2671
- * N.B: Al contrario degli altri componenti form-* questo viene tenuto con **changeDetection: ChangeDetectionStrategy.Default** in quanto il componente
2672
- * utilizzato internamente (angular2-multiselect) non è stato assolutamente pensato per essere usato con **ChangeDetectionStrategy.OnPush**
2673
- */
2674
- class FormMultiSelectComponent extends BaseFormControl {
2675
- /**
2676
- * Costruttore
2677
- *
2678
- * @ignore
2679
- */
2680
- constructor(cdr, lc, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY) {
2681
- super(cdr, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY);
2682
- this.lc = lc;
2683
- /**
2684
- * Modello temporaneo **NON** compatibile in maniera diretta con il componente **angular2-multiselect** usato internamente
2685
- *
2686
- * Serve da appoggio per effettuare un re-bind qualora la sorgente cambiasse e qualora **RebindModelAfterSource** fosse true
2687
- */
2688
- this.TmpModel = [];
2689
- /**
2690
- * Indica se la prossima modifica alla Source deve anche effettuare un re-bind del modello. Serve se la **BoundSource** passa da non avere oggetti ad averne
2691
- */
2692
- this.RebindModelAfterSource = false;
2693
- /**
2694
- * Permette di specificare il testo della Label flottante material-style
2695
- */
2696
- this.SelectLabel = "";
2697
- /**
2698
- * Permette al componente di gestire come modello non una lista di chiavi, ma una lista di KeyValue
2699
- */
2700
- this.UseKeyValues = false;
2701
- /**
2702
- * Impostazioni del componente interno **angular2-multiselect**
2703
- */
2704
- this.Settings = null;
2705
- // Default dei settings per evitare che siano mai nulli, altrimenti il cazzo di CuppaLab salta in araia che è veramente una bellezza
2706
- this.evaluateSettings(false);
2707
- }
2708
- /**
2709
- * @ignore
2710
- */
2711
- ngOnChanges(changes) {
2712
- var _a, _b;
2713
- return __awaiter(this, void 0, void 0, function* () {
2714
- const newSource = changes["Source"];
2715
- if (newSource) {
2716
- this.tryBindSourceDisplay();
2717
- if (this.RebindModelAfterSource) {
2718
- this.writeValue(this.TmpModel);
2719
- this.RebindModelAfterSource = false;
2720
- }
2721
- }
2722
- const readonly = changes["Readonly"];
2723
- this.evaluateSettings(readonly ? (_a = readonly.currentValue) !== null && _a !== void 0 ? _a : false : (_b = this.Readonly) !== null && _b !== void 0 ? _b : false);
2724
- });
2725
- }
2726
- /**
2727
- * Scrive i nuovi settings per il componente
2728
- *
2729
- * @param {boolean} disabled Indica se il componente dev'essere disabilitato o meno
2730
- */
2731
- evaluateSettings(disabled) {
2732
- this.Settings = {
2733
- selectAllText: this.lc.loc("Select everything"),
2734
- unSelectAllText: this.lc.loc("Deselect everything"),
2735
- text: this.SelectLabel || this.lc.loc("Select one or more values..."),
2736
- enableCheckAll: true,
2737
- disabled: disabled,
2738
- labelKey: "description"
2739
- };
2740
- }
2741
- /**
2742
- * @ignore
2743
- */
2744
- onNotNullValueSet() { }
2745
- /**
2746
- * Indica se il comopnente in questione è in grado di gestire ngControl nulli.
2747
- * In questo componente è normale che sia così quindi restituisce semplicemente **true**
2748
- *
2749
- * @returns {boolean} **true** se gestisco ngControl nulli, **false** altrimenti
2750
- */
2751
- handleNullNgControl() {
2752
- return true;
2753
- }
2754
- /**
2755
- * @ignore Override per gestire input in ingresso
2756
- */
2757
- writeValue(obj) {
2758
- this.TmpModel = obj;
2759
- let toPass = [];
2760
- //Qui arrivano solo gli id, o {id: x, description: y} in caso sono in UseKeyValues,
2761
- //devo tirare fuori gli oggetti relativi e piazzarli come lista per il Model
2762
- if (obj && obj.length > 0) {
2763
- obj.forEach(t => {
2764
- let item = this.BoundSource.find(o => o.id == (this.UseKeyValues ? t.id : t));
2765
- if (item)
2766
- toPass.push(JSON.parse(JSON.stringify(item)));
2767
- else if (!this.BoundSource || this.BoundSource.length == 0)
2768
- this.RebindModelAfterSource = true;
2769
- });
2770
- }
2771
- super.writeValue(toPass);
2772
- }
2773
- /**
2774
- * @ignore Override per gestire input in uscita
2775
- */
2776
- changed() {
2777
- let toEmit = null;
2778
- if (!this.UseKeyValues)
2779
- toEmit = this.Model.map(m => m.id);
2780
- else
2781
- toEmit = this.Model.map(m => ({ id: m.id, description: m.itemName }));
2782
- super.changed(toEmit);
2783
- }
2784
- }
2785
- FormMultiSelectComponent.decorators = [
2786
- { type: Component, args: [{
2787
- selector: "form-multiselect",
2788
- viewProviders: [{ provide: LocalizationService, useClass: FormMultiSelectComponentLoc }],
2789
- template: "<ng-container *ngIf=\"!FormLayout\">\r\n <ng-container *ngTemplateOutlet=\"controlTemplate\"></ng-container>\r\n</ng-container>\r\n\r\n<div *ngIf=\"FormLayout && BoundSource\" 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 [class.ms-placeholder]=\"!Model || Model.length == 0\">\r\n <angular2-multiselect #validationControl=\"ngModel\" type=\"text\"\r\n [(ngModel)]=\"Model\" name=\"{{GeneratedName}}\"\r\n [settings]=\"Settings\" [data]=\"BoundSource\"\r\n (onSelect)=\"changed();\" \r\n (onDeSelect)=\"changed();\" \r\n (onSelectAll)=\"changed();\"\r\n (onDeSelectAll)=\"changed();\" \r\n (onDeSelectAll)=\"Model = []; changed();\">\r\n </angular2-multiselect>\r\n </div>\r\n</ng-template>",
2790
- encapsulation: ViewEncapsulation.None,
2791
- changeDetection: ChangeDetectionStrategy.Default,
2792
- styles: [".c-btn{background:#fff;border:1px solid #ccc;color:#333}.selected-list .c-list .c-token{background:#415269}.selected-list .c-list .c-token .c-label{color:#fff}.selected-list .c-list .c-token .c-remove svg{fill:#fff}.selected-list .c-angle-down svg,.selected-list .c-angle-up svg{fill:#333}.dropdown-list ul li:hover{background:#f5f5f5}.arrow-up,.arrow-down{border-bottom:15px solid #fff}.arrow-2{border-bottom:15px solid #ccc}.list-area{border:1px solid #ccc;background:#fff;box-shadow:0 1px 5px #959595}.select-all{border-bottom:1px solid #ccc}.list-filter{border-bottom:1px solid #ccc}.list-filter .c-search svg{fill:#888}.list-filter .c-clear svg{fill:#888}.pure-checkbox input[type=checkbox]:focus+label:before,.pure-checkbox input[type=checkbox]:hover+label:before{border-color:#415269;background-color:#f2f2f2}.pure-checkbox input[type=checkbox]+label{color:#000}.pure-checkbox input[type=checkbox]+label:before{color:#415269;border:1px solid #415269}.pure-checkbox input[type=checkbox]+label:after{background-color:#415269}.pure-checkbox input[type=checkbox]:disabled+label:before{border-color:#ccc}.pure-checkbox input[type=checkbox]:disabled:checked+label:before{background-color:#ccc}.pure-checkbox input[type=checkbox]+label:after{border-color:#fff}.pure-checkbox input[type=radio]:checked+label:before{background-color:#fff}.pure-checkbox input[type=checkbox]:checked+label:before{background:#415269}.single-select-mode .pure-checkbox input[type=checkbox]:focus+label:before,.single-select-mode .pure-checkbox input[type=checkbox]:hover+label:before{border-color:#415269;background-color:#f2f2f2}.single-select-mode .pure-checkbox input[type=checkbox]+label{color:#000}.single-select-mode .pure-checkbox input[type=checkbox]+label:before{color:transparent!important;border:0px solid #415269}.single-select-mode .pure-checkbox input[type=checkbox]+label:after{background-color:transparent!important}.single-select-mode .pure-checkbox input[type=checkbox]:disabled+label:before{border-color:#ccc}.single-select-mode .pure-checkbox input[type=checkbox]:disabled:checked+label:before{background-color:#ccc}.single-select-mode .pure-checkbox input[type=checkbox]+label:after{border-color:#415269}.single-select-mode .pure-checkbox input[type=radio]:checked+label:before{background-color:#fff}.single-select-mode .pure-checkbox input[type=checkbox]:checked+label:before{background:none!important}.selected-item{background:#e9f4ff}.btn-iceblue{background:#415269;border:1px solid #ccc;color:#fff}.cuppa-dropdown{margin-top:2px;min-width:200px}.cuppa-dropdown .c-btn{min-height:34px}.cuppa-dropdown .c-angle-down{margin-top:-2px}.cuppa-dropdown .c-angle-up{margin-top:-2px}.selected-list .c-list{width:auto!important;padding-right:35px!important;margin-top:-2px!important}.selected-list .c-list .c-token{padding:3px 22px 3px 8px!important}.ms-placeholder .cuppa-dropdown .selected-list>div>span{color:#aaa}\n"]
2793
- },] }
2794
- ];
2795
- FormMultiSelectComponent.ctorParameters = () => [
2796
- { type: ChangeDetectorRef },
2797
- { type: LocalizationService },
2798
- { type: NgControl, decorators: [{ type: Optional }, { type: Self }] },
2799
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_VALIDATORS,] }] },
2800
- { type: AccessControlService, decorators: [{ type: Optional }] },
2801
- { type: ComponentContext, decorators: [{ type: Optional }] },
2802
- { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ACO_CUSTOMKEY,] }] }
2803
- ];
2804
- FormMultiSelectComponent.propDecorators = {
2805
- SelectLabel: [{ type: Input }],
2806
- UseKeyValues: [{ type: Input }]
2807
- };
2808
-
2809
- // Angular
2810
- /**
2811
- * Componente che presenta una casella di testo tipicamente utilizzata per scrivere delle note o del log breve
2812
- */
2813
- class FormTextareaComponent extends BaseFormControl {
2814
- /**
2815
- * Costruttore
2816
- *
2817
- * @ignore
2818
- */
2819
- constructor(cdr, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY) {
2820
- super(cdr, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY);
2821
- }
2822
- /**
2823
- * @ignore
2824
- */
2825
- onNotNullValueSet() { }
2826
- }
2827
- FormTextareaComponent.decorators = [
2828
- { type: Component, args: [{
2829
- selector: "form-textarea",
2830
- template: "<div 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 <val-textarea [noValidate]=\"!Validation\"\r\n [submitted]=\"Form?.submitted\"\r\n [forceInvalid]=\"ForcedError\"\r\n [rows]=\"Rows\"\r\n [readonly]=\"Readonly\"\r\n [class]=\"Readonly ? 'app-bg-lightgrey app-no-resize' : 'app-no-resize'\"\r\n [(ngModel)]=\"Model\"\r\n name=\"{{GeneratedName}}\"\r\n autocomplete=\"off\"\r\n [placeholder]=\"Placeholder\"\r\n [validationFailed]=\"FailedValidationMessage\"\r\n #validationControl=\"ngModel\"\r\n (inputChange)=\"changed();\">\r\n </val-textarea>\r\n </div>\r\n <div class=\"clearfix\"></div>\r\n</div>",
2831
- changeDetection: ChangeDetectionStrategy.OnPush
2832
- },] }
2833
- ];
2834
- FormTextareaComponent.ctorParameters = () => [
2835
- { type: ChangeDetectorRef },
2836
- { type: NgControl, decorators: [{ type: Optional }, { type: Self }] },
2837
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_VALIDATORS,] }] },
2838
- { type: AccessControlService, decorators: [{ type: Optional }] },
2839
- { type: ComponentContext, decorators: [{ type: Optional }] },
2840
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [ACO_CUSTOMKEY,] }] }
2841
- ];
2842
- FormTextareaComponent.propDecorators = {
2843
- Rows: [{ type: Input }]
2844
- };
2845
-
2846
- /**
2847
- * Classe di localizzazione per il componente **FormAutocompleteComponent**
2848
- */
2849
- class FormAutocompleteComponentLoc extends LocalizationService {
2850
- /**
2851
- * @ignore
2852
- */
2853
- constructor(LOC_LOCALE) {
2854
- super(LOC_LOCALE !== null && LOC_LOCALE !== void 0 ? LOC_LOCALE : 'it-IT');
2855
- }
2856
- }
2857
- FormAutocompleteComponentLoc.decorators = [
2858
- { type: Injectable }
2859
- ];
2860
- FormAutocompleteComponentLoc.ctorParameters = () => [
2861
- { type: String, decorators: [{ type: Optional }, { type: Inject, args: [FAV_LOCALE,] }] }
2862
- ];
2863
-
2864
- // Angular
2865
- /**
2866
- * Componente di input che si auto-completa in base al valore attuale
2867
- */
2868
- class FormAutocompleteComponent extends BaseFormControl {
2869
- /**
2870
- * Costruttore
2871
- *
2872
- * @ignore
2873
- */
2874
- constructor(cdr, lc, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY) {
2875
- super(cdr, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY);
2876
- this.lc = lc;
2877
- /**
2878
- * Permette di specificare il testo della Label flottante material-style
2879
- */
2880
- this.SelectLabel = "";
2881
- /**
2882
- * Funzione di ricerca che verrà chiamata dal componente
2883
- */
2884
- this.SearchFunction = null;
2885
- /**
2886
- * Numero minimo di caratteri con cui cercare
2887
- */
2888
- this.MinChars = 3;
2889
- /**
2890
- * Override del placeholder per select requried
2891
- */
2892
- this.RequiredPlaceholder = null;
2893
- /**
2894
- * Indica se i controlli devono essere effettuati tenendo conto del Case o meno. Vale solo qualora la **Source** fosse fornita
2895
- */
2896
- this.CaseSensitive = false;
2897
- /**
2898
- * Indica se ignorare il prossimo evento writeValue che normalmente dovrebbe richiedere la nuova source. Serve per quando l'utente seleziona un elemento:
2899
- * Subito dopo partirebbe un altro evento modelChange che ricaricherebbe nuovamente la source
2900
- */
2901
- this.ignoreNextWriteValue = false;
2902
- /**
2903
- * Sorgente Bindata Filtrata in base al contenuto della casella di testo
2904
- */
2905
- this.FilteredBoundSource = [];
2906
- //******************** Funzione di throttling per non spammare richieste in caso di animazioni attivate
2907
- //TODO: spostarla in un metodo di utilità (esfaenza/extensions)
2908
- /** @ignore */
2909
- this.executionTimers = {};
2910
- }
2911
- /**
2912
- * @ignore
2913
- */
2914
- writeValue(value) {
2915
- if (!value)
2916
- return;
2917
- if (this.SearchFunction) {
2918
- this.SearchFunction(value, true).subscribe(t => {
2919
- this.Source = t;
2920
- this.tryBindSourceDisplay();
2921
- setTimeout(() => { this.finalizeValue(value); });
2922
- });
2923
- return;
2924
- }
2925
- this.finalizeValue(value);
2926
- }
2927
- /**
2928
- * 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
2929
- *
2930
- * @param {any} value Valore scritto nell'input di testo
2931
- */
2932
- finalizeValue(value) {
2933
- var val = this.Source.find(t => t.id == value);
2934
- this.propagateChange(val ? val.id : value);
2935
- this.Model = val ? val.description : value;
2936
- }
2937
- /**
2938
- * Evento di filtro della sorgente dati in base all'input utente
2939
- *
2940
- * @param {string} event Input utente
2941
- */
2942
- filterSource(event) {
2943
- if (this.ignoreNextWriteValue) {
2944
- this.ignoreNextWriteValue = false;
2945
- return;
2946
- }
2947
- // Quando filtro la source, se non devo ignorare l'evento devo comunque assicurarmi di impostare il valore selezionato a null
2948
- super.changed("");
2949
- if (!event && this.MinChars == 0 && !this.SearchFunction) {
2950
- this.FilteredBoundSource = this.BoundSource;
2951
- return;
2952
- }
2953
- if (!event || event.length < this.MinChars) {
2954
- this.FilteredBoundSource = [];
2955
- return;
2956
- }
2957
- if (!this.SearchFunction && (!this.Source || this.Source.length == 0))
2958
- throw "Impossibile filtrare gli elementi senza una funzione di ricerca che restituisca una lista di { id: string, description: string }";
2959
- if (this.SearchFunction) {
2960
- this.throttla("filtersource", () => {
2961
- this.SearchFunction(event, false).subscribe(t => {
2962
- this.Source = t;
2963
- this.tryBindSourceDisplay();
2964
- // In questo caso è già filtrata dalla SearchFunction
2965
- this.FilteredBoundSource = this.BoundSource;
2966
- this.cdr.markForCheck();
2967
- });
2968
- }, 400);
2969
- }
2970
- else {
2971
- this.throttla("filtersource", () => {
2972
- // In questo caso devo filtrare io in memoria
2973
- this.FilteredBoundSource = this.BoundSource.filter(t => (this.CaseSensitive && t.description.includes(event)) || (!this.CaseSensitive && t.description.toLowerCase().includes(event.toLowerCase())));
2974
- this.cdr.markForCheck();
2975
- }, 100);
2976
- }
2977
- }
2978
- /**
2979
- * @ignore
2980
- */
2981
- ngOnChanges(changes) {
2982
- var _a;
2983
- let newSource = changes["Source"];
2984
- if (newSource) {
2985
- this.tryBindSourceDisplay();
2986
- // Prima assegnazione se cambia la source sotto (quindi se viene bindata direttamente da HTML)
2987
- if ((((_a = this.Model) === null || _a === void 0 ? void 0 : _a.length) || 0) >= this.MinChars && !this.SearchFunction)
2988
- this.FilteredBoundSource = this.BoundSource;
2989
- else
2990
- this.FilteredBoundSource = [];
2991
- this.cdr.markForCheck();
2992
- }
2993
- }
2994
- /**
2995
- * @ignore
2996
- *
2997
- * Override che marca anche il prossimo evento di filterSource da ignorare
2998
- */
2999
- changed(forcedValue = null, markForCheck = false) {
3000
- this.ignoreNextWriteValue = true;
3001
- super.changed(forcedValue, markForCheck);
3002
- }
3003
- /**
3004
- * @ignore
3005
- */
3006
- onNotNullValueSet() { }
3007
- /** @ignore */
3008
- throttla(id, func, throttleTime) {
3009
- //Se ho la funzione che vuole eseguire ripulisco quel timeout
3010
- if (this.executionTimers[id])
3011
- clearTimeout(this.executionTimers[id]);
3012
- //Ricreo il timeout per eseguire quella funzione dopo throttleTime millisecondi
3013
- this.executionTimers[id] = setTimeout(() => { func(); this.executionTimers[id] = null; }, throttleTime);
3014
- }
3015
- }
3016
- FormAutocompleteComponent.decorators = [
3017
- { type: Component, args: [{
3018
- selector: "form-autocomplete",
3019
- 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 <val-autocomplete [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 name=\"{{GeneratedName}}\"\r\n #validationControl=\"ngModel\"\r\n (inputChange)=\"filterSource($event);\"\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>",
3020
- providers: [{ provide: LocalizationService, useClass: FormAutocompleteComponentLoc }],
3021
- changeDetection: ChangeDetectionStrategy.OnPush
3022
- },] }
3023
- ];
3024
- FormAutocompleteComponent.ctorParameters = () => [
3025
- { type: ChangeDetectorRef },
3026
- { type: LocalizationService },
3027
- { type: NgControl, decorators: [{ type: Optional }, { type: Self }] },
3028
- { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NG_VALIDATORS,] }] },
3029
- { type: AccessControlService, decorators: [{ type: Optional }] },
3030
- { type: ComponentContext, decorators: [{ type: Optional }] },
3031
- { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ACO_CUSTOMKEY,] }] }
3032
- ];
3033
- FormAutocompleteComponent.propDecorators = {
3034
- SelectLabel: [{ type: Input }],
3035
- SearchFunction: [{ type: Input }],
3036
- MinChars: [{ type: Input }],
3037
- RequiredPlaceholder: [{ type: Input }],
3038
- CaseSensitive: [{ type: Input }]
3039
- };
3040
-
3041
- // Angular
3042
- /**
3043
- * Componente che identifica la selezione di un orario
3044
- */
3045
- class FormTimeComponent extends BaseFormControl {
3046
- /**
3047
- * @ignore
3048
- */
3049
- constructor(cdr, dateAdapter, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY) {
3050
- super(cdr, ngControl, _validators, ac, AppContext, ACO_CUSTOMKEY, true);
3051
- this.dateAdapter = dateAdapter;
3052
- /**
3053
- * Mostra o meno gli spinner dove cliccare per aumentare/diminuire le componenti dell'orologio (ore, minuti e secondi)
3054
- */
3055
- this.ShowSpinners = false;
3056
- /**
3057
- * Imposta lo step (minimo avanzamento) per la cella "ore"
3058
- */
3059
- this.StepHour = 1;
3060
- /**
3061
- * Imposta lo step (minimo avanzamento) per la cella "minuti"
3062
- */
3063
- this.StepMinute = 1;
3064
- /**
3065
- * Imposta lo step (minimo avanzamento) per la cella "secondi"
3066
- */
3067
- this.StepSecond = 5;
3068
- /**
3069
- * Indica se mostrare i secondi o meno
3070
- */
3071
- this.ShowSeconds = false;
3072
- /**
3073
- * Indica il formato da utilizzare sia in Input che in Output
3074
- *
3075
- * 1. Se date vengono utilizzate le Date di Javascript
3076
- *
3077
- * 2. Se timestring vengono utilizzate stringhe del tipo '00:00:00'
3078
- *
3079
- * 3. Se dayjs viene utilizzato, appunto, dayjs
3080
- */
3081
- this.InOutFormat = 'timestring';
3082
- }
3083
- /**
3084
- * @ignore Override per gestire input in ingresso
3085
- */
3086
- writeValue(obj) {
3087
- const [hours, minutes, seconds] = (obj || "0:0:0").split(":");
3088
- //Qualsiasi cosa mi arrivi devo ricondurla a un dayjs
3089
- switch (this.InOutFormat) {
3090
- case 'date':
3091
- obj = dayjs(obj);
3092
- break;
3093
- case 'timestring':
3094
- obj = dayjs().hour(hours !== null && hours !== void 0 ? hours : 0).minute(minutes !== null && minutes !== void 0 ? minutes : 0).second(seconds !== null && seconds !== void 0 ? seconds : 0);
3095
- break;
3096
- case 'dayjs':
3097
- obj = obj;
3098
- break;
3099
- }
3100
- super.writeValue(obj);
3101
- }
3102
- /**
3103
- * @ignore Override per gestire input in uscita
3104
- */
3105
- changed() {
3106
- var toEmit = this.dateAdapter.clone(this.Model);
3107
- switch (this.InOutFormat) {
3108
- case 'date':
3109
- toEmit = toEmit.toDate();
3110
- break;
3111
- case 'timestring':
3112
- toEmit = toEmit.format("HH:mm" + (this.ShowSeconds ? ":ss" : ""));
3113
- break;
3114
- case 'dayjs':
3115
- toEmit = toEmit;
3116
- break;
3117
- }
3118
- super.changed(toEmit);
3119
- }
3120
- /**
3121
- * @ignore
3122
- */
3123
- onNotNullValueSet() { }
3124
- }
3125
- FormTimeComponent.decorators = [
3126
- { type: Component, args: [{
3127
- selector: "form-time",
3128
- 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}} m-t-5\">\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\r\n <ngx-mat-timepicker name=\"val-time\" #elementRef #baseInput=\"ngModel\" [(ngModel)]=\"Model\" [disabled]=\"Readonly\"\r\n [showSpinners]=\"ShowSpinners\" [stepHour]=\"StepHour\" [stepMinute]=\"StepMinute\" [stepSecond]=\"StepSecond\"\r\n [showSeconds]=\"ShowSeconds\" (ngModelChange)=\"changed()\" #validationControl=\"ngModel\">\r\n </ngx-mat-timepicker>\r\n\r\n</ng-template>",
3129
- changeDetection: ChangeDetectionStrategy.OnPush
3130
- },] }
3131
- ];
3132
- FormTimeComponent.ctorParameters = () => [
3133
- { type: ChangeDetectorRef },
3134
- { type: NgxMatDateAdapter },
3135
- { type: NgControl, decorators: [{ type: Optional }, { type: Self }] },
3136
- { type: Array, decorators: [{ type: Optional }, { type: Host }, { type: Inject, args: [NG_VALIDATORS,] }] },
3137
- { type: AccessControlService },
3138
- { type: ComponentContext, decorators: [{ type: Optional }] },
3139
- { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ACO_CUSTOMKEY,] }] }
3140
- ];
3141
- FormTimeComponent.propDecorators = {
3142
- ShowSpinners: [{ type: Input }],
3143
- StepHour: [{ type: Input }],
3144
- StepMinute: [{ type: Input }],
3145
- StepSecond: [{ type: Input }],
3146
- ShowSeconds: [{ type: Input }],
3147
- InOutFormat: [{ type: Input }]
3148
- };
3149
-
3150
- // Angular
3151
- /**
3152
- * Formato in display (modalità breve, senza ore, minuti e secondi) delle date per tutti i componenti che utilizzino input data.
3153
- *
3154
- * Da convenzione è sempre quello italiano quindi viene cablato
3155
- */
3156
- const formats = {
3157
- parse: { dateInput: 'DD/MM/YYYY' },
3158
- display: {
3159
- dateInput: 'DD/MM/YYYY',
3160
- monthYearLabel: 'MM YYYY',
3161
- dateA11yLabel: 'DD/MM/YYYY',
3162
- monthYearA11yLabel: 'MM YYYY',
3163
- }
3164
- };
3165
- /**
3166
- * Formato in display (modalità lunga, con ore, minuti e secondi) delle date per tutti i componenti che utilizzino input data.
3167
- *
3168
- * Da convenzione è sempre quello italiano quindi viene cablato
3169
- */
3170
- const formats_long = {
3171
- parse: { dateInput: 'DD/MM/YYYY HH:mm:ss' },
3172
- display: {
3173
- dateInput: 'DD/MM/YYYY HH:mm:ss',
3174
- monthYearLabel: 'MM YYYY',
3175
- dateA11yLabel: 'DD/MM/YYYY HH:mm:ss',
3176
- monthYearA11yLabel: 'MM YYYY',
3177
- }
3178
- };
3179
- /**
3180
- * Componenti Dichiarati ed esportati dalla libreria
3181
- */
3182
- const COMPONENTS = [
3183
- ValidationInputComponent,
3184
- ValidationSelectComponent,
3185
- ValidationDateComponent,
3186
- CustomRequiredDirective,
3187
- ValidationCurrencyComponent,
3188
- ValidationTextAreaComponent,
3189
- FormCheckboxComponent,
3190
- FormDateComponent,
3191
- FormEmptyComponent,
3192
- FormInputComponent,
3193
- FormSelectComponent,
3194
- FormTextareaComponent,
3195
- FormTemplateComponent,
3196
- FormErrorComponent,
3197
- FormInfoComponent,
3198
- FormAdaptiveComponent,
3199
- FormMultiSelectComponent,
3200
- FormFileComponent,
3201
- ValidationAutocompleteComponent,
3202
- FormAutocompleteComponent,
3203
- FormDateTimeComponent,
3204
- ValidationDateTimeComponent,
3205
- FormTimeComponent
3206
- ];
3207
- /**
3208
- * Moduli utilizzati solo dalla libreria
3209
- */
3210
- const MODULES = [
3211
- CommonModule,
3212
- FormsModule,
3213
- LocalizationModule,
3214
- MatInputModule,
3215
- MatDatepickerModule,
3216
- MatDayjsDateModule,
3217
- TooltipModule,
3218
- CurrencyMaskModule,
3219
- MatAutocompleteModule,
3220
- NgxMatDatetimePickerModule,
3221
- NgxMatTimepickerModule
3222
- ];
3223
- /**
3224
- * Moduli utilizzati dalla libreria e che devono essere esposti all'esterno
3225
- */
3226
- const MODULES_TO_EXPORT = [
3227
- AngularMultiSelectModule
3228
- ];
3229
- class FormsAndValidationsModule {
3230
- static forRoot(config) {
3231
- return {
3232
- ngModule: FormsAndValidationsModule,
3233
- providers: [
3234
- { provide: FAV_LOCALE, useValue: (config === null || config === void 0 ? void 0 : config.locale) || 'it-IT' },
3235
- { provide: ACO_CUSTOMKEY, useValue: (config === null || config === void 0 ? void 0 : config.acocustom) || null },
3236
- { provide: MAT_DATE_LOCALE, useValue: 'it' },
3237
- { provide: MAT_DATE_FORMATS, useValue: formats },
3238
- { provide: NGX_MAT_DATE_FORMATS, useValue: formats_long },
3239
- { provide: NgxMatDateAdapter, useClass: NgxExpandedDayJsDateAdapter },
3240
- ]
3241
- };
3242
- }
3243
- }
3244
- FormsAndValidationsModule.decorators = [
3245
- { type: NgModule, args: [{
3246
- imports: [...MODULES, ...MODULES_TO_EXPORT],
3247
- declarations: [...COMPONENTS],
3248
- exports: [...MODULES_TO_EXPORT, ...COMPONENTS]
3249
- },] }
3250
- ];
3251
-
3252
- /*
3253
- * Public API Surface of forms-and-validations
3254
- */
3255
-
3256
- /**
3257
- * Generated bundle index. Do not edit.
3258
- */
3259
-
3260
- export { AppFile, FormAdaptiveComponent, FormAutocompleteComponent, FormCheckboxComponent, FormDateComponent, FormDateTimeComponent, FormEmptyComponent, FormErrorComponent, FormFileComponent, FormInfoComponent, FormInputComponent, FormSelectComponent, FormTemplateComponent, FormTextareaComponent, FormTimeComponent, FormsAndValidationsModule, FormsAndValidationsModuleConfig, ValidationAutocompleteComponent, ValidationCurrencyComponent, ValidationDateComponent, ValidationDateTimeComponent, ValidationInputComponent, ValidationSelectComponent, ValidationTextAreaComponent, BaseValidation as ɵa, BaseValidationLoc as ɵb, FAV_LOCALE as ɵc, ACO_CUSTOMKEY as ɵd, CustomRequiredDirective as ɵe, BaseFormControl as ɵf, FormSelectComponentLoc as ɵg, FormAdaptiveComponentLoc as ɵh, FormMultiSelectComponent as ɵi, FormMultiSelectComponentLoc as ɵj, FormFileComponentLoc as ɵk, FormAutocompleteComponentLoc as ɵl, NgxExpandedDayJsDateAdapter as ɵm };
3261
- //# sourceMappingURL=esfaenza-forms-and-validations.js.map