@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.
- package/karma.conf.js +32 -0
- package/ng-package.json +18 -0
- package/package.json +31 -41
- package/src/lib/components/exported/eqp-dynamic-module/eqp-dynamic-module.component.html +10 -0
- package/src/lib/components/exported/eqp-dynamic-module/eqp-dynamic-module.component.scss +3 -0
- package/src/lib/components/exported/eqp-dynamic-module/eqp-dynamic-module.component.ts +228 -0
- package/src/lib/components/exported/eqp-dynamic-module-configurator/eqp-dynamic-module-configurator.component.html +212 -0
- package/src/lib/components/exported/eqp-dynamic-module-configurator/eqp-dynamic-module-configurator.component.scss +30 -0
- package/src/lib/components/exported/eqp-dynamic-module-configurator/eqp-dynamic-module-configurator.component.ts +692 -0
- package/src/lib/components/private/add-form-field/add-form-field.component.html +417 -0
- package/src/lib/components/private/add-form-field/add-form-field.component.scss +38 -0
- package/src/lib/components/private/add-form-field/add-form-field.component.ts +599 -0
- package/src/lib/components/private/dynamic-module-field/dynamic-module-field.component.html +42 -0
- package/src/lib/components/private/dynamic-module-field/dynamic-module-field.component.scss +0 -0
- package/src/lib/components/private/dynamic-module-field/dynamic-module-field.component.ts +125 -0
- package/src/lib/components/private/field-templates/attachment-field-template/attachment-field-template.component.html +25 -0
- package/src/lib/components/private/field-templates/attachment-field-template/attachment-field-template.component.scss +0 -0
- package/src/lib/components/private/field-templates/attachment-field-template/attachment-field-template.component.ts +172 -0
- package/src/lib/components/private/field-templates/boolean-field-template/boolean-field-template.component.html +32 -0
- package/src/lib/components/private/field-templates/boolean-field-template/boolean-field-template.component.scss +0 -0
- package/src/lib/components/private/field-templates/boolean-field-template/boolean-field-template.component.ts +53 -0
- package/src/lib/components/private/field-templates/date-field-template/date-field-template.component.html +6 -0
- package/src/lib/components/private/field-templates/date-field-template/date-field-template.component.scss +0 -0
- package/src/lib/components/private/field-templates/date-field-template/date-field-template.component.ts +70 -0
- package/src/lib/components/private/field-templates/image-field-template/image-field-template.component.html +57 -0
- package/src/lib/components/private/field-templates/image-field-template/image-field-template.component.scss +4 -0
- package/src/lib/components/private/field-templates/image-field-template/image-field-template.component.ts +203 -0
- package/src/lib/components/private/field-templates/list-value-field-template/list-value-field-template.component.html +46 -0
- package/src/lib/components/private/field-templates/list-value-field-template/list-value-field-template.component.scss +13 -0
- package/src/lib/components/private/field-templates/list-value-field-template/list-value-field-template.component.ts +114 -0
- package/src/lib/components/private/field-templates/numeric-field-template/numeric-field-template.component.html +6 -0
- package/src/lib/components/private/field-templates/numeric-field-template/numeric-field-template.component.scss +0 -0
- package/src/lib/components/private/field-templates/numeric-field-template/numeric-field-template.component.ts +70 -0
- package/src/lib/components/private/field-templates/text-field-template/text-field-template.component.html +5 -0
- package/src/lib/components/private/field-templates/text-field-template/text-field-template.component.scss +0 -0
- package/src/lib/components/private/field-templates/text-field-template/text-field-template.component.ts +65 -0
- package/src/lib/components/private/field-templates/textarea-field-template/textarea-field-template.component.html +5 -0
- package/src/lib/components/private/field-templates/textarea-field-template/textarea-field-template.component.scss +0 -0
- package/src/lib/components/private/field-templates/textarea-field-template/textarea-field-template.component.ts +48 -0
- package/src/lib/components/private/form-records/add-form-record/add-form-record.component.html +74 -0
- package/src/lib/components/private/form-records/add-form-record/add-form-record.component.scss +0 -0
- package/src/lib/components/private/form-records/add-form-record/add-form-record.component.ts +117 -0
- package/src/lib/components/private/form-records/list-form-record/list-form-record.component.html +14 -0
- package/src/lib/components/private/form-records/list-form-record/list-form-record.component.scss +7 -0
- package/src/lib/components/private/form-records/list-form-record/list-form-record.component.ts +213 -0
- package/src/lib/components/private/spinner/spinner.component.html +3 -0
- package/src/lib/components/private/spinner/spinner.component.scss +100 -0
- package/src/lib/components/private/spinner/spinner.component.ts +19 -0
- package/src/lib/eqp-dynamic-module.module.ts +65 -0
- package/{lib/interfaces/iBaseFieldComponent.interface.d.ts → src/lib/interfaces/iBaseFieldComponent.interface.ts} +1 -1
- package/{lib/interfaces/iRootObject.interface.d.ts → src/lib/interfaces/iRootObject.interface.ts} +1 -1
- package/{lib/models/baseField.model.d.ts → src/lib/models/baseField.model.ts} +14 -5
- package/{lib/models/baseObj.model.d.ts → src/lib/models/baseObj.model.ts} +3 -3
- package/src/lib/models/context.model.ts +10 -0
- package/{lib/models/endPointConfiguration.model.d.ts → src/lib/models/endPointConfiguration.model.ts} +16 -12
- package/{lib/models/entity.model.d.ts → src/lib/models/entity.model.ts} +2 -1
- package/src/lib/models/fields/attachmentField.model.ts +32 -0
- package/{lib/models/fields/booleanField.model.d.ts → src/lib/models/fields/booleanField.model.ts} +8 -4
- package/{lib/models/fields/dateField.model.d.ts → src/lib/models/fields/dateField.model.ts} +5 -3
- package/{lib/models/fields/imageField.model.d.ts → src/lib/models/fields/imageField.model.ts} +8 -3
- package/{lib/models/fields/listValueField.model.d.ts → src/lib/models/fields/listValueField.model.ts} +13 -8
- package/{lib/models/fields/lookupField.model.d.ts → src/lib/models/fields/lookupField.model.ts} +5 -2
- package/{lib/models/fields/numericField.model.d.ts → src/lib/models/fields/numericField.model.ts} +3 -2
- package/{lib/models/fields/testareaField.model.d.ts → src/lib/models/fields/testareaField.model.ts} +3 -2
- package/src/lib/models/fields/textField.model.ts +18 -0
- package/{lib/models/form.model.d.ts → src/lib/models/form.model.ts} +25 -12
- package/{lib/models/record.model.d.ts → src/lib/models/record.model.ts} +4 -5
- package/src/lib/modules/material.module.ts +104 -0
- package/src/lib/services/custom-form-validators.service.ts +21 -0
- package/src/lib/services/eqp-dynamic-module-dialog.service.ts +114 -0
- package/src/lib/services/spinner.service.ts +40 -0
- package/src/lib/services/utilityHelper.services.ts +413 -0
- package/{public-api.d.ts → src/public-api.ts} +3 -0
- package/src/test.ts +26 -0
- package/tsconfig.lib.json +23 -0
- package/tsconfig.lib.prod.json +6 -0
- package/tsconfig.spec.json +17 -0
- package/tslint.json +17 -0
- package/bundles/eqproject-eqp-dynamic-module.umd.js +0 -3991
- package/bundles/eqproject-eqp-dynamic-module.umd.js.map +0 -1
- package/bundles/eqproject-eqp-dynamic-module.umd.min.js +0 -17
- package/bundles/eqproject-eqp-dynamic-module.umd.min.js.map +0 -1
- package/eqproject-eqp-dynamic-module.d.ts +0 -6
- package/eqproject-eqp-dynamic-module.metadata.json +0 -1
- package/esm2015/eqproject-eqp-dynamic-module.js +0 -7
- package/esm2015/lib/components/exported/eqp-dynamic-module/eqp-dynamic-module.component.js +0 -262
- package/esm2015/lib/components/exported/eqp-dynamic-module-configurator/eqp-dynamic-module-configurator.component.js +0 -649
- package/esm2015/lib/components/private/add-form-field/add-form-field.component.js +0 -577
- package/esm2015/lib/components/private/dynamic-module-field/dynamic-module-field.component.js +0 -127
- package/esm2015/lib/components/private/field-templates/attachment-field-template/attachment-field-template.component.js +0 -170
- package/esm2015/lib/components/private/field-templates/boolean-field-template/boolean-field-template.component.js +0 -56
- package/esm2015/lib/components/private/field-templates/date-field-template/date-field-template.component.js +0 -71
- package/esm2015/lib/components/private/field-templates/image-field-template/image-field-template.component.js +0 -196
- package/esm2015/lib/components/private/field-templates/list-value-field-template/list-value-field-template.component.js +0 -115
- package/esm2015/lib/components/private/field-templates/numeric-field-template/numeric-field-template.component.js +0 -71
- package/esm2015/lib/components/private/field-templates/text-field-template/text-field-template.component.js +0 -67
- package/esm2015/lib/components/private/field-templates/textarea-field-template/textarea-field-template.component.js +0 -51
- package/esm2015/lib/components/private/form-records/add-form-record/add-form-record.component.js +0 -130
- package/esm2015/lib/components/private/form-records/list-form-record/list-form-record.component.js +0 -216
- package/esm2015/lib/components/private/spinner/spinner.component.js +0 -23
- package/esm2015/lib/eqp-dynamic-module.module.js +0 -69
- package/esm2015/lib/interfaces/iBaseFieldComponent.interface.js +0 -1
- package/esm2015/lib/interfaces/iRootObject.interface.js +0 -1
- package/esm2015/lib/models/baseField.model.js +0 -36
- package/esm2015/lib/models/baseObj.model.js +0 -9
- package/esm2015/lib/models/context.model.js +0 -8
- package/esm2015/lib/models/endPointConfiguration.model.js +0 -23
- package/esm2015/lib/models/entity.model.js +0 -7
- package/esm2015/lib/models/fields/attachmentField.model.js +0 -22
- package/esm2015/lib/models/fields/booleanField.model.js +0 -12
- package/esm2015/lib/models/fields/dateField.model.js +0 -11
- package/esm2015/lib/models/fields/imageField.model.js +0 -8
- package/esm2015/lib/models/fields/listValueField.model.js +0 -14
- package/esm2015/lib/models/fields/lookupField.model.js +0 -5
- package/esm2015/lib/models/fields/numericField.model.js +0 -5
- package/esm2015/lib/models/fields/testareaField.model.js +0 -4
- package/esm2015/lib/models/fields/textField.model.js +0 -14
- package/esm2015/lib/models/form.model.js +0 -24
- package/esm2015/lib/models/record.model.js +0 -8
- package/esm2015/lib/modules/material.module.js +0 -108
- package/esm2015/lib/services/custom-form-validators.service.js +0 -19
- package/esm2015/lib/services/eqp-dynamic-module-dialog.service.js +0 -113
- package/esm2015/lib/services/spinner.service.js +0 -43
- package/esm2015/lib/services/utilityHelper.services.js +0 -387
- package/esm2015/public-api.js +0 -39
- package/esm5/eqproject-eqp-dynamic-module.js +0 -7
- package/esm5/lib/components/exported/eqp-dynamic-module/eqp-dynamic-module.component.js +0 -269
- package/esm5/lib/components/exported/eqp-dynamic-module-configurator/eqp-dynamic-module-configurator.component.js +0 -664
- package/esm5/lib/components/private/add-form-field/add-form-field.component.js +0 -588
- package/esm5/lib/components/private/dynamic-module-field/dynamic-module-field.component.js +0 -128
- package/esm5/lib/components/private/field-templates/attachment-field-template/attachment-field-template.component.js +0 -173
- package/esm5/lib/components/private/field-templates/boolean-field-template/boolean-field-template.component.js +0 -57
- package/esm5/lib/components/private/field-templates/date-field-template/date-field-template.component.js +0 -72
- package/esm5/lib/components/private/field-templates/image-field-template/image-field-template.component.js +0 -206
- package/esm5/lib/components/private/field-templates/list-value-field-template/list-value-field-template.component.js +0 -119
- package/esm5/lib/components/private/field-templates/numeric-field-template/numeric-field-template.component.js +0 -72
- package/esm5/lib/components/private/field-templates/text-field-template/text-field-template.component.js +0 -68
- package/esm5/lib/components/private/field-templates/textarea-field-template/textarea-field-template.component.js +0 -52
- package/esm5/lib/components/private/form-records/add-form-record/add-form-record.component.js +0 -133
- package/esm5/lib/components/private/form-records/list-form-record/list-form-record.component.js +0 -220
- package/esm5/lib/components/private/spinner/spinner.component.js +0 -24
- package/esm5/lib/eqp-dynamic-module.module.js +0 -72
- package/esm5/lib/interfaces/iBaseFieldComponent.interface.js +0 -1
- package/esm5/lib/interfaces/iRootObject.interface.js +0 -1
- package/esm5/lib/models/baseField.model.js +0 -43
- package/esm5/lib/models/baseObj.model.js +0 -13
- package/esm5/lib/models/context.model.js +0 -14
- package/esm5/lib/models/endPointConfiguration.model.js +0 -33
- package/esm5/lib/models/entity.model.js +0 -14
- package/esm5/lib/models/fields/attachmentField.model.js +0 -29
- package/esm5/lib/models/fields/booleanField.model.js +0 -19
- package/esm5/lib/models/fields/dateField.model.js +0 -18
- package/esm5/lib/models/fields/imageField.model.js +0 -19
- package/esm5/lib/models/fields/listValueField.model.js +0 -25
- package/esm5/lib/models/fields/lookupField.model.js +0 -12
- package/esm5/lib/models/fields/numericField.model.js +0 -12
- package/esm5/lib/models/fields/testareaField.model.js +0 -11
- package/esm5/lib/models/fields/textField.model.js +0 -21
- package/esm5/lib/models/form.model.js +0 -39
- package/esm5/lib/models/record.model.js +0 -14
- package/esm5/lib/modules/material.module.js +0 -111
- package/esm5/lib/services/custom-form-validators.service.js +0 -23
- package/esm5/lib/services/eqp-dynamic-module-dialog.service.js +0 -123
- package/esm5/lib/services/spinner.service.js +0 -46
- package/esm5/lib/services/utilityHelper.services.js +0 -396
- package/esm5/public-api.js +0 -39
- package/fesm2015/eqproject-eqp-dynamic-module.js +0 -3580
- package/fesm2015/eqproject-eqp-dynamic-module.js.map +0 -1
- package/fesm5/eqproject-eqp-dynamic-module.js +0 -3766
- package/fesm5/eqproject-eqp-dynamic-module.js.map +0 -1
- package/lib/components/exported/eqp-dynamic-module/eqp-dynamic-module.component.d.ts +0 -101
- package/lib/components/exported/eqp-dynamic-module-configurator/eqp-dynamic-module-configurator.component.d.ts +0 -235
- package/lib/components/private/add-form-field/add-form-field.component.d.ts +0 -199
- package/lib/components/private/dynamic-module-field/dynamic-module-field.component.d.ts +0 -55
- package/lib/components/private/field-templates/attachment-field-template/attachment-field-template.component.d.ts +0 -68
- package/lib/components/private/field-templates/boolean-field-template/boolean-field-template.component.d.ts +0 -21
- package/lib/components/private/field-templates/date-field-template/date-field-template.component.d.ts +0 -27
- package/lib/components/private/field-templates/image-field-template/image-field-template.component.d.ts +0 -65
- package/lib/components/private/field-templates/list-value-field-template/list-value-field-template.component.d.ts +0 -51
- package/lib/components/private/field-templates/numeric-field-template/numeric-field-template.component.d.ts +0 -26
- package/lib/components/private/field-templates/text-field-template/text-field-template.component.d.ts +0 -22
- package/lib/components/private/field-templates/textarea-field-template/textarea-field-template.component.d.ts +0 -20
- package/lib/components/private/form-records/add-form-record/add-form-record.component.d.ts +0 -52
- package/lib/components/private/form-records/list-form-record/list-form-record.component.d.ts +0 -64
- package/lib/components/private/spinner/spinner.component.d.ts +0 -9
- package/lib/eqp-dynamic-module.module.d.ts +0 -2
- package/lib/models/context.model.d.ts +0 -9
- package/lib/models/fields/attachmentField.model.d.ts +0 -17
- package/lib/models/fields/textField.model.d.ts +0 -15
- package/lib/modules/material.module.d.ts +0 -2
- package/lib/services/custom-form-validators.service.d.ts +0 -5
- package/lib/services/eqp-dynamic-module-dialog.service.d.ts +0 -34
- package/lib/services/spinner.service.d.ts +0 -15
- package/lib/services/utilityHelper.services.d.ts +0 -77
|
@@ -0,0 +1,692 @@
|
|
|
1
|
+
import { Component, EventEmitter, Input, OnInit, Output, TemplateRef, ViewChild } from '@angular/core';
|
|
2
|
+
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
|
|
3
|
+
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
|
|
4
|
+
import { CellAlignmentEnum, ConfigColumn, EqpTableComponent, TypeColumn } from '@eqproject/eqp-table';
|
|
5
|
+
import { BaseField, FieldTypeEnum } from '../../../models/baseField.model';
|
|
6
|
+
import { Context } from '../../../models/context.model';
|
|
7
|
+
import { EndPointConfiguration, EndPointData, EndPointDataParams, ParamTypeEnum } from '../../../models/endPointConfiguration.model';
|
|
8
|
+
import { ActionOnRecord, Form, FormFieldGroup, FormScalarTypeEnum, FormTypeEnum } from '../../../models/form.model';
|
|
9
|
+
import { ArrayValidators } from '../../../services/custom-form-validators.service';
|
|
10
|
+
import { EqpDynamicModuleDialogService } from '../../../services/eqp-dynamic-module-dialog.service';
|
|
11
|
+
import { UtilityHelperService } from '../../../services/utilityHelper.services';
|
|
12
|
+
|
|
13
|
+
@Component({
|
|
14
|
+
selector: 'eqp-dynamic-module-configurator',
|
|
15
|
+
templateUrl: './eqp-dynamic-module-configurator.component.html',
|
|
16
|
+
styleUrls: ['./eqp-dynamic-module-configurator.component.scss']
|
|
17
|
+
})
|
|
18
|
+
export class EqpDynamicModuleConfiguratorComponent implements OnInit {
|
|
19
|
+
|
|
20
|
+
@Input() context: Context = new Context();
|
|
21
|
+
@Input() form: Form = new Form();
|
|
22
|
+
@Input() formID: string = null;
|
|
23
|
+
@Input() innerFormManagment: boolean = false;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Url del server da chiamare per recuerare, salvare o eliminare i record.
|
|
27
|
+
* Usato per creare la configurazione di default degli endpoint da chiamare.
|
|
28
|
+
*/
|
|
29
|
+
@Input() baseServerUrl: string = null;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Token da usare negli endpoint da chiamare per recuperare o salvare i record.
|
|
33
|
+
* Usato solo se viene popolata la proprietà "baseServerUrl".
|
|
34
|
+
*/
|
|
35
|
+
@Input() userToken: string = null;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Configurazione degli endpoint da chiamare per recuperare o salvare i dati.
|
|
39
|
+
* Può essere definita dall'utente oppure lasciata null, viene popolata con dei
|
|
40
|
+
* valori di default se viene valorizzata la proprietà "baseServerUrl" altrimenti
|
|
41
|
+
* viene lasciata null e non viene eseguita nessuna chiamata al server.
|
|
42
|
+
*/
|
|
43
|
+
@Input() endPointConfiguration: EndPointConfiguration = null;
|
|
44
|
+
|
|
45
|
+
formFormGroup: FormGroup;
|
|
46
|
+
formCompleted = false;
|
|
47
|
+
previewForm: Form;
|
|
48
|
+
formFieldGroupName: string;
|
|
49
|
+
|
|
50
|
+
actionAutocompleteOptions: Array<{ label: string, value: string }>;
|
|
51
|
+
|
|
52
|
+
//#region Enumeratori usati nell'html
|
|
53
|
+
FormTypeEnum = FormTypeEnum;
|
|
54
|
+
FormScalarTypeEnum = FormScalarTypeEnum;
|
|
55
|
+
//#endregion
|
|
56
|
+
|
|
57
|
+
//#region Proprietà per creazione/modifica campo
|
|
58
|
+
fieldsColumns: Array<ConfigColumn>;
|
|
59
|
+
@ViewChild('fieldsTable', { static: false }) fieldsTable: EqpTableComponent;
|
|
60
|
+
selectedField: BaseField | any;
|
|
61
|
+
indexSelectedField: number;
|
|
62
|
+
actionOnRecordFormGroup: FormGroup;
|
|
63
|
+
dialogFieldRef: MatDialogRef<TemplateRef<any>>;
|
|
64
|
+
@ViewChild('dialogField', { static: true }) dialogField: TemplateRef<any>;
|
|
65
|
+
@ViewChild('fieldSectionColumnTemplate', { static: true }) fieldSectionColumnTemplate: TemplateRef<any>;
|
|
66
|
+
//#endregion
|
|
67
|
+
|
|
68
|
+
//#region Proprietà per creare/modificare una Form di dettaglio
|
|
69
|
+
selectedInnerForm: Form;
|
|
70
|
+
indexSelectedInnerForm: number;
|
|
71
|
+
dialogInnerFormRef: MatDialogRef<TemplateRef<any>>;
|
|
72
|
+
@ViewChild('dialogInnerForm', { static: true }) dialogInnerForm: TemplateRef<any>;
|
|
73
|
+
//#endregion
|
|
74
|
+
|
|
75
|
+
//#region Proprietà per creare/modificare una action sui record di una Form
|
|
76
|
+
actionsOnRecordColumns: Array<ConfigColumn>;
|
|
77
|
+
@ViewChild('actionsOnRecordTable', { static: false }) actionsOnRecordTable: EqpTableComponent;
|
|
78
|
+
selectedAction: ActionOnRecord;
|
|
79
|
+
indexSelectedAction: number;
|
|
80
|
+
dialogActionOnRecordRef: MatDialogRef<TemplateRef<any>>;
|
|
81
|
+
@ViewChild('dialogActionOnRecord', { static: true }) dialogActionOnRecord: TemplateRef<any>;
|
|
82
|
+
//#endregion
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Evento emesso quando si salva una form e non è stato specificato un endpoint da chiamare.
|
|
86
|
+
*/
|
|
87
|
+
@Output() saveFormEvent: EventEmitter<Form> = new EventEmitter<Form>();
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Evento emesso DOPO aver eseguito una chiamata al server per il salvataggiodi una form all'endpoint specificato.
|
|
91
|
+
*/
|
|
92
|
+
@Output() afterSaveFormEvent: EventEmitter<Form> = new EventEmitter<Form>();
|
|
93
|
+
|
|
94
|
+
constructor(
|
|
95
|
+
private formBuilder: FormBuilder,
|
|
96
|
+
private dialog: MatDialog,
|
|
97
|
+
private utilityHelperService: UtilityHelperService
|
|
98
|
+
) { }
|
|
99
|
+
|
|
100
|
+
ngOnInit(): void {
|
|
101
|
+
this.configureDefaultEndPoints();
|
|
102
|
+
this.getFormByID();
|
|
103
|
+
if (this.context) {
|
|
104
|
+
UtilityHelperService.SetContext(this.context);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Metodo per configurare gli endpoint da usare di default a partire dall'url base del server
|
|
110
|
+
* a cui si deve connettere e al token da passare per autenticarsi.
|
|
111
|
+
* Se la proprietà baseServerUrl è null e non sono stati configurati i vari endpoint allora
|
|
112
|
+
* non viene eseguita nessuna chiamata http per recuperare/salvare i dati.
|
|
113
|
+
*/
|
|
114
|
+
configureDefaultEndPoints() {
|
|
115
|
+
if (!this.endPointConfiguration && this.baseServerUrl) {
|
|
116
|
+
this.endPointConfiguration = this.utilityHelperService.ConfigureDefaultEndPoints(this.baseServerUrl, this.userToken);
|
|
117
|
+
if (this.formID) {
|
|
118
|
+
this.endPointConfiguration.Forms.GetByIDEndPoint.Params = [{ ParamName: 'id', ParamValue: this.formID, ParamType: ParamTypeEnum['Query param'] }];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Metodo per recuperare tutti i record salvati per una particolare Form.
|
|
125
|
+
* La chiamata viene effettuata solo se è stato configurato l'endPoint da usare.
|
|
126
|
+
*/
|
|
127
|
+
getFormByID() {
|
|
128
|
+
if (this.formID && this.endPointConfiguration && this.endPointConfiguration.Forms && this.endPointConfiguration.Forms.GetByIDEndPoint) {
|
|
129
|
+
this.utilityHelperService.RunEndPointCall(this.endPointConfiguration.Forms.GetByIDEndPoint, null, (res: Form) => {
|
|
130
|
+
this.setFormAndConfigure(res);
|
|
131
|
+
}, (err) => {
|
|
132
|
+
this.setFormAndConfigure(new Form());
|
|
133
|
+
});
|
|
134
|
+
} else {
|
|
135
|
+
this.setFormAndConfigure();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Metodo invocato al cambio del tipo di visualizzazione della form.
|
|
141
|
+
* Se l'utente sceglie una visualizzazione raggruppata il metodo aggiunge al FormGroup un nuovo
|
|
142
|
+
* controllo per l'array dei nomi delle sezioni da creare.
|
|
143
|
+
*/
|
|
144
|
+
onChangeFormScalarType() {
|
|
145
|
+
if (this.form.FormScalarType != FormScalarTypeEnum.Semplice) {
|
|
146
|
+
if (!this.formFormGroup.contains("FormFieldsGroups")) {
|
|
147
|
+
this.formFormGroup.removeControl("FormFieldsGroups");
|
|
148
|
+
this.formFormGroup.addControl("FormFieldsGroups", new FormControl(this.form.FormFieldsGroups, [Validators.required, ArrayValidators.minLenght(1)]));
|
|
149
|
+
}
|
|
150
|
+
} else {
|
|
151
|
+
this.form.FormFieldsGroups = null;
|
|
152
|
+
if (this.formFormGroup.contains("FormFieldsGroups"))
|
|
153
|
+
this.formFormGroup.removeControl("FormFieldsGroups");
|
|
154
|
+
}
|
|
155
|
+
this.formFormGroup.updateValueAndValidity();
|
|
156
|
+
this.configureColumns();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Evento invocato al keyup nell'input per inserire i nomi delle sezioni per la visualizzazione
|
|
161
|
+
* raggruppata della form. Quanto l'utente preme il tasto invio viene aggiunto il nuovo nome alle
|
|
162
|
+
* sezioni dispobili se non ne esiste una con lo stesso nome.
|
|
163
|
+
* @param event Evento che rappresenta il keyup sulla tastiera.
|
|
164
|
+
*/
|
|
165
|
+
onFormFieldGroupNameKeyUp(event) {
|
|
166
|
+
if (event.code === 'Enter' || event.code === 'NumpadEnter') {
|
|
167
|
+
if (!this.form.FormFieldsGroups) {
|
|
168
|
+
this.form.FormFieldsGroups = new Array<FormFieldGroup>();
|
|
169
|
+
}
|
|
170
|
+
if (!this.form.FormFieldsGroups.find(n => n.Name == this.formFieldGroupName)) {
|
|
171
|
+
this.form.FormFieldsGroups.push({ Name: this.formFieldGroupName });
|
|
172
|
+
}
|
|
173
|
+
// Imposto il nuovo valore del FormControl per aggiornare lo stato della form.
|
|
174
|
+
this.formFormGroup.controls["FormFieldsGroups"].setValue(this.form.FormFieldsGroups);
|
|
175
|
+
this.formFieldGroupName = null;
|
|
176
|
+
this.setFormFieldGroupOrdinalPosition();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Metodo per rimuovere la sezione selezionata da quelle disponibili per la form.
|
|
182
|
+
* @param groupName Nome della sezione da eliminare.
|
|
183
|
+
*/
|
|
184
|
+
onDeleteFormFieldGroupName(groupName: string) {
|
|
185
|
+
this.form.FormFieldsGroups.splice(this.form.FormFieldsGroups.findIndex(g => g.Name === groupName), 1);
|
|
186
|
+
// Imposto il nuovo valore del FormControl per aggiornare lo stato della form.
|
|
187
|
+
this.formFormGroup.controls["FormFieldsGroups"].setValue(this.form.FormFieldsGroups);
|
|
188
|
+
// Se esistono Field legati alla sezione che si vuole eliminare allora rompo il legame.
|
|
189
|
+
if (this.form.Fields.find(f => f.FieldGroup == groupName)) {
|
|
190
|
+
this.form.Fields.filter(f => f.FieldGroup == groupName).forEach(f => f.FieldGroup = null);
|
|
191
|
+
}
|
|
192
|
+
this.setFormFieldGroupOrdinalPosition();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Metodo chiamato quando si vuole aggiungere un nuovo campo o si vuole modificare uno esistente.
|
|
197
|
+
* Memorizza l'eventuale Field scelto one crea uno nuovo prima di aprire il dialog per modificarlo/aggiungerlo.
|
|
198
|
+
* @param field Oggetto BaseField da modificare. Se null ne viene creata una nuova istanza per l'aggiunta.
|
|
199
|
+
*/
|
|
200
|
+
openFieldDialog(field: BaseField = null) {
|
|
201
|
+
if (field) {
|
|
202
|
+
this.indexSelectedField = this.form.Fields.indexOf(field);
|
|
203
|
+
this.selectedField = JSON.parse(JSON.stringify(field));
|
|
204
|
+
} else {
|
|
205
|
+
this.selectedField = new BaseField();
|
|
206
|
+
this.indexSelectedField = null;
|
|
207
|
+
}
|
|
208
|
+
this.dialogFieldRef = this.dialog.open(this.dialogField, {
|
|
209
|
+
disableClose: true,
|
|
210
|
+
hasBackdrop: true,
|
|
211
|
+
width: '75%'
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Metodo che salva il campo appena creato o modificato.
|
|
217
|
+
* Prima del salvataggio controlla se esiste un altro campo con la stessa label, in questo
|
|
218
|
+
* case genere un errore (i campi devono avere nomi, e quindi label, univoche - i nomi vengono
|
|
219
|
+
* ricavati unendo le parole che formano la label tramite "_").
|
|
220
|
+
* @param field Campo da salvare
|
|
221
|
+
*/
|
|
222
|
+
onSaveField(field: BaseField) {
|
|
223
|
+
if (field) {
|
|
224
|
+
if (
|
|
225
|
+
this.form.Fields
|
|
226
|
+
&& this.form.Fields.find(
|
|
227
|
+
(f, i) => f.Label === field.Label
|
|
228
|
+
&& (this.indexSelectedField == null ? true : this.indexSelectedField !== i)
|
|
229
|
+
)
|
|
230
|
+
) {
|
|
231
|
+
EqpDynamicModuleDialogService.Warning('Impossibile inserire due campi con la stessa label.');
|
|
232
|
+
throw new Error('Impossibile inserire due campi con la stessa label.');
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (this.indexSelectedField != null && this.indexSelectedField >= 0) {
|
|
236
|
+
this.form.Fields[this.indexSelectedField] = field;
|
|
237
|
+
} else {
|
|
238
|
+
if (!this.form.Fields) {
|
|
239
|
+
this.form.Fields = new Array<BaseField>();
|
|
240
|
+
}
|
|
241
|
+
this.form.Fields.push(field);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
this.closeFieldDialog();
|
|
245
|
+
this.setFieldOrdinalPosition();
|
|
246
|
+
this.reloadFieldsTable();
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Metodo che controlla se lo step per l'aggiunta dei campi nella form è concluso.
|
|
251
|
+
* @returns Se TRUE lo step viene considerato completato ed è possbile passare al successivo.
|
|
252
|
+
*/
|
|
253
|
+
isFieldStepCompleted(): boolean {
|
|
254
|
+
if (!this.form.Fields) {
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
if (this.form.FormScalarType != FormScalarTypeEnum.Semplice && this.form.Fields.find(f => !f.FieldGroup)) {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
return this.form.Fields.length > 0;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Metodo per aprire il dialog di creazione/modifica delle form di dettaglio.
|
|
265
|
+
* Se il parametro passato è null sono in aggiunta altrimenti sono in modifica.
|
|
266
|
+
* @param innenrForm Form di dettaglio da modificare (se null allora vado in add).
|
|
267
|
+
*/
|
|
268
|
+
openInnerFormDialog(innenrForm: Form = null) {
|
|
269
|
+
if (innenrForm) {
|
|
270
|
+
this.indexSelectedInnerForm = this.form.InnerForms.indexOf(innenrForm);
|
|
271
|
+
this.selectedInnerForm = JSON.parse(JSON.stringify(innenrForm));
|
|
272
|
+
this.selectedInnerForm.OldName = innenrForm.Name;
|
|
273
|
+
this.indexSelectedField = this.form.Fields.findIndex(f => f.Label === innenrForm.Name);
|
|
274
|
+
} else {
|
|
275
|
+
this.selectedInnerForm = new Form();
|
|
276
|
+
this.indexSelectedInnerForm = null;
|
|
277
|
+
this.indexSelectedField = null;
|
|
278
|
+
}
|
|
279
|
+
this.dialogInnerFormRef = this.dialog.open(this.dialogInnerForm, {
|
|
280
|
+
disableClose: true,
|
|
281
|
+
hasBackdrop: true,
|
|
282
|
+
width: '85%'
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Metodo scatenato al salvataggio di una form di dettaglio.
|
|
288
|
+
* @param event Form creata/modificata dall'utente. Se è null allora l'utente ha abbandonato la configurazione.
|
|
289
|
+
*/
|
|
290
|
+
onSaveOrExitInnerForm(event: Form) {
|
|
291
|
+
if (event != null) {
|
|
292
|
+
if (this.form.Name === event.Name ||
|
|
293
|
+
(
|
|
294
|
+
this.form.InnerForms
|
|
295
|
+
&& this.form.InnerForms.find(
|
|
296
|
+
(a, i) => a.Name === event.Name
|
|
297
|
+
&& (this.indexSelectedInnerForm == null ? true : this.indexSelectedInnerForm !== i)
|
|
298
|
+
)
|
|
299
|
+
) ||
|
|
300
|
+
(
|
|
301
|
+
this.form.Fields
|
|
302
|
+
&& this.indexSelectedInnerForm == null
|
|
303
|
+
&& this.form.Fields.find(
|
|
304
|
+
(f, i) => f.Label === event.Name
|
|
305
|
+
&& (this.indexSelectedField == null ? true : this.indexSelectedField !== i)
|
|
306
|
+
)
|
|
307
|
+
)
|
|
308
|
+
) {
|
|
309
|
+
EqpDynamicModuleDialogService.Warning('Impossibile inserire due form di dettaglio con lo stesso nome.');
|
|
310
|
+
throw new Error('Impossibile inserire due form di dettaglio con lo stesso nome.');
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const innerFormField: BaseField = new BaseField();
|
|
314
|
+
innerFormField.Name = event.Name.split(" ").join("_");
|
|
315
|
+
innerFormField.Label = event.Name;
|
|
316
|
+
innerFormField.FieldType = FieldTypeEnum['Form di dettaglio'];
|
|
317
|
+
innerFormField.FieldGroup = this.indexSelectedField != null ? this.form.Fields[this.indexSelectedField].FieldGroup : null;
|
|
318
|
+
|
|
319
|
+
if (this.indexSelectedInnerForm != null && this.indexSelectedInnerForm >= 0) {
|
|
320
|
+
this.form.InnerForms[this.indexSelectedInnerForm] = event;
|
|
321
|
+
this.form.Fields[this.indexSelectedField] = innerFormField;
|
|
322
|
+
} else {
|
|
323
|
+
if (!this.form.InnerForms) {
|
|
324
|
+
this.form.InnerForms = new Array<Form>();
|
|
325
|
+
}
|
|
326
|
+
this.form.InnerForms.push(event);
|
|
327
|
+
this.form.Fields.push(innerFormField);
|
|
328
|
+
}
|
|
329
|
+
this.reloadFieldsTable();
|
|
330
|
+
}
|
|
331
|
+
this.dialogInnerFormRef.close();
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Metodo per aprire il dialog di creazione/modifica delle action.
|
|
336
|
+
* Se il parametro passato è null sono in aggiunta altrimenti sono in modifica.
|
|
337
|
+
* @param action ActionOnRecord da modificare (se null allora vado in add).
|
|
338
|
+
*/
|
|
339
|
+
openActionOnRecordDialog(action: ActionOnRecord = null) {
|
|
340
|
+
if (action) {
|
|
341
|
+
this.indexSelectedAction = this.form.ActionsOnRecord.indexOf(action);
|
|
342
|
+
this.selectedAction = JSON.parse(JSON.stringify(action));
|
|
343
|
+
} else {
|
|
344
|
+
this.selectedAction = new ActionOnRecord();
|
|
345
|
+
this.indexSelectedAction = null;
|
|
346
|
+
}
|
|
347
|
+
this.createActionOnRecordForm();
|
|
348
|
+
this.dialogActionOnRecordRef = this.dialog.open(this.dialogActionOnRecord, {
|
|
349
|
+
disableClose: true,
|
|
350
|
+
hasBackdrop: true,
|
|
351
|
+
width: '75%'
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Metodo per impostare i valori da suggerire nell'autocomplete del campo Formula.
|
|
357
|
+
* Viene scatenato al focus (in questo caso viene passato il parametro a null per differenziarlo
|
|
358
|
+
* dall'evento di click sulla tastiera) e al keyup sull'input (il parametro è diverso da null).
|
|
359
|
+
* @param keyboardEvent Evento scatenato al keyup sulla tastiera. Se null allora il metodo è stato invocato dal focus sull'input.
|
|
360
|
+
* @summary Aggiorna l'elenco dei suggerimenti per l'autocomplete se l'utente esegue il focus sull'input
|
|
361
|
+
* oppure al keyup sulla tastiera di un tasto diverso dalle frecce.
|
|
362
|
+
*/
|
|
363
|
+
setActionAutocompleteOptions(keyboardEvent: KeyboardEvent) {
|
|
364
|
+
// Creo l'array per l'autocomplete solo se sto facendo il focus sull'input o se sto premendo un tasto
|
|
365
|
+
// sulla tastiera diverso dalle frecce (in quest'ultimo caso, se non viene eseguito il filtro sull'evento,
|
|
366
|
+
// non si può selezionare un suggerimento dell'autocomplete perchè al click verrebbe ricaricato l'array e
|
|
367
|
+
// si prederebbe la selezione appena fatta).
|
|
368
|
+
if (!keyboardEvent || !keyboardEvent.code.includes("Arrow")) {
|
|
369
|
+
this.actionAutocompleteOptions = UtilityHelperService.GetAutocompleteOptions(this.form.Fields, this.selectedAction.Action);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Metodo per salvare l'azione creata/modificate.
|
|
375
|
+
*/
|
|
376
|
+
saveActionOnRecord() {
|
|
377
|
+
if (
|
|
378
|
+
this.form.ActionsOnRecord
|
|
379
|
+
&& this.form.ActionsOnRecord.find(
|
|
380
|
+
(a, i) => a.Name === this.selectedAction.Name
|
|
381
|
+
&& (this.indexSelectedAction == null ? true : this.indexSelectedAction !== i)
|
|
382
|
+
)
|
|
383
|
+
) {
|
|
384
|
+
EqpDynamicModuleDialogService.Warning('Impossibile inserire due action con lo stesso nome.');
|
|
385
|
+
throw new Error('Impossibile inserire due action con lo stesso nome.');
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (this.indexSelectedAction != null && this.indexSelectedAction >= 0) {
|
|
389
|
+
this.form.ActionsOnRecord[this.indexSelectedAction] = this.selectedAction;
|
|
390
|
+
} else {
|
|
391
|
+
if (!this.form.ActionsOnRecord) {
|
|
392
|
+
this.form.ActionsOnRecord = new Array<ActionOnRecord>();
|
|
393
|
+
}
|
|
394
|
+
this.form.ActionsOnRecord.push(this.selectedAction);
|
|
395
|
+
}
|
|
396
|
+
this.closeDialogActionOnRecord();
|
|
397
|
+
this.setActionOrdinalPosition();
|
|
398
|
+
this.reloadActionsOnRecordTable();
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Metodo per chiudere il dialog di gestione delle action.
|
|
403
|
+
*/
|
|
404
|
+
closeDialogActionOnRecord() {
|
|
405
|
+
this.dialogActionOnRecordRef.close();
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Metodo per segnare come conclusa la creazione della form e per crearne una copia
|
|
410
|
+
* da visalizzare come anteprima.
|
|
411
|
+
* @param completed Se TRUE segna la form come conclusa e ne crea una copia da visualizzare
|
|
412
|
+
*/
|
|
413
|
+
setFormStatus(completed: boolean) {
|
|
414
|
+
if (completed) {
|
|
415
|
+
this.formCompleted = true;
|
|
416
|
+
this.previewForm = JSON.parse(JSON.stringify(this.form));
|
|
417
|
+
|
|
418
|
+
// Per visualizzare correttamente l'oanteprima della form appena creata
|
|
419
|
+
// bisogna valorizzare la proprietà Name dei campi della form e delle InnerForms.
|
|
420
|
+
this.previewForm.Fields.forEach(field => { field.Name = field.Label.split(' ').join('_'); });
|
|
421
|
+
if (this.previewForm.InnerForms && this.previewForm.InnerForms.length > 0) {
|
|
422
|
+
this.previewForm.InnerForms.forEach(form => {
|
|
423
|
+
form.Fields.forEach(field => { field.Name = field.Label.split(' ').join('_'); });
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
} else {
|
|
427
|
+
this.formCompleted = false;
|
|
428
|
+
this.previewForm = null;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Metodo per salvare la form creata alla fine del wizard.
|
|
434
|
+
* Se è stato configurato un endPoint per il salvataggio viene effettuata una chiamata al server passando l'oggeto da salvare
|
|
435
|
+
* nel body della chiamata, altrimenti scatena l'evento "saveFormEvent".
|
|
436
|
+
* NOTA: Per comunicare correttamente con la parte server del modulo dinamico bisogna modificare l'array dei Fields.
|
|
437
|
+
* Al posto di passare un array di BaseField bisogna passare un array di oggetti del tipo { FieldType: FieldTypeEnum, Value: BaseField }.
|
|
438
|
+
*/
|
|
439
|
+
saveForm() {
|
|
440
|
+
if (this.endPointConfiguration != null && this.endPointConfiguration.Forms.SaveEndPoint) {
|
|
441
|
+
|
|
442
|
+
// Copio la form da salvare per riwrappare i Fields in oggetti del tipo { FieldType: FieldTypeEnum, Value: BaseField }.
|
|
443
|
+
// Necessario per far funzionare correttamente il FieldConverter del server.
|
|
444
|
+
const formToSave = JSON.parse(JSON.stringify(this.form));
|
|
445
|
+
|
|
446
|
+
/*formToSave.Fields = [];
|
|
447
|
+
this.form.Fields.forEach(field => {
|
|
448
|
+
formToSave.Fields.push({
|
|
449
|
+
FieldType: field.FieldType,
|
|
450
|
+
Value: JSON.parse(JSON.stringify(field))
|
|
451
|
+
});
|
|
452
|
+
});*/
|
|
453
|
+
|
|
454
|
+
formToSave.Fields = [];
|
|
455
|
+
this.form.Fields.forEach(field => {
|
|
456
|
+
|
|
457
|
+
let fld = UtilityHelperService.GetFieldType(field);
|
|
458
|
+
|
|
459
|
+
formToSave.Fields.push(fld);
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
const dynamicModuleParams = [
|
|
463
|
+
{ ParamName: "Form", ParamValue: formToSave, ParamType: ParamTypeEnum['In Body'] }
|
|
464
|
+
];
|
|
465
|
+
|
|
466
|
+
this.utilityHelperService.RunEndPointCall(this.endPointConfiguration.Forms.SaveEndPoint, dynamicModuleParams, (res) => {
|
|
467
|
+
EqpDynamicModuleDialogService.Success("Form salvata con successo!");
|
|
468
|
+
this.afterSaveFormEvent.emit(this.form);
|
|
469
|
+
});
|
|
470
|
+
} else {
|
|
471
|
+
this.saveFormEvent.emit(this.form);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
//#region FUNZIONI PRIVATE
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Metodo per impostare la form e configurare colonne/FormGourp.
|
|
479
|
+
* @param form Form da utilizzare.
|
|
480
|
+
*/
|
|
481
|
+
private setFormAndConfigure(form: Form = null) {
|
|
482
|
+
if (form != null) {
|
|
483
|
+
this.form = form;
|
|
484
|
+
}
|
|
485
|
+
this.configureColumns();
|
|
486
|
+
this.createFormForm();
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Configura le colonne per le tabelle necessarie alla creazione della form:
|
|
491
|
+
* - per la visualizzazione dei campi inseriti
|
|
492
|
+
* - per le form di dettaglio create
|
|
493
|
+
* - per le azioni configurate sui record della form
|
|
494
|
+
*/
|
|
495
|
+
private configureColumns() {
|
|
496
|
+
this.fieldsColumns = [
|
|
497
|
+
{
|
|
498
|
+
key: 'action', display: '', type: TypeColumn.MenuAction, buttonMenuIcon: 'more_vert', styles: { flex: '0 0 6%' },
|
|
499
|
+
actions: [
|
|
500
|
+
{ name: 'Modifica', icon: 'edit', fn: (element, index, col) => this.editField(element) },
|
|
501
|
+
{ name: 'Elimina', icon: 'delete', fn: (element, index, col) => this.deleteElement(element, "Fields") },
|
|
502
|
+
{
|
|
503
|
+
name: 'Sposta su', icon: 'arrow_upward',
|
|
504
|
+
fn: (element, index, col) => this.moveElement(element, true, "Fields"),
|
|
505
|
+
disabled: (element) => this.form.Fields.indexOf(element) === 0
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
name: 'Sposta giù', icon: 'arrow_downward',
|
|
509
|
+
fn: (element, index, col) => this.moveElement(element, false, "Fields"),
|
|
510
|
+
disabled: (element) => this.form.Fields.indexOf(element) >= (this.form.Fields.length - 1)
|
|
511
|
+
},
|
|
512
|
+
]
|
|
513
|
+
},
|
|
514
|
+
{ key: 'FieldType', display: 'Tipologia', type: TypeColumn.Enum, enumModel: FieldTypeEnum },
|
|
515
|
+
{ key: 'Label', display: 'Label' },
|
|
516
|
+
{ key: 'Description', display: 'Descrizione' },
|
|
517
|
+
{
|
|
518
|
+
key: 'Required', display: 'Obbligatorio',
|
|
519
|
+
value: (element) => !!element.Required,
|
|
520
|
+
type: TypeColumn.Boolean,
|
|
521
|
+
booleanValues: {
|
|
522
|
+
true: '<i class="fa fa-check success-color"></i>',
|
|
523
|
+
false: '<i class="fa fa-close error-color"></i>'
|
|
524
|
+
},
|
|
525
|
+
styles: { flex: '0 0 7%', cellAlignment: CellAlignmentEnum.CENTER }
|
|
526
|
+
},
|
|
527
|
+
];
|
|
528
|
+
|
|
529
|
+
if (this.form.FormScalarType && this.form.FormScalarType != FormScalarTypeEnum.Semplice) {
|
|
530
|
+
this.fieldsColumns.splice(
|
|
531
|
+
this.fieldsColumns.findIndex(c => c.key == 'Description'), 0,
|
|
532
|
+
{ key: 'FieldGroup', display: 'Sezione', type: TypeColumn.ExternalTemplate, externalTemplate: this.fieldSectionColumnTemplate }
|
|
533
|
+
);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
this.actionsOnRecordColumns = [
|
|
537
|
+
{
|
|
538
|
+
key: 'action', display: '', type: TypeColumn.MenuAction, buttonMenuIcon: 'more_vert', styles: { flex: '0 0 6%' },
|
|
539
|
+
actions: [
|
|
540
|
+
{ name: 'Modifica', icon: 'edit', fn: (element, index, col) => this.openActionOnRecordDialog(element) },
|
|
541
|
+
{ name: 'Elimina', icon: 'delete', fn: (element, index, col) => this.deleteElement(element, "ActionsOnRecord") },
|
|
542
|
+
{
|
|
543
|
+
name: 'Sposta su', icon: 'arrow_upward',
|
|
544
|
+
fn: (element, index, col) => this.moveElement(element, true, "ActionsOnRecord"),
|
|
545
|
+
disabled: (element) => this.form.ActionsOnRecord.indexOf(element) === 0
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
name: 'Sposta giù', icon: 'arrow_downward',
|
|
549
|
+
fn: (element, index, col) => this.moveElement(element, false, "ActionsOnRecord"),
|
|
550
|
+
disabled: (element) => this.form.ActionsOnRecord.indexOf(element) >= (this.form.ActionsOnRecord.length - 1)
|
|
551
|
+
},
|
|
552
|
+
]
|
|
553
|
+
},
|
|
554
|
+
{ key: 'Icon', display: 'Icona', styles: { flex: ' 0 0 15%' } },
|
|
555
|
+
{ key: 'Name', display: 'Nome', styles: { flex: ' 0 0 20%' } },
|
|
556
|
+
{ key: 'Action', display: 'Azione' },
|
|
557
|
+
];
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Crea il FormGroup per l'oggetto Form
|
|
562
|
+
*/
|
|
563
|
+
private createFormForm() {
|
|
564
|
+
this.formFormGroup = this.formBuilder.group({
|
|
565
|
+
Name: [this.form.Name, Validators.required],
|
|
566
|
+
FormScalarType: [this.form.FormScalarType, Validators.required],
|
|
567
|
+
});
|
|
568
|
+
this.onChangeFormScalarType();
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Crea il FormGroup epr l'aggiunta o la modifica di una action sui record della Form.
|
|
573
|
+
*/
|
|
574
|
+
private createActionOnRecordForm() {
|
|
575
|
+
this.actionOnRecordFormGroup = this.formBuilder.group({
|
|
576
|
+
Name: [this.selectedAction.Name, Validators.required],
|
|
577
|
+
Icon: [this.selectedAction.Icon, Validators.required],
|
|
578
|
+
Action: [this.selectedAction.Action, Validators.required],
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Chiude il dialog per aggiungere/modificare un Field senza salvare
|
|
584
|
+
*/
|
|
585
|
+
private closeFieldDialog() {
|
|
586
|
+
this.dialogFieldRef.close();
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Metodo per gestire l'apertura del dialog per la modifica di un Field.
|
|
591
|
+
* Se il field è di tipo "Form di dettaglio" apre il dialog per la modifica di una
|
|
592
|
+
* InnerForm altrimenti apre quello per la modifica di un Field.
|
|
593
|
+
* @param field Campo da modificare
|
|
594
|
+
*/
|
|
595
|
+
private editField(field: BaseField) {
|
|
596
|
+
if (field.FieldType != FieldTypeEnum['Form di dettaglio']) {
|
|
597
|
+
this.openFieldDialog(field);
|
|
598
|
+
} else {
|
|
599
|
+
this.openInnerFormDialog(this.form.InnerForms.find(f => f.Name == field.Label));
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Metodo per rimuovere un Field all'interno di una Form.
|
|
605
|
+
* Richiede conferma all'utente prima di rimuoverlo.
|
|
606
|
+
* @param field BaseField da rimuovere
|
|
607
|
+
*/
|
|
608
|
+
private deleteElement(element: BaseField | ActionOnRecord | Form, propertyName: string) {
|
|
609
|
+
EqpDynamicModuleDialogService.Confirm('Eliminare l\'elemento selezionato?', () => {
|
|
610
|
+
this.form[propertyName].splice(this.form[propertyName].indexOf(element), 1);
|
|
611
|
+
if (propertyName === "Fields") {
|
|
612
|
+
this.setFieldOrdinalPosition();
|
|
613
|
+
this.reloadFieldsTable();
|
|
614
|
+
} else if (propertyName === "ActionsOnRecord") {
|
|
615
|
+
this.setActionOrdinalPosition();
|
|
616
|
+
this.reloadActionsOnRecordTable();
|
|
617
|
+
}
|
|
618
|
+
}, false, 'Richiesta conferma');
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Metodo per spostare un campo all'interno della form.
|
|
623
|
+
* @param field Oggetto di tipo BaseField da spostare.
|
|
624
|
+
* @param moveUp Se TRUE allora sposta verso l'alto il campo (abbassa l'indice) altrimenti il contrario.
|
|
625
|
+
*/
|
|
626
|
+
private moveElement(element: BaseField | ActionOnRecord, moveUp: boolean, propertyName: string) {
|
|
627
|
+
const startingIndex = this.form[propertyName].indexOf(element);
|
|
628
|
+
const endingIndex = startingIndex + (moveUp ? -1 : 1);
|
|
629
|
+
|
|
630
|
+
this.form[propertyName].splice(startingIndex, 1);
|
|
631
|
+
this.form[propertyName].splice(endingIndex, 0, element);
|
|
632
|
+
|
|
633
|
+
if (propertyName === "Fields") {
|
|
634
|
+
this.setFieldOrdinalPosition();
|
|
635
|
+
this.reloadFieldsTable();
|
|
636
|
+
} else if (propertyName === "ActionsOnRecord") {
|
|
637
|
+
this.setActionOrdinalPosition();
|
|
638
|
+
this.reloadActionsOnRecordTable();
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Imposta l'ordinamento delle sezioni che compongono la form.
|
|
644
|
+
*/
|
|
645
|
+
private setFormFieldGroupOrdinalPosition() {
|
|
646
|
+
this.form.FormFieldsGroups.forEach((g, i) => g.OrdinalPosition = i);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Imposta l'ordinamento dei campi all'interno della form in base all'ordine che l'utente
|
|
651
|
+
* ha definito nella tabella in cui sono mostrati
|
|
652
|
+
*/
|
|
653
|
+
private setFieldOrdinalPosition() {
|
|
654
|
+
if (this.form.Fields) {
|
|
655
|
+
this.form.Fields.forEach(field => {
|
|
656
|
+
field.OrdinalPosition = this.form.Fields.indexOf(field);
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Metodo per ricaricare i dati della tabella dei campi aggiunti in una form
|
|
663
|
+
*/
|
|
664
|
+
private reloadFieldsTable() {
|
|
665
|
+
if (this.fieldsTable) {
|
|
666
|
+
this.fieldsTable.reloadDatatable();
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* Imposta l'ordinamento dei campi all'interno della form in base all'ordine che l'utente
|
|
672
|
+
* ha definito nella tabella in cui sono mostrati
|
|
673
|
+
*/
|
|
674
|
+
private setActionOrdinalPosition() {
|
|
675
|
+
if (this.form.ActionsOnRecord) {
|
|
676
|
+
this.form.ActionsOnRecord.forEach(action => {
|
|
677
|
+
action.OrdinalPosition = this.form.ActionsOnRecord.indexOf(action);
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Metodo per ricaricare i dati della tabella delle azioni aggiuntive sui record della Form.
|
|
684
|
+
*/
|
|
685
|
+
private reloadActionsOnRecordTable() {
|
|
686
|
+
if (this.actionsOnRecordTable) {
|
|
687
|
+
this.actionsOnRecordTable.reloadDatatable();
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
//#endregion
|
|
692
|
+
}
|