@eqproject/eqp-dynamic-module 0.0.5 → 0.0.7

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 (194) hide show
  1. package/karma.conf.js +32 -0
  2. package/ng-package.json +18 -0
  3. package/package.json +31 -41
  4. package/src/lib/components/exported/eqp-dynamic-module/eqp-dynamic-module.component.html +10 -0
  5. package/src/lib/components/exported/eqp-dynamic-module/eqp-dynamic-module.component.scss +3 -0
  6. package/src/lib/components/exported/eqp-dynamic-module/eqp-dynamic-module.component.ts +228 -0
  7. package/src/lib/components/exported/eqp-dynamic-module-configurator/eqp-dynamic-module-configurator.component.html +212 -0
  8. package/src/lib/components/exported/eqp-dynamic-module-configurator/eqp-dynamic-module-configurator.component.scss +30 -0
  9. package/src/lib/components/exported/eqp-dynamic-module-configurator/eqp-dynamic-module-configurator.component.ts +692 -0
  10. package/src/lib/components/private/add-form-field/add-form-field.component.html +417 -0
  11. package/src/lib/components/private/add-form-field/add-form-field.component.scss +38 -0
  12. package/src/lib/components/private/add-form-field/add-form-field.component.ts +599 -0
  13. package/src/lib/components/private/dynamic-module-field/dynamic-module-field.component.html +42 -0
  14. package/src/lib/components/private/dynamic-module-field/dynamic-module-field.component.scss +0 -0
  15. package/src/lib/components/private/dynamic-module-field/dynamic-module-field.component.ts +125 -0
  16. package/src/lib/components/private/field-templates/attachment-field-template/attachment-field-template.component.html +25 -0
  17. package/src/lib/components/private/field-templates/attachment-field-template/attachment-field-template.component.scss +0 -0
  18. package/src/lib/components/private/field-templates/attachment-field-template/attachment-field-template.component.ts +172 -0
  19. package/src/lib/components/private/field-templates/boolean-field-template/boolean-field-template.component.html +32 -0
  20. package/src/lib/components/private/field-templates/boolean-field-template/boolean-field-template.component.scss +0 -0
  21. package/src/lib/components/private/field-templates/boolean-field-template/boolean-field-template.component.ts +53 -0
  22. package/src/lib/components/private/field-templates/date-field-template/date-field-template.component.html +6 -0
  23. package/src/lib/components/private/field-templates/date-field-template/date-field-template.component.scss +0 -0
  24. package/src/lib/components/private/field-templates/date-field-template/date-field-template.component.ts +70 -0
  25. package/src/lib/components/private/field-templates/image-field-template/image-field-template.component.html +57 -0
  26. package/src/lib/components/private/field-templates/image-field-template/image-field-template.component.scss +4 -0
  27. package/src/lib/components/private/field-templates/image-field-template/image-field-template.component.ts +203 -0
  28. package/src/lib/components/private/field-templates/list-value-field-template/list-value-field-template.component.html +46 -0
  29. package/src/lib/components/private/field-templates/list-value-field-template/list-value-field-template.component.scss +13 -0
  30. package/src/lib/components/private/field-templates/list-value-field-template/list-value-field-template.component.ts +114 -0
  31. package/src/lib/components/private/field-templates/numeric-field-template/numeric-field-template.component.html +6 -0
  32. package/src/lib/components/private/field-templates/numeric-field-template/numeric-field-template.component.scss +0 -0
  33. package/src/lib/components/private/field-templates/numeric-field-template/numeric-field-template.component.ts +70 -0
  34. package/src/lib/components/private/field-templates/text-field-template/text-field-template.component.html +5 -0
  35. package/src/lib/components/private/field-templates/text-field-template/text-field-template.component.scss +0 -0
  36. package/src/lib/components/private/field-templates/text-field-template/text-field-template.component.ts +65 -0
  37. package/src/lib/components/private/field-templates/textarea-field-template/textarea-field-template.component.html +5 -0
  38. package/src/lib/components/private/field-templates/textarea-field-template/textarea-field-template.component.scss +0 -0
  39. package/src/lib/components/private/field-templates/textarea-field-template/textarea-field-template.component.ts +48 -0
  40. package/src/lib/components/private/form-records/add-form-record/add-form-record.component.html +74 -0
  41. package/src/lib/components/private/form-records/add-form-record/add-form-record.component.scss +0 -0
  42. package/src/lib/components/private/form-records/add-form-record/add-form-record.component.ts +117 -0
  43. package/src/lib/components/private/form-records/list-form-record/list-form-record.component.html +14 -0
  44. package/src/lib/components/private/form-records/list-form-record/list-form-record.component.scss +7 -0
  45. package/src/lib/components/private/form-records/list-form-record/list-form-record.component.ts +213 -0
  46. package/src/lib/components/private/spinner/spinner.component.html +3 -0
  47. package/src/lib/components/private/spinner/spinner.component.scss +100 -0
  48. package/src/lib/components/private/spinner/spinner.component.ts +19 -0
  49. package/src/lib/eqp-dynamic-module.module.ts +65 -0
  50. package/{lib/interfaces/iBaseFieldComponent.interface.d.ts → src/lib/interfaces/iBaseFieldComponent.interface.ts} +1 -1
  51. package/{lib/interfaces/iRootObject.interface.d.ts → src/lib/interfaces/iRootObject.interface.ts} +1 -1
  52. package/{lib/models/baseField.model.d.ts → src/lib/models/baseField.model.ts} +14 -5
  53. package/{lib/models/baseObj.model.d.ts → src/lib/models/baseObj.model.ts} +3 -3
  54. package/src/lib/models/context.model.ts +10 -0
  55. package/{lib/models/endPointConfiguration.model.d.ts → src/lib/models/endPointConfiguration.model.ts} +16 -12
  56. package/{lib/models/entity.model.d.ts → src/lib/models/entity.model.ts} +2 -1
  57. package/src/lib/models/fields/attachmentField.model.ts +32 -0
  58. package/{lib/models/fields/booleanField.model.d.ts → src/lib/models/fields/booleanField.model.ts} +8 -4
  59. package/{lib/models/fields/dateField.model.d.ts → src/lib/models/fields/dateField.model.ts} +5 -3
  60. package/{lib/models/fields/imageField.model.d.ts → src/lib/models/fields/imageField.model.ts} +8 -3
  61. package/{lib/models/fields/listValueField.model.d.ts → src/lib/models/fields/listValueField.model.ts} +13 -8
  62. package/{lib/models/fields/lookupField.model.d.ts → src/lib/models/fields/lookupField.model.ts} +5 -2
  63. package/{lib/models/fields/numericField.model.d.ts → src/lib/models/fields/numericField.model.ts} +3 -2
  64. package/{lib/models/fields/testareaField.model.d.ts → src/lib/models/fields/testareaField.model.ts} +3 -2
  65. package/src/lib/models/fields/textField.model.ts +18 -0
  66. package/{lib/models/form.model.d.ts → src/lib/models/form.model.ts} +25 -12
  67. package/{lib/models/record.model.d.ts → src/lib/models/record.model.ts} +4 -5
  68. package/src/lib/modules/material.module.ts +104 -0
  69. package/src/lib/services/custom-form-validators.service.ts +21 -0
  70. package/src/lib/services/eqp-dynamic-module-dialog.service.ts +114 -0
  71. package/src/lib/services/spinner.service.ts +40 -0
  72. package/src/lib/services/utilityHelper.services.ts +413 -0
  73. package/{public-api.d.ts → src/public-api.ts} +3 -0
  74. package/src/test.ts +26 -0
  75. package/tsconfig.lib.json +23 -0
  76. package/tsconfig.lib.prod.json +6 -0
  77. package/tsconfig.spec.json +17 -0
  78. package/tslint.json +17 -0
  79. package/bundles/eqproject-eqp-dynamic-module.umd.js +0 -3992
  80. package/bundles/eqproject-eqp-dynamic-module.umd.js.map +0 -1
  81. package/bundles/eqproject-eqp-dynamic-module.umd.min.js +0 -17
  82. package/bundles/eqproject-eqp-dynamic-module.umd.min.js.map +0 -1
  83. package/eqproject-eqp-dynamic-module.d.ts +0 -6
  84. package/eqproject-eqp-dynamic-module.metadata.json +0 -1
  85. package/esm2015/eqproject-eqp-dynamic-module.js +0 -7
  86. package/esm2015/lib/components/exported/eqp-dynamic-module/eqp-dynamic-module.component.js +0 -262
  87. package/esm2015/lib/components/exported/eqp-dynamic-module-configurator/eqp-dynamic-module-configurator.component.js +0 -649
  88. package/esm2015/lib/components/private/add-form-field/add-form-field.component.js +0 -577
  89. package/esm2015/lib/components/private/dynamic-module-field/dynamic-module-field.component.js +0 -127
  90. package/esm2015/lib/components/private/field-templates/attachment-field-template/attachment-field-template.component.js +0 -170
  91. package/esm2015/lib/components/private/field-templates/boolean-field-template/boolean-field-template.component.js +0 -56
  92. package/esm2015/lib/components/private/field-templates/date-field-template/date-field-template.component.js +0 -71
  93. package/esm2015/lib/components/private/field-templates/image-field-template/image-field-template.component.js +0 -196
  94. package/esm2015/lib/components/private/field-templates/list-value-field-template/list-value-field-template.component.js +0 -115
  95. package/esm2015/lib/components/private/field-templates/numeric-field-template/numeric-field-template.component.js +0 -71
  96. package/esm2015/lib/components/private/field-templates/text-field-template/text-field-template.component.js +0 -67
  97. package/esm2015/lib/components/private/field-templates/textarea-field-template/textarea-field-template.component.js +0 -51
  98. package/esm2015/lib/components/private/form-records/add-form-record/add-form-record.component.js +0 -130
  99. package/esm2015/lib/components/private/form-records/list-form-record/list-form-record.component.js +0 -216
  100. package/esm2015/lib/components/private/spinner/spinner.component.js +0 -23
  101. package/esm2015/lib/eqp-dynamic-module.module.js +0 -71
  102. package/esm2015/lib/interfaces/iBaseFieldComponent.interface.js +0 -1
  103. package/esm2015/lib/interfaces/iRootObject.interface.js +0 -1
  104. package/esm2015/lib/models/baseField.model.js +0 -36
  105. package/esm2015/lib/models/baseObj.model.js +0 -9
  106. package/esm2015/lib/models/context.model.js +0 -8
  107. package/esm2015/lib/models/endPointConfiguration.model.js +0 -23
  108. package/esm2015/lib/models/entity.model.js +0 -7
  109. package/esm2015/lib/models/fields/attachmentField.model.js +0 -22
  110. package/esm2015/lib/models/fields/booleanField.model.js +0 -12
  111. package/esm2015/lib/models/fields/dateField.model.js +0 -11
  112. package/esm2015/lib/models/fields/imageField.model.js +0 -8
  113. package/esm2015/lib/models/fields/listValueField.model.js +0 -14
  114. package/esm2015/lib/models/fields/lookupField.model.js +0 -5
  115. package/esm2015/lib/models/fields/numericField.model.js +0 -5
  116. package/esm2015/lib/models/fields/testareaField.model.js +0 -4
  117. package/esm2015/lib/models/fields/textField.model.js +0 -14
  118. package/esm2015/lib/models/form.model.js +0 -24
  119. package/esm2015/lib/models/record.model.js +0 -8
  120. package/esm2015/lib/modules/material.module.js +0 -108
  121. package/esm2015/lib/services/custom-form-validators.service.js +0 -19
  122. package/esm2015/lib/services/eqp-dynamic-module-dialog.service.js +0 -113
  123. package/esm2015/lib/services/spinner.service.js +0 -43
  124. package/esm2015/lib/services/utilityHelper.services.js +0 -387
  125. package/esm2015/public-api.js +0 -39
  126. package/esm5/eqproject-eqp-dynamic-module.js +0 -7
  127. package/esm5/lib/components/exported/eqp-dynamic-module/eqp-dynamic-module.component.js +0 -269
  128. package/esm5/lib/components/exported/eqp-dynamic-module-configurator/eqp-dynamic-module-configurator.component.js +0 -664
  129. package/esm5/lib/components/private/add-form-field/add-form-field.component.js +0 -588
  130. package/esm5/lib/components/private/dynamic-module-field/dynamic-module-field.component.js +0 -128
  131. package/esm5/lib/components/private/field-templates/attachment-field-template/attachment-field-template.component.js +0 -173
  132. package/esm5/lib/components/private/field-templates/boolean-field-template/boolean-field-template.component.js +0 -57
  133. package/esm5/lib/components/private/field-templates/date-field-template/date-field-template.component.js +0 -72
  134. package/esm5/lib/components/private/field-templates/image-field-template/image-field-template.component.js +0 -206
  135. package/esm5/lib/components/private/field-templates/list-value-field-template/list-value-field-template.component.js +0 -119
  136. package/esm5/lib/components/private/field-templates/numeric-field-template/numeric-field-template.component.js +0 -72
  137. package/esm5/lib/components/private/field-templates/text-field-template/text-field-template.component.js +0 -68
  138. package/esm5/lib/components/private/field-templates/textarea-field-template/textarea-field-template.component.js +0 -52
  139. package/esm5/lib/components/private/form-records/add-form-record/add-form-record.component.js +0 -133
  140. package/esm5/lib/components/private/form-records/list-form-record/list-form-record.component.js +0 -220
  141. package/esm5/lib/components/private/spinner/spinner.component.js +0 -24
  142. package/esm5/lib/eqp-dynamic-module.module.js +0 -74
  143. package/esm5/lib/interfaces/iBaseFieldComponent.interface.js +0 -1
  144. package/esm5/lib/interfaces/iRootObject.interface.js +0 -1
  145. package/esm5/lib/models/baseField.model.js +0 -43
  146. package/esm5/lib/models/baseObj.model.js +0 -13
  147. package/esm5/lib/models/context.model.js +0 -14
  148. package/esm5/lib/models/endPointConfiguration.model.js +0 -33
  149. package/esm5/lib/models/entity.model.js +0 -14
  150. package/esm5/lib/models/fields/attachmentField.model.js +0 -29
  151. package/esm5/lib/models/fields/booleanField.model.js +0 -19
  152. package/esm5/lib/models/fields/dateField.model.js +0 -18
  153. package/esm5/lib/models/fields/imageField.model.js +0 -19
  154. package/esm5/lib/models/fields/listValueField.model.js +0 -25
  155. package/esm5/lib/models/fields/lookupField.model.js +0 -12
  156. package/esm5/lib/models/fields/numericField.model.js +0 -12
  157. package/esm5/lib/models/fields/testareaField.model.js +0 -11
  158. package/esm5/lib/models/fields/textField.model.js +0 -21
  159. package/esm5/lib/models/form.model.js +0 -39
  160. package/esm5/lib/models/record.model.js +0 -14
  161. package/esm5/lib/modules/material.module.js +0 -111
  162. package/esm5/lib/services/custom-form-validators.service.js +0 -23
  163. package/esm5/lib/services/eqp-dynamic-module-dialog.service.js +0 -123
  164. package/esm5/lib/services/spinner.service.js +0 -46
  165. package/esm5/lib/services/utilityHelper.services.js +0 -396
  166. package/esm5/public-api.js +0 -39
  167. package/fesm2015/eqproject-eqp-dynamic-module.js +0 -3582
  168. package/fesm2015/eqproject-eqp-dynamic-module.js.map +0 -1
  169. package/fesm5/eqproject-eqp-dynamic-module.js +0 -3768
  170. package/fesm5/eqproject-eqp-dynamic-module.js.map +0 -1
  171. package/lib/components/exported/eqp-dynamic-module/eqp-dynamic-module.component.d.ts +0 -101
  172. package/lib/components/exported/eqp-dynamic-module-configurator/eqp-dynamic-module-configurator.component.d.ts +0 -235
  173. package/lib/components/private/add-form-field/add-form-field.component.d.ts +0 -199
  174. package/lib/components/private/dynamic-module-field/dynamic-module-field.component.d.ts +0 -55
  175. package/lib/components/private/field-templates/attachment-field-template/attachment-field-template.component.d.ts +0 -68
  176. package/lib/components/private/field-templates/boolean-field-template/boolean-field-template.component.d.ts +0 -21
  177. package/lib/components/private/field-templates/date-field-template/date-field-template.component.d.ts +0 -27
  178. package/lib/components/private/field-templates/image-field-template/image-field-template.component.d.ts +0 -65
  179. package/lib/components/private/field-templates/list-value-field-template/list-value-field-template.component.d.ts +0 -51
  180. package/lib/components/private/field-templates/numeric-field-template/numeric-field-template.component.d.ts +0 -26
  181. package/lib/components/private/field-templates/text-field-template/text-field-template.component.d.ts +0 -22
  182. package/lib/components/private/field-templates/textarea-field-template/textarea-field-template.component.d.ts +0 -20
  183. package/lib/components/private/form-records/add-form-record/add-form-record.component.d.ts +0 -52
  184. package/lib/components/private/form-records/list-form-record/list-form-record.component.d.ts +0 -64
  185. package/lib/components/private/spinner/spinner.component.d.ts +0 -9
  186. package/lib/eqp-dynamic-module.module.d.ts +0 -2
  187. package/lib/models/context.model.d.ts +0 -9
  188. package/lib/models/fields/attachmentField.model.d.ts +0 -17
  189. package/lib/models/fields/textField.model.d.ts +0 -15
  190. package/lib/modules/material.module.d.ts +0 -2
  191. package/lib/services/custom-form-validators.service.d.ts +0 -5
  192. package/lib/services/eqp-dynamic-module-dialog.service.d.ts +0 -34
  193. package/lib/services/spinner.service.d.ts +0 -15
  194. package/lib/services/utilityHelper.services.d.ts +0 -77
