@esfaenza/parameters 16.2.28 → 17.3.16

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, forwardRef, Component, ViewEncapsulation, Input, NgModule } from '@angular/core';
2
+ import { Injectable, forwardRef, Input, ViewEncapsulation, Component, NgModule } from '@angular/core';
3
3
  import * as i3 from '@angular/common';
4
4
  import { CommonModule } from '@angular/common';
5
5
  import * as i4 from '@angular/forms';
@@ -11,504 +11,504 @@ import { LocalizationService, LocalizationModule } from '@esfaenza/localizations
11
11
  import { of } from 'rxjs';
12
12
  import * as i1 from '@esfaenza/extensions';
13
13
 
14
- /**
15
- * Classe di localizzazione per il componente **EsParametersComponent**
16
- */
17
- class EsParametersLoc extends LocalizationService {
18
- /**
19
- * Costruttore
20
- *
21
- * @ignore
22
- */
23
- constructor(injector) {
24
- super(injector);
25
- super.set("it->en", "Seleziona", ["Select"]);
26
- }
27
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EsParametersLoc, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
28
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EsParametersLoc }); }
29
- }
30
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EsParametersLoc, decorators: [{
31
- type: Injectable
32
- }], ctorParameters: function () { return [{ type: i0.Injector }]; } });
14
+ /**
15
+ * Classe di localizzazione per il componente **EsParametersComponent**
16
+ */
17
+ class EsParametersLoc extends LocalizationService {
18
+ /**
19
+ * Costruttore
20
+ *
21
+ * @ignore
22
+ */
23
+ constructor(injector) {
24
+ super(injector);
25
+ super.set("it->en", "Seleziona", ["Select"]);
26
+ }
27
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EsParametersLoc, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
28
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EsParametersLoc }); }
29
+ }
30
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EsParametersLoc, decorators: [{
31
+ type: Injectable
32
+ }], ctorParameters: () => [{ type: i0.Injector }] });
33
33
 
