@eqproject/eqp-dynamic-module 0.0.6 → 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 -3991
  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 -69
  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 -72
  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 -3580
  168. package/fesm2015/eqproject-eqp-dynamic-module.js.map +0 -1
  169. package/fesm5/eqproject-eqp-dynamic-module.js +0 -3766
  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,117 @@
1
+ import { ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output, QueryList, ViewChildren } from '@angular/core';
2
+ import { FormGroup } from '@angular/forms';
3
+ import { BaseField, FieldTypeEnum } from '../../../../models/baseField.model';
4
+ import { Form, FormScalarTypeEnum } from '../../../../models/form.model';
5
+ import { Record } from '../../../../models/record.model';
6
+ import { UtilityHelperService } from '../../../../services/utilityHelper.services';
7
+ import { DynamicModuleFieldComponent } from '../../dynamic-module-field/dynamic-module-field.component';
8
+
9
+ @Component({
10
+ selector: 'add-form-record',
11
+ templateUrl: './add-form-record.component.html',
12
+ styleUrls: ['./add-form-record.component.scss']
13
+ })
14
+ export class AddFormRecordComponent implements OnInit {
15
+
16
+ @Input() showTitle = true;
17
+ @Input() showButtons = true;
18
+ @Input() form: Form = new Form();
19
+ @Input() record: Record;
20
+ @Input() onlyView: boolean;
21
+ formForm: FormGroup;
22
+ fieldGroups: { [key: string]: Array<BaseField> } = {};
23
+ FormScalarTypeEnum = FormScalarTypeEnum;
24
+ FieldTypeEnum = FieldTypeEnum;
25
+
26
+ @Output() saveRecordEvent: EventEmitter<Record> = new EventEmitter<Record>();
27
+
28
+ @ViewChildren("fieldTemplate") fieldTemplate: QueryList<DynamicModuleFieldComponent>;
29
+
30
+ constructor(
31
+ private cdr: ChangeDetectorRef,
32
+ public utilityService: UtilityHelperService
33
+ ) { }
34
+
35
+ ngOnInit(): void {
36
+ if (this.record == null) {
37
+ this.record = new Record();
38
+ }
39
+ this.createRecordProperties();
40
+ this.reorderFormFields();
41
+ this.createFormGroup();
42
+ if (this.form.FormScalarType != FormScalarTypeEnum.Semplice) {
43
+ this.createFieldGroups();
44
+ }
45
+ this.cdr.detectChanges();
46
+ }
47
+
48
+ /**
49
+ * Metodo invocato al cambio del valore di ogni proprietà dell'oggetto record.
50
+ * Serve ad aggiornare il valore di tutti i campi che hanno una formula.
51
+ */
52
+ onRecordChange() {
53
+ if (this.fieldTemplate && this.fieldTemplate.length > 0) {
54
+ this.fieldTemplate.forEach(f => f.updateField());
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Metodo per salvare i dati inseriti dall'utente una volta conclusa la compilazione della form.
60
+ */
61
+ saveOrExitForm(exit: boolean) {
62
+ if (exit) {
63
+ this.saveRecordEvent.emit(null);
64
+ } else {
65
+ this.saveRecordEvent.emit(this.record);
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Metodo per creare nell'oggetto Record le proprietà mancanti rispetto ai campi che compongono la form.
71
+ */
72
+ private createRecordProperties() {
73
+ const recordProperties: Array<string> = Object.keys(this.record);
74
+ this.form.Fields.forEach(field => {
75
+ if (!recordProperties.find(p => p === field.Name)) {
76
+ this.record[field.Name] = null;
77
+ }
78
+ });
79
+ if (this.form.InnerForms && this.form.InnerForms.length > 0) {
80
+ this.form.InnerForms.forEach(form => {
81
+ const arrayName: string = form.Name.split(" ").join("_");
82
+ if (!recordProperties.find(p => p === arrayName)) {
83
+ this.record[arrayName] = [];
84
+ }
85
+ });
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Metodo per riordinare i campi che compongono la form.
91
+ */
92
+ private reorderFormFields() {
93
+ if (this.form.Fields && this.form.Fields.length > 0) {
94
+ this.form.Fields.sort((a, b) => (a.OrdinalPosition > b.OrdinalPosition) ? 1 : ((b.OrdinalPosition > a.OrdinalPosition) ? -1 : 0));
95
+ }
96
+ }
97
+
98
+ /**
99
+ * Metodo per creare il FormGroup che rappresenta la form.
100
+ */
101
+ private createFormGroup() {
102
+ this.formForm = this.utilityService.CreateFormFormGroup(this.form.Fields, this.record, this.onlyView);
103
+ }
104
+
105
+ /**
106
+ * Metodo per creare i gruppi in cui raggruppare i campi della form in base
107
+ * a come è stata configurata dall'utente.
108
+ */
109
+ private createFieldGroups() {
110
+ this.form.FormFieldsGroups
111
+ .sort((a, b) => (a.OrdinalPosition > b.OrdinalPosition) ? 1 : ((b.OrdinalPosition > a.OrdinalPosition) ? -1 : 0))
112
+ .map(g => g.Name)
113
+ .forEach(groupName => {
114
+ this.fieldGroups[groupName] = this.form.Fields.filter(f => f.FieldGroup == groupName);
115
+ });
116
+ }
117
+ }
@@ -0,0 +1,14 @@
1
+ <div class="row eqp-dynamic-module-title">
2
+ <div class="col-md-6">
3
+ <h4 *ngIf="showTitle"><b>Elenco {{form.Name}}</b></h4>
4
+ </div>
5
+ <div class="col-md-6 text-right">
6
+ <button class="btn btn-primary" mat-raised-button color="primary" type="button" (click)="onAddViewEditRecord.emit(null)">
7
+ <mat-icon>add</mat-icon>
8
+ <span style="margin-left: 10px;">Aggiungi</span>
9
+ </button>
10
+ </div>
11
+ </div>
12
+
13
+
14
+ <eqp-table #tableRecords [data]="values" [columns]="columns"></eqp-table>
@@ -0,0 +1,7 @@
1
+ ::ng-deep .error-color {
2
+ color: var(--danger);
3
+ }
4
+
5
+ ::ng-deep .success-color {
6
+ color: var(--success);
7
+ }
@@ -0,0 +1,213 @@
1
+ import { Component, OnInit, Input, ViewChild, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
2
+ import { IAttachmentDTO } from '@eqproject/eqp-attachments';
3
+ import { CellAlignmentEnum, ConfigColumn, EqpTableComponent, NumberColumnPipe, TypeColumn } from '@eqproject/eqp-table';
4
+ import { Form } from '../../../../models/form.model';
5
+ import { BaseField, FieldTypeEnum } from '../../../../models/baseField.model';
6
+ import { Record } from '../../../../models/record.model';
7
+ import { AttachmentField } from '../../../../models/fields/attachmentField.model';
8
+ import { DateField, DateTimeTypeEnum } from '../../../../models/fields/dateField.model';
9
+ import { ImageField } from '../../../../models/fields/imageField.model';
10
+ import { ListValueField } from '../../../../models/fields/listValueField.model';
11
+ import { NumericField } from '../../../../models/fields/numericField.model';
12
+ import { UtilityHelperService } from '../../../../services/utilityHelper.services';
13
+ import { EqpDynamicModuleDialogService } from '../../../../services/eqp-dynamic-module-dialog.service';
14
+
15
+ @Component({
16
+ selector: 'list-form-record',
17
+ templateUrl: 'list-form-record.component.html',
18
+ styleUrls: ['./list-form-record.component.scss']
19
+ })
20
+ export class ListFormRecordComponent implements OnInit, OnChanges {
21
+
22
+ @Input() showTitle = true;
23
+ @Input() form: Form;
24
+ @Input() values: Array<Record>;
25
+ @ViewChild('tableRecords', { static: true }) tableRecords: EqpTableComponent;
26
+
27
+ columns = new Array<ConfigColumn>();
28
+
29
+ @Output() onAddViewEditRecord: EventEmitter<{ record: Record, onlyView: boolean }> = new EventEmitter<{ record: Record, onlyView: boolean }>();
30
+
31
+ @Output() onDeleteRecord: EventEmitter<Record> = new EventEmitter<Record>();
32
+ @Output() onDuplicateRecord: EventEmitter<Record> = new EventEmitter<Record>();
33
+
34
+
35
+
36
+ constructor() { }
37
+
38
+ ngOnInit(): void {
39
+ this.configureColumns();
40
+ }
41
+
42
+ ngOnChanges(changes: SimpleChanges) {
43
+ // Se viene modificato il valore di "ngModelInput" allora aggiorna l'input
44
+ if (changes['values'] != undefined && changes['values'].firstChange == false) {
45
+ this.values = changes['values'].currentValue;
46
+ this.reloadTables();
47
+ }
48
+ }
49
+
50
+ /**
51
+ * Metodo per configurare le colonne della eqp-table.
52
+ */
53
+ private configureColumns() {
54
+ this.columns = [
55
+ {
56
+ key: "action", display: "",
57
+ type: TypeColumn.MenuAction, buttonMenuIcon: "more_vert", styles: { flex: "0 0 6%" },
58
+ actions: [
59
+ { name: "Visualizza", icon: "info", fn: (element, index, col) => this.viewOrEditRecord(element, true) },
60
+ { name: "Modifica", icon: "edit", fn: (element, index, col) => this.viewOrEditRecord(element, false) },
61
+ { name: "Duplica", icon: "file_copy", fn: (element, index, col) => this.duplicateRecord(element) },
62
+ { name: "Elimina", icon: "delete", fn: (element, index, col) => this.deleteRecord(element) },
63
+ ],
64
+ },
65
+ ];
66
+ this.createAdditionalActions();
67
+ this.createColumnsFromFormFields();
68
+ }
69
+
70
+
71
+ /**
72
+ * Metodo per aggiungere nella colonna "action" della eqp-table le azioni sui record
73
+ * definite dall'utente all'interno della Form.
74
+ */
75
+ private createAdditionalActions() {
76
+ if (this.form.ActionsOnRecord && this.form.ActionsOnRecord.length > 0) {
77
+ this.form.ActionsOnRecord
78
+ .sort((a, b) => (a.OrdinalPosition > b.OrdinalPosition) ? 1 : ((b.OrdinalPosition > a.OrdinalPosition) ? -1 : 0))
79
+ .forEach(action => {
80
+ this.columns.find(c => c.key === 'action')
81
+ .actions
82
+ .push({
83
+ name: action.Name, icon: action.Icon, fn: (element, index, col) => {
84
+ const rec = element;
85
+ const ctx = UtilityHelperService.context;
86
+ eval(action.Action);
87
+ // TODO: salvare le modifiche
88
+ }
89
+ })
90
+ })
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Metodo che scatena l'evento di Output per mostrare o modificare il record
96
+ * selezionato sulla eqp-table.
97
+ * @param record Record da visualizzare o modificare selezionato sulla eqp-table.
98
+ * @param onlyView Se TRUE viene mostrato il componente add-form-record in sola lettura.
99
+ */
100
+ private viewOrEditRecord(record: Record, onlyView: boolean) {
101
+ this.onAddViewEditRecord.emit({ record, onlyView });
102
+ }
103
+
104
+ /**
105
+ * Metodo per duplicare un record della form.
106
+ * @param record Record da duplicare.
107
+ */
108
+ private duplicateRecord(record: Record) {
109
+ this.onDuplicateRecord.emit(record);
110
+ }
111
+
112
+ /**
113
+ * Metodo per eliminare un record dalla lista.
114
+ * @param record Record da eliminare selezionato sulla eqp-table.
115
+ */
116
+ private deleteRecord(record: Record) {
117
+ this.onDeleteRecord.emit(record);
118
+ }
119
+
120
+ /**
121
+ * Metodo per creare la configurazione delle colonne per la eqp-table.
122
+ * Individua i BaseField da mostrare e li usa per creare le ConfigColumn.
123
+ * Le colonne vengono create per i BaseField con il flag InListView a TRUE
124
+ * oppure, nel caso non siano stati specificati i campi da visualizzare,
125
+ * seleziona i primi 6.
126
+ */
127
+ private createColumnsFromFormFields() {
128
+ var fieldsForColumns: Array<BaseField>;
129
+ if (this.form.Fields.find(f => f.InListView)) {
130
+ fieldsForColumns = this.form.Fields.filter(f => f.InListView);
131
+ } else {
132
+ fieldsForColumns = this.form.Fields.filter(f => f.OrdinalPosition < 6);
133
+ }
134
+ fieldsForColumns.sort((a, b) => (a.OrdinalPosition > b.OrdinalPosition) ? 1 : ((b.OrdinalPosition > a.OrdinalPosition) ? -1 : 0))
135
+ .forEach(field => {
136
+ this.columns.push(this.createFieldColumn(field));
137
+ });
138
+ }
139
+
140
+ /**
141
+ * Metodo per creare l'oggetto ConfigureColumn che rappresenta il BaseField passato in input.
142
+ * @param field BaseField per cui creare la colonna nella eqp-table
143
+ * @returns Restituisce una ConfigColumn per la eqp-table
144
+ */
145
+ private createFieldColumn(field: BaseField): ConfigColumn {
146
+ var column: ConfigColumn = { key: field.Name, display: field.Label };
147
+ switch (field.FieldType) {
148
+ case FieldTypeEnum['Booleano']:
149
+ column.type = TypeColumn.Boolean;
150
+ column.booleanValues = { false: '<i class="fa fa-times error-color"></i>', true: '<i class="fa fa-check success-color"></i>' };
151
+ column.styles = { flex: "0 0 7%", cellAlignment: CellAlignmentEnum.CENTER };
152
+ break;
153
+ case FieldTypeEnum['Data e/o ora']:
154
+ if ((field as DateField).IsOnlyDate != DateTimeTypeEnum['Solo orario']) {
155
+ column.type = TypeColumn.Date;
156
+ if ((field as DateField).IsOnlyDate == DateTimeTypeEnum['Data e ora']) {
157
+ column.format = "dd/MM/yyyy HH:mm";
158
+ } else if ((field as DateField).IsOnlyDate == DateTimeTypeEnum['Solo data']) {
159
+ column.format = (field as DateField).DateFormat ? (field as DateField).DateFormat.replace("DD", "dd") : "dd/MM/yyyy";
160
+ }
161
+ }
162
+ break;
163
+ case FieldTypeEnum['Campo numerico']:
164
+ if ((field as NumericField).CurrencySymbol) {
165
+ column.numberPipe = NumberColumnPipe.CURRENCY;
166
+ column.currencyPipeCode = (field as NumericField).CurrencySymbol;
167
+ } else if (!(field as NumericField).IsInteger) {
168
+ column.numberPipe = NumberColumnPipe.DECIMAL;
169
+ }
170
+ break;
171
+ case FieldTypeEnum['Allegato']:
172
+ case FieldTypeEnum['Immagine']:
173
+ column.value = (element: Record) => {
174
+ if ((field as AttachmentField).IsMultiAttach || ((field as ImageField).AttachDefinition && (field as ImageField).AttachDefinition.IsMultiAttach)) {
175
+ return element[field.Name] != null && element[field.Name].length > 0 ? (element[field.Name] as Array<IAttachmentDTO>).map(a => a.FileName).join(", ") : null;
176
+ } else {
177
+ return element[field.Name] != null && element[field.Name].length > 0 ? (element[field.Name] as Array<IAttachmentDTO>)[0].FileName : null;
178
+ }
179
+ };
180
+ column.isSortable = false;
181
+ column.isSearchable = false;
182
+ break;
183
+ case FieldTypeEnum['Elenco generico']:
184
+ column.value = (element: Record) => {
185
+ if ((field as ListValueField).IsMultiChoiche) {
186
+ if (!element[field.Name] || element[field.Name].length == 0) {
187
+ return null;
188
+ } else {
189
+ return Object.keys((field as ListValueField).ValuePairs).filter(k => element[field.Name].includes((field as ListValueField).ValuePairs[k])).join(", ");
190
+ }
191
+ } else {
192
+ return Object.keys((field as ListValueField).ValuePairs).find(k => (field as ListValueField).ValuePairs[k] == element[field.Name]);
193
+ }
194
+ };
195
+ column.isSortable = false;
196
+ column.isSearchable = false;
197
+ break;
198
+ case FieldTypeEnum['Lookup']:
199
+ // TODO
200
+ break;
201
+ }
202
+ return column;
203
+ }
204
+
205
+ /**
206
+ * Metodo per ricaricare i dati della eqp-table.
207
+ */
208
+ private reloadTables() {
209
+ if (this.tableRecords) {
210
+ this.tableRecords.reloadDatatable();
211
+ }
212
+ }
213
+ }
@@ -0,0 +1,3 @@
1
+ <div class="eqp-splash-screen" *ngIf="isLoading | async">
2
+ <div id="loader"></div>
3
+ </div>
@@ -0,0 +1,100 @@
1
+ :host {
2
+ #loader {
3
+ display: block;
4
+ position: relative;
5
+ width: 150px;
6
+ height: 150px;
7
+ border-radius: 50%;
8
+ border: 3px solid transparent;
9
+ border-top-color: var(--primary);
10
+ -webkit-animation: spin 2s linear infinite;
11
+ animation: spin 2s linear infinite;
12
+ }
13
+
14
+ #loader:before {
15
+ content: "";
16
+ position: absolute;
17
+ top: 5px;
18
+ left: 5px;
19
+ right: 5px;
20
+ bottom: 5px;
21
+ border-radius: 50%;
22
+ border: 3px solid transparent;
23
+ border-top-color: var(--primary);
24
+ -webkit-animation: spin 3s linear infinite;
25
+ animation: spin 3s linear infinite;
26
+ }
27
+
28
+ #loader:after {
29
+ content: "";
30
+ position: absolute;
31
+ top: 15px;
32
+ left: 15px;
33
+ right: 15px;
34
+ bottom: 15px;
35
+ border-radius: 50%;
36
+ border: 3px solid transparent;
37
+ border-top-color: var(--primary);
38
+ -webkit-animation: spin 1.5s linear infinite;
39
+ animation: spin 1.5s linear infinite;
40
+ }
41
+
42
+ @-webkit-keyframes spin {
43
+ 0% {
44
+ -webkit-transform: rotate(0deg);
45
+ -ms-transform: rotate(0deg);
46
+ transform: rotate(0deg);
47
+ }
48
+
49
+ 100% {
50
+ -webkit-transform: rotate(360deg);
51
+ -ms-transform: rotate(360deg);
52
+ transform: rotate(360deg);
53
+ }
54
+ }
55
+
56
+ @keyframes spin {
57
+ 0% {
58
+ -webkit-transform: rotate(0deg);
59
+ -ms-transform: rotate(0deg);
60
+ transform: rotate(0deg);
61
+ }
62
+
63
+ 100% {
64
+ -webkit-transform: rotate(360deg);
65
+ -ms-transform: rotate(360deg);
66
+ transform: rotate(360deg);
67
+ }
68
+ }
69
+
70
+ .eqp-splash-screen {
71
+ background-color: #343a4040;
72
+ position: fixed;
73
+ display: flex;
74
+ flex-direction: column;
75
+ align-items: center;
76
+ justify-content: center;
77
+ height: 100%;
78
+ width: 100%;
79
+ z-index: 9999;
80
+
81
+ img {
82
+ margin-left: calc(100vw - 100%);
83
+ width: 90px;
84
+ margin-bottom: 30px;
85
+ }
86
+
87
+ span {
88
+ margin-left: calc(100vw - 100%);
89
+ margin-bottom: 30px;
90
+ }
91
+
92
+ ::ng-deep {
93
+ .mat-progress-spinner circle,
94
+ .mat-spinner circle {
95
+ // brand color
96
+ stroke: #5d78ff;
97
+ }
98
+ }
99
+ }
100
+ }
@@ -0,0 +1,19 @@
1
+ import { Component, OnInit } from '@angular/core';
2
+ import { Subject } from 'rxjs';
3
+ import { SpinnerService } from '../../../services/spinner.service';
4
+
5
+ @Component({
6
+ selector: 'eqp-dynamic-module-spinner',
7
+ templateUrl: './spinner.component.html',
8
+ styleUrls: ['./spinner.component.scss']
9
+ })
10
+ export class SpinnerComponent implements OnInit {
11
+
12
+ isLoading: Subject<boolean> = this.spinnerService.isLoading;
13
+
14
+ constructor(private spinnerService: SpinnerService) { }
15
+
16
+ ngOnInit(): void {
17
+ }
18
+
19
+ }
@@ -0,0 +1,65 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import { NgModule } from '@angular/core';
3
+ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
4
+ import { EqpDynamicModuleComponent } from './components/exported/eqp-dynamic-module/eqp-dynamic-module.component';
5
+ import { MaterialModule } from './modules/material.module';
6
+
7
+ import { EqpTableModule } from '@eqproject/eqp-table';
8
+ import { EqpAttachmentsModule } from '@eqproject/eqp-attachments';
9
+ import { EqpSelectModule } from '@eqproject/eqp-select';
10
+ import { EqpDatetimepickerModule } from '@eqproject/eqp-datetimepicker';
11
+ import { EqpImgDrawingModule } from '@eqproject/eqp-img-drawing';
12
+ import { EqpFiltersModule } from '@eqproject/eqp-filters';
13
+ import { EqpNumericModule } from '@eqproject/eqp-numeric';
14
+ import { EqpDynamicModuleConfiguratorComponent } from './components/exported/eqp-dynamic-module-configurator/eqp-dynamic-module-configurator.component';
15
+ import { AddFormFieldComponent } from './components/private/add-form-field/add-form-field.component';
16
+ import { TextFieldTemplateComponent } from './components/private/field-templates/text-field-template/text-field-template.component';
17
+ import { BooleanFieldTemplateComponent } from './components/private/field-templates/boolean-field-template/boolean-field-template.component';
18
+ import { DateFieldTemplateComponent } from './components/private/field-templates/date-field-template/date-field-template.component';
19
+ import { TextareaFieldTemplateComponent } from './components/private/field-templates/textarea-field-template/textarea-field-template.component';
20
+ import { NumericFieldTemplateComponent } from './components/private/field-templates/numeric-field-template/numeric-field-template.component';
21
+ import { ListValueFieldTemplateComponent } from './components/private/field-templates/list-value-field-template/list-value-field-template.component';
22
+ import { AttachmentFieldTemplateComponent } from './components/private/field-templates/attachment-field-template/attachment-field-template.component';
23
+ import { ImageFieldTemplateComponent } from './components/private/field-templates/image-field-template/image-field-template.component';
24
+ import { ListFormRecordComponent } from './components/private/form-records/list-form-record/list-form-record.component';
25
+ import { AddFormRecordComponent } from './components/private/form-records/add-form-record/add-form-record.component';
26
+ import { DynamicModuleFieldComponent } from './components/private/dynamic-module-field/dynamic-module-field.component';
27
+ import { SpinnerComponent } from './components/private/spinner/spinner.component';
28
+
29
+ @NgModule({
30
+ declarations: [
31
+ EqpDynamicModuleComponent,
32
+ EqpDynamicModuleConfiguratorComponent,
33
+ AddFormFieldComponent,
34
+ TextFieldTemplateComponent,
35
+ BooleanFieldTemplateComponent,
36
+ DateFieldTemplateComponent,
37
+ TextareaFieldTemplateComponent,
38
+ NumericFieldTemplateComponent,
39
+ ListValueFieldTemplateComponent,
40
+ AttachmentFieldTemplateComponent,
41
+ ImageFieldTemplateComponent,
42
+ ListFormRecordComponent,
43
+ AddFormRecordComponent,
44
+ DynamicModuleFieldComponent,
45
+ SpinnerComponent,
46
+ ],
47
+ imports: [
48
+ MaterialModule,
49
+ FormsModule,
50
+ CommonModule,
51
+ ReactiveFormsModule,
52
+ EqpTableModule,
53
+ EqpAttachmentsModule,
54
+ EqpSelectModule,
55
+ EqpDatetimepickerModule,
56
+ EqpFiltersModule,
57
+ EqpNumericModule,
58
+ EqpImgDrawingModule
59
+ ],
60
+ exports: [
61
+ EqpDynamicModuleComponent,
62
+ EqpDynamicModuleConfiguratorComponent
63
+ ]
64
+ })
65
+ export class EqpDynamicModuleModule { }
@@ -5,4 +5,4 @@ export declare interface IBaseFieldComponent {
5
5
  * le formule che utilizzano il campo modificato.
6
6
  */
7
7
  updateField(): void;
8
- }
8
+ }
@@ -7,4 +7,4 @@
7
7
  export interface IRootObject {
8
8
  ID: string;
9
9
  Name: string;
10
- }
10
+ }
@@ -1,10 +1,11 @@
1
1
  import { FormGroup } from '@angular/forms';
2
2
  import { BaseObj } from './baseObj.model';
3
+
3
4
  /**
4
5
  * Contiene le informazioni di base del campo, indipendentemente dal tipo.
5
6
  * Questa classe è volutamente astratta perché il tipo di campo è dettato dal tipo
6
7
  */
7
- export declare class BaseField extends BaseObj {
8
+ export class BaseField extends BaseObj {
8
9
  /**
9
10
  * Nome del campo che per progettazione è una sostituzione della label
10
11
  * Il vero identificativo del campo è l'ID
@@ -15,20 +16,25 @@ export declare class BaseField extends BaseObj {
15
16
  Required: boolean;
16
17
  Formula: string;
17
18
  OrdinalPosition: number;
19
+
18
20
  /**
19
21
  * Entità a cui appartiene il campo. Si tenga presente che sono ammessi anche campi
20
- * di sola visualizzazione e calcolati, da utilizzare nelle form,
22
+ * di sola visualizzazione e calcolati, da utilizzare nelle form,
21
23
  * e per questo motivo possono essere con Entity == null
22
24
  */
23
25
  EntityID: string;
26
+
24
27
  FieldGroup: string;
25
28
  ColSpanSizes: Array<ColSpanSizesEnum>;
26
29
  InListView: boolean;
30
+
31
+ // Proprità client
27
32
  FieldType: FieldTypeEnum;
28
33
  FieldValue: any;
29
34
  FormFormGroup: FormGroup;
30
35
  }
31
- export declare enum FieldTypeEnum {
36
+
37
+ export enum FieldTypeEnum {
32
38
  'Campo di testo' = 1,
33
39
  'Area di testo' = 2,
34
40
  'Booleano' = 3,
@@ -40,17 +46,20 @@ export declare enum FieldTypeEnum {
40
46
  'Lookup' = 9,
41
47
  'Form di dettaglio' = 10
42
48
  }
43
- export declare enum ColSpanSizesEnum {
49
+
50
+ export enum ColSpanSizesEnum {
44
51
  'col-sm-3' = 1,
45
52
  'col-sm-4' = 2,
46
53
  'col-sm-6' = 3,
47
54
  'col-sm-12' = 4,
55
+
48
56
  'col-md-3' = 5,
49
57
  'col-md-4' = 6,
50
58
  'col-md-6' = 7,
51
59
  'col-md-12' = 8,
60
+
52
61
  'col-lg-3' = 9,
53
62
  'col-lg-4' = 10,
54
63
  'col-lg-6' = 11,
55
- 'col-lg-12' = 12
64
+ 'col-lg-12' = 12,
56
65
  }
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Classe base che implementa la valorizzazione dell'ID (se null) con una nuova GUID
2
+ * Classe base che implementa la valorizzazione dell'ID (se null) con una nuova GUID
3
3
  * in creazione dell'oggetto.
4
4
  * Per scelta architetturale, visto che non possiamo assumere la persistenza su DB relazionale o su NOSQL, ogni
5
5
  * oggetto della configurazione viene persistito, e gestito con ID di tipo stringa creato da una GUID.
6
6
  */
7
- export declare class BaseObj {
7
+ export class BaseObj {
8
8
  ID: string;
9
- }
9
+ }
@@ -0,0 +1,10 @@
1
+ export class Context {
2
+ User: ContextUser = new ContextUser();
3
+ Organizzation: string;
4
+ }
5
+
6
+ export class ContextUser {
7
+ Name: string;
8
+ Surname: string;
9
+ Role: string;
10
+ }