@eqproject/eqp-dynamic-module 0.0.1

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 (125) hide show
  1. package/README.md +24 -0
  2. package/bundles/eqproject-eqp-dynamic-module.umd.js +3117 -0
  3. package/bundles/eqproject-eqp-dynamic-module.umd.js.map +1 -0
  4. package/bundles/eqproject-eqp-dynamic-module.umd.min.js +17 -0
  5. package/bundles/eqproject-eqp-dynamic-module.umd.min.js.map +1 -0
  6. package/eqproject-eqp-dynamic-module.d.ts +5 -0
  7. package/eqproject-eqp-dynamic-module.metadata.json +1 -0
  8. package/esm2015/eqproject-eqp-dynamic-module.js +6 -0
  9. package/esm2015/lib/components/exported/eqp-dynamic-module/eqp-dynamic-module.component.js +65 -0
  10. package/esm2015/lib/components/exported/eqp-dynamic-module-configurator/eqp-dynamic-module-configurator.component.js +534 -0
  11. package/esm2015/lib/components/private/add-form-field/add-form-field.component.js +486 -0
  12. package/esm2015/lib/components/private/dynamic-module-field/dynamic-module-field.component.js +127 -0
  13. package/esm2015/lib/components/private/field-templates/attachment-field-template/attachment-field-template.component.js +181 -0
  14. package/esm2015/lib/components/private/field-templates/boolean-field-template/boolean-field-template.component.js +56 -0
  15. package/esm2015/lib/components/private/field-templates/date-field-template/date-field-template.component.js +71 -0
  16. package/esm2015/lib/components/private/field-templates/image-field-template/image-field-template.component.js +54 -0
  17. package/esm2015/lib/components/private/field-templates/list-value-field-template/list-value-field-template.component.js +118 -0
  18. package/esm2015/lib/components/private/field-templates/numeric-field-template/numeric-field-template.component.js +63 -0
  19. package/esm2015/lib/components/private/field-templates/text-field-template/text-field-template.component.js +51 -0
  20. package/esm2015/lib/components/private/field-templates/textarea-field-template/textarea-field-template.component.js +51 -0
  21. package/esm2015/lib/components/private/form-records/add-form-record/add-form-record.component.js +126 -0
  22. package/esm2015/lib/components/private/form-records/list-form-record/list-form-record.component.js +210 -0
  23. package/esm2015/lib/eqp-dynamic-module.module.js +67 -0
  24. package/esm2015/lib/interfaces/iBaseFieldComponent.interface.js +1 -0
  25. package/esm2015/lib/interfaces/iRootObject.interface.js +1 -0
  26. package/esm2015/lib/models/baseField.model.js +36 -0
  27. package/esm2015/lib/models/baseObj.model.js +9 -0
  28. package/esm2015/lib/models/context.model.js +8 -0
  29. package/esm2015/lib/models/entity.model.js +7 -0
  30. package/esm2015/lib/models/fields/attachmentField.model.js +22 -0
  31. package/esm2015/lib/models/fields/booleanField.model.js +12 -0
  32. package/esm2015/lib/models/fields/dateField.model.js +11 -0
  33. package/esm2015/lib/models/fields/imageField.model.js +4 -0
  34. package/esm2015/lib/models/fields/listValueField.model.js +12 -0
  35. package/esm2015/lib/models/fields/lookupField.model.js +5 -0
  36. package/esm2015/lib/models/fields/numericField.model.js +5 -0
  37. package/esm2015/lib/models/fields/testareaField.model.js +4 -0
  38. package/esm2015/lib/models/fields/textField.model.js +5 -0
  39. package/esm2015/lib/models/form.model.js +24 -0
  40. package/esm2015/lib/models/record.model.js +3 -0
  41. package/esm2015/lib/modules/material.module.js +108 -0
  42. package/esm2015/lib/services/custom-form-validators.service.js +19 -0
  43. package/esm2015/lib/services/eqp-dynamic-module-dialog.service.js +104 -0
  44. package/esm2015/lib/services/utilityHelper.services.js +220 -0
  45. package/esm2015/public-api.js +37 -0
  46. package/esm5/eqproject-eqp-dynamic-module.js +6 -0
  47. package/esm5/lib/components/exported/eqp-dynamic-module/eqp-dynamic-module.component.js +66 -0
  48. package/esm5/lib/components/exported/eqp-dynamic-module-configurator/eqp-dynamic-module-configurator.component.js +546 -0
  49. package/esm5/lib/components/private/add-form-field/add-form-field.component.js +497 -0
  50. package/esm5/lib/components/private/dynamic-module-field/dynamic-module-field.component.js +128 -0
  51. package/esm5/lib/components/private/field-templates/attachment-field-template/attachment-field-template.component.js +184 -0
  52. package/esm5/lib/components/private/field-templates/boolean-field-template/boolean-field-template.component.js +57 -0
  53. package/esm5/lib/components/private/field-templates/date-field-template/date-field-template.component.js +72 -0
  54. package/esm5/lib/components/private/field-templates/image-field-template/image-field-template.component.js +55 -0
  55. package/esm5/lib/components/private/field-templates/list-value-field-template/list-value-field-template.component.js +121 -0
  56. package/esm5/lib/components/private/field-templates/numeric-field-template/numeric-field-template.component.js +64 -0
  57. package/esm5/lib/components/private/field-templates/text-field-template/text-field-template.component.js +52 -0
  58. package/esm5/lib/components/private/field-templates/textarea-field-template/textarea-field-template.component.js +52 -0
  59. package/esm5/lib/components/private/form-records/add-form-record/add-form-record.component.js +129 -0
  60. package/esm5/lib/components/private/form-records/list-form-record/list-form-record.component.js +216 -0
  61. package/esm5/lib/eqp-dynamic-module.module.js +70 -0
  62. package/esm5/lib/interfaces/iBaseFieldComponent.interface.js +1 -0
  63. package/esm5/lib/interfaces/iRootObject.interface.js +1 -0
  64. package/esm5/lib/models/baseField.model.js +43 -0
  65. package/esm5/lib/models/baseObj.model.js +13 -0
  66. package/esm5/lib/models/context.model.js +14 -0
  67. package/esm5/lib/models/entity.model.js +14 -0
  68. package/esm5/lib/models/fields/attachmentField.model.js +29 -0
  69. package/esm5/lib/models/fields/booleanField.model.js +19 -0
  70. package/esm5/lib/models/fields/dateField.model.js +18 -0
  71. package/esm5/lib/models/fields/imageField.model.js +11 -0
  72. package/esm5/lib/models/fields/listValueField.model.js +19 -0
  73. package/esm5/lib/models/fields/lookupField.model.js +12 -0
  74. package/esm5/lib/models/fields/numericField.model.js +12 -0
  75. package/esm5/lib/models/fields/testareaField.model.js +11 -0
  76. package/esm5/lib/models/fields/textField.model.js +12 -0
  77. package/esm5/lib/models/form.model.js +39 -0
  78. package/esm5/lib/models/record.model.js +7 -0
  79. package/esm5/lib/modules/material.module.js +111 -0
  80. package/esm5/lib/services/custom-form-validators.service.js +23 -0
  81. package/esm5/lib/services/eqp-dynamic-module-dialog.service.js +113 -0
  82. package/esm5/lib/services/utilityHelper.services.js +225 -0
  83. package/esm5/public-api.js +37 -0
  84. package/fesm2015/eqproject-eqp-dynamic-module.js +2757 -0
  85. package/fesm2015/eqproject-eqp-dynamic-module.js.map +1 -0
  86. package/fesm5/eqproject-eqp-dynamic-module.js +2902 -0
  87. package/fesm5/eqproject-eqp-dynamic-module.js.map +1 -0
  88. package/lib/components/exported/eqp-dynamic-module/eqp-dynamic-module.component.d.ts +21 -0
  89. package/lib/components/exported/eqp-dynamic-module-configurator/eqp-dynamic-module-configurator.component.d.ts +186 -0
  90. package/lib/components/private/add-form-field/add-form-field.component.d.ts +160 -0
  91. package/lib/components/private/dynamic-module-field/dynamic-module-field.component.d.ts +55 -0
  92. package/lib/components/private/field-templates/attachment-field-template/attachment-field-template.component.d.ts +84 -0
  93. package/lib/components/private/field-templates/boolean-field-template/boolean-field-template.component.d.ts +21 -0
  94. package/lib/components/private/field-templates/date-field-template/date-field-template.component.d.ts +27 -0
  95. package/lib/components/private/field-templates/image-field-template/image-field-template.component.d.ts +16 -0
  96. package/lib/components/private/field-templates/list-value-field-template/list-value-field-template.component.d.ts +59 -0
  97. package/lib/components/private/field-templates/numeric-field-template/numeric-field-template.component.d.ts +26 -0
  98. package/lib/components/private/field-templates/text-field-template/text-field-template.component.d.ts +20 -0
  99. package/lib/components/private/field-templates/textarea-field-template/textarea-field-template.component.d.ts +20 -0
  100. package/lib/components/private/form-records/add-form-record/add-form-record.component.d.ts +50 -0
  101. package/lib/components/private/form-records/list-form-record/list-form-record.component.d.ts +59 -0
  102. package/lib/eqp-dynamic-module.module.d.ts +2 -0
  103. package/lib/interfaces/iBaseFieldComponent.interface.d.ts +8 -0
  104. package/lib/interfaces/iRootObject.interface.d.ts +10 -0
  105. package/lib/models/baseField.model.d.ts +56 -0
  106. package/lib/models/baseObj.model.d.ts +9 -0
  107. package/lib/models/context.model.d.ts +9 -0
  108. package/lib/models/entity.model.d.ts +10 -0
  109. package/lib/models/fields/attachmentField.model.d.ts +17 -0
  110. package/lib/models/fields/booleanField.model.d.ts +11 -0
  111. package/lib/models/fields/dateField.model.d.ts +12 -0
  112. package/lib/models/fields/imageField.model.d.ts +10 -0
  113. package/lib/models/fields/listValueField.model.d.ts +21 -0
  114. package/lib/models/fields/lookupField.model.d.ts +10 -0
  115. package/lib/models/fields/numericField.model.d.ts +9 -0
  116. package/lib/models/fields/testareaField.model.d.ts +7 -0
  117. package/lib/models/fields/textField.model.d.ts +7 -0
  118. package/lib/models/form.model.d.ts +45 -0
  119. package/lib/models/record.model.d.ts +5 -0
  120. package/lib/modules/material.module.d.ts +2 -0
  121. package/lib/services/custom-form-validators.service.d.ts +5 -0
  122. package/lib/services/eqp-dynamic-module-dialog.service.d.ts +28 -0
  123. package/lib/services/utilityHelper.services.d.ts +48 -0
  124. package/package.json +39 -0
  125. package/public-api.d.ts +35 -0