34
- /**
35
- * Classe che rappresenta un gruppo di parametri generico
36
- */
37
- class GenericParameterGroup {
38
- /**
39
- * Costruttore
40
- * @param {string} groupName Descrizione del gruppo che fa anche da id
41
- * @param {number} order ordine del gruppo
42
- */
43
- constructor(groupName, order) {
44
- this.groupName = groupName;
45
- this.order = order;
46
- this.parameters = [];
47
- this.subgroups = [];
48
- }
34
+ /**
35
+ * Classe che rappresenta un gruppo di parametri generico
36
+ */
37
+ class GenericParameterGroup {
38
+ /**
39
+ * Costruttore
40
+ * @param {string} groupName Descrizione del gruppo che fa anche da id
41
+ * @param {number} order ordine del gruppo
42
+ */
43
+ constructor(groupName, order) {
44
+ this.groupName = groupName;
45
+ this.order = order;
46
+ this.parameters = [];
47
+ this.subgroups = [];
48
+ }
49
49
  }
50
50
 
51
- // Angular
52
- /** Componente che permette di graficare una lista di **GenericParameter** come Input in base al loro tipo specifico */
53
- class EsParametersComponent {
54
- /** Permette di settare in una volta solo gli input **LabelColWidth** e **InputColWidth**, basta scriverlo con la sintassi "X Y" */
55
- set LabelInputRatio(input) {
56
- var ratio = input.split(/\s/);
57
- this.LabelColWidth = parseInt(ratio[0]);
58
- this.InputColWidth = parseInt(ratio[1]);
59
- }
60
- /**
61
- * Costruttore
62
- *
63
- * @ignore
64
- */
65
- constructor(utiExts, lc, cdr, inj, dates) {
66
- this.utiExts = utiExts;
67
- this.lc = lc;
68
- this.cdr = cdr;
69
- this.inj = inj;
70
- this.dates = dates;
71
- /** Indica se si lavora a singolo parametro forzato dentro un array for the glory of satan */
72
- this.SingleParameterMode = false;
73
- /**
74
- * Pipeline di Angular
75
- *
76
- * @ignore
77
- */
78
- this.propagateChange = (_) => { };
79
- /** Indica che il parametro deve essere in modalità display */
80
- this.DisplayMode = false;
81
- /** Indica che il parametro (In Display mode!!) non appare se vuoto. In più, se tutti sono vuoti, fa vedere una bella card "non ci sono parametri presenti" */
82
- this.HideEmpty = false;
83
- /** Indica che l'ultimo parametro non deve avere margine in fondo */
84
- this.LastParameterNoMargin = false;
85
- /** col-md-X per la label */
86
- this.LabelColWidth = 4;
87
- /** col-md-X per l'input */
88
- this.InputColWidth = 8;
89
- /** Input a cui collegare la variabile **submitted** del form all'interno del quale viene utilizzato questo componente */
90
- this.submitted = false;
91
- /** Valore da mostrare qualora non fossero ancora ricevuti i **Parameters** da mostrare */
92
- this.EmptyMessage = "";
93
- /** Permette di rimuovere i parametri dalla lista cliccando sulla X davanti alla Label */
94
- this.Removal = false;
95
- /** Indica se i componenti di Input generati sono Readonly o no */
96
- this.Readonly = false;
97
- /** Indica il formato lista che dev'essere utilizzato */
98
- this.ListFormat = 'Array';
99
- /** Form che utilizza il componente. Fondamentale collegarlo se si vogliono le validazioni sul submit */
100
- this.Form = null;
101
- /** Quando utilizza un sottocomponente autocomplete abilita o disabilita il reset dell'input per ogni selezione */
102
- this.AutocompleteHideChoicesOnSelection = false;
103
- /** Indica come deve funzionare la multiselect */
104
- this.MultiselectMode = 'CommaSeparated';
105
- this.AllParametersEmpty = false;
106
- this.Initialized = false;
107
- }
108
- ngOnInit() {
109
- // Qui gli input dovrebbero essere settati. Alcuni form-roba non prendono bene i cambi di input
110
- // Non sta funzionando come speravo... da rivedere
111
- this.Initialized = true;
112
- }
113
- /**
114
- * Pipeline di Angular
115
- *
116
- * @ignore
117
- */
118
- writeValue(obj) {
119
- if (!obj)
120
- return;
121
- if (!Array.isArray(obj))
122
- this.SingleParameterMode = true;
123
- this.Parameters = Array.isArray(obj) ? obj : [obj];
124
- this.ParametersCache = {};
125
- this.Parameters.forEach(t => {
126
- this.ParametersCache[t.id] = t;
127
- if (!t.typecode && !t.type)
128
- console.warn("Non è stato specificato né un type né un typecode");
129
- if (t.typecode && !t.type)
130
- t.type = this.utiExts.getJsTypeFromTypeCode(t.typecode);
131
- if (t.typecode && t.type != this.utiExts.getJsTypeFromTypeCode(t.typecode))
132
- console.warn(`Rilevate inconsistenze fra il Tipo ${t.type} e il Tipo ${this.utiExts.getJsTypeFromTypeCode(t.typecode)} calcolato da TypeCode ${t.typecode} per il parametro ${t.id}`);
133
- if (t.type == "boolean")
134
- t.value = t.value?.toString()?.toLowerCase() === "true";
135
- if (t.enumtype || t.dicttype)
136
- t.type = 'enum';
137
- // Valore valido ma modalità di utilizzo a CommaSeparated, devo assicurarmi di riemettere la versione con la stringa
138
- if (t.type == 'enum' && this.ListFormat == 'CommaSeparated' && t.multienum && t.value && Array.isArray(t.value))
139
- this.changed();
140
- // Aggiusto le modalità di funzionamento dei parametri lista. Che internamente funzionano sempre con una lista di valori
141
- if (t.type == 'enum' && this.ListFormat == 'CommaSeparated' && t.multienum && t.value && !Array.isArray(t.value))
142
- t.value = t.value ? t.value.split(',').map(t => t.trim()) : [];
143
- });
144
- this.AllParametersEmpty = this.Parameters.every(t => !t.value);
145
- this.reviewParametersBindings();
146
- this.generateGroups();
147
- }
148
- /**
149
- * Metodo che si occupa di creare e ordinare i gruppi dei parametri
150
- */
151
- generateGroups() {
152
- this.Groups = [];
153
- if (this.Parameters?.length > 0) {
154
- this.Parameters.sort((a, b) => a.order < b.order ? -1 : 1);
155
- // Ciclo tutti i parametri
156
- for (let i = 0; this.Parameters.length > i; i++) {
157
- let par = this.Parameters[i];
158
- let parGroupName = par.group ?? "";
159
- let groupOrder = par.group ? par.order : -1;
160
- // Se il gruppo non esiste, lo aggiungo
161
- if (!this.Groups.some(x => x.groupName == parGroupName)) {
162
- this.Groups.push(new GenericParameterGroup(parGroupName, groupOrder));
163
- }
164
- // Inserisco il parametro dentro al suo gruppo
165
- this.Groups.find(g => g.groupName == parGroupName).parameters.push(par);
166
- }
167
- // Gestione sottogruppi
168
- let subgroups = this.Groups.filter(group => group.groupName.includes('§'));
169
- for (let _; subgroups.length > 0; () => { }) {
170
- // Recupero la lista di gruppi che hanno sottogruppi
171
- // Per convenzione, nel nome contengono "§"
172
- this.tryToAddSubgroups(subgroups);
173
- subgroups = this.Groups.filter(group => group.groupName.includes('§'));
174
- }
175
- this.Groups.sort((a, b) => a.order < b.order ? -1 : 1);
176
- }
177
- }
178
- /**
179
- * Metodo che si occupa di creare e ordinare i sottogruppi dei parametri
180
- */
181
- tryToAddSubgroups(subgroups) {
182
- for (let i = 0; subgroups.length > i; i++) {
183
- let sub = subgroups[i];
184
- // Ottengo un lista con la gerarchia dei gruppi, in ordine
185
- let groupsParentHierarchy = sub.groupName.split('§') ?? [];
186
- // Recupero il gruppo padre
187
- let parentGroupName = sub.groupName.replace(`§${groupsParentHierarchy[groupsParentHierarchy.length - 1]}`, ``);
188
- // Se il gruppo padre non esiste, lo aggiungo
189
- if (!this.Groups.some(x => x.groupName == parentGroupName)) {
190
- this.Groups.push(new GenericParameterGroup(parentGroupName, sub.order));
191
- }
192
- // Rimuovo dal nome del gruppo l'informazione sul padre (Sistemando anche l'etichetta)
193
- // e lo aggiungo ai sottogruppi del padre
194
- sub.groupName = sub.groupName.replace(`${parentGroupName}§`, '');
195
- let parentGroup = this.Groups.find(x => x.groupName == parentGroupName);
196
- if (parentGroup?.subgroups.some(s => s.groupName == sub.groupName)) {
197
- let target = parentGroup.subgroups.find(f => f.groupName == sub.groupName);
198
- sub.parameters.map(p => target.parameters.push(p));
199
- sub.subgroups.map(s => target.subgroups.push(s));
200
- target.order = sub.order < target.order ? sub.order : target.order;
201
- }
202
- else {
203
- parentGroup?.subgroups.push(sub);
204
- }
205
- // Rimuovo il sottogruppo gruppo dalla lista
206
- this.Groups.splice(this.Groups.indexOf(sub), 1);
207
- }
208
- }
209
- /**
210
- * Pipeline di Angular
211
- *
212
- * @ignore
213
- */
214
- registerOnChange(fn) { this.propagateChange = fn; }
215
- /**
216
- * Pipeline di Angular
217
- *
218
- * @ignore
219
- */
220
- registerOnTouched(fn) { }
221
- /**
222
- * Metodo che si occupa di gestire il modello in uscita e propagarlo sul binding ngModel
223
- */
224
- changed() {
225
- if (!this.Parameters)
226
- return;
227
- if (!this.Groups)
228
- this.generateGroups();
229
- // Se ci sono delle modifiche ai binding potrebbero essere cambiati i required. Ricreo tutti i componenti e ri-idrato la cache dei parametri
230
- var changes = this.reviewParametersBindings();
231
- if (changes.length > 0) {
232
- // In base ai binding cambiati devo trovare tutti i parametri che han subito modifiche strutturali (visibilità, obbligatorietà)
233
- // distruggerli e ricrearli in modo che i binding lato html si aggiornino di conseguenza.
234
- // 1: Faccio una copia del parametro corrente
235
- // 2: Trovo la sua posizione all'interno dei gruppi e lo sostituisco con la copia
236
- // 3: Aggiorno la lista dei parametri e la sua cache in modo da puntare all'oggetto nuovo
237
- changes.forEach(ch => {
238
- let index = this.Parameters.findIndex(t => t.id == ch);
239
- let parameterCopy = this.utiExts.deepClone(this.Parameters[index]);
240
- let parameterRefFixed = false;
241
- for (let ig = 0; ig < this.Groups.length; ig++) {
242
- var g = this.Groups[ig];
243
- for (let ip = 0; ip < g.parameters.length; ip++) {
244
- var p = g.parameters[ip];
245
- if (p === this.Parameters[index]) {
246
- this.Groups[ig].parameters[ip] = parameterCopy;
247
- parameterRefFixed = true;
248
- break;
249
- }
250
- }
251
- if (parameterRefFixed)
252
- break;
253
- }
254
- this.Parameters[index] = parameterCopy;
255
- this.ParametersCache[ch] = this.Parameters[index];
256
- this.cdr.markForCheck();
257
- });
258
- }
259
- var ParametersClone = this.utiExts.deepClone(this.Parameters);
260
- // Aggiusto le modalità di funzionamento dei parametri lista. Che internamente funzionano sempre con una lista di valori
261
- ParametersClone?.forEach(t => {
262
- if (t.type == "enum" && this.ListFormat == 'CommaSeparated' && t.multienum && t.value && Array.isArray(t.value))
263
- t.value = t.value.join(',');
264
- });
265
- this.propagateChange(this.SingleParameterMode ? ParametersClone[0] : ParametersClone);
266
- }
267
- /**
268
- * Rimuove il parametro selezionato e propaga il modello
269
- *
270
- * @param {GenericParameter} par Parametro da rimuovere
271
- */
272
- removeParameter(par) {
273
- this.Parameters.splice(this.Parameters.indexOf(par), 1);
274
- this.changed();
275
- }
276
- GenerateParameterGroups() {
277
- let Groups = [];
278
- this.Parameters.forEach(param => {
279
- Groups.push({ id: param.id, groups: param.group.split("§"), order: param.order });
280
- });
281
- let GroupedGroups = Groups.reduce((r, a) => {
282
- let firstGroupId = a.groups?.length > 0 ? a.groups[0] : "";
283
- r[firstGroupId] = [...r[firstGroupId] || [], a];
284
- return r;
285
- }, {});
286
- console.log(GroupedGroups);
287
- // Ciclo del risultato, aggiungendo i gruppi al modello
288
- // Per ogni gruppo che aggiungo, assegno i parametri in ordine
289
- }
290
- /**
291
- * Rivede i bindings dei parametri in base a loro eventuali espressioni di controllo
292
- *
293
- * @returns {string[]} lista con gli id dei parametri che sono stati modificati
294
- */
295
- reviewParametersBindings() {
296
- let changes = [];
297
- for (let i = 0; i < this.Parameters.length; i++) {
298
- var p = this.Parameters[i];
299
- if (p.requiredexp) {
300
- let prevReq = p.required;
301
- p.required = this.evaluate(p.requiredexp);
302
- if (prevReq != p.required)
303
- changes.push(p.id);
304
- }
305
- if (p.visibleexp) {
306
- let prevVisi = p.visible;
307
- p.visible = this.evaluate(p.visibleexp);
308
- if (prevVisi != p.visible)
309
- changes.push(p.id);
310
- }
311
- }
312
- return changes;
313
- }
314
- /**
315
- * Valuta un'espressione in base ai parametri presenti nel modello attuale
316
- *
317
- * @param expr Espressione da valutare scritta nel formato (ripetibile) "ID (==|!=|<|>|>=|<=) (`valore` | null | true | false | XXX,XXX)" separato eventualmente da && ed ||
318
- *
319
- * @returns **true** se la condizione è verificata, **false** altrimenti
320
- */
321
- evaluate(expr) {
322
- var regex = /\s?([a-zA-Z0-9_-]+)\s?(!=|==|<|>|<=|>=)\s?(`[^`]+`|``|null|[0-9,]+|true|false)/gm;
323
- var matches = [];
324
- var finalExpr = expr;
325
- while (matches = regex.exec(expr)) {
326
- var fullMatch = matches[0].trim();
327
- var id = matches[1].trim();
328
- var operation = matches[2].trim();
329
- let bValue = matches[3].trim().trim();
330
- var value = matches[3].trim().trim().replace('`', '').replace('`', '');
331
- finalExpr = finalExpr.replace(fullMatch, `this.checkValue('${id}', '${operation}', ${bValue == 'null' ? 'null' : `'${value}'`})`);
332
- }
333
- return eval(finalExpr);
334
- }
335
- /**
336
- * Restituisce l'operazione di comparazione fra un singolo valore di un parametro e un suo valore di confronto in base ad un operatore
337
- * Richiamata da EVAL
338
- *
339
- * @param {string} key Chiave del parametro di cui verificare il valore
340
- * @param {string} operator Operatore con cui verificare il valore: ==, !=, >, <, >=, <=
341
- * @param {string} value Valore di confronto da utilizzare
342
- *
343
- * @returns **true** se la condizione è verificata, **false** altrimenti
344
- */
345
- checkValue(key, operator, value) {
346
- var rPar = this.ParametersCache[key];
347
- try {
348
- switch (rPar.type) {
349
- case "string":
350
- case "enum":
351
- return eval(`"${this.defaultIfnullOrUndefined(rPar.value, ``)}" ${operator} "${this.defaultIfnullOrUndefined(value, ``)}"`);
352
- case "boolean":
353
- return eval(`${this.defaultIfnullOrUndefined(rPar.value, ``).toString()} ${operator} ${this.defaultIfnullOrUndefined(value, ``)}`);
354
- case "number":
355
- return eval(`${this.defaultIfnullOrUndefined(rPar.value, '""', true).replace(',', '.')} ${operator} ${this.defaultIfnullOrUndefined(value, '""', true).replace(',', '.')}`);
356
- case "date":
357
- let parDateConv = `this.dates.getDateConvertion("${rPar.value}")`;
358
- let valDateConv = `this.dates.getDateConvertion("${value}")`;
359
- switch (operator) {
360
- case "==": return eval(`${parDateConv} == ${valDateConv} || (${parDateConv} != null && ${parDateConv}.isSame(${valDateConv}))`);
361
- case "!=": return eval(`${parDateConv} != ${valDateConv} && ${parDateConv} != null && !${parDateConv}.isSame(${valDateConv})`);
362
- case ">": return eval(`${parDateConv} != null && ${valDateConv} != null && ${parDateConv}.isAfter(${valDateConv})`);
363
- case "<": return eval(`${parDateConv} != null && ${valDateConv} != null && ${parDateConv}.isBefore(${valDateConv})`);
364
- case ">=": return eval(`${parDateConv} != null && ${valDateConv} != null && (${parDateConv}.isAfter(${valDateConv}) || ${parDateConv}?.isSame(${valDateConv}))`);
365
- case "<=": return eval(`${parDateConv} != null && ${valDateConv} != null && (${parDateConv}.isBefore(${valDateConv}) || ${parDateConv}?.isSame(${valDateConv}))`);
366
- }
367
- }
368
- }
369
- catch (error) {
370
- console.error(error);
371
- console.warn("Errori nella valutazione dell'espressione. Fallback a false");
372
- return false;
373
- }
374
- throw `@esfaenza/parameters: Tipo parametro ${key} non riconosciuto: ${rPar.type}`;
375
- }
376
- /** @ignore */
377
- defaultIfnullOrUndefined(item, dflt, emptyStringIsNull = false) {
378
- if (item == null || item == undefined || item.toString() == 'null' || (emptyStringIsNull && item.toString() == ""))
379
- return dflt;
380
- return item;
381
- }
382
- /** @ignore */
383
- getSource(parameter, search, byid) {
384
- if (!this.AutoCompleteDataRetrieve) {
385
- console.error("@forms-and-validations: funzione di dataretrieve non impostata per un parametro autocomplete");
386
- return of([]);
387
- }
388
- else
389
- return this.AutoCompleteDataRetrieve(parameter, search, byid);
390
- }
391
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EsParametersComponent, deps: [{ token: i1.UtilityService }, { token: i2.LocalizationService }, { token: i0.ChangeDetectorRef }, { token: i0.Injector }, { token: i1.DateService }], target: i0.ɵɵFactoryTarget.Component }); }
392
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: EsParametersComponent, selector: "es-parameters", inputs: { DisplayMode: "DisplayMode", HideEmpty: "HideEmpty", LastParameterNoMargin: "LastParameterNoMargin", LabelColWidth: "LabelColWidth", InputColWidth: "InputColWidth", submitted: "submitted", EmptyMessage: "EmptyMessage", Removal: "Removal", Readonly: "Readonly", ListFormat: "ListFormat", Form: "Form", AutocompleteHideChoicesOnSelection: "AutocompleteHideChoicesOnSelection", AutoCompleteDataRetrieve: "AutoCompleteDataRetrieve", MultiselectMode: "MultiselectMode", LabelInputRatio: "LabelInputRatio" }, providers: [
393
- { provide: LocalizationService, useClass: EsParametersLoc },
394
- {
395
- provide: NG_VALUE_ACCESSOR,
396
- useExisting: forwardRef(() => EsParametersComponent),
397
- multi: true
398
- }
399
- ], ngImport: i0, template: "<div *ngIf=\"(!Parameters || Parameters.length == 0) && EmptyMessage\">\r\n <em>{{EmptyMessage}}</em>\r\n</div>\r\n\r\n<div *ngIf=\"Groups && Initialized\">\r\n <ng-container *ngTemplateOutlet=\"Temp; context: {item: { groups: Groups, isSubgroup: false }}\"></ng-container>\r\n</div>\r\n\r\n<ng-template #Temp let-item=\"item\">\r\n <ng-container *ngFor=\"let group of item.groups; let k = index\">\r\n <div [class.pars-subgroup]=\"item.isSubgroup\" [class.pars-group]=\"!item.isSubgroup\">\r\n <ng-container *ngTemplateOutlet=\"GroupsOrSubgroupsDisplay; context: { item: { group: group, index: k + (item.index ? ('_' + item.index) : ''), isSubgroup: item.isSubgroup }}\"></ng-container>\r\n <ng-container *ngIf=\"group.subgroups.length > 0\">\r\n <ng-container *ngTemplateOutlet=\"Temp; context: {item: { groups: group.subgroups, index: k + (item.index ? ('_' + item.index) : ''), isSubgroup: true }};\"></ng-container>\r\n </ng-container>\r\n </div>\r\n </ng-container>\r\n</ng-template>\r\n\r\n<ng-template #GroupsOrSubgroupsDisplay let-item=\"item\">\r\n <div *ngIf=\"item.group && Initialized\">\r\n <div *ngIf=\"item.group.groupName\" [class.pars-group-title]=\"!item.isSubgroup\" [class.pars-subgroup-title]=\"item.isSubgroup\">\r\n {{item.group.groupName}}\r\n </div>\r\n <div *ngIf=\"item.group.parameters && item.group.parameters.length > 0\">\r\n <ng-container *ngFor=\"let par of item.group.parameters; let i= index; let last = last;\">\r\n <ng-container *ngIf=\"!DisplayMode || (!HideEmpty || (par.value))\">\r\n <div class=\"row form-group\" *ngIf=\"par.visible\" [class.app-margin-bottom-0]=\"LastParameterNoMargin && last\">\r\n <label class=\"col-md-{{LabelColWidth}} m-t-5\"><span *ngIf=\"Removal\" class=\"fa fa-remove text-danger\" (click)=\"removeParameter(par)\">&nbsp;</span>{{par.description}}{{par.required ? '*' : ''}}:</label>\r\n <!--Se Data-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'date'\">\r\n <form-date [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [required]=\"par.required\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" (inputChange)=\"changed();\" #validator></form-date>\r\n </div>\r\n <!--Se stringa-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'string'\">\r\n <form-input [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [required]=\"par.required\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" (inputChange)=\"changed();\" #validator></form-input>\r\n </div>\r\n <!--Se numero-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'number'\">\r\n <form-input [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [required]=\"par.required\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" (inputChange)=\"changed();\" #validator pattern=\"{{par.pattern || '^[+-]?[0-9]*[,]?[0-9]+$'}}\"></form-input>\r\n </div>\r\n <!--Se boolean-->\r\n <div class=\"col-md-{{InputColWidth}} m-t-5\" *ngIf=\"par.type == 'boolean'\">\r\n <form-checkbox [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" (inputChange)=\"changed();\" #validator></form-checkbox>\r\n </div>\r\n <!--Se enum single select-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'enum' && !par.multienum && !par.sourceapi\">\r\n <form-select [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [required]=\"par.required\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" (inputChange)=\"changed();\" #validator [Source]=\"par.enumvalues\"></form-select>\r\n </div>\r\n <!--Se enum multi select-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'enum' && par.multienum && !par.sourceapi\">\r\n <form-multiselect [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [UseJsonList]=\"MultiselectMode == 'JsonArray'\" [UseCommaSeparatedList]=\"MultiselectMode == 'CommaSeparated'\" [SelectLabel]=\"('Seleziona' | localize : lc) + '...'\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" [Readonly]=\"Readonly || par.isreadonly\" [Source]=\"par.enumvalues\" [required]=\"par.required\" (inputChange)=\"changed();\" #validator></form-multiselect>\r\n </div>\r\n <!--Se enum multiselect senza sorgente-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'enum' && par.multienum && !par.sourceapi && !par.enumvalues\">\r\n <form-autocomplete [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [HideChoicesOnSelection]=\"true\" [SelectLabel]=\"('Seleziona' | localize : lc) + '...'\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" [Readonly]=\"Readonly || par.isreadonly\" [UnboundMode]=\"true\" [required]=\"par.required\" (inputChange)=\"changed();\" #validator></form-autocomplete> \r\n </div>\r\n <!--Se enum autocomplete-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'enum' && !par.multienum && par.sourceapi\">\r\n <form-autocomplete [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" [Readonly]=\"Readonly || par.isreadonly\" [SearchFunction]=\"getSource.bind(this, par)\" [required]=\"par.required\" (inputChange)=\"changed();\" #validator></form-autocomplete>\r\n </div>\r\n <!--Se enum multiselect autocomplete-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'enum' && par.multienum && par.sourceapi\">\r\n <form-autocomplete [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [HideChoicesOnSelection]=\"AutocompleteHideChoicesOnSelection\" [Multi]=\"true\" [FormLayout]=\"false\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" [Readonly]=\"Readonly || par.isreadonly\" [SearchFunction]=\"getSource.bind(this, par)\" [required]=\"par.required\" (inputChange)=\"changed();\" #validator></form-autocomplete>\r\n </div>\r\n <!--Se file-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'file'\">\r\n <form-file [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [ReadFile]=\"true\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [required]=\"par.required\" [(ngModel)]=\"par.file\" name=\"{{item.index}}par{{i}}_{{par.id}}\" #validator></form-file>\r\n </div>\r\n </div>\r\n <div class=\"clearfix\"></div>\r\n </ng-container>\r\n </ng-container>\r\n <div *ngIf=\"DisplayMode && AllParametersEmpty && HideEmpty\" class=\"card card-info app-padding-10 app-no-margin app-white-text\">\r\n Non &egrave; presente nulla da visualizzare\r\n </div>\r\n </div>\r\n </div>\r\n</ng-template>", styles: [".list-area{position:fixed}.pars-group-title{background:#ddd;margin-bottom:7px;padding:5px;text-transform:uppercase;font-weight:700;text-align:center;color:#333;font-size:13px}.pars-subgroup-title{font-weight:700;color:#333;font-size:16px}.pars-group{margin-left:0}.pars-subgroup{margin-left:15px}\n"], dependencies: [{ kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i4.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { kind: "directive", type: i4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i5.FormCheckboxComponent, selector: "form-checkbox", inputs: ["SliderMode"] }, { kind: "component", type: i5.FormDateComponent, selector: "form-date", inputs: ["JsDates"] }, { kind: "component", type: i5.FormInputComponent, selector: "form-input", inputs: ["Password"], outputs: ["onSuffixAction", "onPrefixAction"] }, { kind: "component", type: i5.FormSelectComponent, selector: "form-select", inputs: ["SelectLabel", "PlaceholderValue", "RequiredPlaceholder", "EmptyFieldValue", "ShowValidationSymbol", "OptionTemplate"] }, { kind: "component", type: i5.FormMultiSelectComponent, selector: "form-multiselect", inputs: ["SelectLabel", "UseKeyValues", "UseCommaSeparatedList", "UseJsonList"] }, { kind: "component", type: i5.FormFileComponent, selector: "form-file", inputs: ["Multiple", "AllowDownload", "MaxSize", "FancyMode", "ReadFile"] }, { kind: "component", type: i5.FormAutocompleteComponent, selector: "form-autocomplete", inputs: ["SelectLabel", "SearchFunctionContext", "SearchFunction", "MinChars", "HideChoicesOnSelection", "RequiredPlaceholder", "CaseSensitive", "Multi", "MultiElementsThreshold", "UnboundMode"] }, { kind: "pipe", type: i2.LocalizePipe, name: "localize" }], encapsulation: i0.ViewEncapsulation.None }); }
400
- }
401
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EsParametersComponent, decorators: [{
402
- type: Component,
403
- args: [{ selector: "es-parameters", providers: [
404
- { provide: LocalizationService, useClass: EsParametersLoc },
405
- {
406
- provide: NG_VALUE_ACCESSOR,
407
- useExisting: forwardRef(() => EsParametersComponent),
408
- multi: true
409
- }
410
- ], encapsulation: ViewEncapsulation.None, template: "<div *ngIf=\"(!Parameters || Parameters.length == 0) && EmptyMessage\">\r\n <em>{{EmptyMessage}}</em>\r\n</div>\r\n\r\n<div *ngIf=\"Groups && Initialized\">\r\n <ng-container *ngTemplateOutlet=\"Temp; context: {item: { groups: Groups, isSubgroup: false }}\"></ng-container>\r\n</div>\r\n\r\n<ng-template #Temp let-item=\"item\">\r\n <ng-container *ngFor=\"let group of item.groups; let k = index\">\r\n <div [class.pars-subgroup]=\"item.isSubgroup\" [class.pars-group]=\"!item.isSubgroup\">\r\n <ng-container *ngTemplateOutlet=\"GroupsOrSubgroupsDisplay; context: { item: { group: group, index: k + (item.index ? ('_' + item.index) : ''), isSubgroup: item.isSubgroup }}\"></ng-container>\r\n <ng-container *ngIf=\"group.subgroups.length > 0\">\r\n <ng-container *ngTemplateOutlet=\"Temp; context: {item: { groups: group.subgroups, index: k + (item.index ? ('_' + item.index) : ''), isSubgroup: true }};\"></ng-container>\r\n </ng-container>\r\n </div>\r\n </ng-container>\r\n</ng-template>\r\n\r\n<ng-template #GroupsOrSubgroupsDisplay let-item=\"item\">\r\n <div *ngIf=\"item.group && Initialized\">\r\n <div *ngIf=\"item.group.groupName\" [class.pars-group-title]=\"!item.isSubgroup\" [class.pars-subgroup-title]=\"item.isSubgroup\">\r\n {{item.group.groupName}}\r\n </div>\r\n <div *ngIf=\"item.group.parameters && item.group.parameters.length > 0\">\r\n <ng-container *ngFor=\"let par of item.group.parameters; let i= index; let last = last;\">\r\n <ng-container *ngIf=\"!DisplayMode || (!HideEmpty || (par.value))\">\r\n <div class=\"row form-group\" *ngIf=\"par.visible\" [class.app-margin-bottom-0]=\"LastParameterNoMargin && last\">\r\n <label class=\"col-md-{{LabelColWidth}} m-t-5\"><span *ngIf=\"Removal\" class=\"fa fa-remove text-danger\" (click)=\"removeParameter(par)\">&nbsp;</span>{{par.description}}{{par.required ? '*' : ''}}:</label>\r\n <!--Se Data-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'date'\">\r\n <form-date [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [required]=\"par.required\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" (inputChange)=\"changed();\" #validator></form-date>\r\n </div>\r\n <!--Se stringa-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'string'\">\r\n <form-input [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [required]=\"par.required\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" (inputChange)=\"changed();\" #validator></form-input>\r\n </div>\r\n <!--Se numero-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'number'\">\r\n <form-input [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [required]=\"par.required\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" (inputChange)=\"changed();\" #validator pattern=\"{{par.pattern || '^[+-]?[0-9]*[,]?[0-9]+$'}}\"></form-input>\r\n </div>\r\n <!--Se boolean-->\r\n <div class=\"col-md-{{InputColWidth}} m-t-5\" *ngIf=\"par.type == 'boolean'\">\r\n <form-checkbox [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" (inputChange)=\"changed();\" #validator></form-checkbox>\r\n </div>\r\n <!--Se enum single select-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'enum' && !par.multienum && !par.sourceapi\">\r\n <form-select [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [required]=\"par.required\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" (inputChange)=\"changed();\" #validator [Source]=\"par.enumvalues\"></form-select>\r\n </div>\r\n <!--Se enum multi select-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'enum' && par.multienum && !par.sourceapi\">\r\n <form-multiselect [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [UseJsonList]=\"MultiselectMode == 'JsonArray'\" [UseCommaSeparatedList]=\"MultiselectMode == 'CommaSeparated'\" [SelectLabel]=\"('Seleziona' | localize : lc) + '...'\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" [Readonly]=\"Readonly || par.isreadonly\" [Source]=\"par.enumvalues\" [required]=\"par.required\" (inputChange)=\"changed();\" #validator></form-multiselect>\r\n </div>\r\n <!--Se enum multiselect senza sorgente-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'enum' && par.multienum && !par.sourceapi && !par.enumvalues\">\r\n <form-autocomplete [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [HideChoicesOnSelection]=\"true\" [SelectLabel]=\"('Seleziona' | localize : lc) + '...'\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" [Readonly]=\"Readonly || par.isreadonly\" [UnboundMode]=\"true\" [required]=\"par.required\" (inputChange)=\"changed();\" #validator></form-autocomplete> \r\n </div>\r\n <!--Se enum autocomplete-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'enum' && !par.multienum && par.sourceapi\">\r\n <form-autocomplete [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" [Readonly]=\"Readonly || par.isreadonly\" [SearchFunction]=\"getSource.bind(this, par)\" [required]=\"par.required\" (inputChange)=\"changed();\" #validator></form-autocomplete>\r\n </div>\r\n <!--Se enum multiselect autocomplete-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'enum' && par.multienum && par.sourceapi\">\r\n <form-autocomplete [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [HideChoicesOnSelection]=\"AutocompleteHideChoicesOnSelection\" [Multi]=\"true\" [FormLayout]=\"false\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" [Readonly]=\"Readonly || par.isreadonly\" [SearchFunction]=\"getSource.bind(this, par)\" [required]=\"par.required\" (inputChange)=\"changed();\" #validator></form-autocomplete>\r\n </div>\r\n <!--Se file-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'file'\">\r\n <form-file [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [ReadFile]=\"true\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [required]=\"par.required\" [(ngModel)]=\"par.file\" name=\"{{item.index}}par{{i}}_{{par.id}}\" #validator></form-file>\r\n </div>\r\n </div>\r\n <div class=\"clearfix\"></div>\r\n </ng-container>\r\n </ng-container>\r\n <div *ngIf=\"DisplayMode && AllParametersEmpty && HideEmpty\" class=\"card card-info app-padding-10 app-no-margin app-white-text\">\r\n Non &egrave; presente nulla da visualizzare\r\n </div>\r\n </div>\r\n </div>\r\n</ng-template>", styles: [".list-area{position:fixed}.pars-group-title{background:#ddd;margin-bottom:7px;padding:5px;text-transform:uppercase;font-weight:700;text-align:center;color:#333;font-size:13px}.pars-subgroup-title{font-weight:700;color:#333;font-size:16px}.pars-group{margin-left:0}.pars-subgroup{margin-left:15px}\n"] }]
411
- }], ctorParameters: function () { return [{ type: i1.UtilityService }, { type: i2.LocalizationService }, { type: i0.ChangeDetectorRef }, { type: i0.Injector }, { type: i1.DateService }]; }, propDecorators: { DisplayMode: [{
412
- type: Input
413
- }], HideEmpty: [{
414
- type: Input
415
- }], LastParameterNoMargin: [{
416
- type: Input
417
- }], LabelColWidth: [{
418
- type: Input
419
- }], InputColWidth: [{
420
- type: Input
421
- }], submitted: [{
422
- type: Input
423
- }], EmptyMessage: [{
424
- type: Input
425
- }], Removal: [{
426
- type: Input
427
- }], Readonly: [{
428
- type: Input
429
- }], ListFormat: [{
430
- type: Input
431
- }], Form: [{
432
- type: Input
433
- }], AutocompleteHideChoicesOnSelection: [{
434
- type: Input
435
- }], AutoCompleteDataRetrieve: [{
436
- type: Input
437
- }], MultiselectMode: [{
438
- type: Input
439
- }], LabelInputRatio: [{
440
- type: Input
51
+ // Angular
52
+ /** Componente che permette di graficare una lista di **GenericParameter** come Input in base al loro tipo specifico */
53
+ class EsParametersComponent {
54
+ /** Permette di settare in una volta solo gli input **LabelColWidth** e **InputColWidth**, basta scriverlo con la sintassi "X Y" */
55
+ set LabelInputRatio(input) {
56
+ var ratio = input.split(/\s/);
57
+ this.LabelColWidth = parseInt(ratio[0]);
58
+ this.InputColWidth = parseInt(ratio[1]);
59
+ }
60
+ /**
61
+ * Costruttore
62
+ *
63
+ * @ignore
64
+ */
65
+ constructor(utiExts, lc, cdr, inj, dates) {
66
+ this.utiExts = utiExts;
67
+ this.lc = lc;
68
+ this.cdr = cdr;
69
+ this.inj = inj;
70
+ this.dates = dates;
71
+ /** Indica se si lavora a singolo parametro forzato dentro un array for the glory of satan */
72
+ this.SingleParameterMode = false;
73
+ /**
74
+ * Pipeline di Angular
75
+ *
76
+ * @ignore
77
+ */
78
+ this.propagateChange = (_) => { };
79
+ /** Indica che il parametro deve essere in modalità display */
80
+ this.DisplayMode = false;
81
+ /** Indica che il parametro (In Display mode!!) non appare se vuoto. In più, se tutti sono vuoti, fa vedere una bella card "non ci sono parametri presenti" */
82
+ this.HideEmpty = false;
83
+ /** Indica che l'ultimo parametro non deve avere margine in fondo */
84
+ this.LastParameterNoMargin = false;
85
+ /** col-md-X per la label */
86
+ this.LabelColWidth = 4;
87
+ /** col-md-X per l'input */
88
+ this.InputColWidth = 8;
89
+ /** Input a cui collegare la variabile **submitted** del form all'interno del quale viene utilizzato questo componente */
90
+ this.submitted = false;
91
+ /** Valore da mostrare qualora non fossero ancora ricevuti i **Parameters** da mostrare */
92
+ this.EmptyMessage = "";
93
+ /** Permette di rimuovere i parametri dalla lista cliccando sulla X davanti alla Label */
94
+ this.Removal = false;
95
+ /** Indica se i componenti di Input generati sono Readonly o no */
96
+ this.Readonly = false;
97
+ /** Indica il formato lista che dev'essere utilizzato */
98
+ this.ListFormat = 'Array';
99
+ /** Form che utilizza il componente. Fondamentale collegarlo se si vogliono le validazioni sul submit */
100
+ this.Form = null;
101
+ /** Quando utilizza un sottocomponente autocomplete abilita o disabilita il reset dell'input per ogni selezione */
102
+ this.AutocompleteHideChoicesOnSelection = false;
103
+ /** Indica come deve funzionare la multiselect */
104
+ this.MultiselectMode = 'CommaSeparated';
105
+ this.AllParametersEmpty = false;
106
+ this.Initialized = false;
107
+ }
108
+ ngOnInit() {
109
+ // Qui gli input dovrebbero essere settati. Alcuni form-roba non prendono bene i cambi di input
110
+ // Non sta funzionando come speravo... da rivedere
111
+ this.Initialized = true;
112
+ }
113
+ /**
114
+ * Pipeline di Angular
115
+ *
116
+ * @ignore
117
+ */
118
+ writeValue(obj) {
119
+ if (!obj)
120
+ return;
121
+ if (!Array.isArray(obj))
122
+ this.SingleParameterMode = true;
123
+ this.Parameters = Array.isArray(obj) ? obj : [obj];
124
+ this.ParametersCache = {};
125
+ this.Parameters.forEach(t => {
126
+ this.ParametersCache[t.id] = t;
127
+ if (!t.typecode && !t.type)
128
+ console.warn("Non è stato specificato né un type né un typecode");
129
+ if (t.typecode && !t.type)
130
+ t.type = this.utiExts.getJsTypeFromTypeCode(t.typecode);
131
+ if (t.typecode && t.type != this.utiExts.getJsTypeFromTypeCode(t.typecode))
132
+ console.warn(`Rilevate inconsistenze fra il Tipo ${t.type} e il Tipo ${this.utiExts.getJsTypeFromTypeCode(t.typecode)} calcolato da TypeCode ${t.typecode} per il parametro ${t.id}`);
133
+ if (t.type == "boolean")
134
+ t.value = t.value?.toString()?.toLowerCase() === "true";
135
+ if (t.enumtype || t.dicttype)
136
+ t.type = 'enum';
137
+ // Valore valido ma modalità di utilizzo a CommaSeparated, devo assicurarmi di riemettere la versione con la stringa
138
+ if (t.type == 'enum' && this.ListFormat == 'CommaSeparated' && t.multienum && t.value && Array.isArray(t.value))
139
+ this.changed();
140
+ // Aggiusto le modalità di funzionamento dei parametri lista. Che internamente funzionano sempre con una lista di valori
141
+ if (t.type == 'enum' && this.ListFormat == 'CommaSeparated' && t.multienum && t.value && !Array.isArray(t.value))
142
+ t.value = t.value ? t.value.split(',').map(t => t.trim()) : [];
143
+ });
144
+ this.AllParametersEmpty = this.Parameters.every(t => !t.value);
145
+ this.reviewParametersBindings();
146
+ this.generateGroups();
147
+ }
148
+ /**
149
+ * Metodo che si occupa di creare e ordinare i gruppi dei parametri
150
+ */
151
+ generateGroups() {
152
+ this.Groups = [];
153
+ if (this.Parameters?.length > 0) {
154
+ this.Parameters.sort((a, b) => a.order < b.order ? -1 : 1);
155
+ // Ciclo tutti i parametri
156
+ for (let i = 0; this.Parameters.length > i; i++) {
157
+ let par = this.Parameters[i];
158
+ let parGroupName = par.group ?? "";
159
+ let groupOrder = par.group ? par.order : -1;
160
+ // Se il gruppo non esiste, lo aggiungo
161
+ if (!this.Groups.some(x => x.groupName == parGroupName)) {
162
+ this.Groups.push(new GenericParameterGroup(parGroupName, groupOrder));
163
+ }
164
+ // Inserisco il parametro dentro al suo gruppo
165
+ this.Groups.find(g => g.groupName == parGroupName).parameters.push(par);
166
+ }
167
+ // Gestione sottogruppi
168
+ let subgroups = this.Groups.filter(group => group.groupName.includes('§'));
169
+ for (let _; subgroups.length > 0; () => { }) {
170
+ // Recupero la lista di gruppi che hanno sottogruppi
171
+ // Per convenzione, nel nome contengono "§"
172
+ this.tryToAddSubgroups(subgroups);
173
+ subgroups = this.Groups.filter(group => group.groupName.includes('§'));
174
+ }
175
+ this.Groups.sort((a, b) => a.order < b.order ? -1 : 1);
176
+ }
177
+ }
178
+ /**
179
+ * Metodo che si occupa di creare e ordinare i sottogruppi dei parametri
180
+ */
181
+ tryToAddSubgroups(subgroups) {
182
+ for (let i = 0; subgroups.length > i; i++) {
183
+ let sub = subgroups[i];
184
+ // Ottengo un lista con la gerarchia dei gruppi, in ordine
185
+ let groupsParentHierarchy = sub.groupName.split('§') ?? [];
186
+ // Recupero il gruppo padre
187
+ let parentGroupName = sub.groupName.replace(`§${groupsParentHierarchy[groupsParentHierarchy.length - 1]}`, ``);
188
+ // Se il gruppo padre non esiste, lo aggiungo
189
+ if (!this.Groups.some(x => x.groupName == parentGroupName)) {
190
+ this.Groups.push(new GenericParameterGroup(parentGroupName, sub.order));
191
+ }
192
+ // Rimuovo dal nome del gruppo l'informazione sul padre (Sistemando anche l'etichetta)
193
+ // e lo aggiungo ai sottogruppi del padre
194
+ sub.groupName = sub.groupName.replace(`${parentGroupName}§`, '');
195
+ let parentGroup = this.Groups.find(x => x.groupName == parentGroupName);
196
+ if (parentGroup?.subgroups.some(s => s.groupName == sub.groupName)) {
197
+ let target = parentGroup.subgroups.find(f => f.groupName == sub.groupName);
198
+ sub.parameters.map(p => target.parameters.push(p));
199
+ sub.subgroups.map(s => target.subgroups.push(s));
200
+ target.order = sub.order < target.order ? sub.order : target.order;
201
+ }
202
+ else {
203
+ parentGroup?.subgroups.push(sub);
204
+ }
205
+ // Rimuovo il sottogruppo gruppo dalla lista
206
+ this.Groups.splice(this.Groups.indexOf(sub), 1);
207
+ }
208
+ }
209
+ /**
210
+ * Pipeline di Angular
211
+ *
212
+ * @ignore
213
+ */
214
+ registerOnChange(fn) { this.propagateChange = fn; }
215
+ /**
216
+ * Pipeline di Angular
217
+ *
218
+ * @ignore
219
+ */
220
+ registerOnTouched(fn) { }
221
+ /**
222
+ * Metodo che si occupa di gestire il modello in uscita e propagarlo sul binding ngModel
223
+ */
224
+ changed() {
225
+ if (!this.Parameters)
226
+ return;
227
+ if (!this.Groups)
228
+ this.generateGroups();
229
+ // Se ci sono delle modifiche ai binding potrebbero essere cambiati i required. Ricreo tutti i componenti e ri-idrato la cache dei parametri
230
+ var changes = this.reviewParametersBindings();
231
+ if (changes.length > 0) {
232
+ // In base ai binding cambiati devo trovare tutti i parametri che han subito modifiche strutturali (visibilità, obbligatorietà)
233
+ // distruggerli e ricrearli in modo che i binding lato html si aggiornino di conseguenza.
234
+ // 1: Faccio una copia del parametro corrente
235
+ // 2: Trovo la sua posizione all'interno dei gruppi e lo sostituisco con la copia
236
+ // 3: Aggiorno la lista dei parametri e la sua cache in modo da puntare all'oggetto nuovo
237
+ changes.forEach(ch => {
238
+ let index = this.Parameters.findIndex(t => t.id == ch);
239
+ let parameterCopy = this.utiExts.deepClone(this.Parameters[index]);
240
+ let parameterRefFixed = false;
241
+ for (let ig = 0; ig < this.Groups.length; ig++) {
242
+ var g = this.Groups[ig];
243
+ for (let ip = 0; ip < g.parameters.length; ip++) {
244
+ var p = g.parameters[ip];
245
+ if (p === this.Parameters[index]) {
246
+ this.Groups[ig].parameters[ip] = parameterCopy;
247
+ parameterRefFixed = true;
248
+ break;
249
+ }
250
+ }
251
+ if (parameterRefFixed)
252
+ break;
253
+ }
254
+ this.Parameters[index] = parameterCopy;
255
+ this.ParametersCache[ch] = this.Parameters[index];
256
+ this.cdr.markForCheck();
257
+ });
258
+ }
259
+ var ParametersClone = this.utiExts.deepClone(this.Parameters);
260
+ // Aggiusto le modalità di funzionamento dei parametri lista. Che internamente funzionano sempre con una lista di valori
261
+ ParametersClone?.forEach(t => {
262
+ if (t.type == "enum" && this.ListFormat == 'CommaSeparated' && t.multienum && t.value && Array.isArray(t.value))
263
+ t.value = t.value.join(',');
264
+ });
265
+ this.propagateChange(this.SingleParameterMode ? ParametersClone[0] : ParametersClone);
266
+ }
267
+ /**
268
+ * Rimuove il parametro selezionato e propaga il modello
269
+ *
270
+ * @param {GenericParameter} par Parametro da rimuovere
271
+ */
272
+ removeParameter(par) {
273
+ this.Parameters.splice(this.Parameters.indexOf(par), 1);
274
+ this.changed();
275
+ }
276
+ GenerateParameterGroups() {
277
+ let Groups = [];
278
+ this.Parameters.forEach(param => {
279
+ Groups.push({ id: param.id, groups: param.group.split("§"), order: param.order });
280
+ });
281
+ let GroupedGroups = Groups.reduce((r, a) => {
282
+ let firstGroupId = a.groups?.length > 0 ? a.groups[0] : "";
283
+ r[firstGroupId] = [...r[firstGroupId] || [], a];
284
+ return r;
285
+ }, {});
286
+ console.log(GroupedGroups);
287
+ // Ciclo del risultato, aggiungendo i gruppi al modello
288
+ // Per ogni gruppo che aggiungo, assegno i parametri in ordine
289
+ }
290
+ /**
291
+ * Rivede i bindings dei parametri in base a loro eventuali espressioni di controllo
292
+ *
293
+ * @returns {string[]} lista con gli id dei parametri che sono stati modificati
294
+ */
295
+ reviewParametersBindings() {
296
+ let changes = [];
297
+ for (let i = 0; i < this.Parameters.length; i++) {
298
+ var p = this.Parameters[i];
299
+ if (p.requiredexp) {
300
+ let prevReq = p.required;
301
+ p.required = this.evaluate(p.requiredexp);
302
+ if (prevReq != p.required)
303
+ changes.push(p.id);
304
+ }
305
+ if (p.visibleexp) {
306
+ let prevVisi = p.visible;
307
+ p.visible = this.evaluate(p.visibleexp);
308
+ if (prevVisi != p.visible)
309
+ changes.push(p.id);
310
+ }
311
+ }
312
+ return changes;
313
+ }
314
+ /**
315
+ * Valuta un'espressione in base ai parametri presenti nel modello attuale
316
+ *
317
+ * @param expr Espressione da valutare scritta nel formato (ripetibile) "ID (==|!=|<|>|>=|<=) (`valore` | null | true | false | XXX,XXX)" separato eventualmente da && ed ||
318
+ *
319
+ * @returns **true** se la condizione è verificata, **false** altrimenti
320
+ */
321
+ evaluate(expr) {
322
+ var regex = /\s?([a-zA-Z0-9_-]+)\s?(!=|==|<|>|<=|>=)\s?(`[^`]+`|``|null|[0-9,]+|true|false)/gm;
323
+ var matches = [];
324
+ var finalExpr = expr;
325
+ while (matches = regex.exec(expr)) {
326
+ var fullMatch = matches[0].trim();
327
+ var id = matches[1].trim();
328
+ var operation = matches[2].trim();
329
+ let bValue = matches[3].trim().trim();
330
+ var value = matches[3].trim().trim().replace('`', '').replace('`', '');
331
+ finalExpr = finalExpr.replace(fullMatch, `this.checkValue('${id}', '${operation}', ${bValue == 'null' ? 'null' : `'${value}'`})`);
332
+ }
333
+ return eval(finalExpr);
334
+ }
335
+ /**
336
+ * Restituisce l'operazione di comparazione fra un singolo valore di un parametro e un suo valore di confronto in base ad un operatore
337
+ * Richiamata da EVAL
338
+ *
339
+ * @param {string} key Chiave del parametro di cui verificare il valore
340
+ * @param {string} operator Operatore con cui verificare il valore: ==, !=, >, <, >=, <=
341
+ * @param {string} value Valore di confronto da utilizzare
342
+ *
343
+ * @returns **true** se la condizione è verificata, **false** altrimenti
344
+ */
345
+ checkValue(key, operator, value) {
346
+ var rPar = this.ParametersCache[key];
347
+ try {
348
+ switch (rPar.type) {
349
+ case "string":
350
+ case "enum":
351
+ return eval(`"${this.defaultIfnullOrUndefined(rPar.value, ``)}" ${operator} "${this.defaultIfnullOrUndefined(value, ``)}"`);
352
+ case "boolean":
353
+ return eval(`${this.defaultIfnullOrUndefined(rPar.value, ``).toString()} ${operator} ${this.defaultIfnullOrUndefined(value, ``)}`);
354
+ case "number":
355
+ return eval(`${this.defaultIfnullOrUndefined(rPar.value, '""', true).replace(',', '.')} ${operator} ${this.defaultIfnullOrUndefined(value, '""', true).replace(',', '.')}`);
356
+ case "date":
357
+ let parDateConv = `this.dates.getDateConvertion("${rPar.value}")`;
358
+ let valDateConv = `this.dates.getDateConvertion("${value}")`;
359
+ switch (operator) {
360
+ case "==": return eval(`${parDateConv} == ${valDateConv} || (${parDateConv} != null && ${parDateConv}.isSame(${valDateConv}))`);
361
+ case "!=": return eval(`${parDateConv} != ${valDateConv} && ${parDateConv} != null && !${parDateConv}.isSame(${valDateConv})`);
362
+ case ">": return eval(`${parDateConv} != null && ${valDateConv} != null && ${parDateConv}.isAfter(${valDateConv})`);
363
+ case "<": return eval(`${parDateConv} != null && ${valDateConv} != null && ${parDateConv}.isBefore(${valDateConv})`);
364
+ case ">=": return eval(`${parDateConv} != null && ${valDateConv} != null && (${parDateConv}.isAfter(${valDateConv}) || ${parDateConv}?.isSame(${valDateConv}))`);
365
+ case "<=": return eval(`${parDateConv} != null && ${valDateConv} != null && (${parDateConv}.isBefore(${valDateConv}) || ${parDateConv}?.isSame(${valDateConv}))`);
366
+ }
367
+ }
368
+ }
369
+ catch (error) {
370
+ console.error(error);
371
+ console.warn("Errori nella valutazione dell'espressione. Fallback a false");
372
+ return false;
373
+ }
374
+ throw `@esfaenza/parameters: Tipo parametro ${key} non riconosciuto: ${rPar.type}`;
375
+ }
376
+ /** @ignore */
377
+ defaultIfnullOrUndefined(item, dflt, emptyStringIsNull = false) {
378
+ if (item == null || item == undefined || item.toString() == 'null' || (emptyStringIsNull && item.toString() == ""))
379
+ return dflt;
380
+ return item;
381
+ }
382
+ /** @ignore */
383
+ getSource(parameter, search, byid) {
384
+ if (!this.AutoCompleteDataRetrieve) {
385
+ console.error("@forms-and-validations: funzione di dataretrieve non impostata per un parametro autocomplete");
386
+ return of([]);
387
+ }
388
+ else
389
+ return this.AutoCompleteDataRetrieve(parameter, search, byid);
390
+ }
391
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EsParametersComponent, deps: [{ token: i1.UtilityService }, { token: i2.LocalizationService }, { token: i0.ChangeDetectorRef }, { token: i0.Injector }, { token: i1.DateService }], target: i0.ɵɵFactoryTarget.Component }); }
392
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: EsParametersComponent, selector: "es-parameters", inputs: { DisplayMode: "DisplayMode", HideEmpty: "HideEmpty", LastParameterNoMargin: "LastParameterNoMargin", LabelColWidth: "LabelColWidth", InputColWidth: "InputColWidth", submitted: "submitted", EmptyMessage: "EmptyMessage", Removal: "Removal", Readonly: "Readonly", ListFormat: "ListFormat", Form: "Form", AutocompleteHideChoicesOnSelection: "AutocompleteHideChoicesOnSelection", AutoCompleteDataRetrieve: "AutoCompleteDataRetrieve", MultiselectMode: "MultiselectMode", LabelInputRatio: "LabelInputRatio" }, providers: [
393
+ { provide: LocalizationService, useClass: EsParametersLoc },
394
+ {
395
+ provide: NG_VALUE_ACCESSOR,
396
+ useExisting: forwardRef(() => EsParametersComponent),
397
+ multi: true
398
+ }
399
+ ], ngImport: i0, template: "<div *ngIf=\"(!Parameters || Parameters.length == 0) && EmptyMessage\">\r\n <em>{{EmptyMessage}}</em>\r\n</div>\r\n\r\n<div *ngIf=\"Groups && Initialized\">\r\n <ng-container *ngTemplateOutlet=\"Temp; context: {item: { groups: Groups, isSubgroup: false }}\"></ng-container>\r\n</div>\r\n\r\n<ng-template #Temp let-item=\"item\">\r\n <ng-container *ngFor=\"let group of item.groups; let k = index\">\r\n <div [class.pars-subgroup]=\"item.isSubgroup\" [class.pars-group]=\"!item.isSubgroup\">\r\n <ng-container *ngTemplateOutlet=\"GroupsOrSubgroupsDisplay; context: { item: { group: group, index: k + (item.index ? ('_' + item.index) : ''), isSubgroup: item.isSubgroup }}\"></ng-container>\r\n <ng-container *ngIf=\"group.subgroups.length > 0\">\r\n <ng-container *ngTemplateOutlet=\"Temp; context: {item: { groups: group.subgroups, index: k + (item.index ? ('_' + item.index) : ''), isSubgroup: true }};\"></ng-container>\r\n </ng-container>\r\n </div>\r\n </ng-container>\r\n</ng-template>\r\n\r\n<ng-template #GroupsOrSubgroupsDisplay let-item=\"item\">\r\n <div *ngIf=\"item.group && Initialized\">\r\n <div *ngIf=\"item.group.groupName\" [class.pars-group-title]=\"!item.isSubgroup\" [class.pars-subgroup-title]=\"item.isSubgroup\">\r\n {{item.group.groupName}}\r\n </div>\r\n <div *ngIf=\"item.group.parameters && item.group.parameters.length > 0\">\r\n <ng-container *ngFor=\"let par of item.group.parameters; let i= index; let last = last;\">\r\n <ng-container *ngIf=\"!DisplayMode || (!HideEmpty || (par.value))\">\r\n <div class=\"row form-group\" *ngIf=\"par.visible\" [class.app-margin-bottom-0]=\"LastParameterNoMargin && last\">\r\n <label class=\"col-md-{{LabelColWidth}} m-t-5\"><span *ngIf=\"Removal\" class=\"fa fa-remove text-danger\" (click)=\"removeParameter(par)\">&nbsp;</span>{{par.description}}{{par.required ? '*' : ''}}:</label>\r\n <!--Se Data-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'date'\">\r\n <form-date [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [required]=\"par.required\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" (inputChange)=\"changed();\" #validator></form-date>\r\n </div>\r\n <!--Se stringa-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'string'\">\r\n <form-input [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [required]=\"par.required\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" (inputChange)=\"changed();\" #validator></form-input>\r\n </div>\r\n <!--Se numero-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'number'\">\r\n <form-input [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [required]=\"par.required\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" (inputChange)=\"changed();\" #validator pattern=\"{{par.pattern || '^[+-]?[0-9]*[,]?[0-9]+$'}}\"></form-input>\r\n </div>\r\n <!--Se boolean-->\r\n <div class=\"col-md-{{InputColWidth}} m-t-5\" *ngIf=\"par.type == 'boolean'\">\r\n <form-checkbox [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" (inputChange)=\"changed();\" #validator></form-checkbox>\r\n </div>\r\n <!--Se enum single select-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'enum' && !par.multienum && !par.sourceapi\">\r\n <form-select [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [required]=\"par.required\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" (inputChange)=\"changed();\" #validator [Source]=\"par.enumvalues\"></form-select>\r\n </div>\r\n <!--Se enum multi select-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'enum' && par.multienum && !par.sourceapi\">\r\n <form-multiselect [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [UseJsonList]=\"MultiselectMode == 'JsonArray'\" [UseCommaSeparatedList]=\"MultiselectMode == 'CommaSeparated'\" [SelectLabel]=\"('Seleziona' | localize : lc) + '...'\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" [Readonly]=\"Readonly || par.isreadonly\" [Source]=\"par.enumvalues\" [required]=\"par.required\" (inputChange)=\"changed();\" #validator></form-multiselect>\r\n </div>\r\n <!--Se enum multiselect senza sorgente-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'enum' && par.multienum && !par.sourceapi && !par.enumvalues\">\r\n <form-autocomplete [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [HideChoicesOnSelection]=\"true\" [SelectLabel]=\"('Seleziona' | localize : lc) + '...'\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" [Readonly]=\"Readonly || par.isreadonly\" [UnboundMode]=\"true\" [required]=\"par.required\" (inputChange)=\"changed();\" #validator></form-autocomplete> \r\n </div>\r\n <!--Se enum autocomplete-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'enum' && !par.multienum && par.sourceapi\">\r\n <form-autocomplete [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" [Readonly]=\"Readonly || par.isreadonly\" [SearchFunction]=\"getSource.bind(this, par)\" [required]=\"par.required\" (inputChange)=\"changed();\" #validator></form-autocomplete>\r\n </div>\r\n <!--Se enum multiselect autocomplete-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'enum' && par.multienum && par.sourceapi\">\r\n <form-autocomplete [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [HideChoicesOnSelection]=\"AutocompleteHideChoicesOnSelection\" [Multi]=\"true\" [FormLayout]=\"false\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" [Readonly]=\"Readonly || par.isreadonly\" [SearchFunction]=\"getSource.bind(this, par)\" [required]=\"par.required\" (inputChange)=\"changed();\" #validator></form-autocomplete>\r\n </div>\r\n <!--Se file-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'file'\">\r\n <form-file [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [ReadFile]=\"true\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [required]=\"par.required\" [(ngModel)]=\"par.file\" name=\"{{item.index}}par{{i}}_{{par.id}}\" #validator></form-file>\r\n </div>\r\n </div>\r\n <div class=\"clearfix\"></div>\r\n </ng-container>\r\n </ng-container>\r\n <div *ngIf=\"DisplayMode && AllParametersEmpty && HideEmpty\" class=\"card card-info app-padding-10 app-no-margin app-white-text\">\r\n Non &egrave; presente nulla da visualizzare\r\n </div>\r\n </div>\r\n </div>\r\n</ng-template>", styles: [".list-area{position:fixed}.pars-group-title{background:#ddd;margin-bottom:7px;padding:5px;text-transform:uppercase;font-weight:700;text-align:center;color:#333;font-size:13px}.pars-subgroup-title{font-weight:700;color:#333;font-size:16px}.pars-group{margin-left:0}.pars-subgroup{margin-left:15px}\n"], dependencies: [{ kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i4.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { kind: "directive", type: i4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i5.FormCheckboxComponent, selector: "form-checkbox", inputs: ["SliderMode"] }, { kind: "component", type: i5.FormDateComponent, selector: "form-date", inputs: ["JsDates"] }, { kind: "component", type: i5.FormInputComponent, selector: "form-input", inputs: ["Password"], outputs: ["onSuffixAction", "onPrefixAction"] }, { kind: "component", type: i5.FormSelectComponent, selector: "form-select", inputs: ["SelectLabel", "PlaceholderValue", "RequiredPlaceholder", "EmptyFieldValue", "ShowValidationSymbol", "OptionTemplate"] }, { kind: "component", type: i5.FormMultiSelectComponent, selector: "form-multiselect", inputs: ["SelectLabel", "UseKeyValues", "UseCommaSeparatedList", "UseJsonList"] }, { kind: "component", type: i5.FormFileComponent, selector: "form-file", inputs: ["Multiple", "AllowDownload", "MaxSize", "FancyMode", "ReadFile"] }, { kind: "component", type: i5.FormAutocompleteComponent, selector: "form-autocomplete", inputs: ["SelectLabel", "SearchFunctionContext", "SearchFunction", "MinChars", "HideChoicesOnSelection", "RequiredPlaceholder", "CaseSensitive", "Multi", "MultiElementsThreshold", "UnboundMode"] }, { kind: "pipe", type: i2.LocalizePipe, name: "localize" }], encapsulation: i0.ViewEncapsulation.None }); }
400
+ }
401
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EsParametersComponent, decorators: [{
402
+ type: Component,
403
+ args: [{ selector: "es-parameters", providers: [
404
+ { provide: LocalizationService, useClass: EsParametersLoc },
405
+ {
406
+ provide: NG_VALUE_ACCESSOR,
407
+ useExisting: forwardRef(() => EsParametersComponent),
408
+ multi: true
409
+ }
410
+ ], encapsulation: ViewEncapsulation.None, template: "<div *ngIf=\"(!Parameters || Parameters.length == 0) && EmptyMessage\">\r\n <em>{{EmptyMessage}}</em>\r\n</div>\r\n\r\n<div *ngIf=\"Groups && Initialized\">\r\n <ng-container *ngTemplateOutlet=\"Temp; context: {item: { groups: Groups, isSubgroup: false }}\"></ng-container>\r\n</div>\r\n\r\n<ng-template #Temp let-item=\"item\">\r\n <ng-container *ngFor=\"let group of item.groups; let k = index\">\r\n <div [class.pars-subgroup]=\"item.isSubgroup\" [class.pars-group]=\"!item.isSubgroup\">\r\n <ng-container *ngTemplateOutlet=\"GroupsOrSubgroupsDisplay; context: { item: { group: group, index: k + (item.index ? ('_' + item.index) : ''), isSubgroup: item.isSubgroup }}\"></ng-container>\r\n <ng-container *ngIf=\"group.subgroups.length > 0\">\r\n <ng-container *ngTemplateOutlet=\"Temp; context: {item: { groups: group.subgroups, index: k + (item.index ? ('_' + item.index) : ''), isSubgroup: true }};\"></ng-container>\r\n </ng-container>\r\n </div>\r\n </ng-container>\r\n</ng-template>\r\n\r\n<ng-template #GroupsOrSubgroupsDisplay let-item=\"item\">\r\n <div *ngIf=\"item.group && Initialized\">\r\n <div *ngIf=\"item.group.groupName\" [class.pars-group-title]=\"!item.isSubgroup\" [class.pars-subgroup-title]=\"item.isSubgroup\">\r\n {{item.group.groupName}}\r\n </div>\r\n <div *ngIf=\"item.group.parameters && item.group.parameters.length > 0\">\r\n <ng-container *ngFor=\"let par of item.group.parameters; let i= index; let last = last;\">\r\n <ng-container *ngIf=\"!DisplayMode || (!HideEmpty || (par.value))\">\r\n <div class=\"row form-group\" *ngIf=\"par.visible\" [class.app-margin-bottom-0]=\"LastParameterNoMargin && last\">\r\n <label class=\"col-md-{{LabelColWidth}} m-t-5\"><span *ngIf=\"Removal\" class=\"fa fa-remove text-danger\" (click)=\"removeParameter(par)\">&nbsp;</span>{{par.description}}{{par.required ? '*' : ''}}:</label>\r\n <!--Se Data-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'date'\">\r\n <form-date [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [required]=\"par.required\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" (inputChange)=\"changed();\" #validator></form-date>\r\n </div>\r\n <!--Se stringa-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'string'\">\r\n <form-input [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [required]=\"par.required\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" (inputChange)=\"changed();\" #validator></form-input>\r\n </div>\r\n <!--Se numero-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'number'\">\r\n <form-input [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [required]=\"par.required\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" (inputChange)=\"changed();\" #validator pattern=\"{{par.pattern || '^[+-]?[0-9]*[,]?[0-9]+$'}}\"></form-input>\r\n </div>\r\n <!--Se boolean-->\r\n <div class=\"col-md-{{InputColWidth}} m-t-5\" *ngIf=\"par.type == 'boolean'\">\r\n <form-checkbox [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" (inputChange)=\"changed();\" #validator></form-checkbox>\r\n </div>\r\n <!--Se enum single select-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'enum' && !par.multienum && !par.sourceapi\">\r\n <form-select [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [required]=\"par.required\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" (inputChange)=\"changed();\" #validator [Source]=\"par.enumvalues\"></form-select>\r\n </div>\r\n <!--Se enum multi select-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'enum' && par.multienum && !par.sourceapi\">\r\n <form-multiselect [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [UseJsonList]=\"MultiselectMode == 'JsonArray'\" [UseCommaSeparatedList]=\"MultiselectMode == 'CommaSeparated'\" [SelectLabel]=\"('Seleziona' | localize : lc) + '...'\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" [Readonly]=\"Readonly || par.isreadonly\" [Source]=\"par.enumvalues\" [required]=\"par.required\" (inputChange)=\"changed();\" #validator></form-multiselect>\r\n </div>\r\n <!--Se enum multiselect senza sorgente-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'enum' && par.multienum && !par.sourceapi && !par.enumvalues\">\r\n <form-autocomplete [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [HideChoicesOnSelection]=\"true\" [SelectLabel]=\"('Seleziona' | localize : lc) + '...'\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" [Readonly]=\"Readonly || par.isreadonly\" [UnboundMode]=\"true\" [required]=\"par.required\" (inputChange)=\"changed();\" #validator></form-autocomplete> \r\n </div>\r\n <!--Se enum autocomplete-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'enum' && !par.multienum && par.sourceapi\">\r\n <form-autocomplete [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [FormLayout]=\"false\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" [Readonly]=\"Readonly || par.isreadonly\" [SearchFunction]=\"getSource.bind(this, par)\" [required]=\"par.required\" (inputChange)=\"changed();\" #validator></form-autocomplete>\r\n </div>\r\n <!--Se enum multiselect autocomplete-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'enum' && par.multienum && par.sourceapi\">\r\n <form-autocomplete [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [HideChoicesOnSelection]=\"AutocompleteHideChoicesOnSelection\" [Multi]=\"true\" [FormLayout]=\"false\" [(ngModel)]=\"par.value\" name=\"{{item.index}}par{{i}}_{{par.id}}\" [Readonly]=\"Readonly || par.isreadonly\" [SearchFunction]=\"getSource.bind(this, par)\" [required]=\"par.required\" (inputChange)=\"changed();\" #validator></form-autocomplete>\r\n </div>\r\n <!--Se file-->\r\n <div class=\"col-md-{{InputColWidth}}\" *ngIf=\"par.type == 'file'\">\r\n <form-file [DisplayMode]=\"DisplayMode\" [Form]=\"Form\" [ReadFile]=\"true\" [FormLayout]=\"false\" [Readonly]=\"Readonly || par.isreadonly\" [required]=\"par.required\" [(ngModel)]=\"par.file\" name=\"{{item.index}}par{{i}}_{{par.id}}\" #validator></form-file>\r\n </div>\r\n </div>\r\n <div class=\"clearfix\"></div>\r\n </ng-container>\r\n </ng-container>\r\n <div *ngIf=\"DisplayMode && AllParametersEmpty && HideEmpty\" class=\"card card-info app-padding-10 app-no-margin app-white-text\">\r\n Non &egrave; presente nulla da visualizzare\r\n </div>\r\n </div>\r\n </div>\r\n</ng-template>", styles: [".list-area{position:fixed}.pars-group-title{background:#ddd;margin-bottom:7px;padding:5px;text-transform:uppercase;font-weight:700;text-align:center;color:#333;font-size:13px}.pars-subgroup-title{font-weight:700;color:#333;font-size:16px}.pars-group{margin-left:0}.pars-subgroup{margin-left:15px}\n"] }]
411
+ }], ctorParameters: () => [{ type: i1.UtilityService }, { type: i2.LocalizationService }, { type: i0.ChangeDetectorRef }, { type: i0.Injector }, { type: i1.DateService }], propDecorators: { DisplayMode: [{
412
+ type: Input
413
+ }], HideEmpty: [{
414
+ type: Input
415
+ }], LastParameterNoMargin: [{
416
+ type: Input
417
+ }], LabelColWidth: [{
418
+ type: Input
419
+ }], InputColWidth: [{
420
+ type: Input
421
+ }], submitted: [{
422
+ type: Input
423
+ }], EmptyMessage: [{
424
+ type: Input
425
+ }], Removal: [{
426
+ type: Input
427
+ }], Readonly: [{
428
+ type: Input
429
+ }], ListFormat: [{
430
+ type: Input
431
+ }], Form: [{
432
+ type: Input
433
+ }], AutocompleteHideChoicesOnSelection: [{
434
+ type: Input
435
+ }], AutoCompleteDataRetrieve: [{
436
+ type: Input
437
+ }], MultiselectMode: [{
438
+ type: Input
439
+ }], LabelInputRatio: [{
440
+ type: Input
441
441
  }] } });