@@ -0,0 +1,125 @@
1
+ import { Component, EventEmitter, Input, OnInit, Output, QueryList, TemplateRef, ViewChild, ViewChildren } from '@angular/core';
2
+ import { MatDialog, MatDialogRef } from '@angular/material/dialog';
3
+ import { IBaseFieldComponent } from '../../../interfaces/iBaseFieldComponent.interface';
4
+ import { BaseField, FieldTypeEnum } from '../../../models/baseField.model';
5
+ import { Form } from '../../../models/form.model';
6
+ import { Record } from '../../../models/record.model';
7
+ import { ListFormRecordComponent } from '../form-records/list-form-record/list-form-record.component';
8
+
9
+ @Component({
10
+ selector: 'dynamic-module-field',
11
+ templateUrl: './dynamic-module-field.component.html',
12
+ styleUrls: ['./dynamic-module-field.component.scss']
13
+ })
14
+ export class DynamicModuleFieldComponent implements OnInit, IBaseFieldComponent {
15
+
16
+ @Input() field: BaseField;
17
+ @Input() form: Form;
18
+ @Input() record: Record;
19
+ @Output() recordChange: EventEmitter<Record> = new EventEmitter<Record>();
20
+
21
+ FieldTypeEnum = FieldTypeEnum;
22
+
23
+ //#region Proprietà per aggiungere/modificare i record di una form di dettaglio
24
+ selectedInnerForm: Form;
25
+ selectedInnerFormRecord: Record;
26
+ indexInnerFormRecord: number;
27
+ onlyViewInnerFormRecord: boolean = false;
28
+ dialogInnerFormRecordRef: MatDialogRef<TemplateRef<any>>;
29
+ @ViewChild('dialogInnerFormRecord', { static: true }) dialogInnerFormRecord: TemplateRef<any>;
30
+ //#endregion
31
+
32
+ @ViewChildren("fieldTemplate") fieldTemplate: QueryList<DynamicModuleFieldComponent>;
33
+ @ViewChildren('listInnerFormRecords') listInnerFormRecords: QueryList<ListFormRecordComponent>;
34
+
35
+ constructor(
36
+ private dialog: MatDialog
37
+ ) { }
38
+
39
+
40
+ updateField(): void {
41
+ if (this.fieldTemplate && this.fieldTemplate.length > 0) {
42
+ this.fieldTemplate.forEach(f => f.updateField());
43
+ }
44
+ }
45
+
46
+ ngOnInit(): void {
47
+ }
48
+
49
+ /**
50
+ * Metodo invocato al cambio del valore di ogni proprietà dell'oggetto record.
51
+ * Serve ad aggiornare il valore di tutti i campi che hanno una formula.
52
+ */
53
+ onRecordChange() {
54
+ this.recordChange.emit(this.record);
55
+ }
56
+
57
+ /**
58
+ * Metodo per recuperare una InnerForm a partire dal Field che la rappresenta.
59
+ * @param field Campo a partire dal quale si vuole recuperare la InnerForm.
60
+ * @returns Restituisce un oggetto di tipo Form.
61
+ */
62
+ getInnerFormFromField(field: BaseField): Form {
63
+ if (this.form.InnerForms && this.form.InnerForms.find(f => f.Name == field.Label)) {
64
+ return this.form.InnerForms.find(f => f.Name == field.Label);
65
+ } else {
66
+ return null;
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Metodo per aprire un dialog in cui aggiungere/modificare/visualizzare un record appartenente
72
+ * a una form di dettaglio.
73
+ * @param record Evento di output del componente list-form-record, contiene il record selezionato e un booleno che indica
74
+ * se l'utente vuole modificare o visualizzare l'elemento selezionato.
75
+ * @param innerForm Contiene la Form di dettaglio dalla quale è stato richiesto il record.
76
+ */
77
+ onAddViewEditInnerFormRecord(record: { record: Record, onlyView: boolean }, field: BaseField) {
78
+ this.selectedInnerForm = this.getInnerFormFromField(field);
79
+ if (record == null) {
80
+ this.selectedInnerFormRecord = new Record();
81
+ this.indexInnerFormRecord = null;
82
+ this.onlyViewInnerFormRecord = false;
83
+ } else {
84
+ this.selectedInnerFormRecord = JSON.parse(JSON.stringify(record.record));
85
+ this.indexInnerFormRecord = this.record[field.Name].indexOf(record);
86
+ this.onlyViewInnerFormRecord = record.onlyView;
87
+ }
88
+
89
+ this.dialogInnerFormRecordRef = this.dialog.open(this.dialogInnerFormRecord, {
90
+ disableClose: true,
91
+ hasBackdrop: true,
92
+ width: '75%'
93
+ });
94
+ }
95
+
96
+ /**
97
+ * Metodo invocato al salvataggio o alla chiusura del dialog di aggiunta/modifica/visualizzazione
98
+ * di un record di una form di dettaglio.
99
+ * @param record Oggetto restituito dal componente add-form-field (questo qui) contenente il Record
100
+ * aggiornato dall'utente. Se null allora l'utente non ha modificato nulla e ha chiuso il dialog.
101
+ */
102
+ onSaveInnerFormRecord(record: Record) {
103
+ if (record != null) {
104
+ const arrayName: string = this.selectedInnerForm.Name.split(' ').join('_');
105
+ if (this.indexInnerFormRecord != null && this.indexInnerFormRecord >= 0) {
106
+ this.record[arrayName][this.indexInnerFormRecord] = record;
107
+ } else {
108
+ if (!this.record[arrayName]) {
109
+ this.record[arrayName] = [];
110
+ }
111
+ this.record[arrayName].push(record);
112
+ }
113
+ }
114
+ this.dialogInnerFormRecordRef.close();
115
+
116
+ // Ricarico la tabella dei record per visualizzare le modifiche fatte dall'utente.
117
+ if (this.listInnerFormRecords && this.listInnerFormRecords.length > 0) {
118
+ this.listInnerFormRecords.forEach(list => {
119
+ if (list && list.tableRecords) {
120
+ list.tableRecords.reloadDatatable();
121
+ }
122
+ });
123
+ }
124
+ }
125
+ }
@@ -0,0 +1,25 @@
1
+ <p *ngIf="!field.IsMultiAttach" class="mb-2">
2
+ {{field.Label + (field.Required ? " *" : "")}}
3
+ </p>
4
+ <div class="row" *ngIf="!field.IsMultiAttach && record[field.Name] && record[field.Name][0]">
5
+ <div class="mt-2" *ngFor="let metadata of field.MetadataFields"
6
+ [ngClass]="utilityService.getFieldSyleClass(metadata)">
7
+ <dynamic-module-field [field]="metadata" [record]="record[field.Name][0]"
8
+ (recordChange)="updateMetadataValidity()">
9
+ </dynamic-module-field>
10
+ </div>
11
+ </div>
12
+
13
+ <eqp-attachments [attachmentsList]="record[field.Name]" [showMatCard]="true" [allowOnlyImages]="onlyImages"
14
+ [isDisabled]="field.FormFormGroup.disabled" [showInlinePreview]="true" [multipleAttachment]="field.IsMultiAttach"
15
+ [disableAction]="field.FormFormGroup.disabled" [acceptedFileTypes]="field.AllowedExtensions" [showHeader]="true"
16
+ [headerTitle]="field.Label + (field.Required ? ' *' : '')" (localEditedAttachments)="catchAttachmentList($event)"
17
+ #eqpAttachments>
18
+ </eqp-attachments>
19
+
20
+ <!-- TEMPLATE PER VISUALIZZARE LA COLONNA DELLA SEZIONE NELLA TABELLA DEI FIELDS -->
21
+ <ng-template #metadataColumnTemplate let-row="row" let-col="col">
22
+ <dynamic-module-field [field]="getFieldFromMetadata(col, row)" [record]="row"
23
+ (recordChange)="updateMetadataValidity()">
24
+ </dynamic-module-field>
25
+ </ng-template>
@@ -0,0 +1,172 @@
1
+ import { AfterViewInit, ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, TemplateRef, ViewChild } from '@angular/core';
2
+ import { Record } from '../../../../models/record.model';
3
+ import { AttachmentField, AvailableFileExtensions, AvailableImageExtensions } from '../../../../models/fields/attachmentField.model';
4
+ import { IBaseFieldComponent } from '../../../../interfaces/iBaseFieldComponent.interface';
5
+ import { UtilityHelperService } from '../../../../services/utilityHelper.services';
6
+ import { EqpAttachmentsComponent } from '@eqproject/eqp-attachments';
7
+ import { FormGroup } from '@angular/forms';
8
+ import { ConfigColumn, TypeColumn } from '@eqproject/eqp-table';
9
+
10
+ @Component({
11
+ selector: 'attachment-field-template',
12
+ templateUrl: './attachment-field-template.component.html',
13
+ styleUrls: ['./attachment-field-template.component.scss']
14
+ })
15
+ export class AttachmentFieldTemplateComponent implements OnInit, OnChanges, IBaseFieldComponent, AfterViewInit {
16
+
17
+ @Input() onlyImages: boolean = false;
18
+ @Input() field: AttachmentField;
19
+ @Input() record: Record;
20
+ @Output() recordChange: EventEmitter<Record> = new EventEmitter<Record>();
21
+ @Output() onAttachmentsChange: EventEmitter<void> = new EventEmitter<void>();
22
+
23
+ @ViewChild("eqpAttachments", { static: true }) eqpAttachments: EqpAttachmentsComponent;
24
+ @ViewChild('metadataColumnTemplate', { static: true }) metadataColumnTemplate: TemplateRef<any>;
25
+
26
+ metadataFormGroups: Array<FormGroup> = new Array<FormGroup>();
27
+
28
+ constructor(
29
+ public utilityService: UtilityHelperService,
30
+ private cdr: ChangeDetectorRef
31
+ ) { }
32
+
33
+ ngOnInit(): void {
34
+ // Nel caso in cui sono in modifica di un Record aggiorno il valore
35
+ // e il validator del FormControl. Se non viene eseguita questa riga
36
+ // l'utente deve modificare la selezione fatta per aggiornare la form.
37
+ this.setFormControlValue();
38
+
39
+ // Sempre nel caso in cui sono in modifica creo i FormGroup che rappresentano
40
+ // gli eventuali metadata degli allegati recuperati.
41
+ this.createMetadataFormGroups();
42
+ if (this.field.MetadataFields) {
43
+ this.field.MetadataFields.sort((a, b) => (a.OrdinalPosition > b.OrdinalPosition) ? 1 : ((b.OrdinalPosition > a.OrdinalPosition) ? -1 : 0));
44
+ }
45
+
46
+ if (!this.field.AllowedExtensions) {
47
+ this.field.AllowedExtensions = AvailableFileExtensions.concat(AvailableImageExtensions).map(ext => ext.key);
48
+ }
49
+ }
50
+
51
+ ngAfterViewInit(): void {
52
+ // Dopo aver renderizzato il DOM, se il campo ammette molteplici allegati
53
+ // configuro le colonne della eqp-table in eqp-attachments.
54
+ if (this.field.IsMultiAttach) {
55
+ this.configureMultiAttachmentColumns();
56
+ }
57
+ }
58
+
59
+ ngOnChanges(changes: SimpleChanges) {
60
+ // Se viene modificato il valore di "ngModelInput" allora aggiorna l'input
61
+ if (changes['record'] != undefined && changes['record'].firstChange == false && JSON.stringify(changes['record'].currentValue) != JSON.stringify(changes['record'].previousValue)) {
62
+ this.record = changes['record'].currentValue;
63
+ this.updateField();
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Metodo per aggiornare il valore del campo quando questo è rappresentato da una formula.
69
+ */
70
+ updateField() {
71
+ if (this.field.Formula) {
72
+ this.record[this.field.Name] = UtilityHelperService.EvaluateFieldFormula(this.field.Formula, this.record, null);
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Metodo per intercettare le modifiche agli allegati caricati.
78
+ * Se il campo prevede dei metadata allora per ogni allegato caricato crea un FormGroup
79
+ * per gestire la validazione degli input che l'utente può/deve riempire. I FormGroup
80
+ * seguono lo stesso ordine degli allegati caricati.
81
+ * @param event Contiene la lista aggiornata degli Attachment caricati dall'utente.
82
+ */
83
+ catchAttachmentList(event) {
84
+ this.record[this.field.Name] = event;
85
+
86
+ this.createMetadataFormGroups();
87
+
88
+ this.setFormControlValue();
89
+ this.onRecordValueChange();
90
+
91
+ // Scateno un evento di output necessario al componente ImageFieldTemplate al
92
+ // variare degli allegati caricati. Viene usato per aprire il dialog per disegnare
93
+ // sull'immagine caricata in base alla configurazione del Field.
94
+ this.onAttachmentsChange.emit();
95
+ this.cdr.detectChanges();
96
+ }
97
+
98
+ /**
99
+ * Metodo per aggiornare lo stato di validazione del FormControl che rappresenta
100
+ * il campo Allegato (non i metadata al suo interno). Se tra le form dei metadata
101
+ * ne trova una invalida allora marca il controllo come invalido.
102
+ */
103
+ updateMetadataValidity() {
104
+ if (this.metadataFormGroups.find(form => form.invalid)) {
105
+ this.field.FormFormGroup.controls[this.field.Name].setErrors({ 'incorrect': true });
106
+ } else {
107
+ this.field.FormFormGroup.controls[this.field.Name].setErrors(null);
108
+ }
109
+ this.onRecordValueChange();
110
+ }
111
+
112
+ /**
113
+ * Metodo per recuperare il BaseField che rappresenta il metadata nella riga della eqp-table
114
+ * in base alla colonna e alla riga. Una volta trovato il BaseField gli viene associato il
115
+ * FormGroup di cui fa parte.
116
+ * @param col Colonna della eqp-table.
117
+ * @param row Riga della eqp-table (in questo caso eredita da IAttachment).
118
+ * @returns Restituisce un BaseField per renderizzare il campo nella eqp-table degli allegati multipli.
119
+ */
120
+ getFieldFromMetadata(col: ConfigColumn, row: any) {
121
+ var baseField = JSON.parse(JSON.stringify(this.field.MetadataFields.find(metadata => metadata.Name === col.key)));
122
+ baseField.FormFormGroup = this.metadataFormGroups[this.record[this.field.Name].indexOf(row)];
123
+ return baseField;
124
+ }
125
+
126
+ /**
127
+ * Metodo per aggiornare il valore e il validator del FormControl associato al campo.
128
+ */
129
+ private setFormControlValue() {
130
+ this.field.FormFormGroup.controls[this.field.Name].setValue(this.record[this.field.Name]);
131
+ }
132
+
133
+ /**
134
+ * Metodo per emettere l'evento che il valore del record è cambiato.
135
+ */
136
+ private onRecordValueChange() {
137
+ if (!this.field.Formula) {
138
+ this.recordChange.emit(this.record);
139
+ }
140
+ }
141
+
142
+ /**
143
+ * Metodo per aggiungere alle colonne di eqp-attachments le colonne per modificare i metadata
144
+ * configurati per il campo Allegato o Immagine.
145
+ */
146
+ private configureMultiAttachmentColumns() {
147
+ if (this.eqpAttachments && this.eqpAttachments.attachmentsColumns && this.field.MetadataFields && this.field.MetadataFields.length > 0) {
148
+ this.field.MetadataFields.forEach(metadata => {
149
+ this.eqpAttachments.attachmentsColumns.splice(
150
+ this.eqpAttachments.attachmentsColumns.length - 1, 0,
151
+ { key: metadata.Name, display: metadata.Label, type: TypeColumn.ExternalTemplate, externalTemplate: this.metadataColumnTemplate }
152
+ );
153
+ });
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Metodo per creare i FormGroup che rappresentano i metadata degli allegati caricati.
159
+ */
160
+ private createMetadataFormGroups() {
161
+ if (this.field.MetadataFields && this.field.MetadataFields.length > 0) {
162
+ this.metadataFormGroups = [];
163
+ if (this.record[this.field.Name] && this.record[this.field.Name].length > 0) {
164
+ this.record[this.field.Name].forEach(attachment => {
165
+ this.metadataFormGroups.push(this.utilityService.CreateFormFormGroup(this.field.MetadataFields, attachment, this.field.FormFormGroup.disabled, !this.field.IsMultiAttach));
166
+ });
167
+ }
168
+
169
+ this.updateMetadataValidity();
170
+ }
171
+ }
172
+ }
@@ -0,0 +1,32 @@
1
+ <div [formGroup]="field.FormFormGroup">
2
+
3
+ <!-- VISUALIZZAZIONE A TOGGLE -->
4
+ <mat-slide-toggle color="primary" *ngIf="field.PresetationType == BoolPresentantioEnum.Toggle"
5
+ [formControlName]="field.Name" [disabled]="field.FormFormGroup.disabled" [required]="field.Required"
6
+ [(ngModel)]="record[field.Name]" (ngModelChange)="onRecordValueChange()">
7
+ {{field.Label + (field.Required ? " *" : "")}}
8
+ </mat-slide-toggle>
9
+
10
+
11
+ <!-- VISUALIZZAZIONE A RADIOBUTTON -->
12
+ <mat-label class="mr-3" *ngIf="field.PresetationType == BoolPresentantioEnum['Radio button']">
13
+ {{field.Label + (field.Required ? " *" : "")}}
14
+ </mat-label>
15
+ <mat-radio-group *ngIf="field.PresetationType == BoolPresentantioEnum['Radio button']"
16
+ [formControlName]="field.Name" [disabled]="field.FormFormGroup.disabled" [required]="field.Required"
17
+ [(ngModel)]="record[field.Name]" (ngModelChange)="onRecordValueChange()">
18
+ <mat-radio-button class="mr-2" [value]="true" color="primary"> Si </mat-radio-button>
19
+ <mat-radio-button class="mr-2" [value]="false" color="primary"> No </mat-radio-button>
20
+ <mat-radio-button class="mr-2" [value]="null" color="primary" *ngIf="field.IsTristate"> ND
21
+ </mat-radio-button>
22
+ </mat-radio-group>
23
+
24
+ <!-- VISUALIZZAZIONE A CHECKBOX -->
25
+ <mat-checkbox class="mr-2" *ngIf="field.PresetationType == BoolPresentantioEnum.Checkbox"
26
+ [disabled]="field.FormFormGroup.disabled" [required]="field.Required" [formControlName]="field.Name"
27
+ [(ngModel)]="record[field.Name]" (ngModelChange)="onRecordValueChange()">
28
+ {{field.Label + (field.Required ? " *" : "")}}
29
+ </mat-checkbox>
30
+
31
+ <!-- TODO: Visualizzazione "Stringa true o false" e "Numerico 0 o 1" ?? -->
32
+ </div>
@@ -0,0 +1,53 @@
1
+ import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
2
+ import { Record } from '../../../../models/record.model';
3
+ import { BooleanField, BoolPresentantioEnum } from '../../../../models/fields/booleanField.model';
4
+ import { IBaseFieldComponent } from '../../../../interfaces/iBaseFieldComponent.interface';
5
+ import { UtilityHelperService } from '../../../../services/utilityHelper.services';
6
+
7
+ @Component({
8
+ selector: 'boolean-field-template',
9
+ templateUrl: './boolean-field-template.component.html',
10
+ styleUrls: ['./boolean-field-template.component.scss']
11
+ })
12
+ export class BooleanFieldTemplateComponent implements OnInit, OnChanges, IBaseFieldComponent {
13
+
14
+ @Input() field: BooleanField;
15
+ @Input() record: Record;
16
+ @Output() recordChange: EventEmitter<Record> = new EventEmitter<Record>();
17
+
18
+ BoolPresentantioEnum = BoolPresentantioEnum;
19
+
20
+ constructor() { }
21
+
22
+ ngOnInit(): void {
23
+ if (this.record[this.field.Name] == undefined || this.record[this.field.Name] == null) {
24
+ this.record[this.field.Name] = this.field.IsTristate ? null : false;
25
+ }
26
+ }
27
+
28
+ ngOnChanges(changes: SimpleChanges) {
29
+ // Se viene modificato il valore di "ngModelInput" allora aggiorna l'input
30
+ if (changes['record'] != undefined && changes['record'].firstChange == false && JSON.stringify(changes['record'].currentValue) != JSON.stringify(changes['record'].previousValue)) {
31
+ this.record = changes['record'].currentValue;
32
+ this.updateField();
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Metodo per aggiornare il valore del campo quando questo è rappresentato da una formula.
38
+ */
39
+ updateField() {
40
+ if (this.field.Formula) {
41
+ this.record[this.field.Name] = UtilityHelperService.EvaluateFieldFormula(this.field.Formula, this.record, null);
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Metodo per emettere l'evento che il valore del record è cambiato.
47
+ */
48
+ onRecordValueChange() {
49
+ if (!this.field.Formula) {
50
+ this.recordChange.emit(this.record);
51
+ }
52
+ }
53
+ }
@@ -0,0 +1,6 @@
1
+ <eqp-datetimepicker [placeholder]="field.Label" [UTCDate]="true" [pickerMode]="pickerMode"
2
+ [formGroupInput]="field.FormFormGroup" [formControlNameInput]="field.Name"
3
+ [minDate]="field.MinDate ? field.MinDate : null" [maxDate]="field.MaxDate ? field.MaxDate : null"
4
+ [isRequired]="field.Required" [disabled]="field.FormFormGroup.disabled" [(ngModelInput)]="record[field.Name]"
5
+ (ngModelInputChange)="onRecordValueChange()" [customDateFormat]="field.DateFormat ? field.DateFormat : null">
6
+ </eqp-datetimepicker>
@@ -0,0 +1,70 @@
1
+ import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
2
+ import { PickerModeEnum } from '@eqproject/eqp-datetimepicker';
3
+ import { Record } from '../../../../models/record.model';
4
+ import { DateField, DateTimeTypeEnum } from '../../../../models/fields/dateField.model';
5
+ import { IBaseFieldComponent } from '../../../../interfaces/iBaseFieldComponent.interface';
6
+ import { UtilityHelperService } from '../../../../services/utilityHelper.services';
7
+
8
+ @Component({
9
+ selector: 'date-field-template',
10
+ templateUrl: './date-field-template.component.html',
11
+ styleUrls: ['./date-field-template.component.scss']
12
+ })
13
+ export class DateFieldTemplateComponent implements OnInit, OnChanges, IBaseFieldComponent {
14
+
15
+ @Input() field: DateField;
16
+ @Input() record: Record;
17
+ @Output() recordChange: EventEmitter<Record> = new EventEmitter<Record>();
18
+
19
+ pickerMode: PickerModeEnum;
20
+
21
+ constructor() { }
22
+
23
+ ngOnInit(): void {
24
+ this.setTimeType();
25
+ }
26
+
27
+ ngOnChanges(changes: SimpleChanges) {
28
+ // Se viene modificato il valore di "ngModelInput" allora aggiorna l'input
29
+ if (changes['record'] != undefined && changes['record'].firstChange == false && JSON.stringify(changes['record'].currentValue) != JSON.stringify(changes['record'].previousValue)) {
30
+ this.record = changes['record'].currentValue;
31
+ this.updateField();
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Metodo per aggiornare il valore del campo quando questo è rappresentato da una formula.
37
+ */
38
+ updateField() {
39
+ if (this.field.Formula) {
40
+ this.record[this.field.Name] = UtilityHelperService.EvaluateFieldFormula(this.field.Formula, this.record, null);
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Metodo per emettere l'evento che il valore del record è cambiato.
46
+ */
47
+ onRecordValueChange() {
48
+ if (!this.field.Formula) {
49
+ this.recordChange.emit(this.record);
50
+ }
51
+ }
52
+
53
+ /**
54
+ * In base al formato della data richiesta nel DateField (solo data, solo orario o data e ora)
55
+ * imposta la visualizzazione corretta del componente eqp-datetimepicker.
56
+ */
57
+ private setTimeType() {
58
+ switch (this.field.IsOnlyDate) {
59
+ case DateTimeTypeEnum["Solo data"]:
60
+ this.pickerMode = PickerModeEnum.DATE;
61
+ break;
62
+ case DateTimeTypeEnum["Solo orario"]:
63
+ this.pickerMode = PickerModeEnum.TIME;
64
+ break;
65
+ case DateTimeTypeEnum["Data e ora"]:
66
+ this.pickerMode = PickerModeEnum.DATETIME;
67
+ break;
68
+ }
69
+ }
70
+ }
@@ -0,0 +1,57 @@
1
+ <!-- VISUALIZZAZIONE ALLEGATO PRE CARICATO CON POSSIBILITA' DI DISEGNO -->
2
+ <div class="row" *ngIf="field.ImageIsContextualAttachment && field.ContextualAttachment">
3
+ <div class="col-sm-12 col-md-6 col-lg-4">
4
+ <p class="mb-2">
5
+ {{ field.Label + (field.Required ? " *" : "")}}
6
+ <br>
7
+ Nome immagine: {{ field.ImgName}}
8
+ </p>
9
+ <eqp-img-drawing
10
+ *ngIf="field.EnableDrawing && record[field.Name] && record[field.Name][0] && width != null && height != null"
11
+ [src]="'data:'+ record[field.Name][0].FileContentType + ';base64,'+ record[field.Name][0].FileDataBase64"
12
+ [showCancelButton]="false" [enableLoadAnotherImage]="false" [enableRemoveImage]="false" [width]="width"
13
+ [height]="height" [i18n]="i18n" [showCancelButton]="true" (save)="saveDrowning($event)"
14
+ (cancel)="resetPreLoadedImage()">
15
+ </eqp-img-drawing>
16
+
17
+ <img *ngIf="!field.EnableDrawing"
18
+ [src]="'data:'+ record[field.Name][0].FileContentType+ ';base64,'+ record[field.Name][0].FileDataBase64">
19
+ </div>
20
+
21
+ <div class="col-sm-12 col-md-6 col-lg-8">
22
+ <div class="row"
23
+ *ngIf="field.AttachDefinition && field.AttachDefinition.MetadataFields && preLoadedImageMetadataFormGroup">
24
+ <div class="mt-2" *ngFor="let metadata of field.AttachDefinition.MetadataFields"
25
+ [ngClass]="utilityService.getFieldSyleClass(metadata)">
26
+ <dynamic-module-field #fieldTemplate [field]="metadata" [form]="preLoadedImageMetadataFormGroup"
27
+ [record]="record[field.Name][0]" (recordChange)="updateMetadataValidity()">
28
+ </dynamic-module-field>
29
+ </div>
30
+ </div>
31
+ </div>
32
+ </div>
33
+
34
+ <!-- COMPONENTE IN CUI CARICARE NUOVI ALLEGATI -->
35
+ <attachment-field-template [(record)]="record" [field]="field.AttachDefinition" [onlyImages]="true"
36
+ (onAttachmentsChange)="onAttachmentsChange()" *ngIf="!field.ImageIsContextualAttachment">
37
+ </attachment-field-template>
38
+
39
+ <!-- DIALOG PER DISEGNARE SUL NUOVO ALLEGATO CARICATO -->
40
+ <ng-template #dialogImageDrowing>
41
+ <div *ngIf="field.EnableDrawing && record[field.Name] && record[field.Name][0] && width != null && height != null"
42
+ class="row">
43
+ <div class="col-sm-12 col-md-12">
44
+ <eqp-img-drawing [showCancelButton]="false" [enableLoadAnotherImage]="false" [enableRemoveImage]="false"
45
+ [src]="'data:'+ record[field.Name][0].FileContentType + ';base64,'+ record[field.Name][0].FileDataBase64"
46
+ [i18n]="i18n" [showCancelButton]="false" (save)="saveDrowning($event)">
47
+ </eqp-img-drawing>
48
+ </div>
49
+ </div>
50
+ <div class="row mt-2 mb-1">
51
+ <div class="col-sm-12 text-right">
52
+ <button class="btn mat-raised-button" (click)="closeImageDrowingDialog()" type="button">
53
+ Annulla disegno
54
+ </button>
55
+ </div>
56
+ </div>
57
+ </ng-template>
@@ -0,0 +1,4 @@
1
+ ::ng-deep image-drawing > button {
2
+ background-color: var(--primary) !important;
3
+ color: white !important;
4
+ }