@@ -0,0 +1,2902 @@
1
+ import { __extends, __decorate } from 'tslib';
2
+ import { CommonModule } from '@angular/common';
3
+ import { ɵɵdefineInjectable, ɵɵinject, Injectable, Input, Component, NgModule, EventEmitter, ViewChild, Output, ChangeDetectorRef, ViewChildren } from '@angular/core';
4
+ import { Validators, FormControl, FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
5
+ import { MatCheckboxModule } from '@angular/material/checkbox';
6
+ import { MatButtonModule } from '@angular/material/button';
7
+ import { MatInputModule } from '@angular/material/input';
8
+ import { MatAutocompleteModule } from '@angular/material/autocomplete';
9
+ import { MatDatepickerModule } from '@angular/material/datepicker';
10
+ import { MatFormFieldModule } from '@angular/material/form-field';
11
+ import { MatRadioModule } from '@angular/material/radio';
12
+ import { MatSelectModule } from '@angular/material/select';
13
+ import { MatSliderModule } from '@angular/material/slider';
14
+ import { MatSlideToggleModule } from '@angular/material/slide-toggle';
15
+ import { MatMenuModule } from '@angular/material/menu';
16
+ import { MatSidenavModule } from '@angular/material/sidenav';
17
+ import { MatToolbarModule } from '@angular/material/toolbar';
18
+ import { MatListModule } from '@angular/material/list';
19
+ import { MatGridListModule } from '@angular/material/grid-list';
20
+ import { MatCardModule } from '@angular/material/card';
21
+ import { MatStepperModule } from '@angular/material/stepper';
22
+ import { MatTabsModule } from '@angular/material/tabs';
23
+ import { MatExpansionModule } from '@angular/material/expansion';
24
+ import { MatButtonToggleModule } from '@angular/material/button-toggle';
25
+ import { MatChipsModule } from '@angular/material/chips';
26
+ import { MatIconModule } from '@angular/material/icon';
27
+ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
28
+ import { MatProgressBarModule } from '@angular/material/progress-bar';
29
+ import { MatDialogModule, MatDialog } from '@angular/material/dialog';
30
+ import { MatTooltipModule } from '@angular/material/tooltip';
31
+ import { MatSnackBarModule } from '@angular/material/snack-bar';
32
+ import { MatTableModule } from '@angular/material/table';
33
+ import { MatSortModule } from '@angular/material/sort';
34
+ import { MatPaginatorModule } from '@angular/material/paginator';
35
+ import { MatNativeDateModule } from '@angular/material/core';
36
+ import { TypeColumn, CellAlignmentEnum, NumberColumnPipe, EqpTableModule } from '@eqproject/eqp-table';
37
+ import { EqpAttachmentsModule } from '@eqproject/eqp-attachments';
38
+ import { EnumHelper, EqpSelectModule } from '@eqproject/eqp-select';
39
+ import { PickerModeEnum, EqpDatetimepickerModule } from '@eqproject/eqp-datetimepicker';
40
+ import { EqpFiltersModule } from '@eqproject/eqp-filters';
41
+ import { EqpNumericModule } from '@eqproject/eqp-numeric';
42
+ import Swal from 'sweetalert2';
43
+ import { BrowserModule } from '@angular/platform-browser';
44
+ import { UtilityHelperService as UtilityHelperService$1 } from 'projects/eqp-dynamic-module/src/lib/services/utilityHelper.services';
45
+ import { UtilityHelperService as UtilityHelperService$2, EqpDynamicModuleDialogService as EqpDynamicModuleDialogService$1, FieldTypeEnum as FieldTypeEnum$1, DateTimeTypeEnum as DateTimeTypeEnum$1 } from 'projects/eqp-dynamic-module/src/public-api';
46
+
47
+ var Context = /** @class */ (function () {
48
+ function Context() {
49
+ this.User = new ContextUser();
50
+ }
51
+ return Context;
52
+ }());
53
+ var ContextUser = /** @class */ (function () {
54
+ function ContextUser() {
55
+ }
56
+ return ContextUser;
57
+ }());
58
+
59
+ /**
60
+ * Classe base che implementa la valorizzazione dell'ID (se null) con una nuova GUID
61
+ * in creazione dell'oggetto.
62
+ * Per scelta architetturale, visto che non possiamo assumere la persistenza su DB relazionale o su NOSQL, ogni
63
+ * oggetto della configurazione viene persistito, e gestito con ID di tipo stringa creato da una GUID.
64
+ */
65
+ var BaseObj = /** @class */ (function () {
66
+ function BaseObj() {
67
+ }
68
+ return BaseObj;
69
+ }());
70
+
71
+ /**
72
+ * Classe che rappresenta una Form completa.
73
+ * Si tratta dell'oggetto che viene rappresentato a video e con cui l'utente interagisce.
74
+ */
75
+ var Form = /** @class */ (function (_super) {
76
+ __extends(Form, _super);
77
+ function Form() {
78
+ return _super !== null && _super.apply(this, arguments) || this;
79
+ }
80
+ return Form;
81
+ }(BaseObj));
82
+ var FormFieldGroup = /** @class */ (function () {
83
+ function FormFieldGroup() {
84
+ }
85
+ return FormFieldGroup;
86
+ }());
87
+ var ActionOnRecord = /** @class */ (function () {
88
+ function ActionOnRecord() {
89
+ }
90
+ return ActionOnRecord;
91
+ }());
92
+ var FormTypeEnum;
93
+ (function (FormTypeEnum) {
94
+ FormTypeEnum[FormTypeEnum["SCALAR"] = 1] = "SCALAR";
95
+ FormTypeEnum[FormTypeEnum["LIST"] = 2] = "LIST"; /* form di tipo lista che viene rappresentata con molti record */
96
+ })(FormTypeEnum || (FormTypeEnum = {}));
97
+ var FormScalarTypeEnum;
98
+ (function (FormScalarTypeEnum) {
99
+ FormScalarTypeEnum[FormScalarTypeEnum["Semplice"] = 1] = "Semplice";
100
+ FormScalarTypeEnum[FormScalarTypeEnum["A step"] = 2] = "A step";
101
+ FormScalarTypeEnum[FormScalarTypeEnum["In tab"] = 3] = "In tab";
102
+ FormScalarTypeEnum[FormScalarTypeEnum["In accordion"] = 4] = "In accordion"; //GROUPED_BY_ACCORDION
103
+ })(FormScalarTypeEnum || (FormScalarTypeEnum = {}));
104
+
105
+ /**
106
+ * Contiene le informazioni di base del campo, indipendentemente dal tipo.
107
+ * Questa classe è volutamente astratta perché il tipo di campo è dettato dal tipo
108
+ */
109
+ var BaseField = /** @class */ (function (_super) {
110
+ __extends(BaseField, _super);
111
+ function BaseField() {
112
+ return _super !== null && _super.apply(this, arguments) || this;
113
+ }
114
+ return BaseField;
115
+ }(BaseObj));
116
+ var FieldTypeEnum;
117
+ (function (FieldTypeEnum) {
118
+ FieldTypeEnum[FieldTypeEnum["Campo di testo"] = 1] = "Campo di testo";
119
+ FieldTypeEnum[FieldTypeEnum["Area di testo"] = 2] = "Area di testo";
120
+ FieldTypeEnum[FieldTypeEnum["Booleano"] = 3] = "Booleano";
121
+ FieldTypeEnum[FieldTypeEnum["Data e/o ora"] = 4] = "Data e/o ora";
122
+ FieldTypeEnum[FieldTypeEnum["Campo numerico"] = 5] = "Campo numerico";
123
+ FieldTypeEnum[FieldTypeEnum["Allegato"] = 6] = "Allegato";
124
+ FieldTypeEnum[FieldTypeEnum["Immagine"] = 7] = "Immagine";
125
+ FieldTypeEnum[FieldTypeEnum["Elenco generico"] = 8] = "Elenco generico";
126
+ FieldTypeEnum[FieldTypeEnum["Lookup"] = 9] = "Lookup";
127
+ FieldTypeEnum[FieldTypeEnum["Form di dettaglio"] = 10] = "Form di dettaglio";
128
+ })(FieldTypeEnum || (FieldTypeEnum = {}));
129
+ var ColSpanSizesEnum;
130
+ (function (ColSpanSizesEnum) {
131
+ ColSpanSizesEnum[ColSpanSizesEnum["col-sm-3"] = 1] = "col-sm-3";
132
+ ColSpanSizesEnum[ColSpanSizesEnum["col-sm-4"] = 2] = "col-sm-4";
133
+ ColSpanSizesEnum[ColSpanSizesEnum["col-sm-6"] = 3] = "col-sm-6";
134
+ ColSpanSizesEnum[ColSpanSizesEnum["col-sm-12"] = 4] = "col-sm-12";
135
+ ColSpanSizesEnum[ColSpanSizesEnum["col-md-3"] = 5] = "col-md-3";
136
+ ColSpanSizesEnum[ColSpanSizesEnum["col-md-4"] = 6] = "col-md-4";
137
+ ColSpanSizesEnum[ColSpanSizesEnum["col-md-6"] = 7] = "col-md-6";
138
+ ColSpanSizesEnum[ColSpanSizesEnum["col-md-12"] = 8] = "col-md-12";
139
+ ColSpanSizesEnum[ColSpanSizesEnum["col-lg-3"] = 9] = "col-lg-3";
140
+ ColSpanSizesEnum[ColSpanSizesEnum["col-lg-4"] = 10] = "col-lg-4";
141
+ ColSpanSizesEnum[ColSpanSizesEnum["col-lg-6"] = 11] = "col-lg-6";
142
+ ColSpanSizesEnum[ColSpanSizesEnum["col-lg-12"] = 12] = "col-lg-12";
143
+ })(ColSpanSizesEnum || (ColSpanSizesEnum = {}));
144
+
145
+ var ArrayValidators = /** @class */ (function () {
146
+ function ArrayValidators() {
147
+ }
148
+ ArrayValidators.minLenght = function (minLenght) {
149
+ var validationFunction = function (control) {
150
+ return !!control && !!control.value && Array.isArray(control.value) && control.value.length >= minLenght
151
+ ? null
152
+ : { hasMinLenght: false };
153
+ };
154
+ return validationFunction;
155
+ };
156
+ ArrayValidators.maxLenght = function (maxLenght) {
157
+ var validationFunction = function (control) {
158
+ return !!control && !!control.value && Array.isArray(control.value) && control.value.length <= maxLenght
159
+ ? null
160
+ : { hasMinLenght: false };
161
+ };
162
+ return validationFunction;
163
+ };
164
+ return ArrayValidators;
165
+ }());
166
+
167
+ var UtilityHelperService = /** @class */ (function () {
168
+ function UtilityHelperService(formBuilder) {
169
+ this.formBuilder = formBuilder;
170
+ }
171
+ UtilityHelperService_1 = UtilityHelperService;
172
+ UtilityHelperService.EvaluateFieldFormula = function (formula, rec, ctx) {
173
+ var evaluatedValue = eval(formula.replace('"', '\"'));
174
+ return (evaluatedValue ? evaluatedValue : null);
175
+ };
176
+ UtilityHelperService.SetContext = function (ctx) {
177
+ this.context = ctx;
178
+ };
179
+ /**
180
+ * Metodo per impostare i valori da suggerire nell'autocomplete per i campi in cui l'utente deve scrivere comandi javascript.
181
+ * In base all'ultimo carattere digitato viene impostato un elenco di oggetti o proprietà che l'utente ha a disposizione in quel momento.
182
+ * @param fields Array di BaseField aggiunti alla Form
183
+ * @param typedFormula Stringa digitata dall'utente
184
+ * @summary Il metodo imposta i suggerimenti basandosi su 3 casi:
185
+ * 1) l'utente non ha digitato nulla o la stringa digitata dall'utente finisce con uno spazio vuoto
186
+ * 2) la stringa digitata dall'utente finisce con un "."
187
+ * 3) la stringa digitata dall'utente non coincide con nessun altro caso sopra (finisce con un carattere qualunque)
188
+ */
189
+ UtilityHelperService.GetAutocompleteOptions = function (fields, typedFormula) {
190
+ var autocompleteOptions = [];
191
+ // Recupero i nomi di tutti i campi creati fino ad ora nella form.
192
+ var availableRecProperties = fields.map(function (f) { return f.Label.split(' ').join('_'); });
193
+ // Nel casi in cui l'utente non ha inserito nulla oppure la stringa finisce con uno spazio vuoto o un simbolo diverso da "."
194
+ // (un carattere non alfanumerico) imposto come suggerimenti solo "rec" e "ctx", ovvero gli unici due oggetti a cui l'utente ha accesso.
195
+ if (!typedFormula ||
196
+ (!typedFormula.endsWith(".")
197
+ && new RegExp("[^0-9a-zA-Z_]").test(typedFormula.substring(typedFormula.length - 1, typedFormula.length)))) {
198
+ autocompleteOptions = [
199
+ { label: "rec", value: (typedFormula ? typedFormula : '') + "rec" },
200
+ { label: "ctx", value: (typedFormula ? typedFormula : '') + "ctx" }
201
+ ];
202
+ }
203
+ // Se la stringa finisce con un "." vuol dire che l'utente sta cercando di accedere ad una proprietà di un oggetto
204
+ // a sua disposizione. Recupero il nome dell'ultimo oggetto digitato dall'utente e se l'oggetto scelto è "rec" o "ctx"
205
+ // allora suggerisco le proprietà che esistono all'interno di questi oggetti altrimenti non mostro nulla.
206
+ else if (typedFormula.endsWith(".")) {
207
+ var formulaPieces = typedFormula.split(" ")[typedFormula.split(" ").length - 1].split('.');
208
+ if (formulaPieces[formulaPieces.length - 2] === "rec") {
209
+ autocompleteOptions = availableRecProperties.map(function (f) { return { label: f, value: typedFormula + f }; });
210
+ }
211
+ else if (formulaPieces[formulaPieces.length - 2] === "ctx") {
212
+ autocompleteOptions = Object.keys(UtilityHelperService_1.context).map(function (f) { return { label: f, value: typedFormula + f }; });
213
+ }
214
+ else if (formulaPieces.length > 2 && formulaPieces[formulaPieces.length - 3] === "ctx" && formulaPieces[formulaPieces.length - 2] === "User") {
215
+ autocompleteOptions = Object.keys(UtilityHelperService_1.context.User).map(function (f) { return { label: f, value: typedFormula + f }; });
216
+ }
217
+ else {
218
+ autocompleteOptions = [];
219
+ }
220
+ }
221
+ // In tutti gli altri casi, ovvero quando la stringa digitata finisce con un carattere diverso da quelli
222
+ // controllati finora, vuol dire che l'utente sta digitanto il nome di un oggetto, una proprietà o una
223
+ // funzione javascript. Controllo la parola che l'utente sta digitando e se fa parte di uno degli oggetti a disposizione
224
+ // o una proprietà di essi allora suggerisco i possibili match.
225
+ else {
226
+ var availableOptions = [];
227
+ // Prendo tutti i blocchi di caratteri digitati dall'utente
228
+ var allFormulaWords = typedFormula.split(" ");
229
+ // Prendo l'ultimo blocco di caratteri digitato dall'utente
230
+ var lastTypedString = allFormulaWords[allFormulaWords.length - 1];
231
+ // Se la l'ultima stringa digitata non contiene caratteri speciali allora splitto la stringa
232
+ // sui "." e imposto i suggerimenti in base al path della prorpietà che si sta digitando.
233
+ if (!new RegExp("[^0-9a-zA-Z_.]").test(lastTypedString)) {
234
+ var propertyPath = lastTypedString.split(".");
235
+ var lastTypedWork = propertyPath[propertyPath.length - 1];
236
+ var propertiesToCheck = [];
237
+ if (propertyPath.length == 1) {
238
+ propertiesToCheck = ["rec", "ctx"];
239
+ }
240
+ else if (propertyPath.length > 1 && propertyPath[propertyPath.length - 2] === "ctx") {
241
+ propertiesToCheck = Object.keys(UtilityHelperService_1.context);
242
+ }
243
+ else if (propertyPath.length > 2 && propertyPath[propertyPath.length - 3] === "ctx" && propertyPath[propertyPath.length - 2] === "User") {
244
+ propertiesToCheck = Object.keys(UtilityHelperService_1.context.User);
245
+ }
246
+ else if (propertyPath.length > 1 && propertyPath[propertyPath.length - 2] === "rec") {
247
+ propertiesToCheck = availableRecProperties;
248
+ }
249
+ // Eseguo il controllo sulle proprietà recuperate, aggiungo ai suggerimenti tutti i nomi che iniziano con
250
+ // quello che sta digitando l'utente.
251
+ propertiesToCheck.forEach(function (prop) {
252
+ if (prop.startsWith(lastTypedWork)) {
253
+ availableOptions.push({ label: prop, value: typedFormula + prop.substring(lastTypedWork.length, prop.length) });
254
+ }
255
+ });
256
+ }
257
+ autocompleteOptions = availableOptions;
258
+ }
259
+ return autocompleteOptions;
260
+ };
261
+ /**
262
+ * Metodo invocato dall'html per impostare le classi css per visualizzare il campo all'interno della form.
263
+ * Se per il field sono state specificate delle classi allora vengono applcate quelle, altrimenti vengono usate
264
+ * delle classi di default.
265
+ * @param field BaseField da visualizzare.
266
+ * @returns Restituisce una stringa contenente le classi css da applicare.
267
+ */
268
+ UtilityHelperService.prototype.getFieldSyleClass = function (field) {
269
+ if (field.ColSpanSizes && field.ColSpanSizes.length > 0)
270
+ return field.ColSpanSizes.map(function (size) { return ColSpanSizesEnum[size].toString(); }).join(" ");
271
+ switch (field.FieldType) {
272
+ case FieldTypeEnum["Campo di testo"]:
273
+ return "col-sm-12 col-md-4 col-lg-4";
274
+ case FieldTypeEnum["Area di testo"]:
275
+ return "col-sm-12 col-md-12 col-lg-12";
276
+ case FieldTypeEnum["Booleano"]:
277
+ return "col-sm-12 col-md-4 col-lg-4 d-flex align-items-center";
278
+ case FieldTypeEnum["Data e/o ora"]:
279
+ return "col-sm-12 col-md-4 col-lg-4";
280
+ case FieldTypeEnum["Campo numerico"]:
281
+ return "col-sm-12 col-md-4 col-lg-4";
282
+ case FieldTypeEnum["Allegato"]:
283
+ if (field.IsMultiAttach ||
284
+ (field.MetadataFields && field.MetadataFields.length > 0)) {
285
+ return "col-sm-12 col-md-12 col-lg-12";
286
+ }
287
+ else {
288
+ return "col-sm-12 col-md-4 col-lg-4";
289
+ }
290
+ case FieldTypeEnum["Immagine"]:
291
+ if (field.AttachDefinition.IsMultiAttach ||
292
+ (field.AttachDefinition.MetadataFields && field.AttachDefinition.MetadataFields.length > 0)) {
293
+ return "col-sm-12 col-md-12 col-lg-12";
294
+ }
295
+ else {
296
+ return "col-sm-12 col-md-4 col-lg-4";
297
+ }
298
+ case FieldTypeEnum["Elenco generico"]:
299
+ return "col-sm-12 col-md-4 col-lg-4";
300
+ case FieldTypeEnum["Lookup"]:
301
+ return "col-sm-12 col-md-4 col-lg-4";
302
+ case FieldTypeEnum['Form di dettaglio']:
303
+ return "col-sm-12 col-md-12 col-lg-12";
304
+ }
305
+ };
306
+ /**
307
+ * Metodo per creare il FormGroup che rappresenta una Form a partire dai suoi BaseField.
308
+ * @param formFields Lista dei BaseField che compongono la form.
309
+ * @param record Oggetto di tipo Record che contiene i valori dei campi.
310
+ * @param onlyView Se TRUE disabilita la form per renderla in sola lettura.
311
+ * @param includeCurrentFormInField Se TRUE popola la proprietà FormFormGroup all'interno di ogni BaseField con il FormGroup corrente.
312
+ * @returns Restituisce un FormGroup rappresentate la Form a cui appartengono i BaseField ricevuti in input.
313
+ */
314
+ UtilityHelperService.prototype.CreateFormFormGroup = function (formFields, record, onlyView, includeCurrentFormInField) {
315
+ var _this = this;
316
+ if (onlyView === void 0) { onlyView = false; }
317
+ if (includeCurrentFormInField === void 0) { includeCurrentFormInField = true; }
318
+ var formForm = this.formBuilder.group([]);
319
+ formFields.forEach(function (field) {
320
+ formForm.addControl(field.Name, _this.createFieldFormControl(field, record));
321
+ if (includeCurrentFormInField) {
322
+ field.FormFormGroup = formForm;
323
+ }
324
+ });
325
+ if (onlyView) {
326
+ formForm.disable();
327
+ }
328
+ return formForm;
329
+ };
330
+ /**
331
+ * Funzione per creare e aggiungere al FormGroup rappresentante la form un nuovo FormControl a partire da un Field.
332
+ * In nuovo FormControl avrà il nome del campo passato e verranno impostati i Validators in base al tipo del campo stesso.
333
+ * @param field BaseField per cui creare il FormControl da inserire nel FormGroup dela form.
334
+ */
335
+ UtilityHelperService.prototype.createFieldFormControl = function (field, record) {
336
+ var validators = [];
337
+ if (field.Required)
338
+ validators.push(Validators.required);
339
+ switch (field.FieldType) {
340
+ case FieldTypeEnum["Campo di testo"]:
341
+ if (field.MaxLenght) {
342
+ validators.push(Validators.maxLength(field.MaxLenght));
343
+ }
344
+ if (field.MinLenght) {
345
+ validators.push(Validators.minLength(field.MinLenght));
346
+ }
347
+ break;
348
+ case FieldTypeEnum["Area di testo"]:
349
+ if (field.MaxLenght) {
350
+ validators.push(Validators.maxLength(field.MaxLenght));
351
+ }
352
+ if (field.MinLenght) {
353
+ validators.push(Validators.minLength(field.MinLenght));
354
+ }
355
+ break;
356
+ case FieldTypeEnum.Allegato:
357
+ case FieldTypeEnum.Immagine:
358
+ if (field.Required)
359
+ validators.push(ArrayValidators.minLenght(1));
360
+ break;
361
+ case FieldTypeEnum['Elenco generico']:
362
+ if (field.IsMultiChoiche)
363
+ if (field.Required)
364
+ validators.push(ArrayValidators.minLenght(1));
365
+ break;
366
+ }
367
+ return new FormControl(record[field.Name], validators);
368
+ };
369
+ var UtilityHelperService_1;
370
+ UtilityHelperService.context = new Context();
371
+ UtilityHelperService.ctorParameters = function () { return [
372
+ { type: FormBuilder }
373
+ ]; };
374
+ UtilityHelperService.ɵprov = ɵɵdefineInjectable({ factory: function UtilityHelperService_Factory() { return new UtilityHelperService(ɵɵinject(FormBuilder)); }, token: UtilityHelperService, providedIn: "root" });
375
+ UtilityHelperService = UtilityHelperService_1 = __decorate([
376
+ Injectable({
377
+ providedIn: 'root'
378
+ })
379
+ ], UtilityHelperService);
380
+ return UtilityHelperService;
381
+ }());
382
+
383
+ var EqpDynamicModuleComponent = /** @class */ (function () {
384
+ function EqpDynamicModuleComponent() {
385
+ this.context = new Context();
386
+ this.form = new Form();
387
+ this.showButtons = true;
388
+ this.viewMode = FormTypeEnum.LIST;
389
+ this.FormTypeEnum = FormTypeEnum;
390
+ }
391
+ EqpDynamicModuleComponent.prototype.ngOnInit = function () {
392
+ UtilityHelperService.SetContext(this.context);
393
+ };
394
+ EqpDynamicModuleComponent.prototype.onAddViewEditRecord = function (event) {
395
+ if (event != null) {
396
+ this.selectedRecord = JSON.parse(JSON.stringify(event.record));
397
+ this.onlyView = event.onlyView;
398
+ }
399
+ else {
400
+ this.selectedRecord = null;
401
+ this.onlyView = false;
402
+ }
403
+ this.viewMode = FormTypeEnum.SCALAR;
404
+ };
405
+ EqpDynamicModuleComponent.prototype.onSaveForm = function (event) {
406
+ //TODO: Salvare il record!
407
+ if (event != null) {
408
+ if (event.ID && this.values.find(function (v) { return v.ID == event.ID; })) {
409
+ this.values[this.values.findIndex(function (v) { return v.ID == event.ID; })] = event;
410
+ }
411
+ else {
412
+ this.values.push(event);
413
+ }
414
+ }
415
+ this.viewMode = FormTypeEnum.LIST;
416
+ console.log(event);
417
+ };
418
+ __decorate([
419
+ Input()
420
+ ], EqpDynamicModuleComponent.prototype, "context", void 0);
421
+ __decorate([
422
+ Input()
423
+ ], EqpDynamicModuleComponent.prototype, "form", void 0);
424
+ __decorate([
425
+ Input()
426
+ ], EqpDynamicModuleComponent.prototype, "values", void 0);
427
+ __decorate([
428
+ Input()
429
+ ], EqpDynamicModuleComponent.prototype, "showButtons", void 0);
430
+ __decorate([
431
+ Input()
432
+ ], EqpDynamicModuleComponent.prototype, "viewMode", void 0);
433
+ EqpDynamicModuleComponent = __decorate([
434
+ Component({
435
+ selector: 'eqp-dynamic-module',
436
+ template: "<add-form-record *ngIf=\"viewMode == FormTypeEnum.SCALAR\" [form]=\"form\" [record]=\"selectedRecord\"\r\n [showButtons]=\"showButtons\" [onlyView]=\"onlyView\" (saveRecordEvent)=\"onSaveForm($event)\">\r\n</add-form-record>\r\n\r\n<list-form-record *ngIf=\"viewMode == FormTypeEnum.LIST\" [form]=\"form\" [values]=\"values\"\r\n (onAddViewEditRecord)=\"onAddViewEditRecord($event)\">\r\n</list-form-record>",
437
+ styles: ["::ng-deep mat-form-field{width:100%}"]
438
+ })
439
+ ], EqpDynamicModuleComponent);
440
+ return EqpDynamicModuleComponent;
441
+ }());
442
+
443
+ var MaterialModule = /** @class */ (function () {
444
+ function MaterialModule() {
445
+ }
446
+ MaterialModule = __decorate([
447
+ NgModule({
448
+ imports: [
449
+ MatCheckboxModule,
450
+ MatButtonModule,
451
+ MatInputModule,
452
+ MatAutocompleteModule,
453
+ MatDatepickerModule,
454
+ MatFormFieldModule,
455
+ MatRadioModule,
456
+ MatSelectModule,
457
+ MatSliderModule,
458
+ MatSlideToggleModule,
459
+ MatMenuModule,
460
+ MatSidenavModule,
461
+ MatToolbarModule,
462
+ MatListModule,
463
+ MatGridListModule,
464
+ MatCardModule,
465
+ MatStepperModule,
466
+ MatTabsModule,
467
+ MatExpansionModule,
468
+ MatButtonToggleModule,
469
+ MatChipsModule,
470
+ MatIconModule,
471
+ MatProgressSpinnerModule,
472
+ MatProgressBarModule,
473
+ MatDialogModule,
474
+ MatTooltipModule,
475
+ MatSnackBarModule,
476
+ MatTableModule,
477
+ MatSortModule,
478
+ MatPaginatorModule,
479
+ MatDatepickerModule,
480
+ MatNativeDateModule
481
+ ],
482
+ exports: [
483
+ MatCheckboxModule,
484
+ MatButtonModule,
485
+ MatInputModule,
486
+ MatAutocompleteModule,
487
+ MatDatepickerModule,
488
+ MatFormFieldModule,
489
+ MatRadioModule,
490
+ MatSelectModule,
491
+ MatSliderModule,
492
+ MatSlideToggleModule,
493
+ MatMenuModule,
494
+ MatSidenavModule,
495
+ MatToolbarModule,
496
+ MatListModule,
497
+ MatGridListModule,
498
+ MatCardModule,
499
+ MatStepperModule,
500
+ MatTabsModule,
501
+ MatExpansionModule,
502
+ MatButtonToggleModule,
503
+ MatChipsModule,
504
+ MatIconModule,
505
+ MatProgressSpinnerModule,
506
+ MatProgressBarModule,
507
+ MatDialogModule,
508
+ MatTooltipModule,
509
+ MatSnackBarModule,
510
+ MatTableModule,
511
+ MatSortModule,
512
+ MatPaginatorModule
513
+ ],
514
+ })
515
+ ], MaterialModule);
516
+ return MaterialModule;
517
+ }());
518
+
519
+ var EqpDynamicModuleDialogService = /** @class */ (function () {
520
+ function EqpDynamicModuleDialogService() {
521
+ }
522
+ /**
523
+ * Mostra uno sweet alert di tipo ERROR con il messaggio passato come parametro.
524
+ * @param message Messaggio d'errore da mostrare nello sweetalert
525
+ * @param title Titolo dello sweetalert (di default mostra 'Errore')
526
+ */
527
+ EqpDynamicModuleDialogService.Error = function (message, title) {
528
+ if (title === void 0) { title = null; }
529
+ var currentTitle = title != null ? title : 'Errore';
530
+ if (Array.isArray(message)) {
531
+ currentTitle = title != null ? title : 'Errore';
532
+ var htmlErrors = message.join("<br>");
533
+ Swal.fire({
534
+ title: currentTitle,
535
+ html: htmlErrors,
536
+ icon: 'error'
537
+ });
538
+ }
539
+ else {
540
+ Swal.fire(currentTitle, message, 'error');
541
+ }
542
+ };
543
+ /**
544
+ * Mostra uno sweetalert di tipo CONFIRM con il messaggio passato come parametro e se viene premuto
545
+ * CONFERMA lancia la funzione di callback passata come parametro
546
+ * @param message Messaggio da mostrare nello sweetalert
547
+ * @param title Titolo dello sweetalert (di default mostra 'Info')
548
+ */
549
+ EqpDynamicModuleDialogService.Confirm = function (message, confirmCallback, isWarning, title, customWidth) {
550
+ if (isWarning === void 0) { isWarning = false; }
551
+ if (title === void 0) { title = null; }
552
+ if (customWidth === void 0) { customWidth = null; }
553
+ var currentTitle = title != null ? title : 'Sei sicuro di voler procedere?';
554
+ if (Array.isArray(message)) {
555
+ var htmlErrors = message.join("<br>");
556
+ Swal.fire({
557
+ title: currentTitle,
558
+ html: htmlErrors,
559
+ width: customWidth ? customWidth : '32rem',
560
+ icon: !isWarning ? 'question' : 'warning',
561
+ showCancelButton: true,
562
+ allowOutsideClick: false,
563
+ allowEscapeKey: false
564
+ }).then(function (result) {
565
+ if (result.value && confirmCallback) {
566
+ confirmCallback();
567
+ }
568
+ });
569
+ }
570
+ else {
571
+ Swal.fire({
572
+ title: currentTitle,
573
+ text: message,
574
+ width: customWidth ? customWidth : '32rem',
575
+ icon: !isWarning ? 'question' : 'warning',
576
+ showCancelButton: true,
577
+ allowOutsideClick: false,
578
+ allowEscapeKey: false
579
+ }).then(function (result) {
580
+ if (result.value && confirmCallback) {
581
+ confirmCallback();
582
+ }
583
+ });
584
+ }
585
+ };
586
+ /**
587
+ * Mostra uno sweetalert di tipo INFO con il messaggio passato come parametro
588
+ * @param message Messaggio da mostrare nello sweetalert
589
+ * @param title Titolo dello sweetalert (di default mostra 'Info')
590
+ */
591
+ EqpDynamicModuleDialogService.Info = function (message, title, isToast) {
592
+ if (title === void 0) { title = null; }
593
+ if (isToast === void 0) { isToast = null; }
594
+ var currentTitle = title != null ? title : "Informazione:";
595
+ Swal.fire(currentTitle, message, 'info');
596
+ };
597
+ /**
598
+ * Mostra uno sweetalert di tipo WARNING con il messaggio passato come parametro
599
+ * @param message Messaggio da mostrare nello sweetalert
600
+ * @param title Titolo dello sweetalert (di default mostra 'Attenzione!')
601
+ */
602
+ EqpDynamicModuleDialogService.Warning = function (message, title, isToast) {
603
+ if (title === void 0) { title = null; }
604
+ if (isToast === void 0) { isToast = null; }
605
+ var currentTitle = title != null ? title : "Attenzione!";
606
+ if (Array.isArray(message)) {
607
+ var htmlWarnings = message.join("<br>");
608
+ Swal.fire({
609
+ title: currentTitle,
610
+ html: htmlWarnings,
611
+ icon: 'warning'
612
+ });
613
+ }
614
+ else {
615
+ Swal.fire(currentTitle, message, 'warning');
616
+ }
617
+ };
618
+ EqpDynamicModuleDialogService.ɵprov = ɵɵdefineInjectable({ factory: function EqpDynamicModuleDialogService_Factory() { return new EqpDynamicModuleDialogService(); }, token: EqpDynamicModuleDialogService, providedIn: "root" });
619
+ EqpDynamicModuleDialogService = __decorate([
620
+ Injectable({
621
+ providedIn: 'root'
622
+ })
623
+ ], EqpDynamicModuleDialogService);
624
+ return EqpDynamicModuleDialogService;
625
+ }());
626
+
627
+ var EqpDynamicModuleConfiguratorComponent = /** @class */ (function () {
628
+ function EqpDynamicModuleConfiguratorComponent(formBuilder, dialog) {
629
+ this.formBuilder = formBuilder;
630
+ this.dialog = dialog;
631
+ this.context = new Context();
632
+ this.form = new Form();
633
+ this.innerFormManagment = false;
634
+ this.formCompleted = false;
635
+ //#region Enumeratori usati nell'html
636
+ this.FormTypeEnum = FormTypeEnum;
637
+ this.FormScalarTypeEnum = FormScalarTypeEnum;
638
+ //#endregion
639
+ this.saveFormEvent = new EventEmitter();
640
+ }
641
+ EqpDynamicModuleConfiguratorComponent.prototype.ngOnInit = function () {
642
+ if (this.context) {
643
+ UtilityHelperService.SetContext(this.context);
644
+ }
645
+ this.configureColumns();
646
+ this.createFormForm();
647
+ };
648
+ /**
649
+ * Metodo invocato al cambio del tipo di visualizzazione della form.
650
+ * Se l'utente sceglie una visualizzazione raggruppata il metodo aggiunge al FormGroup un nuovo
651
+ * controllo per l'array dei nomi delle sezioni da creare.
652
+ */
653
+ EqpDynamicModuleConfiguratorComponent.prototype.onChangeFormScalarType = function () {
654
+ if (this.form.FormScalarType != FormScalarTypeEnum.Semplice) {
655
+ if (!this.formFormGroup.contains("FormFieldsGroups")) {
656
+ this.formFormGroup.removeControl("FormFieldsGroups");
657
+ this.formFormGroup.addControl("FormFieldsGroups", new FormControl(this.form.FormFieldsGroups, [Validators.required, ArrayValidators.minLenght(1)]));
658
+ }
659
+ }
660
+ else {
661
+ this.form.FormFieldsGroups = null;
662
+ if (this.formFormGroup.contains("FormFieldsGroups"))
663
+ this.formFormGroup.removeControl("FormFieldsGroups");
664
+ }
665
+ this.formFormGroup.updateValueAndValidity();
666
+ this.configureColumns();
667
+ };
668
+ /**
669
+ * Evento invocato al keyup nell'input per inserire i nomi delle sezioni per la visualizzazione
670
+ * raggruppata della form. Quanto l'utente preme il tasto invio viene aggiunto il nuovo nome alle
671
+ * sezioni dispobili se non ne esiste una con lo stesso nome.
672
+ * @param event Evento che rappresenta il keyup sulla tastiera.
673
+ */
674
+ EqpDynamicModuleConfiguratorComponent.prototype.onFormFieldGroupNameKeyUp = function (event) {
675
+ var _this = this;
676
+ if (event.code === 'Enter' || event.code === 'NumpadEnter') {
677
+ if (!this.form.FormFieldsGroups) {
678
+ this.form.FormFieldsGroups = new Array();
679
+ }
680
+ if (!this.form.FormFieldsGroups.find(function (n) { return n.Name == _this.formFieldGroupName; })) {
681
+ this.form.FormFieldsGroups.push({ Name: this.formFieldGroupName });
682
+ }
683
+ // Imposto il nuovo valore del FormControl per aggiornare lo stato della form.
684
+ this.formFormGroup.controls["FormFieldsGroups"].setValue(this.form.FormFieldsGroups);
685
+ this.formFieldGroupName = null;
686
+ this.setFormFieldGroupOrdinalPosition();
687
+ }
688
+ };
689
+ /**
690
+ * Metodo per rimuovere la sezione selezionata da quelle disponibili per la form.
691
+ * @param groupName Nome della sezione da eliminare.
692
+ */
693
+ EqpDynamicModuleConfiguratorComponent.prototype.onDeleteFormFieldGroupName = function (groupName) {
694
+ this.form.FormFieldsGroups.splice(this.form.FormFieldsGroups.findIndex(function (g) { return g.Name === groupName; }), 1);
695
+ // Imposto il nuovo valore del FormControl per aggiornare lo stato della form.
696
+ this.formFormGroup.controls["FormFieldsGroups"].setValue(this.form.FormFieldsGroups);
697
+ // Se esistono Field legati alla sezione che si vuole eliminare allora rompo il legame.
698
+ if (this.form.Fields.find(function (f) { return f.FieldGroup == groupName; })) {
699
+ this.form.Fields.filter(function (f) { return f.FieldGroup == groupName; }).forEach(function (f) { return f.FieldGroup = null; });
700
+ }
701
+ this.setFormFieldGroupOrdinalPosition();
702
+ };
703
+ /**
704
+ * Metodo chiamato quando si vuole aggiungere un nuovo campo o si vuole modificare uno esistente.
705
+ * Memorizza l'eventuale Field scelto one crea uno nuovo prima di aprire il dialog per modificarlo/aggiungerlo.
706
+ * @param field Oggetto BaseField da modificare. Se null ne viene creata una nuova istanza per l'aggiunta.
707
+ */
708
+ EqpDynamicModuleConfiguratorComponent.prototype.openFieldDialog = function (field) {
709
+ if (field === void 0) { field = null; }
710
+ if (field) {
711
+ this.indexSelectedField = this.form.Fields.indexOf(field);
712
+ this.selectedField = JSON.parse(JSON.stringify(field));
713
+ }
714
+ else {
715
+ this.selectedField = new BaseField();
716
+ this.indexSelectedField = null;
717
+ }
718
+ this.dialogFieldRef = this.dialog.open(this.dialogField, {
719
+ disableClose: true,
720
+ hasBackdrop: true,
721
+ width: '75%'
722
+ });
723
+ };
724
+ /**
725
+ * Metodo che salva il campo appena creato o modificato.
726
+ * Prima del salvataggio controlla se esiste un altro campo con la stessa label, in questo
727
+ * case genere un errore (i campi devono avere nomi, e quindi label, univoche - i nomi vengono
728
+ * ricavati unendo le parole che formano la label tramite "_").
729
+ * @param field Campo da salvare
730
+ */
731
+ EqpDynamicModuleConfiguratorComponent.prototype.onSaveField = function (field) {
732
+ var _this = this;
733
+ if (field) {
734
+ if (this.form.Fields
735
+ && this.form.Fields.find(function (f, i) { return f.Label === field.Label
736
+ && (_this.indexSelectedField == null ? true : _this.indexSelectedField !== i); })) {
737
+ EqpDynamicModuleDialogService.Warning('Impossibile inserire due campi con la stessa label.');
738
+ throw new Error('Impossibile inserire due campi con la stessa label.');
739
+ }
740
+ if (this.indexSelectedField != null && this.indexSelectedField >= 0) {
741
+ this.form.Fields[this.indexSelectedField] = field;
742
+ }
743
+ else {
744
+ if (!this.form.Fields) {
745
+ this.form.Fields = new Array();
746
+ }
747
+ this.form.Fields.push(field);
748
+ }
749
+ }
750
+ this.closeFieldDialog();
751
+ this.setFieldOrdinalPosition();
752
+ this.reloadFieldsTable();
753
+ };
754
+ /**
755
+ * Metodo che controlla se lo step per l'aggiunta dei campi nella form è concluso.
756
+ * @returns Se TRUE lo step viene considerato completato ed è possbile passare al successivo.
757
+ */
758
+ EqpDynamicModuleConfiguratorComponent.prototype.isFieldStepCompleted = function () {
759
+ if (!this.form.Fields) {
760
+ return false;
761
+ }
762
+ if (this.form.FormScalarType != FormScalarTypeEnum.Semplice && this.form.Fields.find(function (f) { return !f.FieldGroup; })) {
763
+ return false;
764
+ }
765
+ return this.form.Fields.length > 0;
766
+ };
767
+ /**
768
+ * Metodo per aprire il dialog di creazione/modifica delle form di dettaglio.
769
+ * Se il parametro passato è null sono in aggiunta altrimenti sono in modifica.
770
+ * @param innenrForm Form di dettaglio da modificare (se null allora vado in add).
771
+ */
772
+ EqpDynamicModuleConfiguratorComponent.prototype.openInnerFormDialog = function (innenrForm) {
773
+ if (innenrForm === void 0) { innenrForm = null; }
774
+ if (innenrForm) {
775
+ this.indexSelectedInnerForm = this.form.InnerForms.indexOf(innenrForm);
776
+ this.selectedInnerForm = JSON.parse(JSON.stringify(innenrForm));
777
+ this.selectedInnerForm.OldName = innenrForm.Name;
778
+ this.indexSelectedField = this.form.Fields.findIndex(function (f) { return f.Label === innenrForm.Name; });
779
+ }
780
+ else {
781
+ this.selectedInnerForm = new Form();
782
+ this.indexSelectedInnerForm = null;
783
+ this.indexSelectedField = null;
784
+ }
785
+ this.dialogInnerFormRef = this.dialog.open(this.dialogInnerForm, {
786
+ disableClose: true,
787
+ hasBackdrop: true,
788
+ width: '85%'
789
+ });
790
+ };
791
+ /**
792
+ * Metodo scatenato al salvataggio di una form di dettaglio.
793
+ * @param event Form creata/modificata dall'utente. Se è null allora l'utente ha abbandonato la configurazione.
794
+ */
795
+ EqpDynamicModuleConfiguratorComponent.prototype.onSaveOrExitInnerForm = function (event) {
796
+ var _this = this;
797
+ if (event != null) {
798
+ if (this.form.Name === event.Name ||
799
+ (this.form.InnerForms
800
+ && this.form.InnerForms.find(function (a, i) { return a.Name === event.Name
801
+ && (_this.indexSelectedInnerForm == null ? true : _this.indexSelectedInnerForm !== i); })) ||
802
+ (this.form.Fields
803
+ && this.indexSelectedInnerForm == null
804
+ && this.form.Fields.find(function (f, i) { return f.Label === event.Name
805
+ && (_this.indexSelectedField == null ? true : _this.indexSelectedField !== i); }))) {
806
+ EqpDynamicModuleDialogService.Warning('Impossibile inserire due form di dettaglio con lo stesso nome.');
807
+ throw new Error('Impossibile inserire due form di dettaglio con lo stesso nome.');
808
+ }
809
+ var innerFormField = new BaseField();
810
+ innerFormField.Name = event.Name.split(" ").join("_");
811
+ innerFormField.Label = event.Name;
812
+ innerFormField.FieldType = FieldTypeEnum['Form di dettaglio'];
813
+ innerFormField.FieldGroup = this.indexSelectedField != null ? this.form.Fields[this.indexSelectedField].FieldGroup : null;
814
+ if (this.indexSelectedInnerForm != null && this.indexSelectedInnerForm >= 0) {
815
+ this.form.InnerForms[this.indexSelectedInnerForm] = event;
816
+ this.form.Fields[this.indexSelectedField] = innerFormField;
817
+ }
818
+ else {
819
+ if (!this.form.InnerForms) {
820
+ this.form.InnerForms = new Array();
821
+ }
822
+ this.form.InnerForms.push(event);
823
+ this.form.Fields.push(innerFormField);
824
+ }
825
+ this.reloadFieldsTable();
826
+ }
827
+ this.dialogInnerFormRef.close();
828
+ };
829
+ /**
830
+ * Metodo per aprire il dialog di creazione/modifica delle action.
831
+ * Se il parametro passato è null sono in aggiunta altrimenti sono in modifica.
832
+ * @param action ActionOnRecord da modificare (se null allora vado in add).
833
+ */
834
+ EqpDynamicModuleConfiguratorComponent.prototype.openActionOnRecordDialog = function (action) {
835
+ if (action === void 0) { action = null; }
836
+ if (action) {
837
+ this.indexSelectedAction = this.form.ActionsOnRecord.indexOf(action);
838
+ this.selectedAction = JSON.parse(JSON.stringify(action));
839
+ }
840
+ else {
841
+ this.selectedAction = new ActionOnRecord();
842
+ this.indexSelectedAction = null;
843
+ }
844
+ this.createActionOnRecordForm();
845
+ this.dialogActionOnRecordRef = this.dialog.open(this.dialogActionOnRecord, {
846
+ disableClose: true,
847
+ hasBackdrop: true,
848
+ width: '75%'
849
+ });
850
+ };
851
+ /**
852
+ * Metodo per impostare i valori da suggerire nell'autocomplete del campo Formula.
853
+ * Viene scatenato al focus (in questo caso viene passato il parametro a null per differenziarlo
854
+ * dall'evento di click sulla tastiera) e al keyup sull'input (il parametro è diverso da null).
855
+ * @param keyboardEvent Evento scatenato al keyup sulla tastiera. Se null allora il metodo è stato invocato dal focus sull'input.
856
+ * @summary Aggiorna l'elenco dei suggerimenti per l'autocomplete se l'utente esegue il focus sull'input
857
+ * oppure al keyup sulla tastiera di un tasto diverso dalle frecce.
858
+ */
859
+ EqpDynamicModuleConfiguratorComponent.prototype.setActionAutocompleteOptions = function (keyboardEvent) {
860
+ // Creo l'array per l'autocomplete solo se sto facendo il focus sull'input o se sto premendo un tasto
861
+ // sulla tastiera diverso dalle frecce (in quest'ultimo caso, se non viene eseguito il filtro sull'evento,
862
+ // non si può selezionare un suggerimento dell'autocomplete perchè al click verrebbe ricaricato l'array e
863
+ // si prederebbe la selezione appena fatta).
864
+ if (!keyboardEvent || !keyboardEvent.code.includes("Arrow")) {
865
+ this.actionAutocompleteOptions = UtilityHelperService.GetAutocompleteOptions(this.form.Fields, this.selectedAction.Action);
866
+ }
867
+ };
868
+ /**
869
+ * Metodo per salvare l'azione creata/modificate.
870
+ */
871
+ EqpDynamicModuleConfiguratorComponent.prototype.saveActionOnRecord = function () {
872
+ var _this = this;
873
+ if (this.form.ActionsOnRecord
874
+ && this.form.ActionsOnRecord.find(function (a, i) { return a.Name === _this.selectedAction.Name
875
+ && (_this.indexSelectedAction == null ? true : _this.indexSelectedAction !== i); })) {
876
+ EqpDynamicModuleDialogService.Warning('Impossibile inserire due action con lo stesso nome.');
877
+ throw new Error('Impossibile inserire due action con lo stesso nome.');
878
+ }
879
+ if (this.indexSelectedAction != null && this.indexSelectedAction >= 0) {
880
+ this.form.ActionsOnRecord[this.indexSelectedAction] = this.selectedAction;
881
+ }
882
+ else {
883
+ if (!this.form.ActionsOnRecord) {
884
+ this.form.ActionsOnRecord = new Array();
885
+ }
886
+ this.form.ActionsOnRecord.push(this.selectedAction);
887
+ }
888
+ this.closeDialogActionOnRecord();
889
+ this.setActionOrdinalPosition();
890
+ this.reloadActionsOnRecordTable();
891
+ };
892
+ /**
893
+ * Metodo per chiudere il dialog di gestione delle action.
894
+ */
895
+ EqpDynamicModuleConfiguratorComponent.prototype.closeDialogActionOnRecord = function () {
896
+ this.dialogActionOnRecordRef.close();
897
+ };
898
+ /**
899
+ * Metodo per segnare come conclusa la creazione della form e per crearne una copia
900
+ * da visalizzare come anteprima.
901
+ * @param completed Se TRUE segna la form come conclusa e ne crea una copia da visualizzare
902
+ */
903
+ EqpDynamicModuleConfiguratorComponent.prototype.setFormStatus = function (completed) {
904
+ if (completed) {
905
+ this.formCompleted = true;
906
+ this.previewForm = JSON.parse(JSON.stringify(this.form));
907
+ // Per visualizzare correttamente l'oanteprima della form appena creata
908
+ // bisogna valorizzare la proprietà Name dei campi della form e delle InnerForms.
909
+ this.previewForm.Fields.forEach(function (field) { field.Name = field.Label.split(' ').join('_'); });
910
+ if (this.previewForm.InnerForms && this.previewForm.InnerForms.length > 0) {
911
+ this.previewForm.InnerForms.forEach(function (form) {
912
+ form.Fields.forEach(function (field) { field.Name = field.Label.split(' ').join('_'); });
913
+ });
914
+ }
915
+ }
916
+ else {
917
+ this.formCompleted = false;
918
+ this.previewForm = null;
919
+ }
920
+ };
921
+ /**
922
+ * Metodo che scatena l'evento di output per salvare la form creata alla fine del wizard
923
+ */
924
+ EqpDynamicModuleConfiguratorComponent.prototype.saveForm = function () {
925
+ this.saveFormEvent.emit(this.form);
926
+ };
927
+ /**
928
+ * Configura le colonne per le tabelle necessarie alla creazione della form:
929
+ * - per la visualizzazione dei campi inseriti
930
+ * - per le form di dettaglio create
931
+ * - per le azioni configurate sui record della form
932
+ */
933
+ EqpDynamicModuleConfiguratorComponent.prototype.configureColumns = function () {
934
+ var _this = this;
935
+ this.fieldsColumns = [
936
+ {
937
+ key: 'action', display: '', type: TypeColumn.MenuAction, buttonMenuIcon: 'more_vert', styles: { flex: '0 0 6%' },
938
+ actions: [
939
+ { name: 'Modifica', icon: 'edit', fn: function (element, index, col) { return _this.editField(element); } },
940
+ { name: 'Elimina', icon: 'delete', fn: function (element, index, col) { return _this.deleteElement(element, "Fields"); } },
941
+ {
942
+ name: 'Sposta su', icon: 'arrow_upward',
943
+ fn: function (element, index, col) { return _this.moveElement(element, true, "Fields"); },
944
+ disabled: function (element) { return _this.form.Fields.indexOf(element) === 0; }
945
+ },
946
+ {
947
+ name: 'Sposta giù', icon: 'arrow_downward',
948
+ fn: function (element, index, col) { return _this.moveElement(element, false, "Fields"); },
949
+ disabled: function (element) { return _this.form.Fields.indexOf(element) >= (_this.form.Fields.length - 1); }
950
+ },
951
+ ]
952
+ },
953
+ { key: 'FieldType', display: 'Tipologia', type: TypeColumn.Enum, enumModel: FieldTypeEnum },
954
+ { key: 'Label', display: 'Label' },
955
+ { key: 'Description', display: 'Descrizione' },
956
+ {
957
+ key: 'Required', display: 'Obbligatorio',
958
+ value: function (element) { return !!element.Required; },
959
+ type: TypeColumn.Boolean,
960
+ booleanValues: {
961
+ true: '<i class="fa fa-check success-color"></i>',
962
+ false: '<i class="fa fa-close error-color"></i>'
963
+ },
964
+ styles: { flex: '0 0 7%', cellAlignment: CellAlignmentEnum.CENTER }
965
+ },
966
+ ];
967
+ if (this.form.FormScalarType && this.form.FormScalarType != FormScalarTypeEnum.Semplice) {
968
+ this.fieldsColumns.splice(this.fieldsColumns.findIndex(function (c) { return c.key == 'Description'; }), 0, { key: 'FieldGroup', display: 'Sezione', type: TypeColumn.ExternalTemplate, externalTemplate: this.fieldSectionColumnTemplate });
969
+ }
970
+ this.actionsOnRecordColumns = [
971
+ {
972
+ key: 'action', display: '', type: TypeColumn.MenuAction, buttonMenuIcon: 'more_vert', styles: { flex: '0 0 6%' },
973
+ actions: [
974
+ { name: 'Modifica', icon: 'edit', fn: function (element, index, col) { return _this.openActionOnRecordDialog(element); } },
975
+ { name: 'Elimina', icon: 'delete', fn: function (element, index, col) { return _this.deleteElement(element, "ActionsOnRecord"); } },
976
+ {
977
+ name: 'Sposta su', icon: 'arrow_upward',
978
+ fn: function (element, index, col) { return _this.moveElement(element, true, "ActionsOnRecord"); },
979
+ disabled: function (element) { return _this.form.ActionsOnRecord.indexOf(element) === 0; }
980
+ },
981
+ {
982
+ name: 'Sposta giù', icon: 'arrow_downward',
983
+ fn: function (element, index, col) { return _this.moveElement(element, false, "ActionsOnRecord"); },
984
+ disabled: function (element) { return _this.form.ActionsOnRecord.indexOf(element) >= (_this.form.ActionsOnRecord.length - 1); }
985
+ },
986
+ ]
987
+ },
988
+ { key: 'Icon', display: 'Icona', styles: { flex: ' 0 0 15%' } },
989
+ { key: 'Name', display: 'Nome', styles: { flex: ' 0 0 20%' } },
990
+ { key: 'Action', display: 'Azione' },
991
+ ];
992
+ };
993
+ /**
994
+ * Crea il FormGroup per l'oggetto Form
995
+ */
996
+ EqpDynamicModuleConfiguratorComponent.prototype.createFormForm = function () {
997
+ this.formFormGroup = this.formBuilder.group({
998
+ Name: [this.form.Name, Validators.required],
999
+ FormScalarType: [this.form.FormScalarType, Validators.required],
1000
+ });
1001
+ this.onChangeFormScalarType();
1002
+ };
1003
+ /**
1004
+ * Crea il FormGroup epr l'aggiunta o la modifica di una action sui record della Form.
1005
+ */
1006
+ EqpDynamicModuleConfiguratorComponent.prototype.createActionOnRecordForm = function () {
1007
+ this.actionOnRecordFormGroup = this.formBuilder.group({
1008
+ Name: [this.selectedAction.Name, Validators.required],
1009
+ Icon: [this.selectedAction.Icon, Validators.required],
1010
+ Action: [this.selectedAction.Action, Validators.required],
1011
+ });
1012
+ };
1013
+ /**
1014
+ * Chiude il dialog per aggiungere/modificare un Field senza salvare
1015
+ */
1016
+ EqpDynamicModuleConfiguratorComponent.prototype.closeFieldDialog = function () {
1017
+ this.dialogFieldRef.close();
1018
+ };
1019
+ /**
1020
+ * Metodo per gestire l'apertura del dialog per la modifica di un Field.
1021
+ * Se il field è di tipo "Form di dettaglio" apre il dialog per la modifica di una
1022
+ * InnerForm altrimenti apre quello per la modifica di un Field.
1023
+ * @param field Campo da modificare
1024
+ */
1025
+ EqpDynamicModuleConfiguratorComponent.prototype.editField = function (field) {
1026
+ if (field.FieldType != FieldTypeEnum['Form di dettaglio']) {
1027
+ this.openFieldDialog(field);
1028
+ }
1029
+ else {
1030
+ this.openInnerFormDialog(this.form.InnerForms.find(function (f) { return f.Name == field.Label; }));
1031
+ }
1032
+ };
1033
+ /**
1034
+ * Metodo per rimuovere un Field all'interno di una Form.
1035
+ * Richiede conferma all'utente prima di rimuoverlo.
1036
+ * @param field BaseField da rimuovere
1037
+ */
1038
+ EqpDynamicModuleConfiguratorComponent.prototype.deleteElement = function (element, propertyName) {
1039
+ var _this = this;
1040
+ EqpDynamicModuleDialogService.Confirm('Eliminare l\'elemento selezionato?', function () {
1041
+ _this.form[propertyName].splice(_this.form[propertyName].indexOf(element), 1);
1042
+ if (propertyName === "Fields") {
1043
+ _this.setFieldOrdinalPosition();
1044
+ _this.reloadFieldsTable();
1045
+ }
1046
+ else if (propertyName === "ActionsOnRecord") {
1047
+ _this.setActionOrdinalPosition();
1048
+ _this.reloadActionsOnRecordTable();
1049
+ }
1050
+ }, false, 'Richiesta conferma');
1051
+ };
1052
+ /**
1053
+ * Metodo per spostare un campo all'interno della form.
1054
+ * @param field Oggetto di tipo BaseField da spostare.
1055
+ * @param moveUp Se TRUE allora sposta verso l'alto il campo (abbassa l'indice) altrimenti il contrario.
1056
+ */
1057
+ EqpDynamicModuleConfiguratorComponent.prototype.moveElement = function (element, moveUp, propertyName) {
1058
+ var startingIndex = this.form[propertyName].indexOf(element);
1059
+ var endingIndex = startingIndex + (moveUp ? -1 : 1);
1060
+ this.form[propertyName].splice(startingIndex, 1);
1061
+ this.form[propertyName].splice(endingIndex, 0, element);
1062
+ if (propertyName === "Fields") {
1063
+ this.setFieldOrdinalPosition();
1064
+ this.reloadFieldsTable();
1065
+ }
1066
+ else if (propertyName === "ActionsOnRecord") {
1067
+ this.setActionOrdinalPosition();
1068
+ this.reloadActionsOnRecordTable();
1069
+ }
1070
+ };
1071
+ /**
1072
+ * Imposta l'ordinamento delle sezioni che compongono la form.
1073
+ */
1074
+ EqpDynamicModuleConfiguratorComponent.prototype.setFormFieldGroupOrdinalPosition = function () {
1075
+ this.form.FormFieldsGroups.forEach(function (g, i) { return g.OrdinalPosition = i; });
1076
+ };
1077
+ /**
1078
+ * Imposta l'ordinamento dei campi all'interno della form in base all'ordine che l'utente
1079
+ * ha definito nella tabella in cui sono mostrati
1080
+ */
1081
+ EqpDynamicModuleConfiguratorComponent.prototype.setFieldOrdinalPosition = function () {
1082
+ var _this = this;
1083
+ if (this.form.Fields) {
1084
+ this.form.Fields.forEach(function (field) {
1085
+ field.OrdinalPosition = _this.form.Fields.indexOf(field);
1086
+ });
1087
+ }
1088
+ };
1089
+ /**
1090
+ * Metodo per ricaricare i dati della tabella dei campi aggiunti in una form
1091
+ */
1092
+ EqpDynamicModuleConfiguratorComponent.prototype.reloadFieldsTable = function () {
1093
+ if (this.fieldsTable) {
1094
+ this.fieldsTable.reloadDatatable();
1095
+ }
1096
+ };
1097
+ /**
1098
+ * Imposta l'ordinamento dei campi all'interno della form in base all'ordine che l'utente
1099
+ * ha definito nella tabella in cui sono mostrati
1100
+ */
1101
+ EqpDynamicModuleConfiguratorComponent.prototype.setActionOrdinalPosition = function () {
1102
+ var _this = this;
1103
+ if (this.form.ActionsOnRecord) {
1104
+ this.form.ActionsOnRecord.forEach(function (action) {
1105
+ action.OrdinalPosition = _this.form.ActionsOnRecord.indexOf(action);
1106
+ });
1107
+ }
1108
+ };
1109
+ /**
1110
+ * Metodo per ricaricare i dati della tabella delle azioni aggiuntive sui record della Form.
1111
+ */
1112
+ EqpDynamicModuleConfiguratorComponent.prototype.reloadActionsOnRecordTable = function () {
1113
+ if (this.actionsOnRecordTable) {
1114
+ this.actionsOnRecordTable.reloadDatatable();
1115
+ }
1116
+ };
1117
+ EqpDynamicModuleConfiguratorComponent.ctorParameters = function () { return [
1118
+ { type: FormBuilder },
1119
+ { type: MatDialog }
1120
+ ]; };
1121
+ __decorate([
1122
+ Input()
1123
+ ], EqpDynamicModuleConfiguratorComponent.prototype, "context", void 0);
1124
+ __decorate([
1125
+ Input()
1126
+ ], EqpDynamicModuleConfiguratorComponent.prototype, "form", void 0);
1127
+ __decorate([
1128
+ Input()
1129
+ ], EqpDynamicModuleConfiguratorComponent.prototype, "innerFormManagment", void 0);
1130
+ __decorate([
1131
+ ViewChild('fieldsTable', { static: false })
1132
+ ], EqpDynamicModuleConfiguratorComponent.prototype, "fieldsTable", void 0);
1133
+ __decorate([
1134
+ ViewChild('dialogField', { static: true })
1135
+ ], EqpDynamicModuleConfiguratorComponent.prototype, "dialogField", void 0);
1136
+ __decorate([
1137
+ ViewChild('fieldSectionColumnTemplate', { static: true })
1138
+ ], EqpDynamicModuleConfiguratorComponent.prototype, "fieldSectionColumnTemplate", void 0);
1139
+ __decorate([
1140
+ ViewChild('dialogInnerForm', { static: true })
1141
+ ], EqpDynamicModuleConfiguratorComponent.prototype, "dialogInnerForm", void 0);
1142
+ __decorate([
1143
+ ViewChild('actionsOnRecordTable', { static: false })
1144
+ ], EqpDynamicModuleConfiguratorComponent.prototype, "actionsOnRecordTable", void 0);
1145
+ __decorate([
1146
+ ViewChild('dialogActionOnRecord', { static: true })
1147
+ ], EqpDynamicModuleConfiguratorComponent.prototype, "dialogActionOnRecord", void 0);
1148
+ __decorate([
1149
+ Output()
1150
+ ], EqpDynamicModuleConfiguratorComponent.prototype, "saveFormEvent", void 0);
1151
+ EqpDynamicModuleConfiguratorComponent = __decorate([
1152
+ Component({
1153
+ selector: 'eqp-dynamic-module-configurator',
1154
+ template: "<mat-horizontal-stepper linear #stepper>\r\n <!-- DATI GENERALI DELLA FORM -->\r\n <mat-step [stepControl]=\"formFormGroup\">\r\n <form [formGroup]=\"formFormGroup\" (keydown.enter)=\"false\">\r\n <ng-template matStepLabel>\r\n <div class=\"stepper-header-overlay\" (click)=\"setFormStatus(false)\"></div>\r\n Dati generali della form\r\n </ng-template>\r\n\r\n <div class=\"row\">\r\n <div class=\"col-md-4\">\r\n <mat-form-field>\r\n <mat-label>Nome</mat-label>\r\n <input matInput formControlName=\"Name\" [(ngModel)]=\"form.Name\" required>\r\n </mat-form-field>\r\n </div>\r\n\r\n <div class=\"col-md-4\">\r\n <eqp-select [enumData]=\"FormScalarTypeEnum\" [(ngModelInput)]=\"form.FormScalarType\"\r\n [isRequired]=\"true\" [showCancelButton]=\"false\" placeholder=\"Tipo di visualizzazione\"\r\n [formGroupInput]=\"formFormGroup\" [formControlNameInput]=\"'FormScalarType'\"\r\n (ngModelInputChange)=\"onChangeFormScalarType()\">\r\n </eqp-select>\r\n </div>\r\n </div>\r\n <div class=\"row\" *ngIf=\"form.FormScalarType && form.FormScalarType != FormScalarTypeEnum.Semplice\">\r\n <div class=\"col-md-4 d-flex align-items-center\">\r\n <mat-form-field>\r\n <mat-label> Nome sezione (invio per confermare) </mat-label>\r\n <input matInput [(ngModel)]=\"formFieldGroupName\" [ngModelOptions]=\"{standalone: true}\"\r\n (keyup)=\"onFormFieldGroupNameKeyUp($event)\">\r\n </mat-form-field>\r\n </div>\r\n <div class=\"col-md-4 d-flex align-items-center\">\r\n <span class=\"mr-3\">Sezioni inserite:</span>\r\n <ul class=\"section-list\">\r\n <li *ngFor=\"let groupName of form.FormFieldsGroups, let i=index\">\r\n <mat-icon class=\"mr-1\" (click)=\"onDeleteFormFieldGroupName(groupName.Name)\">close\r\n </mat-icon>\r\n <span> {{i+1}}) {{groupName.Name}}</span>\r\n </li>\r\n </ul>\r\n </div>\r\n </div>\r\n\r\n <div class=\"mt-2 d-flex justify-content-end\">\r\n <button mat-raised-button color=\"primary\" matStepperNext\r\n [disabled]=\"formFormGroup.invalid\">Successivo</button>\r\n </div>\r\n </form>\r\n </mat-step>\r\n\r\n <!-- AGGIUNTA DEI CAMPI DELLA FORM -->\r\n <mat-step [completed]=\"isFieldStepCompleted()\">\r\n <ng-template matStepLabel>\r\n <div class=\"stepper-header-overlay\" (click)=\"setFormStatus(false)\"></div>\r\n Campi da inserire\r\n </ng-template>\r\n\r\n <div class=\"row justify-content-end\">\r\n <button class=\"btn btn-primary\" mat-raised-button color=\"primary\" type=\"button\" (click)=\"openFieldDialog()\">\r\n <mat-icon>add</mat-icon>\r\n <span style=\"margin-left: 10px;\">Aggiungi campo</span>\r\n </button>\r\n\r\n <button class=\"btn btn-primary ml-2\" mat-raised-button color=\"primary\" type=\"button\"\r\n (click)=\"openInnerFormDialog()\" *ngIf=\"!innerFormManagment\">\r\n <mat-icon>add</mat-icon>\r\n <span style=\"margin-left: 10px;\">Aggiungi form di dettaglio</span>\r\n </button>\r\n </div>\r\n\r\n <eqp-table #fieldsTable [createMatCard]=\"false\" [columns]=\"fieldsColumns\" [data]=\"form.Fields\"\r\n [emptyTableMessage]=\"'Nessun campo inserito'\" [searchText]=\"'Cerca'\">\r\n </eqp-table>\r\n\r\n <div class=\"mt-2 d-flex justify-content-end\">\r\n <button class=\"mr-2\" mat-raised-button matStepperPrevious>Precedente</button>\r\n <button mat-raised-button color=\"primary\" matStepperNext [disabled]=\"!isFieldStepCompleted()\"\r\n (click)=\"setFormStatus(false)\">Successivo</button>\r\n </div>\r\n </mat-step>\r\n\r\n <!-- AGGIUNTA DELLE OPERAZIONI SUI RECORD -->\r\n <mat-step>\r\n <ng-template matStepLabel>\r\n <div class=\"stepper-header-overlay\" (click)=\"setFormStatus(false)\"></div>\r\n Azioni aggiuntive sui record\r\n </ng-template>\r\n\r\n <div class=\"row justify-content-end\">\r\n <button class=\"btn btn-primary\" mat-raised-button color=\"primary\" type=\"button\"\r\n (click)=\"openActionOnRecordDialog()\">\r\n <mat-icon>add</mat-icon>\r\n <span style=\"margin-left: 10px;\">Aggiungi azione</span>\r\n </button>\r\n </div>\r\n <eqp-table #actionsOnRecordTable [createMatCard]=\"false\" [columns]=\"actionsOnRecordColumns\"\r\n [data]=\"form.ActionsOnRecord\" [emptyTableMessage]=\"'Nessuna action inserita'\" [searchText]=\"'Cerca'\">\r\n </eqp-table>\r\n\r\n <div class=\"mt-2 d-flex justify-content-end\">\r\n <button class=\"mr-2\" mat-raised-button matStepperPrevious>Precedente</button>\r\n <button mat-raised-button color=\"primary\" matStepperNext (click)=\"setFormStatus(true)\">\r\n Successivo\r\n </button>\r\n </div>\r\n </mat-step>\r\n\r\n <!-- VISUALIZZAZIONE FORM CREATA -->\r\n <mat-step>\r\n <ng-template matStepLabel>\r\n <div class=\"stepper-header-overlay\"\r\n (click)=\"setFormStatus(formFormGroup.valid && form.Fields && form.Fields.length > 0)\"></div>\r\n Riepilogo\r\n </ng-template>\r\n\r\n <eqp-dynamic-module [form]=\"previewForm\" *ngIf=\"previewForm && formCompleted\" [showButtons]=\"false\"\r\n [viewMode]=\"FormTypeEnum.SCALAR\"></eqp-dynamic-module>\r\n\r\n <div class=\"mt-2 d-flex justify-content-end\">\r\n <button class=\"mr-2\" mat-raised-button matStepperPrevious (click)=\"setFormStatus(false)\">Precedente</button>\r\n <button mat-raised-button color=\"primary\" (click)=\"saveForm()\">Salva form</button>\r\n </div>\r\n </mat-step>\r\n</mat-horizontal-stepper>\r\n\r\n<div class=\"row\" *ngIf=\"innerFormManagment\">\r\n <div class=\"col-md-12 text-right\">\r\n <button mat-raised-button (click)=\"saveFormEvent.emit(null)\">Esci</button>\r\n </div>\r\n</div>\r\n\r\n<!-- DIALOG AGGIUNTA/MODIFICA CAMPO -->\r\n<ng-template #dialogField>\r\n <eqp-dynamic-module-add-form-field [field]=\"selectedField\" [indexField]=\"indexSelectedField\"\r\n (saveFieldEvent)=\"onSaveField($event)\" [availableFields]=\"form.Fields\"\r\n [formFieldsGroups]=\"form.FormScalarType != FormScalarTypeEnum.Semplice ? form.FormFieldsGroups : null\">\r\n </eqp-dynamic-module-add-form-field>\r\n</ng-template>\r\n\r\n<!-- TEMPLATE PER VISUALIZZARE LA COLONNA DELLA SEZIONE NELLA TABELLA DEI FIELDS -->\r\n<ng-template #fieldSectionColumnTemplate let-row=\"row\">\r\n <eqp-select [arrayData]=\"form.FormFieldsGroups\" [(ngModelInput)]=\"row.FieldGroup\" [arrayKeyProperty]=\"'Name'\"\r\n [arrayValueProperty]=\"'Name'\" placeholder=\"Sezione\" [isRequired]=\"true\" [includeFullObject]=\"false\">\r\n </eqp-select>\r\n</ng-template>\r\n\r\n<!-- DIALOG PER AGGIUNGERE/MODIFICARE UNA ACTION SUI RECORD DELLA FORM -->\r\n<ng-template #dialogActionOnRecord>\r\n <div class=\"container-fluid\" style=\"max-height: 70vh !important; overflow-x: hidden; overflow-y: auto;\">\r\n <form [formGroup]=\"actionOnRecordFormGroup\">\r\n <div class=\"row\">\r\n <div class=\"header-title-standard\">{{indexSelectedAction != null && indexSelectedAction >= 0 ?\r\n \"Modifica\"\r\n : \"Aggiungi\"}} azione sul record</div>\r\n </div>\r\n <div class=\"row\">\r\n <div class=\"col-sm-12 col-md-4 mt-2\">\r\n <mat-form-field>\r\n <mat-label> Nome </mat-label>\r\n <input formControlName=\"Name\" required matInput [(ngModel)]=\"selectedAction.Name\">\r\n </mat-form-field>\r\n </div>\r\n\r\n <div class=\"col-sm-12 col-md-4 mt-2\">\r\n <mat-form-field>\r\n <mat-label> Icona </mat-label>\r\n <input formControlName=\"Icon\" required matInput [(ngModel)]=\"selectedAction.Icon\">\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n <div class=\"row\">\r\n <div class=\"col-sm-12 col-md-12 mt-2\">\r\n <mat-form-field>\r\n <textarea matInput [placeholder]=\"'Azione (Javascript)'\" [rows]=\"3\" formControlName=\"Action\"\r\n required [(ngModel)]=\"selectedAction.Action\" [matAutocomplete]=\"actionAutocomplete\"\r\n (keyup)=\"setActionAutocompleteOptions($event)\"\r\n (focus)=\"setActionAutocompleteOptions(null)\"></textarea>\r\n <mat-autocomplete #actionAutocomplete=\"matAutocomplete\">\r\n <mat-option *ngFor=\"let option of actionAutocompleteOptions\" [value]=\"option.value\">\r\n {{option.label}}\r\n </mat-option>\r\n </mat-autocomplete>\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n\r\n\r\n <div class=\"row mt-2 mb-1\">\r\n <div class=\"col-sm-12 text-right\">\r\n <button class=\"mr-2\" mat-raised-button color=\"primary\" (click)=\"saveActionOnRecord()\"\r\n [disabled]=\"actionOnRecordFormGroup.invalid\" type=\"button\">\r\n Salva\r\n </button>\r\n <button class=\"btn mat-raised-button\" (click)=\"closeDialogActionOnRecord()\" type=\"button\">\r\n Esci\r\n </button>\r\n </div>\r\n </div>\r\n </form>\r\n </div>\r\n</ng-template>\r\n\r\n<ng-template #dialogInnerForm>\r\n <eqp-dynamic-module-configurator [form]=\"selectedInnerForm\" [innerFormManagment]=\"true\"\r\n (saveFormEvent)=\"onSaveOrExitInnerForm($event)\"></eqp-dynamic-module-configurator>\r\n</ng-template>",
1155
+ styles: ["::ng-deep mat-form-field{width:100%}.stepper-header-overlay{position:absolute;top:0;left:0;width:100%;height:100%}.section-list{list-style:none;padding:0}.section-list mat-icon{vertical-align:middle;font-size:15px;height:15px;width:15px;color:var(--danger);margin-right:10px;cursor:pointer}.danger-color{color:var(--danger)}"]
1156
+ })
1157
+ ], EqpDynamicModuleConfiguratorComponent);
1158
+ return EqpDynamicModuleConfiguratorComponent;
1159
+ }());
1160
+
1161
+ var AttachmentField = /** @class */ (function (_super) {
1162
+ __extends(AttachmentField, _super);
1163
+ function AttachmentField() {
1164
+ return _super !== null && _super.apply(this, arguments) || this;
1165
+ }
1166
+ return AttachmentField;
1167
+ }(BaseField));
1168
+ var AvailableFileExtensions = [
1169
+ { value: '.pdf', key: 'application/pdf' },
1170
+ { value: '.doc', key: 'application/msword' },
1171
+ { value: '.xls', key: 'application/vnd.ms-excel' },
1172
+ { value: '.ppt', key: 'application/vnd.ms-powerpoint' },
1173
+ { value: '.docx', key: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' },
1174
+ { value: '.xlsx', key: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' },
1175
+ { value: '.pptx', key: 'application/vnd.openxmlformats-officedocument.presentationml.presentation' },
1176
+ { value: '.csv', key: 'text/csv' },
1177
+ { value: '.txt', key: 'text/plain' },
1178
+ ];
1179
+ var AvailableImageExtensions = [
1180
+ { value: '.jpg/.jpeg', key: 'image/jpeg' },
1181
+ { value: '.png', key: 'image/png' },
1182
+ { value: '.bmp', key: 'image/bmp' },
1183
+ { value: '.svg', key: 'image/svg+xml' },
1184
+ { value: '.ico', key: 'image/x-icon' },
1185
+ ];
1186
+
1187
+ var BooleanField = /** @class */ (function (_super) {
1188
+ __extends(BooleanField, _super);
1189
+ function BooleanField() {
1190
+ return _super !== null && _super.apply(this, arguments) || this;
1191
+ }
1192
+ return BooleanField;
1193
+ }(BaseField));
1194
+ var BoolPresentantioEnum;
1195
+ (function (BoolPresentantioEnum) {
1196
+ BoolPresentantioEnum[BoolPresentantioEnum["Checkbox"] = 1] = "Checkbox";
1197
+ BoolPresentantioEnum[BoolPresentantioEnum["Toggle"] = 2] = "Toggle";
1198
+ BoolPresentantioEnum[BoolPresentantioEnum["Radio button"] = 3] = "Radio button";
1199
+ // "Stringa true o false" = 3,
1200
+ // "Numerico 0 o 1" = 4
1201
+ })(BoolPresentantioEnum || (BoolPresentantioEnum = {}));
1202
+
1203
+ /**Rappresenta la configurazione di un campo Data o Data e ora, o solo ora */
1204
+ var DateField = /** @class */ (function (_super) {
1205
+ __extends(DateField, _super);
1206
+ function DateField() {
1207
+ return _super !== null && _super.apply(this, arguments) || this;
1208
+ }
1209
+ return DateField;
1210
+ }(BaseField));
1211
+ var DateTimeTypeEnum;
1212
+ (function (DateTimeTypeEnum) {
1213
+ DateTimeTypeEnum[DateTimeTypeEnum["Solo data"] = 1] = "Solo data";
1214
+ DateTimeTypeEnum[DateTimeTypeEnum["Solo orario"] = 2] = "Solo orario";
1215
+ DateTimeTypeEnum[DateTimeTypeEnum["Data e ora"] = 3] = "Data e ora";
1216
+ })(DateTimeTypeEnum || (DateTimeTypeEnum = {}));
1217
+
1218
+ /**Lista di valori */
1219
+ var ListValueField = /** @class */ (function (_super) {
1220
+ __extends(ListValueField, _super);
1221
+ function ListValueField() {
1222
+ return _super !== null && _super.apply(this, arguments) || this;
1223
+ }
1224
+ return ListValueField;
1225
+ }(BaseField));
1226
+ var ListPresentationEnum;
1227
+ (function (ListPresentationEnum) {
1228
+ ListPresentationEnum[ListPresentationEnum["Combo box"] = 1] = "Combo box";
1229
+ ListPresentationEnum[ListPresentationEnum["Radio button"] = 2] = "Radio button";
1230
+ ListPresentationEnum[ListPresentationEnum["Pulsante con testo"] = 3] = "Pulsante con testo";
1231
+ ListPresentationEnum[ListPresentationEnum["Immagini"] = 4] = "Immagini";
1232
+ })(ListPresentationEnum || (ListPresentationEnum = {}));
1233
+
1234
+ var AddFormFieldComponent = /** @class */ (function () {
1235
+ //#endregion
1236
+ function AddFormFieldComponent(formBuilder, enumHelper, dialog) {
1237
+ this.formBuilder = formBuilder;
1238
+ this.enumHelper = enumHelper;
1239
+ this.dialog = dialog;
1240
+ this.fieldTypesToExclude = [FieldTypeEnum['Form di dettaglio']];
1241
+ this.keyValueObject = { key: '', value: '' };
1242
+ this.availableColSpanSizes = [];
1243
+ this.AvailableFileExtensions = AvailableFileExtensions;
1244
+ this.AvailableImageExtensions = AvailableImageExtensions;
1245
+ this.saveFieldEvent = new EventEmitter();
1246
+ //#endregion
1247
+ //#region Enumeratori usati nell'html
1248
+ this.FieldTypeEnum = FieldTypeEnum;
1249
+ this.BoolPresentantioEnum = BoolPresentantioEnum;
1250
+ this.DateTimeTypeEnum = DateTimeTypeEnum;
1251
+ this.ListPresentationEnum = ListPresentationEnum;
1252
+ }
1253
+ AddFormFieldComponent.prototype.ngOnInit = function () {
1254
+ var _this = this;
1255
+ if (!this.fieldTypesToExclude.includes(FieldTypeEnum['Form di dettaglio'])) {
1256
+ this.fieldTypesToExclude.push(FieldTypeEnum['Form di dettaglio']);
1257
+ }
1258
+ this.onFieldTypeChange(false);
1259
+ this.availableFields = this.availableFields ? this.availableFields.filter(function (f) { return f != _this.field; }) : [];
1260
+ this.configureColumns();
1261
+ };
1262
+ /**
1263
+ * Metodo per impostare i valori da suggerire nell'autocomplete del campo Formula.
1264
+ * Viene scatenato al focus (in questo caso viene passato il parametro a null per differenziarlo
1265
+ * dall'evento di click sulla tastiera) e al keyup sull'input (il parametro è diverso da null).
1266
+ * @param keyboardEvent Evento scatenato al keyup sulla tastiera. Se null allora il metodo è stato invocato dal focus sull'input.
1267
+ * @summary Aggiorna l'elenco dei suggerimenti per l'autocomplete se l'utente esegue il focus sull'input
1268
+ * oppure al keyup sulla tastiera di un tasto diverso dalle frecce.
1269
+ */
1270
+ AddFormFieldComponent.prototype.setFormulaAutocompleteOptions = function (keyboardEvent) {
1271
+ // Creo l'array per l'autocomplete solo se sto facendo il focus sull'input o se sto premendo un tasto
1272
+ // sulla tastiera diverso dalle frecce (in quest'ultimo caso, se non viene eseguito il filtro sull'evento,
1273
+ // non si può selezionare un suggerimento dell'autocomplete perchè al click verrebbe ricaricato l'array e
1274
+ // si prederebbe la selezione appena fatta).
1275
+ if (!keyboardEvent || !keyboardEvent.code.includes("Arrow")) {
1276
+ this.formulaAutocompleteOptions = UtilityHelperService.GetAutocompleteOptions(this.availableFields, this.field.Formula);
1277
+ }
1278
+ };
1279
+ /**
1280
+ * Crea il FormGroup per l'aggiunta di un nuovo campo all'interno della form.
1281
+ * Metodo richiamato ogni volta che cambia il tipo del campo scelto o viene aggiunto/modificato un Field
1282
+ */
1283
+ AddFormFieldComponent.prototype.createFieldForm = function () {
1284
+ this.fieldFormGroup = this.formBuilder.group({
1285
+ Label: [this.field.Label, Validators.required],
1286
+ Description: [this.field.Description],
1287
+ Required: [this.field.Required],
1288
+ FieldType: [this.field.FieldType, Validators.required],
1289
+ Formula: [this.field.Formula],
1290
+ ColSizes: [this.field.ColSizes],
1291
+ InListView: [this.field.InListView],
1292
+ });
1293
+ if (this.formFieldsGroups) {
1294
+ this.fieldFormGroup.addControl('FieldGroup', new FormControl(this.field.FieldGroup, Validators.required));
1295
+ }
1296
+ };
1297
+ /**
1298
+ * Metodo chiamato quando cambia il FieldType del BaseField che si sta aggiungendo/modificando.
1299
+ * Ricrea l'oggetto field popolando solo le proprietà del BaseField inserite dall'utente
1300
+ * (quelle comuni a tutte le tipologie di campo), ricrea la form e, in base al FieldType scelto,
1301
+ * aggiunge alla form i FormControl necessari e seleziona il template corretto da usare.
1302
+ * @param restoreField Se TRUE ripristina i valori base (ereditati dal modello BaseField) del campo aggiunto/modificato
1303
+ */
1304
+ AddFormFieldComponent.prototype.onFieldTypeChange = function (restoreField) {
1305
+ if (restoreField === void 0) { restoreField = true; }
1306
+ if (restoreField)
1307
+ this.restoreBaseFieldProperties();
1308
+ this.createFieldForm();
1309
+ this.onColSizeSelect();
1310
+ this.fieldTypeFormTemplate = null;
1311
+ switch (this.field.FieldType) {
1312
+ case FieldTypeEnum['Campo di testo']:
1313
+ this.fieldFormGroup.addControl('TextMask', new FormControl(this.field.TextMask));
1314
+ this.fieldFormGroup.addControl('MaxLenght', new FormControl(this.field.MaxLenght));
1315
+ this.fieldFormGroup.addControl('MinLenght', new FormControl(this.field.MinLenght));
1316
+ this.fieldTypeFormTemplate = this.textFieldFormTemplate;
1317
+ break;
1318
+ case FieldTypeEnum['Area di testo']:
1319
+ this.fieldFormGroup.addControl('Rows', new FormControl(this.field.Rows));
1320
+ this.fieldFormGroup.addControl('MaxLenght', new FormControl(this.field.MaxLenght));
1321
+ this.fieldFormGroup.addControl('MinLenght', new FormControl(this.field.MinLenght));
1322
+ this.fieldTypeFormTemplate = this.textareaFieldFormTemplate;
1323
+ break;
1324
+ case FieldTypeEnum.Booleano:
1325
+ this.fieldFormGroup.addControl('IsTristate', new FormControl(this.field.IsTristate));
1326
+ this.fieldFormGroup.addControl('PresetationType', new FormControl(this.field.PresetationType, Validators.required));
1327
+ this.fieldTypeFormTemplate = this.booleadFieldFormTemplate;
1328
+ break;
1329
+ case FieldTypeEnum['Data e/o ora']:
1330
+ this.fieldFormGroup.addControl('IsOnlyDate', new FormControl(this.field.IsOnlyDate, Validators.required));
1331
+ this.fieldFormGroup.addControl('MinDate', new FormControl(this.field.MinDate));
1332
+ this.fieldFormGroup.addControl('MaxDate', new FormControl(this.field.MaxDate));
1333
+ this.fieldTypeFormTemplate = this.dateFieldFormTemplate;
1334
+ break;
1335
+ case FieldTypeEnum['Campo numerico']:
1336
+ this.fieldFormGroup.addControl('IsInteger', new FormControl(this.field.IsInteger));
1337
+ this.fieldFormGroup.addControl('MinValue', new FormControl(this.field.MinValue));
1338
+ this.fieldFormGroup.addControl('MaxValue', new FormControl(this.field.MaxValue));
1339
+ this.fieldFormGroup.addControl('NumberFormat', new FormControl(this.field.NumberFormat));
1340
+ this.fieldFormGroup.addControl('CurrencySymbol', new FormControl(this.field.CurrencySymbol));
1341
+ this.fieldTypeFormTemplate = this.numericFieldFormTemplate;
1342
+ break;
1343
+ case FieldTypeEnum.Allegato:
1344
+ this.fieldFormGroup.addControl("AllowedExtensions", new FormControl(this.field.AllowedExtensions));
1345
+ this.fieldFormGroup.addControl('IsMultiAttach', new FormControl(this.field.IsMultiAttach));
1346
+ this.fieldTypeFormTemplate = this.attachmentFieldFormTemplate;
1347
+ break;
1348
+ case FieldTypeEnum.Immagine:
1349
+ this.field.AttachDefinition = new AttachmentField();
1350
+ this.fieldFormGroup.addControl('IsMultiAttach', new FormControl(this.field.AttachDefinition.IsMultiAttach));
1351
+ // this.fieldFormGroup.addControl('ImgName', new FormControl((this.field as ImageField).ImgName, Validators.required));
1352
+ this.fieldFormGroup.addControl('IsMultiPoint', new FormControl(this.field.IsMultiPoint));
1353
+ this.fieldFormGroup.addControl("AllowedExtensions", new FormControl(this.field.AttachDefinition.AllowedExtensions));
1354
+ this.fieldFormGroup.addControl('ImageIsContextualAttachment', new FormControl(this.field.ImageIsContextualAttachment));
1355
+ this.fieldTypeFormTemplate = this.imageFieldFormTemplate;
1356
+ break;
1357
+ case FieldTypeEnum['Elenco generico']:
1358
+ this.fieldFormGroup.addControl('IsMultiChoiche', new FormControl(this.field.IsMultiChoiche));
1359
+ this.fieldFormGroup.addControl('PresentationMode', new FormControl(this.field.PresentationMode, Validators.required));
1360
+ this.fieldTypeFormTemplate = this.listValueFieldFormTemplate;
1361
+ break;
1362
+ case FieldTypeEnum.Lookup:
1363
+ this.fieldFormGroup.addControl('EntitySourceName', new FormControl(this.field.EntitySourceName, Validators.required));
1364
+ this.fieldFormGroup.addControl('UseAsGetOrDiscard', new FormControl(this.field.UseAsGetOrDiscard));
1365
+ this.fieldTypeFormTemplate = this.lookupFieldFormTemplate;
1366
+ break;
1367
+ }
1368
+ if ([FieldTypeEnum.Allegato, FieldTypeEnum.Immagine, FieldTypeEnum['Form di dettaglio']].includes(this.field.FieldType)) {
1369
+ this.field.Formula = null;
1370
+ this.fieldFormGroup.controls["Formula"].disable();
1371
+ }
1372
+ else {
1373
+ this.fieldFormGroup.controls["Formula"].enable();
1374
+ }
1375
+ };
1376
+ /**
1377
+ * Metodo invocato alla selezione di una classe nella select per le colonne di bootstrap
1378
+ * da usare nella visualizzazione del campo. Questa funzione manipola la sorgente dati per
1379
+ * la eqp-select in modo da escludere i valori dell'enumeratore che fanno riferimento ad
1380
+ * una larghezza di schermo già selezionata. Esempio: per gli schermi piccoli (sm) l'utente
1381
+ * seleziona la classe "col-sm-6", al change del valore questo metodo rimuove dalla select
1382
+ * tutti gli altri valori per la grandezza di schermo selezionata.
1383
+ */
1384
+ AddFormFieldComponent.prototype.onColSizeSelect = function () {
1385
+ // Recupero l'array degli oggetti chiave-valore che rappreseta l'enumeratore
1386
+ var colSizeClassEnumArray = this.enumHelper.getEnumArray(ColSpanSizesEnum, false, null);
1387
+ // Costruisco l'array delle classi selezionate dall'utente in formato stringa
1388
+ var selectedDimensions = this.field.ColSizes ? this.field.ColSizes.map(function (col) { return ColSpanSizesEnum[col]; }) : [];
1389
+ // Filtro i valori ottenuti dall'enumeratore per escludere tutti i valori per le
1390
+ // grandezze di schermo già selezionatead esclusione dei valori selezionati.
1391
+ this.availableColSpanSizes = colSizeClassEnumArray.filter(function (value) {
1392
+ return !selectedDimensions.find(function (col) { return value.value.includes(col.substring(4, 6)) && value.value != col; });
1393
+ });
1394
+ };
1395
+ /**
1396
+ * Metodo chiamato al keyup degli input testuali che prevedono l'aggiunta del valore inserito in un array.
1397
+ * Se l'utente preme il tasto invio, in base al tipo di campo che sta inserendo/modificando, questo metodo
1398
+ * aggiunge il valore inserito dall'utente nella lista di stringhe corretta (in input viene passato il nome
1399
+ * della proprietà in cui inserire la stringa).
1400
+ * @param event Evento che rappresenta il keyup dell'utente
1401
+ * @param propertyName Nome della proprietà del field in cui inserire la stringa digitata.
1402
+ */
1403
+ AddFormFieldComponent.prototype.onMultiSelectInputKeyup = function (event, propertyName) {
1404
+ if (event.code === 'Enter' || event.code === 'NumpadEnter') {
1405
+ switch (this.field.FieldType) {
1406
+ case FieldTypeEnum.Lookup:
1407
+ case FieldTypeEnum.Allegato:
1408
+ if (!this.field[propertyName]) {
1409
+ this.field[propertyName] = new Array();
1410
+ }
1411
+ this.field[propertyName].push(event.currentTarget.value);
1412
+ break;
1413
+ case FieldTypeEnum.Immagine:
1414
+ if (!this.field.AttachDefinition[propertyName]) {
1415
+ this.field.AttachDefinition[propertyName] = new Array();
1416
+ }
1417
+ this.field.AttachDefinition[propertyName].push(event.currentTarget.value);
1418
+ break;
1419
+ case FieldTypeEnum['Elenco generico']:
1420
+ if (!this.keyValueObject.key || !this.keyValueObject.value) {
1421
+ return;
1422
+ }
1423
+ if (!this.field.ValuePairs) {
1424
+ this.field.ValuePairs = {};
1425
+ }
1426
+ this.field.ValuePairs[this.keyValueObject.key] = this.keyValueObject.value;
1427
+ this.keyValueObject = { key: '', value: '' };
1428
+ break;
1429
+ }
1430
+ event.currentTarget.value = null;
1431
+ }
1432
+ };
1433
+ /**
1434
+ * Metodo chiamato per mostrare come elenco le opzioni aggiunte in un campo di tipo "Elenco generico".
1435
+ * @returns Restituisce un array di oggetti del tipo { key: string, value: string } con i valori inseriti dall'utente.
1436
+ */
1437
+ AddFormFieldComponent.prototype.getDictionaryKeyValue = function () {
1438
+ var _this = this;
1439
+ if (this.field.ValuePairs) {
1440
+ return Object.keys(this.field.ValuePairs).map(function (k) {
1441
+ return {
1442
+ key: k,
1443
+ value: _this.field.ValuePairs[k]
1444
+ };
1445
+ });
1446
+ }
1447
+ else {
1448
+ return [];
1449
+ }
1450
+ };
1451
+ /**
1452
+ * Metodo per rimuovere una opzione aggiunta al campo di tipo "Elenco generico"
1453
+ * @param key Nome della chiave da rimuovere
1454
+ */
1455
+ AddFormFieldComponent.prototype.deleteKeyFromDictionary = function (key) {
1456
+ delete this.field.ValuePairs[key];
1457
+ };
1458
+ /**
1459
+ * Metodo per aprire il dialog per aggiungere/modificare un metadata in un campo di tipo Allegato o Immagine.
1460
+ * @param metadata Metadata da modificare, se null allora ne sto creando uno nuovo.
1461
+ */
1462
+ AddFormFieldComponent.prototype.openMetadataDialog = function (field) {
1463
+ if (field === void 0) { field = null; }
1464
+ if (field) {
1465
+ if (this.field.FieldType === FieldTypeEnum.Allegato) {
1466
+ this.indexSelectedMetadata = this.field.MetadataFields.indexOf(field);
1467
+ this.selectedMetadata = JSON.parse(JSON.stringify(field));
1468
+ }
1469
+ else if (this.field.FieldType === FieldTypeEnum.Immagine) {
1470
+ this.indexSelectedMetadata = this.field.AttachDefinition.MetadataFields.indexOf(field);
1471
+ this.selectedMetadata = JSON.parse(JSON.stringify(field));
1472
+ }
1473
+ }
1474
+ else {
1475
+ this.selectedMetadata = new BaseField();
1476
+ this.indexSelectedMetadata = null;
1477
+ }
1478
+ this.dialogMetadataRef = this.dialog.open(this.dialogMetadata, {
1479
+ disableClose: true,
1480
+ hasBackdrop: true,
1481
+ width: '75%'
1482
+ });
1483
+ };
1484
+ /**
1485
+ * Metodo invocato dall'output dal dialog per aggiungere/modificare un metadata
1486
+ * nei campi di tipo Allegato o Immagine. Prima di aggiungere il metadata nell'elenco
1487
+ * contolla se esiste un altro metadata con lo stesso nome e nel caso genera un errore
1488
+ * (i metadata, come per i campi della form, devono avere un nome univoco).
1489
+ * @param metadata Metadata aggiunto o modificato, se null allora il dialog è stato chiuso senza fare modifiche.
1490
+ */
1491
+ AddFormFieldComponent.prototype.onSaveMetadata = function (metadata) {
1492
+ var _this = this;
1493
+ if (metadata) {
1494
+ if ((this.field.FieldType === FieldTypeEnum.Allegato
1495
+ && this.field.MetadataFields
1496
+ && this.field.MetadataFields.find(function (m, i) { return m.Label === metadata.Label
1497
+ && (_this.indexSelectedMetadata == null ? true : _this.indexSelectedMetadata !== i); })) ||
1498
+ (this.field.FieldType === FieldTypeEnum.Immagine
1499
+ && this.field.AttachDefinition.MetadataFields
1500
+ && this.field.AttachDefinition.MetadataFields.find(function (m, i) { return m.Label === metadata.Label
1501
+ && (_this.indexSelectedMetadata == null ? true : _this.indexSelectedMetadata !== i); }))) {
1502
+ EqpDynamicModuleDialogService.Warning('Impossibile inserire due metadata con la stessa label.');
1503
+ throw new Error('Impossibile inserire due metadata con la stessa label.');
1504
+ }
1505
+ if (this.indexSelectedMetadata != null && this.indexSelectedMetadata >= 0) {
1506
+ if (this.field.FieldType === FieldTypeEnum.Allegato) {
1507
+ this.field.MetadataFields[this.indexSelectedMetadata] = metadata;
1508
+ }
1509
+ else if (this.field.FieldType === FieldTypeEnum.Immagine) {
1510
+ this.field.AttachDefinition.MetadataFields[this.indexSelectedMetadata] = metadata;
1511
+ }
1512
+ }
1513
+ else {
1514
+ if (this.field.FieldType === FieldTypeEnum.Allegato) {
1515
+ if (!this.field.MetadataFields) {
1516
+ this.field.MetadataFields = new Array();
1517
+ }
1518
+ this.field.MetadataFields.push(metadata);
1519
+ }
1520
+ else if (this.field.FieldType === FieldTypeEnum.Immagine) {
1521
+ if (!this.field.AttachDefinition.MetadataFields) {
1522
+ this.field.AttachDefinition.MetadataFields = new Array();
1523
+ }
1524
+ this.field.AttachDefinition.MetadataFields.push(metadata);
1525
+ }
1526
+ }
1527
+ }
1528
+ this.dialogMetadataRef.close();
1529
+ this.setMetadataOrdinalPosition();
1530
+ this.reloadMetadataTable();
1531
+ };
1532
+ /**
1533
+ * Metodo per disabilitare il pulsante per salvare il campo inserito/modificato.
1534
+ * @returns Restituisce un booleano, se true il salvataggio viene disabilitato.
1535
+ */
1536
+ AddFormFieldComponent.prototype.disableSaveField = function () {
1537
+ if (this.fieldFormGroup.invalid) {
1538
+ return true;
1539
+ }
1540
+ switch (this.field.FieldType) {
1541
+ case FieldTypeEnum['Elenco generico']:
1542
+ return !this.field.ValuePairs || this.field.ValuePairs.length === 0;
1543
+ case FieldTypeEnum.Lookup:
1544
+ return !this.field.FieldNames || this.field.FieldNames.length === 0;
1545
+ default:
1546
+ return false;
1547
+ }
1548
+ };
1549
+ /**
1550
+ * Metodo per salvare il campo inserito/modificato.
1551
+ * Se è stato inserito un field con la stessa label viene generato un errore (le label devono essere univoche).
1552
+ * Una volta aggiunto/aggiornato il campo nell'elenco dei Field della Form chiude il dialog e ricarica la tabella
1553
+ * che mostra l'elenco dei campi aggiunti alla form.
1554
+ */
1555
+ AddFormFieldComponent.prototype.saveAndExitAddField = function (save) {
1556
+ if (save) {
1557
+ this.saveFieldEvent.emit(this.field);
1558
+ }
1559
+ else {
1560
+ this.saveFieldEvent.emit(null);
1561
+ }
1562
+ };
1563
+ /**
1564
+ * Metodo per ripristinare l'oggetto field al cambio del tipo selezionato.
1565
+ * Lascia valorizzate solo le proprietà dell'oggetto BaseField comune a tutti i tipi di campo.
1566
+ */
1567
+ AddFormFieldComponent.prototype.restoreBaseFieldProperties = function () {
1568
+ if (this.field) {
1569
+ var tmpBaseField = JSON.parse(JSON.stringify(this.field));
1570
+ this.field = new BaseField();
1571
+ this.field.Label = tmpBaseField.Label;
1572
+ this.field.Description = tmpBaseField.Description;
1573
+ this.field.Required = tmpBaseField.Required;
1574
+ this.field.FieldType = tmpBaseField.FieldType;
1575
+ this.field.Formula = tmpBaseField.Formula;
1576
+ this.field.ColSizes = tmpBaseField.ColSizes;
1577
+ this.field.FieldGroup = tmpBaseField.FieldGroup;
1578
+ }
1579
+ };
1580
+ AddFormFieldComponent.prototype.configureColumns = function () {
1581
+ var _this = this;
1582
+ this.metadataColumns = [
1583
+ {
1584
+ key: 'action', display: '', type: TypeColumn.MenuAction, buttonMenuIcon: 'more_vert', styles: { flex: '0 0 6%' },
1585
+ actions: [
1586
+ { name: 'Modifica', icon: 'edit', fn: function (element, index, col) { return _this.openMetadataDialog(element); } },
1587
+ { name: 'Elimina', icon: 'delete', fn: function (element, index, col) { return _this.deleteMetadata(element); } },
1588
+ ]
1589
+ },
1590
+ { key: 'FieldType', display: 'Tipologia', type: TypeColumn.Enum, enumModel: FieldTypeEnum },
1591
+ { key: 'Label', display: 'Label' },
1592
+ { key: 'Description', display: 'Descrizione' },
1593
+ {
1594
+ key: 'Required', display: 'Obbligatorio',
1595
+ value: function (element) { return !!element.Required; },
1596
+ type: TypeColumn.Boolean,
1597
+ booleanValues: {
1598
+ true: '<i class="fa fa-check success-color"></i>',
1599
+ false: '<i class="fa fa-close error-color"></i>'
1600
+ },
1601
+ styles: { flex: '0 0 7%', cellAlignment: CellAlignmentEnum.CENTER }
1602
+ },
1603
+ ];
1604
+ };
1605
+ /**
1606
+ * Metodo per eliminare un metadata aggiunto per un campo di tipo Allegato o Immagine.
1607
+ * @param metadata Metadata da eliminare.
1608
+ */
1609
+ AddFormFieldComponent.prototype.deleteMetadata = function (metadata) {
1610
+ var _this = this;
1611
+ EqpDynamicModuleDialogService.Confirm('Eliminare il metadata selezionato?', function () {
1612
+ if (_this.field.FieldType === FieldTypeEnum.Allegato) {
1613
+ _this.field.MetadataFields.splice(_this.field.MetadataFields.indexOf(metadata), 1);
1614
+ }
1615
+ else if (_this.field.FieldType === FieldTypeEnum.Immagine) {
1616
+ _this.field.AttachDefinition.MetadataFields.splice(_this.field.AttachDefinition.MetadataFields.indexOf(metadata), 1);
1617
+ }
1618
+ _this.setMetadataOrdinalPosition();
1619
+ _this.reloadMetadataTable();
1620
+ }, false, 'Richiesta conferma');
1621
+ };
1622
+ /**
1623
+ * Imposta l'ordinamento dei metadata all'interno dei campi di tipo Allegato e Immagine.
1624
+ */
1625
+ AddFormFieldComponent.prototype.setMetadataOrdinalPosition = function () {
1626
+ var _this = this;
1627
+ if (this.field.FieldType === FieldTypeEnum.Allegato) {
1628
+ if (this.field.MetadataFields) {
1629
+ this.field.MetadataFields.forEach(function (metadata) {
1630
+ metadata.OrdinalPosition = _this.field.MetadataFields.indexOf(metadata);
1631
+ });
1632
+ }
1633
+ }
1634
+ else if (this.field.FieldType === FieldTypeEnum.Immagine) {
1635
+ if (this.field.AttachDefinition.MetadataFields) {
1636
+ this.field.AttachDefinition.MetadataFields.forEach(function (metadata) {
1637
+ metadata.OrdinalPosition = _this.field.AttachDefinition.MetadataFields.indexOf(metadata);
1638
+ });
1639
+ }
1640
+ }
1641
+ };
1642
+ /**
1643
+ * Metodo per ricaricare i dati della tabella dei metadata visualizzata nella creazione/modifica
1644
+ * dei campi di tipo Allegato o Immagine.
1645
+ */
1646
+ AddFormFieldComponent.prototype.reloadMetadataTable = function () {
1647
+ if (this.metadataFieldsTable) {
1648
+ this.metadataFieldsTable.reloadDatatable();
1649
+ }
1650
+ };
1651
+ AddFormFieldComponent.ctorParameters = function () { return [
1652
+ { type: FormBuilder },
1653
+ { type: EnumHelper },
1654
+ { type: MatDialog }
1655
+ ]; };
1656
+ __decorate([
1657
+ Input()
1658
+ ], AddFormFieldComponent.prototype, "field", void 0);
1659
+ __decorate([
1660
+ Input()
1661
+ ], AddFormFieldComponent.prototype, "indexField", void 0);
1662
+ __decorate([
1663
+ Input()
1664
+ ], AddFormFieldComponent.prototype, "formFieldsGroups", void 0);
1665
+ __decorate([
1666
+ Input()
1667
+ ], AddFormFieldComponent.prototype, "availableFields", void 0);
1668
+ __decorate([
1669
+ Input()
1670
+ ], AddFormFieldComponent.prototype, "fieldTypesToExclude", void 0);
1671
+ __decorate([
1672
+ Output()
1673
+ ], AddFormFieldComponent.prototype, "saveFieldEvent", void 0);
1674
+ __decorate([
1675
+ ViewChild('textFieldFormTemplate', { static: true })
1676
+ ], AddFormFieldComponent.prototype, "textFieldFormTemplate", void 0);
1677
+ __decorate([
1678
+ ViewChild('textareaFieldFormTemplate', { static: true })
1679
+ ], AddFormFieldComponent.prototype, "textareaFieldFormTemplate", void 0);
1680
+ __decorate([
1681
+ ViewChild('booleadFieldFormTemplate', { static: true })
1682
+ ], AddFormFieldComponent.prototype, "booleadFieldFormTemplate", void 0);
1683
+ __decorate([
1684
+ ViewChild('dateFieldFormTemplate', { static: true })
1685
+ ], AddFormFieldComponent.prototype, "dateFieldFormTemplate", void 0);
1686
+ __decorate([
1687
+ ViewChild('numericFieldFormTemplate', { static: true })
1688
+ ], AddFormFieldComponent.prototype, "numericFieldFormTemplate", void 0);
1689
+ __decorate([
1690
+ ViewChild('attachmentFieldFormTemplate', { static: true })
1691
+ ], AddFormFieldComponent.prototype, "attachmentFieldFormTemplate", void 0);
1692
+ __decorate([
1693
+ ViewChild('imageFieldFormTemplate', { static: true })
1694
+ ], AddFormFieldComponent.prototype, "imageFieldFormTemplate", void 0);
1695
+ __decorate([
1696
+ ViewChild('listValueFieldFormTemplate', { static: true })
1697
+ ], AddFormFieldComponent.prototype, "listValueFieldFormTemplate", void 0);
1698
+ __decorate([
1699
+ ViewChild('lookupFieldFormTemplate', { static: true })
1700
+ ], AddFormFieldComponent.prototype, "lookupFieldFormTemplate", void 0);
1701
+ __decorate([
1702
+ ViewChild('metadataFieldsTable', { static: false })
1703
+ ], AddFormFieldComponent.prototype, "metadataFieldsTable", void 0);
1704
+ __decorate([
1705
+ ViewChild('dialogMetadata', { static: true })
1706
+ ], AddFormFieldComponent.prototype, "dialogMetadata", void 0);
1707
+ AddFormFieldComponent = __decorate([
1708
+ Component({
1709
+ selector: 'eqp-dynamic-module-add-form-field',
1710
+ template: "<div class=\"container-fluid\" style=\"max-height: 70vh !important; overflow-x: hidden; overflow-y: auto;\">\n <form [formGroup]=\"fieldFormGroup\">\n <div class=\"row\">\n <div class=\"header-title-standard\">{{indexField != null && indexField >= 0 ? \"Modifica\"\n : \"Aggiungi\"}} campo</div>\n </div>\n <div class=\"row\">\n <div class=\"col-sm-12 col-md-4 mt-2\">\n <eqp-select [enumData]=\"FieldTypeEnum\" [(ngModelInput)]=\"field.FieldType\" [isRequired]=\"true\"\n [showCancelButton]=\"false\" placeholder=\"Tipo campo\" (ngModelInputChange)=\"onFieldTypeChange()\"\n [formGroupInput]=\"fieldFormGroup\" [formControlNameInput]=\"'FieldType'\"\n [enumDataToExclude]=\"fieldTypesToExclude\">\n </eqp-select>\n </div>\n\n <div class=\"col-sm-12 col-md-4 mt-2\">\n <mat-form-field>\n <mat-label> Label </mat-label>\n <input formControlName=\"Label\" required matInput [(ngModel)]=\"field.Label\">\n </mat-form-field>\n </div>\n\n <div class=\"col-sm-12 col-md-4 mt-2\">\n <mat-form-field>\n <mat-label> Descrizione </mat-label>\n <input formControlName=\"Description\" required matInput [(ngModel)]=\"field.Description\">\n </mat-form-field>\n </div>\n\n <div class=\"col-sm-12 col-md-4 mt-2 d-flex align-items-center\">\n <mat-slide-toggle [(ngModel)]=\"field.Required\" formControlName=\"Required\" color=\"primary\">\n Obbligatorio\n </mat-slide-toggle>\n </div>\n\n <div class=\"col-sm-12 col-md-4 mt-2\">\n <mat-form-field>\n <mat-label> Formula (Javascript) </mat-label>\n <input formControlName=\"Formula\" matInput [(ngModel)]=\"field.Formula\"\n [matAutocomplete]=\"formulaAutocomplete\" (keyup)=\"setFormulaAutocompleteOptions($event)\"\n (focus)=\"setFormulaAutocompleteOptions(null)\">\n <mat-autocomplete #formulaAutocomplete=\"matAutocomplete\">\n <mat-option *ngFor=\"let option of formulaAutocompleteOptions\" [value]=\"option.value\">\n {{option.label}}\n </mat-option>\n </mat-autocomplete>\n </mat-form-field>\n </div>\n\n <div class=\"col-sm-12 col-md-4 mt-2\" *ngIf=\"formFieldsGroups\">\n <eqp-select [arrayData]=\"formFieldsGroups\" [(ngModelInput)]=\"field.FieldGroup\"\n [arrayKeyProperty]=\"'Name'\" [arrayValueProperty]=\"'Name'\" placeholder=\"Sezione\"\n [formGroupInput]=\"fieldFormGroup\" [formControlNameInput]=\"'FieldGroup'\" [isRequired]=\"true\"\n [includeFullObject]=\"false\">\n </eqp-select>\n </div>\n\n <div class=\"col-sm-12 col-md-4 mt-2\">\n <eqp-select [arrayData]=\"availableColSpanSizes\" [(ngModelInput)]=\"field.ColSizes\"\n [arrayKeyProperty]=\"'key'\" [arrayValueProperty]=\"'value'\" (ngModelInputChange)=\"onColSizeSelect()\"\n [isMultiSelect]=\"true\" placeholder=\"Larghezza campo\" [formGroupInput]=\"fieldFormGroup\"\n [formControlNameInput]=\"'ColSizes'\" [includeFullObject]=\"false\">\n </eqp-select>\n </div>\n\n <div class=\"col-sm-12 col-md-4 mt-2 d-flex align-items-center\">\n <mat-slide-toggle [(ngModel)]=\"field.InListView\" formControlName=\"InListView\" color=\"primary\">\n Mostrare nella visualizzazione a lista\n </mat-slide-toggle>\n </div>\n\n <ng-container *ngTemplateOutlet=\"fieldTypeFormTemplate\">\n </ng-container>\n </div>\n\n\n <div class=\"row mt-2 mb-1\">\n <div class=\"col-sm-12 text-right\">\n <button class=\"mr-2\" mat-raised-button color=\"primary\" (click)=\"saveAndExitAddField(true)\"\n [disabled]=\"disableSaveField()\" type=\"button\">\n Salva\n </button>\n <button class=\"btn mat-raised-button\" (click)=\"saveAndExitAddField(false)\" type=\"button\">\n Esci\n </button>\n </div>\n </div>\n </form>\n</div>\n\n\n<!-- FORM PROPRIET\u00C0 CAMPI DI TESTO -->\n<ng-template #textFieldFormTemplate>\n <div class=\"col-sm-12 col-md-4 mt-2\" [formGroup]=\"fieldFormGroup\">\n <mat-form-field>\n <mat-label> Maschera </mat-label>\n <input formControlName=\"TextMask\" matInput [(ngModel)]=\"field.TextMask\">\n </mat-form-field>\n </div>\n <div class=\"col-sm-12 col-md-4\" [formGroup]=\"fieldFormGroup\">\n <mat-form-field>\n <mat-label> Lunghezza massima </mat-label>\n <input formControlName=\"MaxLenght\" type=\"number\" [min]=\"0\" matInput [(ngModel)]=\"field.MaxLenght\">\n </mat-form-field>\n </div>\n <div class=\"col-sm-12 col-md-4\" [formGroup]=\"fieldFormGroup\">\n <mat-form-field>\n <mat-label> Lunghezza minima </mat-label>\n <input formControlName=\"MinLenght\" type=\"number\" [min]=\"0\" matInput [(ngModel)]=\"field.MinLenght\">\n </mat-form-field>\n </div>\n</ng-template>\n\n<!-- FORM PROPRIET\u00C0 CAMPI AREA DI TESTO -->\n<ng-template #textareaFieldFormTemplate>\n <div class=\"col-sm-12 col-md-4 mt-2\" [formGroup]=\"fieldFormGroup\">\n <mat-form-field>\n <mat-label> Righe </mat-label>\n <input formControlName=\"Rows\" type=\"number\" [min]=\"0\" matInput [(ngModel)]=\"field.Rows\">\n </mat-form-field>\n </div>\n <div class=\"col-sm-12 col-md-4 mt-2\" [formGroup]=\"fieldFormGroup\">\n <mat-form-field>\n <mat-label> Lunghezza massima </mat-label>\n <input formControlName=\"MaxLenght\" type=\"number\" [min]=\"0\" matInput [(ngModel)]=\"field.MaxLenght\">\n </mat-form-field>\n </div>\n <div class=\"col-sm-12 col-md-4 mt-2\" [formGroup]=\"fieldFormGroup\">\n <mat-form-field>\n <mat-label> Lunghezza minima </mat-label>\n <input formControlName=\"MinLenght\" type=\"number\" [min]=\"0\" matInput [(ngModel)]=\"field.MinLenght\">\n </mat-form-field>\n </div>\n</ng-template>\n\n<!-- FORM PROPRIET\u00C0 CAMPI BOOLEANI -->\n<ng-template #booleadFieldFormTemplate>\n <div class=\"col-sm-12 col-md-4 mt-2 d-flex align-items-center\" [formGroup]=\"fieldFormGroup\">\n <mat-slide-toggle [(ngModel)]=\"field.IsTristate\" formControlName=\"IsTristate\" color=\"primary\">\n A tre stati\n </mat-slide-toggle>\n </div>\n <div class=\"col-sm-12 col-md-4 mt-2\">\n <eqp-select [enumData]=\"BoolPresentantioEnum\" [(ngModelInput)]=\"field.PresetationType\" [isRequired]=\"true\"\n [showCancelButton]=\"false\" placeholder=\"Tipo di presentazione\" [formGroupInput]=\"fieldFormGroup\"\n [formControlNameInput]=\"'PresetationType'\">\n </eqp-select>\n </div>\n</ng-template>\n\n<!-- FORM PROPRIET\u00C0 CAMPI DATA -->\n<ng-template #dateFieldFormTemplate>\n <div class=\"col-sm-12 col-md-4 mt-2\">\n <eqp-datetimepicker [placeholder]=\"'Data minima'\" [(ngModelInput)]=\"field.MinDate\"\n [formGroupInput]=\"fieldFormGroup\" [formControlNameInput]=\"'MinDate'\" [UTCDate]=\"true\" [showSeconds]=\"false\">\n </eqp-datetimepicker>\n </div>\n <div class=\"col-sm-12 col-md-4 mt-2\">\n <eqp-datetimepicker [placeholder]=\"'Data massima'\" [(ngModelInput)]=\"field.MaxDate\"\n [formGroupInput]=\"fieldFormGroup\" [formControlNameInput]=\"'MaxDate'\" [UTCDate]=\"true\" [showSeconds]=\"false\">\n </eqp-datetimepicker>\n </div>\n <div class=\"col-sm-12 col-md-4 mt-2\">\n <eqp-select [enumData]=\"DateTimeTypeEnum\" [(ngModelInput)]=\"field.IsOnlyDate\" [isRequired]=\"true\"\n [showCancelButton]=\"false\" placeholder=\"Tipo di data\" [formGroupInput]=\"fieldFormGroup\"\n [formControlNameInput]=\"'IsOnlyDate'\">\n </eqp-select>\n </div>\n</ng-template>\n\n<!-- FORM PROPRIET\u00C0 CAMPI NUMERICI -->\n<ng-template #numericFieldFormTemplate>\n <div class=\"col-sm-12 col-md-4 mt-2 d-flex align-items-center\" [formGroup]=\"fieldFormGroup\">\n <mat-slide-toggle [(ngModel)]=\"field.IsInteger\" formControlName=\"IsInteger\" color=\"primary\">\n Valore intero\n </mat-slide-toggle>\n </div>\n <div class=\"col-sm-12 col-md-4 mt-2\" [formGroup]=\"fieldFormGroup\">\n <mat-form-field>\n <mat-label> Formato numerico </mat-label>\n <input formControlName=\"NumberFormat\" matInput [(ngModel)]=\"field.NumberFormat\">\n </mat-form-field>\n </div>\n <div class=\"col-sm-12 col-md-4 mt-2\" [formGroup]=\"fieldFormGroup\">\n <mat-form-field>\n <mat-label> Simbolo valuta </mat-label>\n <input formControlName=\"CurrencySymbol\" matInput [(ngModel)]=\"field.CurrencySymbol\">\n </mat-form-field>\n </div>\n <div class=\"col-sm-12 col-md-4 mt-2\" [formGroup]=\"fieldFormGroup\">\n <mat-form-field>\n <mat-label> Valore massimo </mat-label>\n <input formControlName=\"MinValue\" type=\"number\" [min]=\"0\" matInput [(ngModel)]=\"field.MinValue\">\n </mat-form-field>\n </div>\n <div class=\"col-sm-12 col-md-4 mt-2\" [formGroup]=\"fieldFormGroup\">\n <mat-form-field>\n <mat-label> Valore minimo </mat-label>\n <input formControlName=\"MaxValue\" type=\"number\" [min]=\"0\" matInput [(ngModel)]=\"field.MaxValue\">\n </mat-form-field>\n </div>\n</ng-template>\n\n<!-- FORM PROPRIET\u00C0 CAMPI ALLEGATO -->\n<ng-template #attachmentFieldFormTemplate>\n <div class=\"col-sm-12 col-md-4 mt-2 d-flex align-items-center\" [formGroup]=\"fieldFormGroup\">\n <mat-slide-toggle [(ngModel)]=\"field.IsMultiAttach\" formControlName=\"IsMultiAttach\" color=\"primary\">\n Allegati multipli\n </mat-slide-toggle>\n </div>\n <div class=\"col-sm-12 col-md-4 mt-2\">\n <eqp-select [arrayData]=\"AvailableFileExtensions.concat(AvailableImageExtensions)\"\n [(ngModelInput)]=\"field.AllowedExtensions\" [arrayKeyProperty]=\"'key'\" [arrayValueProperty]=\"'value'\"\n [isMultiSelect]=\"true\" placeholder=\"Estensioni accettate\" [formGroupInput]=\"fieldFormGroup\"\n [formControlNameInput]=\"'AllowedExtensions'\" [includeFullObject]=\"false\">\n </eqp-select>\n </div>\n <div class=\"col-sm-12 mt-2\">\n <div class=\"row mt-2\">\n <div class=\"col-sm-12 col-md-6\">\n <div class=\"header-title-standard\">\n Elenco metadata\n </div>\n </div>\n <div class=\"col-sm-12 col-md-6 text-right\">\n <button class=\"btn btn-primary\" mat-raised-button color=\"primary\" type=\"button\"\n (click)=\"openMetadataDialog()\">\n <mat-icon>add</mat-icon>\n <span style=\"margin-left: 10px;\">Aggiungi</span>\n </button>\n </div>\n </div>\n <eqp-table #metadataFieldsTable [createMatCard]=\"false\" [columns]=\"metadataColumns\"\n [data]=\"field.MetadataFields\" [emptyTableMessage]=\"'Nessun metadata inserito'\" [searchText]=\"'Cerca'\">\n </eqp-table>\n </div>\n</ng-template>\n\n<!-- FORM PROPRIET\u00C0 CAMPI IMMAGINE -->\n<ng-template #imageFieldFormTemplate>\n <!-- <div class=\"col-sm-12 col-md-4 mt-2\" [formGroup]=\"fieldFormGroup\">\n <mat-form-field>\n <mat-label> Nome immagine </mat-label>\n <input formControlName=\"ImgName\" matInput [(ngModel)]=\"field.ImgName\">\n </mat-form-field>\n </div> -->\n <div class=\"col-sm-12 col-md-4 mt-2 d-flex align-items-center\" [formGroup]=\"fieldFormGroup\">\n <mat-slide-toggle [(ngModel)]=\"field.IsMultiPoint\" formControlName=\"IsMultiPoint\" color=\"primary\">\n Immagine multi-point\n </mat-slide-toggle>\n </div>\n <div class=\"col-sm-12 col-md-4 mt-2 d-flex align-items-center\" [formGroup]=\"fieldFormGroup\">\n <mat-slide-toggle [(ngModel)]=\"field.ImageIsContextualAttachment\" formControlName=\"ImageIsContextualAttachment\"\n color=\"primary\">\n Carica immagine come allegato\n </mat-slide-toggle>\n </div>\n <div class=\"col-sm-12 col-md-4 mt-2 d-flex align-items-center\" [formGroup]=\"fieldFormGroup\">\n <mat-slide-toggle [(ngModel)]=\"field.AttachDefinition.IsMultiAttach\" formControlName=\"IsMultiAttach\"\n color=\"primary\">\n Immagini multiple\n </mat-slide-toggle>\n </div>\n <div class=\"col-sm-12 col-md-4 mt-2\">\n <eqp-select [arrayData]=\"AvailableImageExtensions\" [(ngModelInput)]=\"field.AttachDefinition.AllowedExtensions\"\n [arrayKeyProperty]=\"'key'\" [arrayValueProperty]=\"'value'\" [isMultiSelect]=\"true\"\n placeholder=\"Estensioni accettate\" [formGroupInput]=\"fieldFormGroup\"\n [formControlNameInput]=\"'AllowedExtensions'\" [includeFullObject]=\"false\">\n </eqp-select>\n </div>\n <div class=\"col-sm-12 mt-2\">\n <div class=\"row mt-2\">\n <div class=\"col-sm-12 col-md-6\">\n <div class=\"header-title-standard\">\n Elenco metadata\n </div>\n </div>\n <div class=\"col-sm-12 col-md-6 text-right\">\n <button class=\"btn btn-primary\" mat-raised-button color=\"primary\" type=\"button\"\n (click)=\"openMetadataDialog()\">\n <mat-icon>add</mat-icon>\n <span style=\"margin-left: 10px;\">Aggiungi</span>\n </button>\n </div>\n </div>\n <eqp-table #metadataFieldsTable [createMatCard]=\"false\" [columns]=\"metadataColumns\"\n [data]=\"field.AttachDefinition.MetadataFields\" [emptyTableMessage]=\"'Nessun metadata inserito'\"\n [searchText]=\"'Cerca'\">\n </eqp-table>\n </div>\n</ng-template>\n\n<!-- FORM PROPRIET\u00C0 CAMPI LISTA DI VALORI -->\n<ng-template #listValueFieldFormTemplate>\n <div class=\"col-sm-12 col-md-4 mt-2 d-flex align-items-center\" [formGroup]=\"fieldFormGroup\">\n <mat-slide-toggle [(ngModel)]=\"field.IsMultiChoiche\" formControlName=\"IsMultiChoiche\" color=\"primary\">\n Scelta multipla\n </mat-slide-toggle>\n </div>\n <div class=\"col-sm-12 col-md-4 mt-2\">\n <eqp-select [enumData]=\"ListPresentationEnum\" [(ngModelInput)]=\"field.PresentationMode\" [isRequired]=\"true\"\n [showCancelButton]=\"false\" placeholder=\"Tipo di presentazione\" [formGroupInput]=\"fieldFormGroup\"\n [formControlNameInput]=\"'PresentationMode'\">\n </eqp-select>\n </div>\n <div class=\"col-sm-12 mt-2\">\n <div class=\"row\">\n <h4 class=\"key-value-list-section-title\"> </h4>\n <div class=\"col-md-4 d-flex align-items-center\">\n <mat-form-field>\n <mat-label> Label opzione (invio per confermare)</mat-label>\n <input matInput [(ngModel)]=\"keyValueObject.key\" (keyup)=\"onMultiSelectInputKeyup($event, null)\">\n </mat-form-field>\n </div>\n <div class=\"col-md-4 d-flex align-items-center\">\n <mat-form-field>\n <mat-label> Valore opzione (invio per confermare)</mat-label>\n <input matInput [(ngModel)]=\"keyValueObject.value\" (keyup)=\"onMultiSelectInputKeyup($event, null)\">\n </mat-form-field>\n </div>\n <div class=\"col-md-4 d-flex align-items-center\">\n <span class=\"mr-3\">Opzioni inserite:</span>\n <ul class=\"value-pairs-list\">\n <li *ngFor=\"let keyValuePair of getDictionaryKeyValue()\">\n <mat-icon class=\"mr-1\" (click)=\"deleteKeyFromDictionary(keyValuePair.key)\">close\n </mat-icon>\n <span><b>Label: </b> {{keyValuePair.key}} - <b>Valore: </b> {{keyValuePair.value}}</span>\n </li>\n </ul>\n </div>\n </div>\n </div>\n</ng-template>\n\n<!-- FORM PROPRIET\u00C0 CAMPI LOOKUP -->\n<ng-template #lookupFieldFormTemplate>\n <div class=\"col-sm-12 col-md-4 mt-2 d-flex align-items-center\" [formGroup]=\"fieldFormGroup\">\n <mat-slide-toggle [(ngModel)]=\"field.UseAsGetOrDiscard\" formControlName=\"UseAsGetOrDiscard\" color=\"primary\"\n matTooltip=\"Se true la lookup viene visualizzata in una modale per lo scegli scarta\">\n Usa per scegli o scarta\n </mat-slide-toggle>\n </div>\n <div class=\"col-sm-12 col-md-4 mt-2\" [formGroup]=\"fieldFormGroup\">\n <mat-form-field matTooltip=\"Nome dell'entit\u00E0 relazionata\">\n <mat-label> Nome entit\u00E0 </mat-label>\n <input formControlName=\"EntitySourceName\" required matInput [(ngModel)]=\"field.EntitySourceName\">\n </mat-form-field>\n </div>\n <div class=\"col-sm-12 mt-2\">\n <div class=\"row\">\n <div class=\"col-md-4\">\n <mat-form-field\n matTooltip=\"Elenco di campi ordinato che verr\u00E0 visualizzato nella lookup (premere invio per confermare)\">\n <mat-label>\n Nomi dei campi (invio per confermare) </mat-label>\n <input matInput (keyup)=\"onMultiSelectInputKeyup($event, 'FieldNames')\">\n </mat-form-field>\n </div>\n <div class=\"col-md-8 d-flex align-items-center\">\n <span class=\"mr-3\">Nomi selezionati:</span>\n <div class=\"extension-container\" *ngFor=\"let extension of field.FieldNames; let i = index\">\n <span>{{extension}}</span>\n <mat-icon class=\"ml-1\" (click)=\"field.FieldNames.splice(i,1)\">close\n </mat-icon>\n </div>\n </div>\n </div>\n </div>\n</ng-template>\n\n<!-- DIALOG PER AGGIUNGERE UN METADATA NEI CAMPI DI TIPO ALLEGATO O IMMAGINE -->\n<ng-template #dialogMetadata>\n <eqp-dynamic-module-add-form-field [field]=\"selectedMetadata\" [availableFields]=\"availableFields\"\n [indexField]=\"indexSelectedMetadata\" (saveFieldEvent)=\"onSaveMetadata($event)\" [fieldTypesToExclude]=\"[6,7,10]\">\n </eqp-dynamic-module-add-form-field>\n</ng-template>",
1711
+ styles: [".extension-container{display:inline-block;font-size:15px;border:1px solid var(--primary);border-radius:15px;margin-right:10px}.extension-container mat-icon{vertical-align:middle;font-size:15px;height:15px;width:15px;color:var(--danger);margin-right:10px;cursor:pointer}.extension-container span{margin-left:10px}.key-value-list-section-title{background:linear-gradient(to right,var(--gray) 0,#fff 100%) left bottom #fff no-repeat;background-size:100% 1px}.value-pairs-list{list-style:none;padding:0}.value-pairs-list mat-icon{vertical-align:middle;font-size:15px;height:15px;width:15px;color:var(--danger);margin-right:10px;cursor:pointer}"]
1712
+ })
1713
+ ], AddFormFieldComponent);
1714
+ return AddFormFieldComponent;
1715
+ }());
1716
+
1717
+ var TextFieldTemplateComponent = /** @class */ (function () {
1718
+ function TextFieldTemplateComponent() {
1719
+ this.recordChange = new EventEmitter();
1720
+ }
1721
+ TextFieldTemplateComponent.prototype.ngOnInit = function () {
1722
+ };
1723
+ TextFieldTemplateComponent.prototype.ngOnChanges = function (changes) {
1724
+ // Se viene modificato il valore di "ngModelInput" allora aggiorna l'input
1725
+ if (changes['record'] != undefined && changes['record'].firstChange == false && JSON.stringify(changes['record'].currentValue) != JSON.stringify(changes['record'].previousValue)) {
1726
+ this.record = changes['record'].currentValue;
1727
+ this.updateField();
1728
+ }
1729
+ };
1730
+ /**
1731
+ * Metodo per aggiornare il valore del campo quando questo è rappresentato da una formula.
1732
+ */
1733
+ TextFieldTemplateComponent.prototype.updateField = function () {
1734
+ if (this.field.Formula) {
1735
+ this.record[this.field.Name] = UtilityHelperService.EvaluateFieldFormula(this.field.Formula, this.record, null);
1736
+ }
1737
+ };
1738
+ /**
1739
+ * Metodo per emettere l'evento che il valore del record è cambiato.
1740
+ */
1741
+ TextFieldTemplateComponent.prototype.onRecordValueChange = function () {
1742
+ if (!this.field.Formula) {
1743
+ this.recordChange.emit(this.record);
1744
+ }
1745
+ };
1746
+ __decorate([
1747
+ Input()
1748
+ ], TextFieldTemplateComponent.prototype, "field", void 0);
1749
+ __decorate([
1750
+ Input()
1751
+ ], TextFieldTemplateComponent.prototype, "record", void 0);
1752
+ __decorate([
1753
+ Output()
1754
+ ], TextFieldTemplateComponent.prototype, "recordChange", void 0);
1755
+ TextFieldTemplateComponent = __decorate([
1756
+ Component({
1757
+ selector: 'text-field-template',
1758
+ template: "<mat-form-field [formGroup]=\"field.FormFormGroup\">\r\n <mat-label> {{field.Label}} </mat-label>\r\n <input matInput type=\"text\" [formControlName]=\"field.Name\" [disabled]=\"field.FormFormGroup.disabled\"\r\n [required]=\"field.Required\" [(ngModel)]=\"record[field.Name]\" (ngModelChange)=\"onRecordValueChange()\">\r\n</mat-form-field>",
1759
+ styles: [""]
1760
+ })
1761
+ ], TextFieldTemplateComponent);
1762
+ return TextFieldTemplateComponent;
1763
+ }());
1764
+
1765
+ var BooleanFieldTemplateComponent = /** @class */ (function () {
1766
+ function BooleanFieldTemplateComponent() {
1767
+ this.recordChange = new EventEmitter();
1768
+ this.BoolPresentantioEnum = BoolPresentantioEnum;
1769
+ }
1770
+ BooleanFieldTemplateComponent.prototype.ngOnInit = function () {
1771
+ if (this.record[this.field.Name] == undefined || this.record[this.field.Name] == null) {
1772
+ this.record[this.field.Name] = this.field.IsTristate ? null : false;
1773
+ }
1774
+ };
1775
+ BooleanFieldTemplateComponent.prototype.ngOnChanges = function (changes) {
1776
+ // Se viene modificato il valore di "ngModelInput" allora aggiorna l'input
1777
+ if (changes['record'] != undefined && changes['record'].firstChange == false && JSON.stringify(changes['record'].currentValue) != JSON.stringify(changes['record'].previousValue)) {
1778
+ this.record = changes['record'].currentValue;
1779
+ this.updateField();
1780
+ }
1781
+ };
1782
+ /**
1783
+ * Metodo per aggiornare il valore del campo quando questo è rappresentato da una formula.
1784
+ */
1785
+ BooleanFieldTemplateComponent.prototype.updateField = function () {
1786
+ if (this.field.Formula) {
1787
+ this.record[this.field.Name] = UtilityHelperService.EvaluateFieldFormula(this.field.Formula, this.record, null);
1788
+ }
1789
+ };
1790
+ /**
1791
+ * Metodo per emettere l'evento che il valore del record è cambiato.
1792
+ */
1793
+ BooleanFieldTemplateComponent.prototype.onRecordValueChange = function () {
1794
+ if (!this.field.Formula) {
1795
+ this.recordChange.emit(this.record);
1796
+ }
1797
+ };
1798
+ __decorate([
1799
+ Input()
1800
+ ], BooleanFieldTemplateComponent.prototype, "field", void 0);
1801
+ __decorate([
1802
+ Input()
1803
+ ], BooleanFieldTemplateComponent.prototype, "record", void 0);
1804
+ __decorate([
1805
+ Output()
1806
+ ], BooleanFieldTemplateComponent.prototype, "recordChange", void 0);
1807
+ BooleanFieldTemplateComponent = __decorate([
1808
+ Component({
1809
+ selector: 'boolean-field-template',
1810
+ template: "<div [formGroup]=\"field.FormFormGroup\">\n\n <!-- VISUALIZZAZIONE A TOGGLE -->\n <mat-slide-toggle color=\"primary\" *ngIf=\"field.PresetationType == BoolPresentantioEnum.Toggle\"\n [formControlName]=\"field.Name\" [disabled]=\"field.FormFormGroup.disabled\" [required]=\"field.Required\"\n [(ngModel)]=\"record[field.Name]\" (ngModelChange)=\"onRecordValueChange()\">\n {{field.Label + (field.Required ? \" *\" : \"\")}}\n </mat-slide-toggle>\n\n\n <!-- VISUALIZZAZIONE A RADIOBUTTON -->\n <mat-label class=\"mr-3\" *ngIf=\"field.PresetationType == BoolPresentantioEnum['Radio button']\">\n {{field.Label + (field.Required ? \" *\" : \"\")}}\n </mat-label>\n <mat-radio-group *ngIf=\"field.PresetationType == BoolPresentantioEnum['Radio button']\"\n [formControlName]=\"field.Name\" [disabled]=\"field.FormFormGroup.disabled\" [required]=\"field.Required\"\n [(ngModel)]=\"record[field.Name]\" (ngModelChange)=\"onRecordValueChange()\">\n <mat-radio-button class=\"mr-2\" [value]=\"true\" color=\"primary\"> Si </mat-radio-button>\n <mat-radio-button class=\"mr-2\" [value]=\"false\" color=\"primary\"> No </mat-radio-button>\n <mat-radio-button class=\"mr-2\" [value]=\"null\" color=\"primary\" *ngIf=\"field.IsTristate\"> ND\n </mat-radio-button>\n </mat-radio-group>\n\n <!-- VISUALIZZAZIONE A CHECKBOX -->\n <mat-checkbox class=\"mr-2\" *ngIf=\"field.PresetationType == BoolPresentantioEnum.Checkbox\"\n [disabled]=\"field.FormFormGroup.disabled\" [required]=\"field.Required\" [formControlName]=\"field.Name\"\n [(ngModel)]=\"record[field.Name]\" (ngModelChange)=\"onRecordValueChange()\">\n {{field.Label + (field.Required ? \" *\" : \"\")}}\n </mat-checkbox>\n\n <!-- TODO: Visualizzazione \"Stringa true o false\" e \"Numerico 0 o 1\" ?? -->\n</div>",
1811
+ styles: [""]
1812
+ })
1813
+ ], BooleanFieldTemplateComponent);
1814
+ return BooleanFieldTemplateComponent;
1815
+ }());
1816
+
1817
+ var DateFieldTemplateComponent = /** @class */ (function () {
1818
+ function DateFieldTemplateComponent() {
1819
+ this.recordChange = new EventEmitter();
1820
+ }
1821
+ DateFieldTemplateComponent.prototype.ngOnInit = function () {
1822
+ this.setTimeType();
1823
+ };
1824
+ DateFieldTemplateComponent.prototype.ngOnChanges = function (changes) {
1825
+ // Se viene modificato il valore di "ngModelInput" allora aggiorna l'input
1826
+ if (changes['record'] != undefined && changes['record'].firstChange == false && JSON.stringify(changes['record'].currentValue) != JSON.stringify(changes['record'].previousValue)) {
1827
+ this.record = changes['record'].currentValue;
1828
+ this.updateField();
1829
+ }
1830
+ };
1831
+ /**
1832
+ * Metodo per aggiornare il valore del campo quando questo è rappresentato da una formula.
1833
+ */
1834
+ DateFieldTemplateComponent.prototype.updateField = function () {
1835
+ if (this.field.Formula) {
1836
+ this.record[this.field.Name] = UtilityHelperService.EvaluateFieldFormula(this.field.Formula, this.record, null);
1837
+ }
1838
+ };
1839
+ /**
1840
+ * Metodo per emettere l'evento che il valore del record è cambiato.
1841
+ */
1842
+ DateFieldTemplateComponent.prototype.onRecordValueChange = function () {
1843
+ if (!this.field.Formula) {
1844
+ this.recordChange.emit(this.record);
1845
+ }
1846
+ };
1847
+ /**
1848
+ * In base al formato della data richiesta nel DateField (solo data, solo orario o data e ora)
1849
+ * imposta la visualizzazione corretta del componente eqp-datetimepicker.
1850
+ */
1851
+ DateFieldTemplateComponent.prototype.setTimeType = function () {
1852
+ switch (this.field.IsOnlyDate) {
1853
+ case DateTimeTypeEnum["Solo data"]:
1854
+ this.pickerMode = PickerModeEnum.DATE;
1855
+ break;
1856
+ case DateTimeTypeEnum["Solo orario"]:
1857
+ this.pickerMode = PickerModeEnum.TIME;
1858
+ break;
1859
+ case DateTimeTypeEnum["Data e ora"]:
1860
+ this.pickerMode = PickerModeEnum.DATETIME;
1861
+ break;
1862
+ }
1863
+ };
1864
+ __decorate([
1865
+ Input()
1866
+ ], DateFieldTemplateComponent.prototype, "field", void 0);
1867
+ __decorate([
1868
+ Input()
1869
+ ], DateFieldTemplateComponent.prototype, "record", void 0);
1870
+ __decorate([
1871
+ Output()
1872
+ ], DateFieldTemplateComponent.prototype, "recordChange", void 0);
1873
+ DateFieldTemplateComponent = __decorate([
1874
+ Component({
1875
+ selector: 'date-field-template',
1876
+ template: "<eqp-datetimepicker [placeholder]=\"field.Label\" [UTCDate]=\"true\" [pickerMode]=\"pickerMode\"\n [formGroupInput]=\"field.FormFormGroup\" [formControlNameInput]=\"field.Name\"\n [minDate]=\"field.MinDate ? field.MinDate : null\" [maxDate]=\"field.MaxDate ? field.MaxDate : null\"\n [isRequired]=\"field.Required\" [disabled]=\"field.FormFormGroup.disabled\" [(ngModelInput)]=\"record[field.Name]\"\n (ngModelInputChange)=\"onRecordValueChange()\">\n</eqp-datetimepicker>",
1877
+ styles: [""]
1878
+ })
1879
+ ], DateFieldTemplateComponent);
1880
+ return DateFieldTemplateComponent;
1881
+ }());
1882
+
1883
+ var TextareaFieldTemplateComponent = /** @class */ (function () {
1884
+ function TextareaFieldTemplateComponent() {
1885
+ this.recordChange = new EventEmitter();
1886
+ }
1887
+ TextareaFieldTemplateComponent.prototype.ngOnInit = function () {
1888
+ };
1889
+ TextareaFieldTemplateComponent.prototype.ngOnChanges = function (changes) {
1890
+ // Se viene modificato il valore di "ngModelInput" allora aggiorna l'input
1891
+ if (changes['record'] != undefined && changes['record'].firstChange == false && JSON.stringify(changes['record'].currentValue) != JSON.stringify(changes['record'].previousValue)) {
1892
+ this.record = changes['record'].currentValue;
1893
+ this.updateField();
1894
+ }
1895
+ };
1896
+ /**
1897
+ * Metodo per aggiornare il valore del campo quando questo è rappresentato da una formula.
1898
+ */
1899
+ TextareaFieldTemplateComponent.prototype.updateField = function () {
1900
+ if (this.field.Formula) {
1901
+ this.record[this.field.Name] = UtilityHelperService.EvaluateFieldFormula(this.field.Formula, this.record, null);
1902
+ }
1903
+ };
1904
+ /**
1905
+ * Metodo per emettere l'evento che il valore del record è cambiato.
1906
+ */
1907
+ TextareaFieldTemplateComponent.prototype.onRecordValueChange = function () {
1908
+ if (!this.field.Formula) {
1909
+ this.recordChange.emit(this.record);
1910
+ }
1911
+ };
1912
+ __decorate([
1913
+ Input()
1914
+ ], TextareaFieldTemplateComponent.prototype, "field", void 0);
1915
+ __decorate([
1916
+ Input()
1917
+ ], TextareaFieldTemplateComponent.prototype, "record", void 0);
1918
+ __decorate([
1919
+ Output()
1920
+ ], TextareaFieldTemplateComponent.prototype, "recordChange", void 0);
1921
+ TextareaFieldTemplateComponent = __decorate([
1922
+ Component({
1923
+ selector: 'textarea-field-template',
1924
+ template: "<mat-form-field [formGroup]=\"field.FormFormGroup\">\n <textarea matInput [placeholder]=\"field.Label\" [rows]=\"field.Rows\" [formControlName]=\"field.Name\"\n [disabled]=\"field.FormFormGroup.disabled\" [required]=\"field.Required\" [(ngModel)]=\"record[field.Name]\"\n (ngModelChange)=\"onRecordValueChange()\"></textarea>\n</mat-form-field>",
1925
+ styles: [""]
1926
+ })
1927
+ ], TextareaFieldTemplateComponent);
1928
+ return TextareaFieldTemplateComponent;
1929
+ }());
1930
+
1931
+ var NumericFieldTemplateComponent = /** @class */ (function () {
1932
+ function NumericFieldTemplateComponent() {
1933
+ this.recordChange = new EventEmitter();
1934
+ this.eqpNumericOptions = {};
1935
+ }
1936
+ NumericFieldTemplateComponent.prototype.ngOnInit = function () {
1937
+ this.configureEqpNumericOptions();
1938
+ };
1939
+ NumericFieldTemplateComponent.prototype.ngOnChanges = function (changes) {
1940
+ // Se viene modificato il valore di "ngModelInput" allora aggiorna l'input
1941
+ if (changes['record'] != undefined && changes['record'].firstChange == false && JSON.stringify(changes['record'].currentValue) != JSON.stringify(changes['record'].previousValue)) {
1942
+ this.record = changes['record'].currentValue;
1943
+ this.updateField();
1944
+ }
1945
+ };
1946
+ /**
1947
+ * Metodo per aggiornare il valore del campo quando questo è rappresentato da una formula.
1948
+ */
1949
+ NumericFieldTemplateComponent.prototype.updateField = function () {
1950
+ if (this.field.Formula) {
1951
+ this.record[this.field.Name] = UtilityHelperService.EvaluateFieldFormula(this.field.Formula, this.record, null);
1952
+ }
1953
+ };
1954
+ /**
1955
+ * Metodo per emettere l'evento che il valore del record è cambiato.
1956
+ */
1957
+ NumericFieldTemplateComponent.prototype.onRecordValueChange = function () {
1958
+ if (!this.field.Formula) {
1959
+ this.recordChange.emit(this.record);
1960
+ }
1961
+ };
1962
+ /**
1963
+ * Metodo per configurare eqp-numeric
1964
+ */
1965
+ NumericFieldTemplateComponent.prototype.configureEqpNumericOptions = function () {
1966
+ this.eqpNumericOptions.prefix = this.field.CurrencySymbol ? this.field.CurrencySymbol : "";
1967
+ if (this.field.MinValue != null && this.field.MinValue != undefined)
1968
+ this.eqpNumericOptions.min = this.field.MinValue;
1969
+ if (this.field.MaxValue != null && this.field.MaxValue != undefined)
1970
+ this.eqpNumericOptions.max = this.field.MaxValue;
1971
+ };
1972
+ __decorate([
1973
+ Input()
1974
+ ], NumericFieldTemplateComponent.prototype, "field", void 0);
1975
+ __decorate([
1976
+ Input()
1977
+ ], NumericFieldTemplateComponent.prototype, "record", void 0);
1978
+ __decorate([
1979
+ Output()
1980
+ ], NumericFieldTemplateComponent.prototype, "recordChange", void 0);
1981
+ NumericFieldTemplateComponent = __decorate([
1982
+ Component({
1983
+ selector: 'numeric-field-template',
1984
+ template: "<mat-form-field [formGroup]=\"field.FormFormGroup\">\n <mat-label> {{field.Label}} </mat-label>\n <input matInput eqpNumericMask [formControlName]=\"field.Name\" [disabled]=\"field.FormFormGroup.disabled\"\n [required]=\"field.Required\" [(ngModel)]=\"record[field.Name]\" [options]=\"eqpNumericOptions\"\n [step]=\"field.IsInteger ? 1 : null\" (ngModelChange)=\"onRecordValueChange()\" />\n</mat-form-field>",
1985
+ styles: [""]
1986
+ })
1987
+ ], NumericFieldTemplateComponent);
1988
+ return NumericFieldTemplateComponent;
1989
+ }());
1990
+
1991
+ var ListValueFieldTemplateComponent = /** @class */ (function () {
1992
+ function ListValueFieldTemplateComponent() {
1993
+ this.recordChange = new EventEmitter();
1994
+ this.ListPresentationEnum = ListPresentationEnum;
1995
+ this.arrayData = [];
1996
+ }
1997
+ ListValueFieldTemplateComponent.prototype.ngOnInit = function () {
1998
+ this.setArrayData();
1999
+ if (this.field.IsMultiChoiche && !this.record[this.field.Name]) {
2000
+ this.record[this.field.Name] = [];
2001
+ }
2002
+ // Nel caso in cui sono in modifica di un Record aggiorno il valore
2003
+ // e il validator del FormControl. Se non viene eseguita questa riga
2004
+ // l'utente deve modificare la selezione fatta per aggiornare la form.
2005
+ this.setFormControlValue();
2006
+ };
2007
+ ListValueFieldTemplateComponent.prototype.ngOnChanges = function (changes) {
2008
+ // Se viene modificato il valore di "ngModelInput" allora aggiorna l'input
2009
+ if (changes['record'] != undefined && changes['record'].firstChange == false && JSON.stringify(changes['record'].currentValue) != JSON.stringify(changes['record'].previousValue)) {
2010
+ this.record = changes['record'].currentValue;
2011
+ this.updateField();
2012
+ }
2013
+ };
2014
+ /**
2015
+ * Metodo per aggiornare il valore del campo quando questo è rappresentato da una formula.
2016
+ */
2017
+ ListValueFieldTemplateComponent.prototype.updateField = function () {
2018
+ if (this.field.Formula) {
2019
+ this.record[this.field.Name] = UtilityHelperService.EvaluateFieldFormula(this.field.Formula, this.record, null);
2020
+ }
2021
+ };
2022
+ /**
2023
+ * Metodo per recuperare la classe da applicare al button (nella relativa visualizzazione).
2024
+ * Se il pulsante è stato selezionato imposta la classe "selected-button".
2025
+ * @param data Oggetto bindato al pulsante
2026
+ * @returns Restituisce la classe da applicare tramite [ngClass]
2027
+ */
2028
+ ListValueFieldTemplateComponent.prototype.getSelectButtonClass = function (data) {
2029
+ var selectedButtonClass = "selected-button";
2030
+ return data.Selected ? selectedButtonClass : null;
2031
+ };
2032
+ /**
2033
+ * Metodo invocato quando viene selezionata un'opzione nella visualizzazione a button
2034
+ * @param data Rappresenta l'oggetto selezionato
2035
+ */
2036
+ ListValueFieldTemplateComponent.prototype.buttonSelectClick = function (data) {
2037
+ if (this.field.IsMultiChoiche) {
2038
+ data.Selected = !data.Selected;
2039
+ this.updateSelected(false);
2040
+ }
2041
+ else {
2042
+ this.record[this.field.Name] = data.Value;
2043
+ }
2044
+ this.onRecordValueChange();
2045
+ };
2046
+ /**
2047
+ * Metodo per aggiornare il/i valore/i selezionato/i dall'utente.
2048
+ * @param emitChange Se true scatena l'evento di output della modifica del valore di record
2049
+ */
2050
+ ListValueFieldTemplateComponent.prototype.updateSelected = function (emitChange) {
2051
+ if (emitChange === void 0) { emitChange = true; }
2052
+ this.record[this.field.Name] = this.arrayData.filter(function (data) { return data.Selected; }).map(function (data) { return data.Value; });
2053
+ this.setFormControlValue();
2054
+ if (emitChange) {
2055
+ this.onRecordValueChange();
2056
+ }
2057
+ };
2058
+ /**
2059
+ * Metodo per emettere l'evento che il valore del record è cambiato.
2060
+ */
2061
+ ListValueFieldTemplateComponent.prototype.onRecordValueChange = function () {
2062
+ if (!this.field.Formula) {
2063
+ this.recordChange.emit(this.record);
2064
+ }
2065
+ };
2066
+ /**
2067
+ * Metodo per creare un array di oggetti del tipo { Key: string, Value: any } da usare come sorgente dati per la eqp-select.
2068
+ */
2069
+ ListValueFieldTemplateComponent.prototype.setArrayData = function () {
2070
+ var _this = this;
2071
+ Object.keys(this.field.ValuePairs).forEach(function (k) {
2072
+ var isOptionSelected;
2073
+ if (_this.field.IsMultiChoiche && _this.record[_this.field.Name] && _this.record[_this.field.Name].length > 0) {
2074
+ isOptionSelected = !!_this.record[_this.field.Name].find(function (v) { return v == _this.field.ValuePairs[k]; });
2075
+ }
2076
+ else {
2077
+ isOptionSelected = _this.record[_this.field.Name] === _this.field.ValuePairs[k];
2078
+ }
2079
+ _this.arrayData.push({ Key: k, Value: _this.field.ValuePairs[k], Selected: isOptionSelected });
2080
+ });
2081
+ };
2082
+ /**
2083
+ * Metodo per aggiornare il valore e il validator del FormControl associato al campo.
2084
+ */
2085
+ ListValueFieldTemplateComponent.prototype.setFormControlValue = function () {
2086
+ this.field.FormFormGroup.controls[this.field.Name].setValue(this.record[this.field.Name]);
2087
+ };
2088
+ __decorate([
2089
+ Input()
2090
+ ], ListValueFieldTemplateComponent.prototype, "field", void 0);
2091
+ __decorate([
2092
+ Input()
2093
+ ], ListValueFieldTemplateComponent.prototype, "record", void 0);
2094
+ __decorate([
2095
+ Output()
2096
+ ], ListValueFieldTemplateComponent.prototype, "recordChange", void 0);
2097
+ ListValueFieldTemplateComponent = __decorate([
2098
+ Component({
2099
+ selector: 'list-value-field-template',
2100
+ template: "<eqp-select *ngIf=\"field.PresentationMode == ListPresentationEnum['Combo box']\" [arrayData]=\"arrayData\"\n [arrayKeyProperty]=\"'Value'\" [showCancelButton]=\"!field.Required\" [arrayValueProperty]=\"'Key'\"\n [formGroupInput]=\"field.FormFormGroup\" [formControlNameInput]=\"field.Name\" [placeholder]=\"field.Label\"\n [includeFullObject]=\"false\" [isRequired]=\"field.Required\" [isDisabled]=\"field.FormFormGroup.disabled\"\n [(ngModelInput)]=\"record[field.Name]\" [isMultiSelect]=\"field.IsMultiChoiche\"\n (ngModelInputChange)=\"onRecordValueChange()\">\n</eqp-select>\n\n<div *ngIf=\"field.PresentationMode != ListPresentationEnum['Combo box']\" [formGroup]=\"field.FormFormGroup\">\n\n <mat-label class=\"mr-3\"> {{field.Label + (field.Required ? \" *\" : \"\")}} </mat-label>\n\n <!-- VISUALIZZAZIONE A RADIO BUTTON (SENZA SELEZIONE MULTIPLA) -->\n <mat-radio-group *ngIf=\"field.PresentationMode == ListPresentationEnum['Radio button'] && !field.IsMultiChoiche\"\n [formControlName]=\"field.Name\" [disabled]=\"field.FormFormGroup.disabled\" [required]=\"field.Required\"\n [(ngModel)]=\"record[field.Name]\" (ngModelChange)=\"onRecordValueChange()\">\n <mat-radio-button class=\"mr-2\" *ngFor=\"let data of arrayData\" [value]=\"data.Value\" color=\"primary\">\n {{data.Key}}\n </mat-radio-button>\n </mat-radio-group>\n\n <!-- VISUALIZZAZIONE A CHECKBOX (SELEZIONE MULTIPLA) -->\n <div class=\"d-inline-block\"\n *ngIf=\"field.PresentationMode == ListPresentationEnum['Radio button'] && field.IsMultiChoiche\">\n <mat-checkbox class=\"mr-2\" *ngFor=\"let data of arrayData\" [disabled]=\"field.FormFormGroup.disabled\"\n [formControlName]=\"field.Name\" [(ngModel)]=\"data.Selected\" (ngModelChange)=\"updateSelected()\">\n {{data.Key}}\n </mat-checkbox>\n </div>\n\n <!-- VISUALIZZAZIONE A PULSANTI (CON TESTO) -->\n <div class=\"d-inline-block\" *ngIf=\"field.PresentationMode == ListPresentationEnum['Pulsante con testo']\">\n <button mat-raised-button color=\"primary\" class=\"btn btn-primary mr-2\" *ngFor=\"let data of arrayData\"\n (click)=\"buttonSelectClick(data)\" [ngClass]=\"getSelectButtonClass(data)\"\n [disabled]=\"field.FormFormGroup.disabled\">\n {{data.Key}}\n </button>\n </div>\n\n <!-- TODO: VISUALIZZAZIONE A PULSANTI (CON IMMAGINI) ?? -->\n</div>",
2101
+ styles: [".selected-button{opacity:.7}.selected-button:disabled{background-color:var(--primary)!important;opacity:.3;color:#fff}"]
2102
+ })
2103
+ ], ListValueFieldTemplateComponent);
2104
+ return ListValueFieldTemplateComponent;
2105
+ }());
2106
+
2107
+ var AttachmentFieldTemplateComponent = /** @class */ (function () {
2108
+ //#endregion
2109
+ function AttachmentFieldTemplateComponent(utilityService, cdr) {
2110
+ this.utilityService = utilityService;
2111
+ this.cdr = cdr;
2112
+ this.onlyImages = false;
2113
+ this.recordChange = new EventEmitter();
2114
+ this.metadataFormGroups = new Array();
2115
+ //#region Etichette per eqp-attachments
2116
+ this.previewLabel = "Anteprima";
2117
+ this.emptyTableMessage = "No record found";
2118
+ this.downloadTooltipPosition = "below";
2119
+ this.openLinkLabel = "Apri link";
2120
+ this.addButtonLabel = "Aggiungi";
2121
+ this.downloadLabel = "Download";
2122
+ this.deleteLabel = "Elimina";
2123
+ this.fileNameLabel = "Nome file";
2124
+ this.uploadFileLabel = "Carica file";
2125
+ this.confirmLabel = "Conferma";
2126
+ this.abortLabel = "Annulla";
2127
+ this.saveLabel = "Salva";
2128
+ this.exitLabel = "Esci";
2129
+ this.eqpTableSearchText = "Cerca...";
2130
+ this.deleteDialogTitle = "Attenzione:";
2131
+ this.deleteDialogMessage = "Sicuro di voler eliminare questo allegato?";
2132
+ this.noImageSelectedErrorMessage = "Nessuna immagine selezionata!";
2133
+ }
2134
+ AttachmentFieldTemplateComponent.prototype.ngOnInit = function () {
2135
+ // Nel caso in cui sono in modifica di un Record aggiorno il valore
2136
+ // e il validator del FormControl. Se non viene eseguita questa riga
2137
+ // l'utente deve modificare la selezione fatta per aggiornare la form.
2138
+ this.setFormControlValue();
2139
+ // Sempre nel caso in cui sono in modifica creo i FormGroup che rappresentano
2140
+ // gli eventuali metadata degli allegati recuperati.
2141
+ this.createMetadataFormGroups();
2142
+ if (this.field.MetadataFields) {
2143
+ this.field.MetadataFields.sort(function (a, b) { return (a.OrdinalPosition > b.OrdinalPosition) ? 1 : ((b.OrdinalPosition > a.OrdinalPosition) ? -1 : 0); });
2144
+ }
2145
+ if (!this.field.AllowedExtensions) {
2146
+ this.field.AllowedExtensions = AvailableFileExtensions.concat(AvailableImageExtensions).map(function (ext) { return ext.key; });
2147
+ }
2148
+ };
2149
+ AttachmentFieldTemplateComponent.prototype.ngAfterViewInit = function () {
2150
+ // Dopo aver renderizzato il DOM, se il campo ammette molteplici allegati
2151
+ // configuro le colonne della eqp-table in eqp-attachments.
2152
+ if (this.field.IsMultiAttach) {
2153
+ this.configureMultiAttachmentColumns();
2154
+ }
2155
+ };
2156
+ AttachmentFieldTemplateComponent.prototype.ngOnChanges = function (changes) {
2157
+ // Se viene modificato il valore di "ngModelInput" allora aggiorna l'input
2158
+ if (changes['record'] != undefined && changes['record'].firstChange == false && JSON.stringify(changes['record'].currentValue) != JSON.stringify(changes['record'].previousValue)) {
2159
+ this.record = changes['record'].currentValue;
2160
+ this.updateField();
2161
+ }
2162
+ };
2163
+ /**
2164
+ * Metodo per aggiornare il valore del campo quando questo è rappresentato da una formula.
2165
+ */
2166
+ AttachmentFieldTemplateComponent.prototype.updateField = function () {
2167
+ if (this.field.Formula) {
2168
+ this.record[this.field.Name] = UtilityHelperService.EvaluateFieldFormula(this.field.Formula, this.record, null);
2169
+ }
2170
+ };
2171
+ /**
2172
+ * Metodo per intercettare le modifiche agli allegati caricati.
2173
+ * Se il campo prevede dei metadata allora per ogni allegato caricato crea un FormGroup
2174
+ * per gestire la validazione degli input che l'utente può/deve riempire. I FormGroup
2175
+ * seguono lo stesso ordine degli allegati caricati.
2176
+ * @param event Contiene la lista aggiornata degli Attachment caricati dall'utente.
2177
+ */
2178
+ AttachmentFieldTemplateComponent.prototype.catchAttachmentList = function (event) {
2179
+ this.record[this.field.Name] = event;
2180
+ this.createMetadataFormGroups();
2181
+ this.setFormControlValue();
2182
+ this.onRecordValueChange();
2183
+ this.cdr.detectChanges();
2184
+ };
2185
+ /**
2186
+ * Metodo per aggiornare lo stato di validazione del FormControl che rappresenta
2187
+ * il campo Allegato (non i metadata al suo interno). Se tra le form dei metadata
2188
+ * ne trova una invalida allora marca il controllo come invalido.
2189
+ */
2190
+ AttachmentFieldTemplateComponent.prototype.updateMetadataValidity = function () {
2191
+ if (this.metadataFormGroups.find(function (form) { return form.invalid; })) {
2192
+ this.field.FormFormGroup.controls[this.field.Name].setErrors({ 'incorrect': true });
2193
+ }
2194
+ else {
2195
+ this.field.FormFormGroup.controls[this.field.Name].setErrors(null);
2196
+ }
2197
+ this.onRecordValueChange();
2198
+ };
2199
+ /**
2200
+ * Metodo per recuperare il BaseField che rappresenta il metadata nella riga della eqp-table
2201
+ * in base alla colonna e alla riga. Una volta trovato il BaseField gli viene associato il
2202
+ * FormGroup di cui fa parte.
2203
+ * @param col Colonna della eqp-table.
2204
+ * @param row Riga della eqp-table (in questo caso eredita da IAttachment).
2205
+ * @returns Restituisce un BaseField per renderizzare il campo nella eqp-table degli allegati multipli.
2206
+ */
2207
+ AttachmentFieldTemplateComponent.prototype.getFieldFromMetadata = function (col, row) {
2208
+ var baseField = JSON.parse(JSON.stringify(this.field.MetadataFields.find(function (metadata) { return metadata.Name === col.key; })));
2209
+ baseField.FormFormGroup = this.metadataFormGroups[this.record[this.field.Name].indexOf(row)];
2210
+ return baseField;
2211
+ };
2212
+ /**
2213
+ * Metodo per aggiornare il valore e il validator del FormControl associato al campo.
2214
+ */
2215
+ AttachmentFieldTemplateComponent.prototype.setFormControlValue = function () {
2216
+ this.field.FormFormGroup.controls[this.field.Name].setValue(this.record[this.field.Name]);
2217
+ };
2218
+ /**
2219
+ * Metodo per emettere l'evento che il valore del record è cambiato.
2220
+ */
2221
+ AttachmentFieldTemplateComponent.prototype.onRecordValueChange = function () {
2222
+ if (!this.field.Formula) {
2223
+ this.recordChange.emit(this.record);
2224
+ }
2225
+ };
2226
+ /**
2227
+ * Metodo per aggiungere alle colonne di eqp-attachments le colonne per modificare i metadata
2228
+ * configurati per il campo Allegato o Immagine.
2229
+ */
2230
+ AttachmentFieldTemplateComponent.prototype.configureMultiAttachmentColumns = function () {
2231
+ var _this = this;
2232
+ if (this.eqpAttachments && this.eqpAttachments.attachmentsColumns && this.field.MetadataFields && this.field.MetadataFields.length > 0) {
2233
+ this.field.MetadataFields.forEach(function (metadata) {
2234
+ _this.eqpAttachments.attachmentsColumns.splice(_this.eqpAttachments.attachmentsColumns.length - 1, 0, { key: metadata.Name, display: metadata.Label, type: TypeColumn.ExternalTemplate, externalTemplate: _this.metadataColumnTemplate });
2235
+ });
2236
+ }
2237
+ };
2238
+ /**
2239
+ * Metodo per creare i FormGroup che rappresentano i metadata degli allegati caricati.
2240
+ */
2241
+ AttachmentFieldTemplateComponent.prototype.createMetadataFormGroups = function () {
2242
+ var _this = this;
2243
+ if (this.field.MetadataFields && this.field.MetadataFields.length > 0) {
2244
+ this.metadataFormGroups = [];
2245
+ if (this.record[this.field.Name] && this.record[this.field.Name].length > 0) {
2246
+ this.record[this.field.Name].forEach(function (attachment) {
2247
+ _this.metadataFormGroups.push(_this.utilityService.CreateFormFormGroup(_this.field.MetadataFields, attachment, _this.field.FormFormGroup.disabled, !_this.field.IsMultiAttach));
2248
+ });
2249
+ }
2250
+ this.updateMetadataValidity();
2251
+ }
2252
+ };
2253
+ AttachmentFieldTemplateComponent.ctorParameters = function () { return [
2254
+ { type: UtilityHelperService },
2255
+ { type: ChangeDetectorRef }
2256
+ ]; };
2257
+ __decorate([
2258
+ Input()
2259
+ ], AttachmentFieldTemplateComponent.prototype, "onlyImages", void 0);
2260
+ __decorate([
2261
+ Input()
2262
+ ], AttachmentFieldTemplateComponent.prototype, "field", void 0);
2263
+ __decorate([
2264
+ Input()
2265
+ ], AttachmentFieldTemplateComponent.prototype, "record", void 0);
2266
+ __decorate([
2267
+ Output()
2268
+ ], AttachmentFieldTemplateComponent.prototype, "recordChange", void 0);
2269
+ __decorate([
2270
+ ViewChild("eqpAttachments", { static: true })
2271
+ ], AttachmentFieldTemplateComponent.prototype, "eqpAttachments", void 0);
2272
+ __decorate([
2273
+ ViewChild('metadataColumnTemplate', { static: true })
2274
+ ], AttachmentFieldTemplateComponent.prototype, "metadataColumnTemplate", void 0);
2275
+ AttachmentFieldTemplateComponent = __decorate([
2276
+ Component({
2277
+ selector: 'attachment-field-template',
2278
+ template: "<p *ngIf=\"!field.IsMultiAttach\" class=\"mb-2\">\n {{field.Label + (field.Required ? \" *\" : \"\")}}\n</p>\n<div class=\"row\" *ngIf=\"!field.IsMultiAttach && record[field.Name] && record[field.Name][0]\">\n <div class=\"mt-2\" *ngFor=\"let metadata of field.MetadataFields\" [ngClass]=\"utilityService.getFieldSyleClass(metadata)\">\n <dynamic-module-field [field]=\"metadata\" [record]=\"record[field.Name][0]\"\n (recordChange)=\"updateMetadataValidity()\">\n </dynamic-module-field>\n </div>\n</div>\n\n\n\n<eqp-attachments [attachmentsList]=\"record[field.Name]\" [showMatCard]=\"true\" [allowOnlyImages]=\"onlyImages\"\n [isDisabled]=\"field.FormFormGroup.disabled\" [showInlinePreview]=\"true\" [multipleAttachment]=\"field.IsMultiAttach\"\n [disableAction]=\"field.FormFormGroup.disabled\" [acceptedFileTypes]=\"field.AllowedExtensions\" [showHeader]=\"true\"\n [headerTitle]=\"field.Label + (field.Required ? ' *' : '')\" [previewLabel]=\"previewLabel\"\n [emptyTableMessage]=\"emptyTableMessage\" [downloadTooltipPosition]=\"downloadTooltipPosition\"\n [openLinkLabel]=\"openLinkLabel\" [addButtonLabel]=\"addButtonLabel\" [downloadLabel]=\"downloadLabel\"\n [deleteLabel]=\"deleteLabel\" [fileNameLabel]=\"fileNameLabel\" [uploadFileLabel]=\"uploadFileLabel\"\n [confirmLabel]=\"confirmLabel\" [abortLabel]=\"abortLabel\" [saveLabel]=\"saveLabel\" [exitLabel]=\"exitLabel\"\n [eqpTableSearchText]=\"eqpTableSearchText\" [deleteDialogTitle]=\"deleteDialogTitle\"\n [deleteDialogMessage]=\"deleteDialogMessage\" [noImageSelectedErrorMessage]=\"noImageSelectedErrorMessage\"\n (localEditedAttachments)=\"catchAttachmentList($event)\" #eqpAttachments>\n</eqp-attachments>\n\n<!-- TEMPLATE PER VISUALIZZARE LA COLONNA DELLA SEZIONE NELLA TABELLA DEI FIELDS -->\n<ng-template #metadataColumnTemplate let-row=\"row\" let-col=\"col\">\n <dynamic-module-field [field]=\"getFieldFromMetadata(col, row)\" [record]=\"row\"\n (recordChange)=\"updateMetadataValidity()\">\n </dynamic-module-field>\n</ng-template>",
2279
+ styles: [""]
2280
+ })
2281
+ ], AttachmentFieldTemplateComponent);
2282
+ return AttachmentFieldTemplateComponent;
2283
+ }());
2284
+
2285
+ var ImageFieldTemplateComponent = /** @class */ (function () {
2286
+ function ImageFieldTemplateComponent() {
2287
+ this.recordChange = new EventEmitter();
2288
+ }
2289
+ ImageFieldTemplateComponent.prototype.ngOnInit = function () {
2290
+ this.field.AttachDefinition.FormFormGroup = this.field.FormFormGroup;
2291
+ if (!this.field.AttachDefinition.AllowedExtensions) {
2292
+ this.field.AttachDefinition.AllowedExtensions = AvailableImageExtensions.map(function (ext) { return ext.key; });
2293
+ }
2294
+ this.field.AttachDefinition.Name = this.field.Name;
2295
+ this.field.AttachDefinition.Label = this.field.Label;
2296
+ this.field.AttachDefinition.Description = this.field.Description;
2297
+ this.field.AttachDefinition.Required = this.field.Required;
2298
+ this.field.AttachDefinition.Formula = this.field.Formula;
2299
+ this.field.AttachDefinition.FieldValue = this.field.FieldValue;
2300
+ };
2301
+ ImageFieldTemplateComponent.prototype.ngOnChanges = function (changes) {
2302
+ // Se viene modificato il valore di "ngModelInput" allora aggiorna l'input
2303
+ if (changes['record'] != undefined && changes['record'].firstChange == false && JSON.stringify(changes['record'].currentValue) != JSON.stringify(changes['record'].previousValue)) {
2304
+ this.record = changes['record'].currentValue;
2305
+ this.updateField();
2306
+ }
2307
+ };
2308
+ /**
2309
+ * Metodo per aggiornare il valore del campo quando questo è rappresentato da una formula.
2310
+ */
2311
+ ImageFieldTemplateComponent.prototype.updateField = function () {
2312
+ if (this.field.Formula) {
2313
+ this.record[this.field.Name] = UtilityHelperService$1.EvaluateFieldFormula(this.field.Formula, this.record, null);
2314
+ }
2315
+ };
2316
+ __decorate([
2317
+ Input()
2318
+ ], ImageFieldTemplateComponent.prototype, "record", void 0);
2319
+ __decorate([
2320
+ Input()
2321
+ ], ImageFieldTemplateComponent.prototype, "field", void 0);
2322
+ __decorate([
2323
+ Output()
2324
+ ], ImageFieldTemplateComponent.prototype, "recordChange", void 0);
2325
+ ImageFieldTemplateComponent = __decorate([
2326
+ Component({
2327
+ selector: 'image-field-template',
2328
+ template: "<attachment-field-template [(record)]=\"record\" [field]=\"field.AttachDefinition\"\n [onlyImages]=\"true\">\n</attachment-field-template>",
2329
+ styles: [""]
2330
+ })
2331
+ ], ImageFieldTemplateComponent);
2332
+ return ImageFieldTemplateComponent;
2333
+ }());
2334
+
2335
+ var ListFormRecordComponent = /** @class */ (function () {
2336
+ function ListFormRecordComponent() {
2337
+ this.columns = new Array();
2338
+ this.onAddViewEditRecord = new EventEmitter();
2339
+ }
2340
+ ListFormRecordComponent.prototype.ngOnInit = function () {
2341
+ this.configureColumns();
2342
+ };
2343
+ /**
2344
+ * Metodo per configurare le colonne della eqp-table.
2345
+ */
2346
+ ListFormRecordComponent.prototype.configureColumns = function () {
2347
+ var _this = this;
2348
+ this.columns = [
2349
+ {
2350
+ key: "action", display: "",
2351
+ type: TypeColumn.MenuAction, buttonMenuIcon: "more_vert", styles: { flex: "0 0 6%" },
2352
+ actions: [
2353
+ { name: "Visualizza", icon: "info", fn: function (element, index, col) { return _this.viewOrEditRecord(element, true); } },
2354
+ { name: "Modifica", icon: "edit", fn: function (element, index, col) { return _this.viewOrEditRecord(element, false); } },
2355
+ { name: "Duplica", icon: "file_copy", fn: function (element, index, col) { return _this.duplicateRecord(element); } },
2356
+ { name: "Elimina", icon: "delete", fn: function (element, index, col) { return _this.deleteRecord(element); } },
2357
+ ],
2358
+ },
2359
+ ];
2360
+ this.createAdditionalActions();
2361
+ this.createColumnsFromFormFields();
2362
+ };
2363
+ /**
2364
+ * Metodo per aggiungere nella colonna "action" della eqp-table le azioni sui record
2365
+ * definite dall'utente all'interno della Form.
2366
+ */
2367
+ ListFormRecordComponent.prototype.createAdditionalActions = function () {
2368
+ var _this = this;
2369
+ if (this.form.ActionsOnRecord && this.form.ActionsOnRecord.length > 0) {
2370
+ this.form.ActionsOnRecord
2371
+ .sort(function (a, b) { return (a.OrdinalPosition > b.OrdinalPosition) ? 1 : ((b.OrdinalPosition > a.OrdinalPosition) ? -1 : 0); })
2372
+ .forEach(function (action) {
2373
+ _this.columns.find(function (c) { return c.key === 'action'; })
2374
+ .actions
2375
+ .push({
2376
+ name: action.Name, icon: action.Icon, fn: function (element, index, col) {
2377
+ var rec = element;
2378
+ var ctx = UtilityHelperService$2.context;
2379
+ eval(action.Action);
2380
+ // TODO: salvare le modifiche
2381
+ }
2382
+ });
2383
+ });
2384
+ }
2385
+ };
2386
+ /**
2387
+ * Metodo che scatena l'evento di Output per mostrare o modificare il record
2388
+ * selezionato sulla eqp-table.
2389
+ * @param record Record da visualizzare o modificare selezionato sulla eqp-table.
2390
+ * @param onlyView Se TRUE viene mostrato il componente add-form-record in sola lettura.
2391
+ */
2392
+ ListFormRecordComponent.prototype.viewOrEditRecord = function (record, onlyView) {
2393
+ this.onAddViewEditRecord.emit({ record: record, onlyView: onlyView });
2394
+ };
2395
+ /**
2396
+ * Metodo per duplicare un record della form.
2397
+ * @param record Record da duplicare.
2398
+ */
2399
+ ListFormRecordComponent.prototype.duplicateRecord = function (record) {
2400
+ var _this = this;
2401
+ EqpDynamicModuleDialogService$1.Confirm('Duplicare il record selezionato?', function () {
2402
+ var copiedRecord = JSON.parse(JSON.stringify(record));
2403
+ if (!isNaN(parseInt(copiedRecord.ID))) {
2404
+ copiedRecord.ID = (parseInt(copiedRecord.ID) + 1).toString();
2405
+ }
2406
+ else {
2407
+ copiedRecord.ID = "xxxxxxxxx".replace("x", function (c) { return (Math.random() + 16 | 0).toString(16); });
2408
+ }
2409
+ _this.values.push(copiedRecord);
2410
+ _this.reloadTables();
2411
+ }, false, 'Richiesta conferma');
2412
+ //TODO
2413
+ };
2414
+ /**
2415
+ * Metodo per eliminare un record dalla lista.
2416
+ * @param record Record da eliminare selezionato sulla eqp-table.
2417
+ */
2418
+ ListFormRecordComponent.prototype.deleteRecord = function (record) {
2419
+ var _this = this;
2420
+ EqpDynamicModuleDialogService$1.Confirm('Eliminare il record selezionato?', function () {
2421
+ _this.values.splice(_this.values.indexOf(record), 1);
2422
+ _this.reloadTables();
2423
+ }, false, 'Richiesta conferma');
2424
+ // TODO
2425
+ };
2426
+ /**
2427
+ * Metodo per creare la configurazione delle colonne per la eqp-table.
2428
+ * Individua i BaseField da mostrare e li usa per creare le ConfigColumn.
2429
+ * Le colonne vengono create per i BaseField con il flag InListView a TRUE
2430
+ * oppure, nel caso non siano stati specificati i campi da visualizzare,
2431
+ * seleziona i primi 6.
2432
+ */
2433
+ ListFormRecordComponent.prototype.createColumnsFromFormFields = function () {
2434
+ var _this = this;
2435
+ var fieldsForColumns;
2436
+ if (this.form.Fields.find(function (f) { return f.InListView; })) {
2437
+ fieldsForColumns = this.form.Fields.filter(function (f) { return f.InListView; });
2438
+ }
2439
+ else {
2440
+ fieldsForColumns = this.form.Fields.filter(function (f) { return f.OrdinalPosition < 6; });
2441
+ }
2442
+ fieldsForColumns.sort(function (a, b) { return (a.OrdinalPosition > b.OrdinalPosition) ? 1 : ((b.OrdinalPosition > a.OrdinalPosition) ? -1 : 0); })
2443
+ .forEach(function (field) {
2444
+ _this.columns.push(_this.createFieldColumn(field));
2445
+ });
2446
+ };
2447
+ /**
2448
+ * Metodo per creare l'oggetto ConfigureColumn che rappresenta il BaseField passato in input.
2449
+ * @param field BaseField per cui creare la colonna nella eqp-table
2450
+ * @returns Restituisce una ConfigColumn per la eqp-table
2451
+ */
2452
+ ListFormRecordComponent.prototype.createFieldColumn = function (field) {
2453
+ var column = { key: field.Name, display: field.Label };
2454
+ switch (field.FieldType) {
2455
+ case FieldTypeEnum$1['Booleano']:
2456
+ column.type = TypeColumn.Boolean;
2457
+ column.booleanValues = { false: '<i class="fa fa-times error-color"></i>', true: '<i class="fa fa-check success-color"></i>' };
2458
+ column.styles = { flex: "0 0 7%", cellAlignment: CellAlignmentEnum.CENTER };
2459
+ break;
2460
+ case FieldTypeEnum$1['Data e/o ora']:
2461
+ if (field.IsOnlyDate != DateTimeTypeEnum$1['Solo orario']) {
2462
+ column.type = TypeColumn.Date;
2463
+ if (field.IsOnlyDate == DateTimeTypeEnum$1['Data e ora']) {
2464
+ column.format = "dd/MM/yyyy HH:mm";
2465
+ }
2466
+ else if (field.IsOnlyDate == DateTimeTypeEnum$1['Solo data']) {
2467
+ column.format = "dd/MM/yyyy";
2468
+ }
2469
+ }
2470
+ break;
2471
+ case FieldTypeEnum$1['Campo numerico']:
2472
+ if (field.CurrencySymbol) {
2473
+ column.numberPipe = NumberColumnPipe.CURRENCY;
2474
+ column.currencyPipeCode = field.CurrencySymbol;
2475
+ }
2476
+ else if (!field.IsInteger) {
2477
+ column.numberPipe = NumberColumnPipe.DECIMAL;
2478
+ }
2479
+ break;
2480
+ case FieldTypeEnum$1['Allegato']:
2481
+ case FieldTypeEnum$1['Immagine']:
2482
+ column.value = function (element) {
2483
+ if (field.IsMultiAttach || (field.AttachDefinition && field.AttachDefinition.IsMultiAttach)) {
2484
+ return element[field.Name] != null && element[field.Name].length > 0 ? element[field.Name].map(function (a) { return a.FileName; }).join(", ") : null;
2485
+ }
2486
+ else {
2487
+ return element[field.Name] != null && element[field.Name].length > 0 ? element[field.Name][0].FileName : null;
2488
+ }
2489
+ };
2490
+ column.isSortable = false;
2491
+ column.isSearchable = false;
2492
+ break;
2493
+ case FieldTypeEnum$1['Elenco generico']:
2494
+ column.value = function (element) {
2495
+ if (field.IsMultiChoiche) {
2496
+ if (!element[field.Name] || element[field.Name].length == 0) {
2497
+ return null;
2498
+ }
2499
+ else {
2500
+ return Object.keys(field.ValuePairs).filter(function (k) { return element[field.Name].includes(field.ValuePairs[k]); }).join(", ");
2501
+ }
2502
+ }
2503
+ else {
2504
+ return Object.keys(field.ValuePairs).find(function (k) { return field.ValuePairs[k] == element[field.Name]; });
2505
+ }
2506
+ };
2507
+ column.isSortable = false;
2508
+ column.isSearchable = false;
2509
+ break;
2510
+ case FieldTypeEnum$1['Lookup']:
2511
+ // TODO
2512
+ break;
2513
+ }
2514
+ return column;
2515
+ };
2516
+ /**
2517
+ * Metodo per ricaricare i dati della eqp-table.
2518
+ */
2519
+ ListFormRecordComponent.prototype.reloadTables = function () {
2520
+ if (this.tableRecords) {
2521
+ this.tableRecords.reloadDatatable();
2522
+ }
2523
+ };
2524
+ __decorate([
2525
+ Input()
2526
+ ], ListFormRecordComponent.prototype, "form", void 0);
2527
+ __decorate([
2528
+ Input()
2529
+ ], ListFormRecordComponent.prototype, "values", void 0);
2530
+ __decorate([
2531
+ ViewChild('tableRecords', { static: true })
2532
+ ], ListFormRecordComponent.prototype, "tableRecords", void 0);
2533
+ __decorate([
2534
+ Output()
2535
+ ], ListFormRecordComponent.prototype, "onAddViewEditRecord", void 0);
2536
+ ListFormRecordComponent = __decorate([
2537
+ Component({
2538
+ selector: 'list-form-record',
2539
+ template: "<div class=\"row eqp-dynamic-module-title\">\r\n <div class=\"col-md-6\">\r\n <h4><b>Elenco {{form.Name}}</b></h4>\r\n </div>\r\n <div class=\"col-md-6 text-right\">\r\n <button class=\"btn btn-primary\" mat-raised-button color=\"primary\" type=\"button\" (click)=\"onAddViewEditRecord.emit(null)\">\r\n <mat-icon>add</mat-icon>\r\n <span style=\"margin-left: 10px;\">Aggiungi</span>\r\n </button>\r\n </div>\r\n</div>\r\n\r\n\r\n<eqp-table #tableRecords [data]=\"values\" [columns]=\"columns\"></eqp-table>",
2540
+ styles: ["::ng-deep .error-color{color:var(--danger)}::ng-deep .success-color{color:var(--success)}"]
2541
+ })
2542
+ ], ListFormRecordComponent);
2543
+ return ListFormRecordComponent;
2544
+ }());
2545
+
2546
+ var Record = /** @class */ (function () {
2547
+ function Record() {
2548
+ }
2549
+ return Record;
2550
+ }());
2551
+
2552
+ var AddFormRecordComponent = /** @class */ (function () {
2553
+ function AddFormRecordComponent(cdr, utilityService) {
2554
+ this.cdr = cdr;
2555
+ this.utilityService = utilityService;
2556
+ this.showButtons = true;
2557
+ this.form = new Form();
2558
+ this.fieldGroups = {};
2559
+ this.FormScalarTypeEnum = FormScalarTypeEnum;
2560
+ this.FieldTypeEnum = FieldTypeEnum;
2561
+ this.saveRecordEvent = new EventEmitter();
2562
+ }
2563
+ AddFormRecordComponent.prototype.ngOnInit = function () {
2564
+ if (this.record == null) {
2565
+ this.record = new Record();
2566
+ }
2567
+ this.createRecordProperties();
2568
+ this.reorderFormFields();
2569
+ this.createFormGroup();
2570
+ if (this.form.FormScalarType != FormScalarTypeEnum.Semplice) {
2571
+ this.createFieldGroups();
2572
+ }
2573
+ this.cdr.detectChanges();
2574
+ };
2575
+ /**
2576
+ * Metodo invocato al cambio del valore di ogni proprietà dell'oggetto record.
2577
+ * Serve ad aggiornare il valore di tutti i campi che hanno una formula.
2578
+ */
2579
+ AddFormRecordComponent.prototype.onRecordChange = function () {
2580
+ if (this.fieldTemplate && this.fieldTemplate.length > 0) {
2581
+ this.fieldTemplate.forEach(function (f) { return f.updateField(); });
2582
+ }
2583
+ };
2584
+ /**
2585
+ * Metodo per salvare i dati inseriti dall'utente una volta conclusa la compilazione della form.
2586
+ */
2587
+ AddFormRecordComponent.prototype.saveOrExitForm = function (exit) {
2588
+ if (exit) {
2589
+ this.saveRecordEvent.emit(null);
2590
+ }
2591
+ else {
2592
+ this.saveRecordEvent.emit(this.record);
2593
+ }
2594
+ };
2595
+ /**
2596
+ * Metodo per creare nell'oggetto Record le proprietà mancanti rispetto ai campi che compongono la form.
2597
+ */
2598
+ AddFormRecordComponent.prototype.createRecordProperties = function () {
2599
+ var _this = this;
2600
+ var recordProperties = Object.keys(this.record);
2601
+ this.form.Fields.forEach(function (field) {
2602
+ if (!recordProperties.find(function (p) { return p === field.Name; })) {
2603
+ _this.record[field.Name] = null;
2604
+ }
2605
+ });
2606
+ if (this.form.InnerForms && this.form.InnerForms.length > 0) {
2607
+ this.form.InnerForms.forEach(function (form) {
2608
+ var arrayName = form.Name.split(" ").join("_");
2609
+ if (!recordProperties.find(function (p) { return p === arrayName; })) {
2610
+ _this.record[arrayName] = [];
2611
+ }
2612
+ });
2613
+ }
2614
+ };
2615
+ /**
2616
+ * Metodo per riordinare i campi che compongono la form.
2617
+ */
2618
+ AddFormRecordComponent.prototype.reorderFormFields = function () {
2619
+ if (this.form.Fields && this.form.Fields.length > 0) {
2620
+ this.form.Fields.sort(function (a, b) { return (a.OrdinalPosition > b.OrdinalPosition) ? 1 : ((b.OrdinalPosition > a.OrdinalPosition) ? -1 : 0); });
2621
+ }
2622
+ };
2623
+ /**
2624
+ * Metodo per creare il FormGroup che rappresenta la form.
2625
+ */
2626
+ AddFormRecordComponent.prototype.createFormGroup = function () {
2627
+ this.formForm = this.utilityService.CreateFormFormGroup(this.form.Fields, this.record, this.onlyView);
2628
+ };
2629
+ /**
2630
+ * Metodo per creare i gruppi in cui raggruppare i campi della form in base
2631
+ * a come è stata configurata dall'utente.
2632
+ */
2633
+ AddFormRecordComponent.prototype.createFieldGroups = function () {
2634
+ var _this = this;
2635
+ this.form.FormFieldsGroups
2636
+ .sort(function (a, b) { return (a.OrdinalPosition > b.OrdinalPosition) ? 1 : ((b.OrdinalPosition > a.OrdinalPosition) ? -1 : 0); })
2637
+ .map(function (g) { return g.Name; })
2638
+ .forEach(function (groupName) {
2639
+ _this.fieldGroups[groupName] = _this.form.Fields.filter(function (f) { return f.FieldGroup == groupName; });
2640
+ });
2641
+ };
2642
+ AddFormRecordComponent.ctorParameters = function () { return [
2643
+ { type: ChangeDetectorRef },
2644
+ { type: UtilityHelperService$2 }
2645
+ ]; };
2646
+ __decorate([
2647
+ Input()
2648
+ ], AddFormRecordComponent.prototype, "showButtons", void 0);
2649
+ __decorate([
2650
+ Input()
2651
+ ], AddFormRecordComponent.prototype, "form", void 0);
2652
+ __decorate([
2653
+ Input()
2654
+ ], AddFormRecordComponent.prototype, "record", void 0);
2655
+ __decorate([
2656
+ Input()
2657
+ ], AddFormRecordComponent.prototype, "onlyView", void 0);
2658
+ __decorate([
2659
+ Output()
2660
+ ], AddFormRecordComponent.prototype, "saveRecordEvent", void 0);
2661
+ __decorate([
2662
+ ViewChildren("fieldTemplate")
2663
+ ], AddFormRecordComponent.prototype, "fieldTemplate", void 0);
2664
+ AddFormRecordComponent = __decorate([
2665
+ Component({
2666
+ selector: 'add-form-record',
2667
+ template: "<div class=\"row eqp-dynamic-module-title\">\n <div class=\"col-md-12 text-center\">\n <h4><b>{{form.Name}}</b></h4>\n </div>\n</div>\n\n<form [formGroup]=\"formForm\">\n\n <!-- VISUALIZZAZIONE SEMPLICE -->\n <ng-container *ngIf=\"form.FormScalarType == FormScalarTypeEnum.Semplice\" [ngTemplateOutlet]=\"fieldTemplates\"\n [ngTemplateOutletContext]=\"{ fields: form.Fields }\">\n </ng-container>\n\n <!-- VISUALIZZAZIONE A STEPPER -->\n <mat-horizontal-stepper linear *ngIf=\"form.FormScalarType == FormScalarTypeEnum['A step']\">\n <mat-step *ngFor=\"let group of form.FormFieldsGroups\">\n <ng-template matStepLabel>\n {{group.Name}}\n </ng-template>\n\n <ng-container [ngTemplateOutlet]=\"fieldTemplates\"\n [ngTemplateOutletContext]=\"{ fields: fieldGroups[group.Name] }\">\n </ng-container>\n </mat-step>\n </mat-horizontal-stepper>\n\n <!-- VISUALIZZAZIONE A TAB -->\n <mat-tab-group *ngIf=\"form.FormScalarType == FormScalarTypeEnum['In tab']\">\n <mat-tab *ngFor=\"let group of form.FormFieldsGroups\" [label]=\"group.Name\">\n <div class=\"mt-3\">\n <ng-container [ngTemplateOutlet]=\"fieldTemplates\"\n [ngTemplateOutletContext]=\"{ fields: fieldGroups[group.Name] }\">\n </ng-container>\n </div>\n </mat-tab>\n </mat-tab-group>\n\n <!-- VISUALIZZAZIONE AD ACCORDION -->\n <mat-accordion multi *ngIf=\"form.FormScalarType == FormScalarTypeEnum['In accordion']\">\n <mat-expansion-panel *ngFor=\"let group of form.FormFieldsGroups\">\n <mat-expansion-panel-header>\n <mat-panel-title>\n {{group.Name}}\n </mat-panel-title>\n </mat-expansion-panel-header>\n\n <ng-container [ngTemplateOutlet]=\"fieldTemplates\"\n [ngTemplateOutletContext]=\"{ fields: fieldGroups[group.Name] }\">\n </ng-container>\n </mat-expansion-panel>\n </mat-accordion>\n</form>\n\n<div class=\"row mt-2\" *ngIf=\"showButtons\">\n <div class=\"col-sm-12 text-right\">\n <button class=\"mr-2\" mat-raised-button (click)=\"saveOrExitForm(true)\" type=\"button\">\n Annulla\n </button>\n <button class=\"mr-2\" mat-raised-button color=\"primary\" (click)=\"saveOrExitForm(false)\"\n [disabled]=\"formForm.invalid || formForm.disabled\" type=\"button\">\n Salva\n </button>\n </div>\n</div>\n\n<!-- TEMPLATE PER LA VISUALIZZAZIONE DEI CAMPI DELLA FORM -->\n<ng-template #fieldTemplates let-fields='fields'>\n <div class=\"row\">\n <div class=\"mt-2\" *ngFor=\"let field of fields\" [ngClass]=\"utilityService.getFieldSyleClass(field)\">\n <dynamic-module-field #fieldTemplate [field]=\"field\" [form]=\"form\" [record]=\"record\" (recordChange)=\"onRecordChange()\"></dynamic-module-field>\n </div>\n </div>\n</ng-template>",
2668
+ styles: [""]
2669
+ })
2670
+ ], AddFormRecordComponent);
2671
+ return AddFormRecordComponent;
2672
+ }());
2673
+
2674
+ var DynamicModuleFieldComponent = /** @class */ (function () {
2675
+ function DynamicModuleFieldComponent(dialog) {
2676
+ this.dialog = dialog;
2677
+ this.recordChange = new EventEmitter();
2678
+ this.FieldTypeEnum = FieldTypeEnum;
2679
+ this.onlyViewInnerFormRecord = false;
2680
+ }
2681
+ DynamicModuleFieldComponent.prototype.updateField = function () {
2682
+ if (this.fieldTemplate && this.fieldTemplate.length > 0) {
2683
+ this.fieldTemplate.forEach(function (f) { return f.updateField(); });
2684
+ }
2685
+ };
2686
+ DynamicModuleFieldComponent.prototype.ngOnInit = function () {
2687
+ };
2688
+ /**
2689
+ * Metodo invocato al cambio del valore di ogni proprietà dell'oggetto record.
2690
+ * Serve ad aggiornare il valore di tutti i campi che hanno una formula.
2691
+ */
2692
+ DynamicModuleFieldComponent.prototype.onRecordChange = function () {
2693
+ this.recordChange.emit(this.record);
2694
+ };
2695
+ /**
2696
+ * Metodo per recuperare una InnerForm a partire dal Field che la rappresenta.
2697
+ * @param field Campo a partire dal quale si vuole recuperare la InnerForm.
2698
+ * @returns Restituisce un oggetto di tipo Form.
2699
+ */
2700
+ DynamicModuleFieldComponent.prototype.getInnerFormFromField = function (field) {
2701
+ if (this.form.InnerForms && this.form.InnerForms.find(function (f) { return f.Name == field.Label; })) {
2702
+ return this.form.InnerForms.find(function (f) { return f.Name == field.Label; });
2703
+ }
2704
+ else {
2705
+ return null;
2706
+ }
2707
+ };
2708
+ /**
2709
+ * Metodo per aprire un dialog in cui aggiungere/modificare/visualizzare un record appartenente
2710
+ * a una form di dettaglio.
2711
+ * @param record Evento di output del componente list-form-record, contiene il record selezionato e un booleno che indica
2712
+ * se l'utente vuole modificare o visualizzare l'elemento selezionato.
2713
+ * @param innerForm Contiene la Form di dettaglio dalla quale è stato richiesto il record.
2714
+ */
2715
+ DynamicModuleFieldComponent.prototype.onAddViewEditInnerFormRecord = function (record, field) {
2716
+ this.selectedInnerForm = this.getInnerFormFromField(field);
2717
+ if (record == null) {
2718
+ this.selectedInnerFormRecord = new Record();
2719
+ this.indexInnerFormRecord = null;
2720
+ this.onlyViewInnerFormRecord = false;
2721
+ }
2722
+ else {
2723
+ this.selectedInnerFormRecord = JSON.parse(JSON.stringify(record.record));
2724
+ this.indexInnerFormRecord = this.record[field.Name].indexOf(record);
2725
+ this.onlyViewInnerFormRecord = record.onlyView;
2726
+ }
2727
+ this.dialogInnerFormRecordRef = this.dialog.open(this.dialogInnerFormRecord, {
2728
+ disableClose: true,
2729
+ hasBackdrop: true,
2730
+ width: '75%'
2731
+ });
2732
+ };
2733
+ /**
2734
+ * Metodo invocato al salvataggio o alla chiusura del dialog di aggiunta/modifica/visualizzazione
2735
+ * di un record di una form di dettaglio.
2736
+ * @param record Oggetto restituito dal componente add-form-field (questo qui) contenente il Record
2737
+ * aggiornato dall'utente. Se null allora l'utente non ha modificato nulla e ha chiuso il dialog.
2738
+ */
2739
+ DynamicModuleFieldComponent.prototype.onSaveInnerFormRecord = function (record) {
2740
+ if (record != null) {
2741
+ var arrayName = this.selectedInnerForm.Name.split(' ').join('_');
2742
+ if (this.indexInnerFormRecord != null && this.indexInnerFormRecord >= 0) {
2743
+ this.record[arrayName][this.indexInnerFormRecord] = record;
2744
+ }
2745
+ else {
2746
+ if (!this.record[arrayName]) {
2747
+ this.record[arrayName] = [];
2748
+ }
2749
+ this.record[arrayName].push(record);
2750
+ }
2751
+ }
2752
+ this.dialogInnerFormRecordRef.close();
2753
+ // Ricarico la tabella dei record per visualizzare le modifiche fatte dall'utente.
2754
+ if (this.listInnerFormRecords && this.listInnerFormRecords.length > 0) {
2755
+ this.listInnerFormRecords.forEach(function (list) {
2756
+ if (list && list.tableRecords) {
2757
+ list.tableRecords.reloadDatatable();
2758
+ }
2759
+ });
2760
+ }
2761
+ };
2762
+ DynamicModuleFieldComponent.ctorParameters = function () { return [
2763
+ { type: MatDialog }
2764
+ ]; };
2765
+ __decorate([
2766
+ Input()
2767
+ ], DynamicModuleFieldComponent.prototype, "field", void 0);
2768
+ __decorate([
2769
+ Input()
2770
+ ], DynamicModuleFieldComponent.prototype, "form", void 0);
2771
+ __decorate([
2772
+ Input()
2773
+ ], DynamicModuleFieldComponent.prototype, "record", void 0);
2774
+ __decorate([
2775
+ Output()
2776
+ ], DynamicModuleFieldComponent.prototype, "recordChange", void 0);
2777
+ __decorate([
2778
+ ViewChild('dialogInnerFormRecord', { static: true })
2779
+ ], DynamicModuleFieldComponent.prototype, "dialogInnerFormRecord", void 0);
2780
+ __decorate([
2781
+ ViewChildren("fieldTemplate")
2782
+ ], DynamicModuleFieldComponent.prototype, "fieldTemplate", void 0);
2783
+ __decorate([
2784
+ ViewChildren('listInnerFormRecords')
2785
+ ], DynamicModuleFieldComponent.prototype, "listInnerFormRecords", void 0);
2786
+ DynamicModuleFieldComponent = __decorate([
2787
+ Component({
2788
+ selector: 'dynamic-module-field',
2789
+ template: "<text-field-template #fieldTemplate *ngIf=\"field.FieldType == FieldTypeEnum['Campo di testo']\"\n [matTooltip]=\"field.Description\" [(record)]=\"record\" [field]=\"field\" (recordChange)=\"onRecordChange()\">\n</text-field-template>\n\n<textarea-field-template #fieldTemplate *ngIf=\"field.FieldType == FieldTypeEnum['Area di testo']\"\n [matTooltip]=\"field.Description\" [(record)]=\"record\" [field]=\"field\" (recordChange)=\"onRecordChange()\">\n</textarea-field-template>\n\n<boolean-field-template #fieldTemplate *ngIf=\"field.FieldType == FieldTypeEnum['Booleano']\"\n [matTooltip]=\"field.Description\" [(record)]=\"record\" [field]=\"field\" (recordChange)=\"onRecordChange()\">\n</boolean-field-template>\n\n<date-field-template #fieldTemplate *ngIf=\"field.FieldType == FieldTypeEnum['Data e/o ora']\"\n [matTooltip]=\"field.Description\" [(record)]=\"record\" [field]=\"field\" (recordChange)=\"onRecordChange()\">\n</date-field-template>\n\n<numeric-field-template #fieldTemplate *ngIf=\"field.FieldType == FieldTypeEnum['Campo numerico']\"\n [matTooltip]=\"field.Description\" [(record)]=\"record\" [field]=\"field\" (recordChange)=\"onRecordChange()\">\n</numeric-field-template>\n\n<list-value-field-template #fieldTemplate *ngIf=\"field.FieldType == FieldTypeEnum['Elenco generico']\"\n [matTooltip]=\"field.Description\" [(record)]=\"record\" [field]=\"field\" (recordChange)=\"onRecordChange()\">\n</list-value-field-template>\n\n<attachment-field-template #fieldTemplate *ngIf=\"field.FieldType == FieldTypeEnum['Allegato']\"\n [matTooltip]=\"field.Description\" [(record)]=\"record\" [field]=\"field\" (recordChange)=\"onRecordChange()\">\n</attachment-field-template>\n\n<image-field-template #fieldTemplate *ngIf=\"field.FieldType == FieldTypeEnum['Immagine']\"\n [matTooltip]=\"field.Description\" [(record)]=\"record\" [field]=\"field\" (recordChange)=\"onRecordChange()\">\n</image-field-template>\n\n<list-form-record #listInnerFormRecords *ngIf=\"field.FieldType == FieldTypeEnum['Form di dettaglio']\"\n [form]=\"getInnerFormFromField(field)\" [values]=\"record[field.Name]\"\n (onAddViewEditRecord)=\"onAddViewEditInnerFormRecord($event, field)\">\n</list-form-record>\n\n<!-- DIALOG PER AGGIUNGERE/MODIFICARE/VISUALIZZARE UN RECORD IN UNA FORM DI DETTAGLIO -->\n<ng-template #dialogInnerFormRecord>\n <add-form-record [form]=\"selectedInnerForm\" [record]=\"selectedInnerFormRecord\" [onlyView]=\"onlyViewInnerFormRecord\"\n (saveRecordEvent)=\"onSaveInnerFormRecord($event)\"></add-form-record>\n</ng-template>",
2790
+ styles: [""]
2791
+ })
2792
+ ], DynamicModuleFieldComponent);
2793
+ return DynamicModuleFieldComponent;
2794
+ }());
2795
+
2796
+ var EqpDynamicModuleModule = /** @class */ (function () {
2797
+ function EqpDynamicModuleModule() {
2798
+ }
2799
+ EqpDynamicModuleModule = __decorate([
2800
+ NgModule({
2801
+ declarations: [
2802
+ EqpDynamicModuleComponent,
2803
+ EqpDynamicModuleConfiguratorComponent,
2804
+ AddFormFieldComponent,
2805
+ TextFieldTemplateComponent,
2806
+ BooleanFieldTemplateComponent,
2807
+ DateFieldTemplateComponent,
2808
+ TextareaFieldTemplateComponent,
2809
+ NumericFieldTemplateComponent,
2810
+ ListValueFieldTemplateComponent,
2811
+ AttachmentFieldTemplateComponent,
2812
+ ImageFieldTemplateComponent,
2813
+ ListFormRecordComponent,
2814
+ AddFormRecordComponent,
2815
+ DynamicModuleFieldComponent,
2816
+ ],
2817
+ imports: [
2818
+ BrowserModule,
2819
+ MaterialModule,
2820
+ FormsModule,
2821
+ CommonModule,
2822
+ ReactiveFormsModule,
2823
+ EqpTableModule,
2824
+ EqpAttachmentsModule,
2825
+ EqpSelectModule,
2826
+ EqpDatetimepickerModule,
2827
+ EqpFiltersModule,
2828
+ EqpNumericModule
2829
+ ],
2830
+ exports: [
2831
+ EqpDynamicModuleComponent,
2832
+ EqpDynamicModuleConfiguratorComponent
2833
+ ]
2834
+ })
2835
+ ], EqpDynamicModuleModule);
2836
+ return EqpDynamicModuleModule;
2837
+ }());
2838
+
2839
+ /**
2840
+ * Rappresenta l'entità su cui vengono eseguite le operazioni di salvataggio.
2841
+ */
2842
+ var Entity = /** @class */ (function (_super) {
2843
+ __extends(Entity, _super);
2844
+ function Entity() {
2845
+ return _super !== null && _super.apply(this, arguments) || this;
2846
+ }
2847
+ return Entity;
2848
+ }(BaseObj));
2849
+
2850
+ var ImageField = /** @class */ (function (_super) {
2851
+ __extends(ImageField, _super);
2852
+ function ImageField() {
2853
+ return _super !== null && _super.apply(this, arguments) || this;
2854
+ }
2855
+ return ImageField;
2856
+ }(BaseField));
2857
+
2858
+ /**Questo tipo di campo rappresenta una lookup ad altri valori */
2859
+ var LookupField = /** @class */ (function (_super) {
2860
+ __extends(LookupField, _super);
2861
+ function LookupField() {
2862
+ return _super !== null && _super.apply(this, arguments) || this;
2863
+ }
2864
+ return LookupField;
2865
+ }(BaseField));
2866
+
2867
+ /**Classe contiene la configurazione dei campi numerici */
2868
+ var NumericField = /** @class */ (function (_super) {
2869
+ __extends(NumericField, _super);
2870
+ function NumericField() {
2871
+ return _super !== null && _super.apply(this, arguments) || this;
2872
+ }
2873
+ return NumericField;
2874
+ }(BaseField));
2875
+
2876
+ var TextareaField = /** @class */ (function (_super) {
2877
+ __extends(TextareaField, _super);
2878
+ function TextareaField() {
2879
+ return _super !== null && _super.apply(this, arguments) || this;
2880
+ }
2881
+ return TextareaField;
2882
+ }(BaseField));
2883
+
2884
+ /**Campo di testo */
2885
+ var TextField = /** @class */ (function (_super) {
2886
+ __extends(TextField, _super);
2887
+ function TextField() {
2888
+ return _super !== null && _super.apply(this, arguments) || this;
2889
+ }
2890
+ return TextField;
2891
+ }(BaseField));
2892
+
2893
+ /*
2894
+ * Public API Surface of eqp-dynamic-module
2895
+ */
2896
+
2897
+ /**
2898
+ * Generated bundle index. Do not edit.
2899
+ */
2900
+
2901
+ export { ActionOnRecord, AddFormFieldComponent, AddFormRecordComponent, ArrayValidators, AttachmentField, AttachmentFieldTemplateComponent, AvailableFileExtensions, AvailableImageExtensions, BaseField, BaseObj, BoolPresentantioEnum, BooleanField, BooleanFieldTemplateComponent, ColSpanSizesEnum, Context, ContextUser, DateField, DateFieldTemplateComponent, DateTimeTypeEnum, DynamicModuleFieldComponent, Entity, EqpDynamicModuleComponent, EqpDynamicModuleConfiguratorComponent, EqpDynamicModuleDialogService, EqpDynamicModuleModule, FieldTypeEnum, Form, FormFieldGroup, FormScalarTypeEnum, FormTypeEnum, ImageField, ImageFieldTemplateComponent, ListFormRecordComponent, ListPresentationEnum, ListValueField, ListValueFieldTemplateComponent, LookupField, NumericField, NumericFieldTemplateComponent, Record, TextField, TextFieldTemplateComponent, TextareaField, TextareaFieldTemplateComponent, UtilityHelperService, MaterialModule as ɵa };
2902
+ //# sourceMappingURL=eqproject-eqp-dynamic-module.js.map