442
442
 
443
- class EsParametersModule {
444
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EsParametersModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
445
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: EsParametersModule, declarations: [EsParametersComponent], imports: [CommonModule,
446
- LocalizationModule,
447
- FormsModule,
448
- FormsAndValidationsModule], exports: [EsParametersComponent] }); }
449
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EsParametersModule, imports: [CommonModule,
450
- LocalizationModule,
451
- FormsModule,
452
- FormsAndValidationsModule] }); }
453
- }
454
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EsParametersModule, decorators: [{
455
- type: NgModule,
456
- args: [{
457
- declarations: [EsParametersComponent],
458
- imports: [
459
- CommonModule,
460
- LocalizationModule,
461
- FormsModule,
462
- FormsAndValidationsModule,
463
- ],
464
- exports: [EsParametersComponent]
465
- }]
443
+ class EsParametersModule {
444
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EsParametersModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
445
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: EsParametersModule, declarations: [EsParametersComponent], imports: [CommonModule,
446
+ LocalizationModule,
447
+ FormsModule,
448
+ FormsAndValidationsModule], exports: [EsParametersComponent] }); }
449
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EsParametersModule, imports: [CommonModule,
450
+ LocalizationModule,
451
+ FormsModule,
452
+ FormsAndValidationsModule] }); }
453
+ }
454
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EsParametersModule, decorators: [{
455
+ type: NgModule,
456
+ args: [{
457
+ declarations: [EsParametersComponent],
458
+ imports: [
459
+ CommonModule,
460
+ LocalizationModule,
461
+ FormsModule,
462
+ FormsAndValidationsModule,
463
+ ],
464
+ exports: [EsParametersComponent]
465
+ }]
466
466
  }] });
467
467
 
468
- /**
469
- * Classe che rappresenta un parametro generico
470
- */
471
- class GenericParameter {
472
- /**
473
- * Costruttore
474
- *
475
- * @param {string} id Codice del parametro
476
- * @param {string} description Descrizione del parametro
477
- * @param {string} pattern Pattern di validazione
478
- * @param {'date' | 'string' | 'number' | 'boolean' | 'enum'} type Tipo di input
479
- * @param {boolean} required Indica se il valore è obbligatorio o meno
480
- * @param {any} v_default Valore di default per questo Parametro
481
- * @param {{ id: string, description: string }[]} enumvalues Qualora il **type** fosse di tipo **enum**, qui devono esserci tutti i valori che può assumere
482
- * @param {boolean} multienum Qualora il **type** fosse di tipo **enum**, indica se è possibile selezionare più valori (multiselect)
483
- * @param {string} sourceapi Nei casi in cui il **type** è **enum** indica l'api da cui recuperare i valori da bindare alla select o alla multiselect
484
- * @param {boolean} pageddata Nei casi in cui il **type** è **enum** indica che l'api specificata eventualmetne da **sourceapi** è paginata
485
- */
486
- constructor(id, description, pattern, type, required, v_default = null, enumvalues = [], multienum, sourceapi, pageddata) {
487
- this.id = id;
488
- this.description = description;
489
- this.pattern = pattern;
490
- this.required = required;
491
- this.enumvalues = enumvalues;
492
- this.multienum = multienum;
493
- this.sourceapi = sourceapi;
494
- this.pageddata = pageddata;
495
- this.type = type == 'enum' ? null : type;
496
- this.visible = true;
497
- this.enumtype = type == 'enum' ? type : "";
498
- this.isreadonly = false;
499
- if (!this.enumtype && enumvalues.length != 0)
500
- console.error("impossibile gestire valori di dizionario per un parametro non di tipo enum");
501
- if (v_default != null)
502
- this.value = v_default;
503
- }
468
+ /**
469
+ * Classe che rappresenta un parametro generico
470
+ */
471
+ class GenericParameter {
472
+ /**
473
+ * Costruttore
474
+ *
475
+ * @param {string} id Codice del parametro
476
+ * @param {string} description Descrizione del parametro
477
+ * @param {string} pattern Pattern di validazione
478
+ * @param {'date' | 'string' | 'number' | 'boolean' | 'enum'} type Tipo di input
479
+ * @param {boolean} required Indica se il valore è obbligatorio o meno
480
+ * @param {any} v_default Valore di default per questo Parametro
481
+ * @param {{ id: string, description: string }[]} enumvalues Qualora il **type** fosse di tipo **enum**, qui devono esserci tutti i valori che può assumere
482
+ * @param {boolean} multienum Qualora il **type** fosse di tipo **enum**, indica se è possibile selezionare più valori (multiselect)
483
+ * @param {string} sourceapi Nei casi in cui il **type** è **enum** indica l'api da cui recuperare i valori da bindare alla select o alla multiselect
484
+ * @param {boolean} pageddata Nei casi in cui il **type** è **enum** indica che l'api specificata eventualmetne da **sourceapi** è paginata
485
+ */
486
+ constructor(id, description, pattern, type, required, v_default = null, enumvalues = [], multienum, sourceapi, pageddata) {
487
+ this.id = id;
488
+ this.description = description;
489
+ this.pattern = pattern;
490
+ this.required = required;
491
+ this.enumvalues = enumvalues;
492
+ this.multienum = multienum;
493
+ this.sourceapi = sourceapi;
494
+ this.pageddata = pageddata;
495
+ this.type = type == 'enum' ? null : type;
496
+ this.visible = true;
497
+ this.enumtype = type == 'enum' ? type : "";
498
+ this.isreadonly = false;
499
+ if (!this.enumtype && enumvalues.length != 0)
500
+ console.error("impossibile gestire valori di dizionario per un parametro non di tipo enum");
501
+ if (v_default != null)
502
+ this.value = v_default;
503
+ }
504
504
  }
505
505
 
506
- /*
507
- * Public API Surface of parameters
506
+ /*
507
+ * Public API Surface of parameters
508
508
  */
509
509
 
510
- /**
511
- * Generated bundle index. Do not edit.
510
+ /**
511
+ * Generated bundle index. Do not edit.
512
512
  */
513
513
 
514
514
  export { EsParametersComponent, EsParametersModule, GenericParameter };