@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,203 @@
|
|
|
1
|
+
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, TemplateRef, ViewChild } from '@angular/core';
|
|
2
|
+
import { ImageField } from '../../../../models/fields/imageField.model';
|
|
3
|
+
import { AvailableImageExtensions } from '../../../../models/fields/attachmentField.model';
|
|
4
|
+
import { Record } from '../../../../models/record.model';
|
|
5
|
+
import { IBaseFieldComponent } from '../../../../interfaces/iBaseFieldComponent.interface';
|
|
6
|
+
import { UtilityHelperService } from '../../../../services/utilityHelper.services';
|
|
7
|
+
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
|
|
8
|
+
import { FormGroup } from '@angular/forms';
|
|
9
|
+
import { I18nInterface } from '@eqproject/eqp-img-drawing';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Metodo per recuperare, a partire da un Blob, la stringa contenente il base64 del file.
|
|
13
|
+
* Usato per prendere il base64 dell'immagine dopo che l'utente ci ha disegnato sopra.
|
|
14
|
+
* @param file Blob che rappresenta l'immagine.
|
|
15
|
+
*/
|
|
16
|
+
const toBase64 = file => new Promise<string>((resolve, reject) => {
|
|
17
|
+
const reader = new FileReader();
|
|
18
|
+
reader.readAsDataURL(file);
|
|
19
|
+
reader.onload = () => resolve(reader.result.toString());
|
|
20
|
+
reader.onerror = error => reject(error);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
@Component({
|
|
24
|
+
selector: 'image-field-template',
|
|
25
|
+
templateUrl: './image-field-template.component.html',
|
|
26
|
+
styleUrls: ['./image-field-template.component.scss']
|
|
27
|
+
})
|
|
28
|
+
export class ImageFieldTemplateComponent implements OnInit, OnChanges, IBaseFieldComponent {
|
|
29
|
+
|
|
30
|
+
@Input() record: Record;
|
|
31
|
+
@Input() field: ImageField;
|
|
32
|
+
@Output() recordChange: EventEmitter<Record> = new EventEmitter<Record>();
|
|
33
|
+
|
|
34
|
+
preLoadedImageMetadataFormGroup: FormGroup;
|
|
35
|
+
|
|
36
|
+
//#region Proprietà per configurare il componente ngx-image-drawing e aprire il relativo dialog.
|
|
37
|
+
public width = null;
|
|
38
|
+
public height = null;
|
|
39
|
+
public i18n: I18nInterface = {
|
|
40
|
+
saveBtn: 'Salva modifiche',
|
|
41
|
+
cancelBtn: 'Ricarica originale'
|
|
42
|
+
};
|
|
43
|
+
dialogImageDrowingRef: MatDialogRef<TemplateRef<any>>;
|
|
44
|
+
@ViewChild("dialogImageDrowing", { static: true }) dialogImageDrowing: TemplateRef<any>;
|
|
45
|
+
//#endregion
|
|
46
|
+
|
|
47
|
+
constructor(
|
|
48
|
+
private dialog: MatDialog,
|
|
49
|
+
public utilityService: UtilityHelperService
|
|
50
|
+
) { }
|
|
51
|
+
|
|
52
|
+
ngOnInit(): void {
|
|
53
|
+
this.field.AttachDefinition.FormFormGroup = this.field.FormFormGroup;
|
|
54
|
+
|
|
55
|
+
if (!this.field.AttachDefinition.AllowedExtensions) {
|
|
56
|
+
this.field.AttachDefinition.AllowedExtensions = AvailableImageExtensions.map(ext => ext.key);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
this.field.AttachDefinition.Name = this.field.Name;
|
|
60
|
+
this.field.AttachDefinition.Label = this.field.Label;
|
|
61
|
+
this.field.AttachDefinition.Description = this.field.Description;
|
|
62
|
+
this.field.AttachDefinition.Required = this.field.Required;
|
|
63
|
+
this.field.AttachDefinition.Formula = this.field.Formula;
|
|
64
|
+
this.field.AttachDefinition.FieldValue = this.field.FieldValue;
|
|
65
|
+
|
|
66
|
+
// Se il campo prevede un'immagine pre-caricata (ImageIsContextualAttachment == true) sulla quale
|
|
67
|
+
// l'utente può disegnare (EnableDrawing == true) e non sono in modifica di un record (ovvero nel record
|
|
68
|
+
// non ho un'immagine già salvata) allora imposta l'immagine pre caricata come valore iniziale
|
|
69
|
+
// nel record corrente e ne recupera le dimensioni per visualizzare correttamente l'area in cui
|
|
70
|
+
// l'utente può disegnare. Se non effettua modifiche o non salva i disegni fatti viene salvata
|
|
71
|
+
// l'immagine originale.
|
|
72
|
+
if (this.field.ImageIsContextualAttachment && this.field.ContextualAttachment) {
|
|
73
|
+
if (!this.record[this.field.Name] || !Array.isArray(this.record[this.field.Name]) || !(this.record[this.field.Name].length > 0)) {
|
|
74
|
+
this.record[this.field.Name] = [JSON.parse(JSON.stringify(this.field.ContextualAttachment))];
|
|
75
|
+
}
|
|
76
|
+
this.preLoadedImageMetadataFormGroup = this.utilityService.CreateFormFormGroup(this.field.AttachDefinition.MetadataFields, this.record[this.field.Name][0]);
|
|
77
|
+
this.getImageDimensions();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
ngOnChanges(changes: SimpleChanges) {
|
|
82
|
+
// Se viene modificato il valore di "ngModelInput" allora aggiorna l'input
|
|
83
|
+
if (changes['record'] != undefined && changes['record'].firstChange == false && JSON.stringify(changes['record'].currentValue) != JSON.stringify(changes['record'].previousValue)) {
|
|
84
|
+
this.record = changes['record'].currentValue;
|
|
85
|
+
this.updateField();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
updateMetadataValidity() {
|
|
91
|
+
if (this.preLoadedImageMetadataFormGroup.invalid) {
|
|
92
|
+
this.field.FormFormGroup.controls[this.field.Name].setErrors({ 'incorrect': true });
|
|
93
|
+
} else {
|
|
94
|
+
this.field.FormFormGroup.controls[this.field.Name].setErrors(null);
|
|
95
|
+
}
|
|
96
|
+
this.onRecordValueChange();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Metodo per aggiornare il valore del campo quando questo è rappresentato da una formula.
|
|
102
|
+
*/
|
|
103
|
+
updateField() {
|
|
104
|
+
if (this.field.Formula) {
|
|
105
|
+
this.record[this.field.Name] = UtilityHelperService.EvaluateFieldFormula(this.field.Formula, this.record, null);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
resetPreLoadedImage() {
|
|
111
|
+
this.width = null;
|
|
112
|
+
this.height = null;
|
|
113
|
+
this.record[this.field.Name] = [JSON.parse(JSON.stringify(this.field.ContextualAttachment))];
|
|
114
|
+
this.getImageDimensions();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Metodo invocato quando vengono aggiunti o eliminati gli allegati nel componente AttachmentFieldTemplate.
|
|
119
|
+
* Se l'ImageField è abilitato al disegno (EnableDrawing == true), non permette allegati multipli (IsMulitAttach == false)
|
|
120
|
+
* e nel Record corrente è presente l'immagine caricata dall'utente allora recupera le dimensioni dell'immagine e
|
|
121
|
+
* apre il dialog con il componente image-drawing per permettere il disegno sull'immagine appena caricata.
|
|
122
|
+
*/
|
|
123
|
+
onAttachmentsChange() {
|
|
124
|
+
if (!this.field.AttachDefinition.IsMultiAttach && this.field.EnableDrawing && this.record[this.field.Name] && this.record[this.field.Name][0]) {
|
|
125
|
+
this.getImageDimensions();
|
|
126
|
+
this.dialogImageDrowingRef = this.dialog.open(this.dialogImageDrowing, {
|
|
127
|
+
disableClose: true,
|
|
128
|
+
hasBackdrop: true,
|
|
129
|
+
width: '75%'
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Metodo invocato al salvataggio dell'immagine dal componente image-drawing.
|
|
136
|
+
* Trasforma il Blob ricevuto in un base64, aggiorna il FileContetType e il FileDataBase64
|
|
137
|
+
* dell'allegato caricato e chiude il dialog in cui disegnare.
|
|
138
|
+
* @param drawnPicture Blob dell'immagine disegnata.
|
|
139
|
+
*/
|
|
140
|
+
async saveDrowning(drawnPicture: Blob) {
|
|
141
|
+
let base64File = await toBase64(drawnPicture);
|
|
142
|
+
if (base64File) {
|
|
143
|
+
this.record[this.field.Name][0].FileContentType = base64File.split(",")[0].split(":")[1].split(";")[0];
|
|
144
|
+
this.record[this.field.Name][0].FileDataBase64 = base64File.split(",")[1];
|
|
145
|
+
}
|
|
146
|
+
if (this.dialogImageDrowingRef) {
|
|
147
|
+
this.closeImageDrowingDialog();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Metodo per chiudere il dialog in cui disegnare sull'immagine cariata e svuotare le dimensioni.
|
|
153
|
+
*/
|
|
154
|
+
closeImageDrowingDialog() {
|
|
155
|
+
this.dialogImageDrowingRef.close();
|
|
156
|
+
this.width = null;
|
|
157
|
+
this.height = null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Metodo per recuperare le dimensioni dell'immagine caricata per mostrare correttamente
|
|
162
|
+
* il componente image-drawing. Se non viene eseguito questo passaggio l'area in cui disegnare
|
|
163
|
+
* è più grande dell'immagine stessa e al salvataggio i tratti disegnati vengono spostati.
|
|
164
|
+
*/
|
|
165
|
+
private getImageDimensions() {
|
|
166
|
+
var blob: Blob = this.getBlobFromBase64();
|
|
167
|
+
const reader = new FileReader();
|
|
168
|
+
reader.onload = (e: any) => {
|
|
169
|
+
const image = new Image();
|
|
170
|
+
image.src = e.target.result;
|
|
171
|
+
image.onload = rs => {
|
|
172
|
+
this.height = rs.currentTarget['height'];
|
|
173
|
+
this.width = rs.currentTarget['width'];
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
reader.readAsDataURL(blob);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Metodo per convertire il base64 di un'immagine in un Blob.
|
|
181
|
+
* Necessario per il recupero delle dimensioni dell'immagine caricata a partire dal suo base64.
|
|
182
|
+
* Viene eseguito solo nel caso in cui l'ImageField non ammette allegati multipli.
|
|
183
|
+
* @returns Restituisce il Blob dell'immagine caricata.
|
|
184
|
+
*/
|
|
185
|
+
private getBlobFromBase64() {
|
|
186
|
+
const byteCharacters = atob(this.record[this.field.Name][0].FileDataBase64);
|
|
187
|
+
const byteNumbers = new Array(byteCharacters.length);
|
|
188
|
+
for (let i = 0; i < byteCharacters.length; i++) {
|
|
189
|
+
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
|
190
|
+
}
|
|
191
|
+
const byteArray = new Uint8Array(byteNumbers);
|
|
192
|
+
return new Blob([byteArray], { type: this.record[this.field.Name][0].FileContentType });
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Metodo per emettere l'evento che il valore del record è cambiato.
|
|
197
|
+
*/
|
|
198
|
+
private onRecordValueChange() {
|
|
199
|
+
if (!this.field.Formula) {
|
|
200
|
+
this.recordChange.emit(this.record);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<eqp-select *ngIf="field.PresentationMode == ListPresentationEnum['Combo box']" [arrayData]="arrayData"
|
|
2
|
+
[arrayKeyProperty]="'Value'" [showCancelButton]="!field.Required" [arrayValueProperty]="'Key'"
|
|
3
|
+
[formGroupInput]="field.FormFormGroup" [formControlNameInput]="field.Name" [placeholder]="field.Label"
|
|
4
|
+
[includeFullObject]="false" [isRequired]="field.Required" [isDisabled]="field.FormFormGroup.disabled"
|
|
5
|
+
[(ngModelInput)]="record[field.Name]" [isMultiSelect]="field.IsMultiChoiche"
|
|
6
|
+
(ngModelInputChange)="onRecordValueChange()">
|
|
7
|
+
</eqp-select>
|
|
8
|
+
|
|
9
|
+
<div *ngIf="field.PresentationMode != ListPresentationEnum['Combo box']" [formGroup]="field.FormFormGroup">
|
|
10
|
+
|
|
11
|
+
<mat-label class="mr-3"> {{field.Label + (field.Required ? " *" : "")}} </mat-label>
|
|
12
|
+
|
|
13
|
+
<!-- VISUALIZZAZIONE A RADIO BUTTON (SENZA SELEZIONE MULTIPLA) -->
|
|
14
|
+
<mat-radio-group *ngIf="field.PresentationMode == ListPresentationEnum['Radio button'] && !field.IsMultiChoiche"
|
|
15
|
+
[formControlName]="field.Name" [disabled]="field.FormFormGroup.disabled" [required]="field.Required"
|
|
16
|
+
[(ngModel)]="record[field.Name]" (ngModelChange)="onRecordValueChange()">
|
|
17
|
+
<mat-radio-button class="mr-2" *ngFor="let data of arrayData" [value]="data.Value" color="primary">
|
|
18
|
+
{{data.Key}}
|
|
19
|
+
</mat-radio-button>
|
|
20
|
+
</mat-radio-group>
|
|
21
|
+
|
|
22
|
+
<!-- VISUALIZZAZIONE A CHECKBOX (SELEZIONE MULTIPLA) -->
|
|
23
|
+
<div class="d-inline-block"
|
|
24
|
+
*ngIf="field.PresentationMode == ListPresentationEnum['Radio button'] && field.IsMultiChoiche">
|
|
25
|
+
<mat-checkbox class="mr-2" *ngFor="let data of arrayData" [disabled]="field.FormFormGroup.disabled"
|
|
26
|
+
[formControlName]="field.Name" [(ngModel)]="data.Selected" (ngModelChange)="updateSelected()">
|
|
27
|
+
{{data.Key}}
|
|
28
|
+
</mat-checkbox>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<!-- VISUALIZZAZIONE A PULSANTI (CON TESTO O IMMAGINI) -->
|
|
32
|
+
<div class="d-inline-block"
|
|
33
|
+
*ngIf="[ListPresentationEnum['Pulsante con testo'], ListPresentationEnum.Immagini].includes(field.PresentationMode)">
|
|
34
|
+
<button mat-raised-button color="primary" class="btn btn-primary m-1 data-button" *ngFor="let data of arrayData"
|
|
35
|
+
[ngClass]="{'selected-button': data.Selected == true, 'p-0': field.PresentationMode == ListPresentationEnum.Immagini}"
|
|
36
|
+
(click)="buttonSelectClick(data)" [disabled]="field.FormFormGroup.disabled">
|
|
37
|
+
|
|
38
|
+
<!-- TESTO DEL PULSANTE -->
|
|
39
|
+
<span *ngIf="field.PresentationMode == ListPresentationEnum['Pulsante con testo']"> {{data.Key}}</span>
|
|
40
|
+
|
|
41
|
+
<!-- IMMAGINE DEL PULSANTE -->
|
|
42
|
+
<img *ngIf="field.PresentationMode == ListPresentationEnum.Immagini" [src]="data.ImgUrl">
|
|
43
|
+
</button>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
</div>
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
|
|
2
|
+
import { Record } from '../../../../models/record.model';
|
|
3
|
+
import { ListPresentationEnum, ListValueField } from '../../../../models/fields/listValueField.model';
|
|
4
|
+
import { IBaseFieldComponent } from '../../../../interfaces/iBaseFieldComponent.interface';
|
|
5
|
+
import { UtilityHelperService } from '../../../../services/utilityHelper.services';
|
|
6
|
+
|
|
7
|
+
@Component({
|
|
8
|
+
selector: 'list-value-field-template',
|
|
9
|
+
templateUrl: './list-value-field-template.component.html',
|
|
10
|
+
styleUrls: ['./list-value-field-template.component.scss']
|
|
11
|
+
})
|
|
12
|
+
export class ListValueFieldTemplateComponent implements OnInit, OnChanges, IBaseFieldComponent {
|
|
13
|
+
|
|
14
|
+
@Input() field: ListValueField;
|
|
15
|
+
@Input() record: Record;
|
|
16
|
+
@Output() recordChange: EventEmitter<Record> = new EventEmitter<Record>();
|
|
17
|
+
|
|
18
|
+
ListPresentationEnum = ListPresentationEnum;
|
|
19
|
+
arrayData: { Key: string, Value: any, Selected?: boolean, ImgUrl?: string }[] = [];
|
|
20
|
+
|
|
21
|
+
constructor() { }
|
|
22
|
+
|
|
23
|
+
ngOnInit(): void {
|
|
24
|
+
this.setArrayData();
|
|
25
|
+
if (this.field.IsMultiChoiche && !this.record[this.field.Name]) {
|
|
26
|
+
this.record[this.field.Name] = [];
|
|
27
|
+
}
|
|
28
|
+
// Nel caso in cui sono in modifica di un Record aggiorno il valore
|
|
29
|
+
// e il validator del FormControl. Se non viene eseguita questa riga
|
|
30
|
+
// l'utente deve modificare la selezione fatta per aggiornare la form.
|
|
31
|
+
this.setFormControlValue();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
ngOnChanges(changes: SimpleChanges) {
|
|
35
|
+
// Se viene modificato il valore di "ngModelInput" allora aggiorna l'input
|
|
36
|
+
if (changes['record'] != undefined && changes['record'].firstChange == false && JSON.stringify(changes['record'].currentValue) != JSON.stringify(changes['record'].previousValue)) {
|
|
37
|
+
this.record = changes['record'].currentValue;
|
|
38
|
+
this.updateField();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Metodo per aggiornare il valore del campo quando questo è rappresentato da una formula.
|
|
44
|
+
*/
|
|
45
|
+
updateField() {
|
|
46
|
+
if (this.field.Formula) {
|
|
47
|
+
this.record[this.field.Name] = UtilityHelperService.EvaluateFieldFormula(this.field.Formula, this.record, null);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Metodo invocato quando viene selezionata un'opzione nella visualizzazione a button
|
|
53
|
+
* @param data Rappresenta l'oggetto selezionato
|
|
54
|
+
*/
|
|
55
|
+
buttonSelectClick(data: { Key: string, Value: any, Selected?: boolean, ImgUrl?: string }) {
|
|
56
|
+
data.Selected = !data.Selected;
|
|
57
|
+
if (this.field.IsMultiChoiche) {
|
|
58
|
+
this.updateSelected(false);
|
|
59
|
+
} else {
|
|
60
|
+
this.arrayData.filter(d => d.Key != data.Key && d.Value != data.Value).forEach(d => d.Selected = false);
|
|
61
|
+
this.record[this.field.Name] = data.Value;
|
|
62
|
+
}
|
|
63
|
+
this.onRecordValueChange();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Metodo per aggiornare il/i valore/i selezionato/i dall'utente.
|
|
68
|
+
* @param emitChange Se true scatena l'evento di output della modifica del valore di record
|
|
69
|
+
*/
|
|
70
|
+
updateSelected(emitChange: boolean = true) {
|
|
71
|
+
this.record[this.field.Name] = this.arrayData.filter(data => data.Selected).map(data => data.Value);
|
|
72
|
+
this.setFormControlValue();
|
|
73
|
+
if (emitChange) {
|
|
74
|
+
this.onRecordValueChange();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Metodo per emettere l'evento che il valore del record è cambiato.
|
|
80
|
+
*/
|
|
81
|
+
onRecordValueChange() {
|
|
82
|
+
if (!this.field.Formula) {
|
|
83
|
+
this.recordChange.emit(this.record);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Metodo per creare un array di oggetti del tipo { Key: string, Value: any } da usare come sorgente dati per la eqp-select.
|
|
89
|
+
*/
|
|
90
|
+
private setArrayData() {
|
|
91
|
+
if (this.field.PresentationMode != ListPresentationEnum.Immagini) {
|
|
92
|
+
Object.keys(this.field.ValuePairs).forEach(k => { this.createArrayDataElement(k, this.field.ValuePairs[k]); });
|
|
93
|
+
} else {
|
|
94
|
+
this.field.ButtonImageList.forEach(i => { this.createArrayDataElement(i.ButtonKey, i.ButtonValue, 'data:' + i.FileContentType + ';base64,' + i.FileDataBase64); });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
private createArrayDataElement(key: string, value: string, imgUrl: string = null) {
|
|
99
|
+
var isOptionSelected: boolean;
|
|
100
|
+
if (this.field.IsMultiChoiche && this.record[this.field.Name] && this.record[this.field.Name].length > 0) {
|
|
101
|
+
isOptionSelected = !!this.record[this.field.Name].find(v => v == value);
|
|
102
|
+
} else {
|
|
103
|
+
isOptionSelected = this.record[this.field.Name] === value;
|
|
104
|
+
}
|
|
105
|
+
this.arrayData.push({ Key: key, Value: value, Selected: isOptionSelected, ImgUrl: imgUrl });
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Metodo per aggiornare il valore e il validator del FormControl associato al campo.
|
|
110
|
+
*/
|
|
111
|
+
private setFormControlValue() {
|
|
112
|
+
this.field.FormFormGroup.controls[this.field.Name].setValue(this.record[this.field.Name]);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<mat-form-field [formGroup]="field.FormFormGroup">
|
|
2
|
+
<mat-label> {{field.Label}} </mat-label>
|
|
3
|
+
<input matInput eqpNumericMask [formControlName]="field.Name" [disabled]="field.FormFormGroup.disabled"
|
|
4
|
+
[required]="field.Required" [(ngModel)]="record[field.Name]" [options]="eqpNumericOptions"
|
|
5
|
+
[step]="field.IsInteger ? 1 : null" (ngModelChange)="onRecordValueChange()" />
|
|
6
|
+
</mat-form-field>
|
|
File without changes
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
|
|
2
|
+
import { EqpNumericInputMode, NumericMaskConfig } from '@eqproject/eqp-numeric';
|
|
3
|
+
import { UtilityHelperService } from '../../../../services/utilityHelper.services';
|
|
4
|
+
import { Record } from '../../../../models/record.model';
|
|
5
|
+
import { NumericField } from '../../../../models/fields/numericField.model';
|
|
6
|
+
import { IBaseFieldComponent } from '../../../../interfaces/iBaseFieldComponent.interface';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'numeric-field-template',
|
|
10
|
+
templateUrl: './numeric-field-template.component.html',
|
|
11
|
+
styleUrls: ['./numeric-field-template.component.scss']
|
|
12
|
+
})
|
|
13
|
+
export class NumericFieldTemplateComponent implements OnInit, OnChanges, IBaseFieldComponent {
|
|
14
|
+
|
|
15
|
+
@Input() field: NumericField;
|
|
16
|
+
@Input() record: Record;
|
|
17
|
+
@Output() recordChange: EventEmitter<Record> = new EventEmitter<Record>();
|
|
18
|
+
|
|
19
|
+
eqpNumericOptions: Partial<NumericMaskConfig> = {};
|
|
20
|
+
|
|
21
|
+
constructor() { }
|
|
22
|
+
|
|
23
|
+
ngOnInit(): void {
|
|
24
|
+
this.configureEqpNumericOptions();
|
|
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
|
+
* Metodo per configurare eqp-numeric
|
|
55
|
+
*/
|
|
56
|
+
private configureEqpNumericOptions() {
|
|
57
|
+
this.eqpNumericOptions.prefix = this.field.CurrencySymbol ? this.field.CurrencySymbol : "";
|
|
58
|
+
this.eqpNumericOptions.inputMode = this.field.CurrencySymbol ? EqpNumericInputMode.FINANCIAL : EqpNumericInputMode.NATURAL;
|
|
59
|
+
if (this.field.MinValue != null && this.field.MinValue != undefined)
|
|
60
|
+
this.eqpNumericOptions.min = this.field.MinValue;
|
|
61
|
+
if (this.field.MaxValue != null && this.field.MaxValue != undefined)
|
|
62
|
+
this.eqpNumericOptions.max = this.field.MaxValue;
|
|
63
|
+
if (this.field.DecimalSeparator != null && this.field.DecimalSeparator != undefined)
|
|
64
|
+
this.eqpNumericOptions.decimal = this.field.DecimalSeparator;
|
|
65
|
+
if (this.field.ThousandsSeparator != null && this.field.ThousandsSeparator != undefined)
|
|
66
|
+
this.eqpNumericOptions.thousands = this.field.ThousandsSeparator;
|
|
67
|
+
if (this.field.DecimalPrecision != null && this.field.DecimalPrecision != undefined)
|
|
68
|
+
this.eqpNumericOptions.precision = this.field.DecimalPrecision;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<mat-form-field [formGroup]="field.FormFormGroup">
|
|
2
|
+
<mat-label> {{field.Label}} </mat-label>
|
|
3
|
+
<input matInput [type]="getInputType()" [formControlName]="field.Name" [disabled]="field.FormFormGroup.disabled"
|
|
4
|
+
[required]="field.Required" [(ngModel)]="record[field.Name]" (ngModelChange)="onRecordValueChange()">
|
|
5
|
+
</mat-form-field>
|
|
File without changes
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
|
|
2
|
+
import { Record } from '../../../../models/record.model';
|
|
3
|
+
import { TextMaskEnum, TextField } from '../../../../models/fields/textField.model';
|
|
4
|
+
import { IBaseFieldComponent } from '../../../../interfaces/iBaseFieldComponent.interface';
|
|
5
|
+
import { UtilityHelperService } from '../../../../services/utilityHelper.services';
|
|
6
|
+
|
|
7
|
+
@Component({
|
|
8
|
+
selector: 'text-field-template',
|
|
9
|
+
templateUrl: './text-field-template.component.html',
|
|
10
|
+
styleUrls: ['./text-field-template.component.scss']
|
|
11
|
+
})
|
|
12
|
+
export class TextFieldTemplateComponent implements OnInit, OnChanges, IBaseFieldComponent {
|
|
13
|
+
|
|
14
|
+
@Input() field: TextField;
|
|
15
|
+
@Input() record: Record;
|
|
16
|
+
@Output() recordChange: EventEmitter<Record> = new EventEmitter<Record>();
|
|
17
|
+
|
|
18
|
+
InputMaskEnum = TextMaskEnum;
|
|
19
|
+
|
|
20
|
+
constructor() { }
|
|
21
|
+
|
|
22
|
+
ngOnInit(): void {
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
ngOnChanges(changes: SimpleChanges) {
|
|
26
|
+
// Se viene modificato il valore di "ngModelInput" allora aggiorna l'input
|
|
27
|
+
if (changes['record'] != undefined && changes['record'].firstChange == false && JSON.stringify(changes['record'].currentValue) != JSON.stringify(changes['record'].previousValue)) {
|
|
28
|
+
this.record = changes['record'].currentValue;
|
|
29
|
+
this.updateField();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getInputType() {
|
|
34
|
+
switch (this.field.TextMask) {
|
|
35
|
+
case TextMaskEnum.Email:
|
|
36
|
+
return 'email';
|
|
37
|
+
case TextMaskEnum.Password:
|
|
38
|
+
return 'password';
|
|
39
|
+
case TextMaskEnum.Telefono:
|
|
40
|
+
return 'tel';
|
|
41
|
+
case TextMaskEnum.Url:
|
|
42
|
+
return 'url'
|
|
43
|
+
default:
|
|
44
|
+
return 'text';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Metodo per aggiornare il valore del campo quando questo è rappresentato da una formula.
|
|
50
|
+
*/
|
|
51
|
+
updateField() {
|
|
52
|
+
if (this.field.Formula) {
|
|
53
|
+
this.record[this.field.Name] = UtilityHelperService.EvaluateFieldFormula(this.field.Formula, this.record, null);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Metodo per emettere l'evento che il valore del record è cambiato.
|
|
59
|
+
*/
|
|
60
|
+
onRecordValueChange() {
|
|
61
|
+
if (!this.field.Formula) {
|
|
62
|
+
this.recordChange.emit(this.record);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<mat-form-field [formGroup]="field.FormFormGroup">
|
|
2
|
+
<textarea matInput [placeholder]="field.Label" [rows]="field.Rows" [formControlName]="field.Name"
|
|
3
|
+
[disabled]="field.FormFormGroup.disabled" [required]="field.Required" [(ngModel)]="record[field.Name]"
|
|
4
|
+
(ngModelChange)="onRecordValueChange()"></textarea>
|
|
5
|
+
</mat-form-field>
|
|
File without changes
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
|
|
2
|
+
import { IBaseFieldComponent } from '../../../../interfaces/iBaseFieldComponent.interface';
|
|
3
|
+
import { UtilityHelperService } from '../../../../services/utilityHelper.services';
|
|
4
|
+
import { Record } from '../../../../models/record.model';
|
|
5
|
+
import { TextareaField } from '../../../../models/fields/testareaField.model';
|
|
6
|
+
|
|
7
|
+
@Component({
|
|
8
|
+
selector: 'textarea-field-template',
|
|
9
|
+
templateUrl: './textarea-field-template.component.html',
|
|
10
|
+
styleUrls: ['./textarea-field-template.component.scss']
|
|
11
|
+
})
|
|
12
|
+
export class TextareaFieldTemplateComponent implements OnInit, OnChanges, IBaseFieldComponent {
|
|
13
|
+
|
|
14
|
+
@Input() field: TextareaField;
|
|
15
|
+
@Input() record: Record;
|
|
16
|
+
@Output() recordChange: EventEmitter<Record> = new EventEmitter<Record>();
|
|
17
|
+
|
|
18
|
+
constructor() { }
|
|
19
|
+
|
|
20
|
+
ngOnInit(): void {
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
ngOnChanges(changes: SimpleChanges) {
|
|
24
|
+
// Se viene modificato il valore di "ngModelInput" allora aggiorna l'input
|
|
25
|
+
if (changes['record'] != undefined && changes['record'].firstChange == false && JSON.stringify(changes['record'].currentValue) != JSON.stringify(changes['record'].previousValue)) {
|
|
26
|
+
this.record = changes['record'].currentValue;
|
|
27
|
+
this.updateField();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Metodo per aggiornare il valore del campo quando questo è rappresentato da una formula.
|
|
33
|
+
*/
|
|
34
|
+
updateField() {
|
|
35
|
+
if (this.field.Formula) {
|
|
36
|
+
this.record[this.field.Name] = UtilityHelperService.EvaluateFieldFormula(this.field.Formula, this.record, null);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Metodo per emettere l'evento che il valore del record è cambiato.
|
|
42
|
+
*/
|
|
43
|
+
onRecordValueChange() {
|
|
44
|
+
if (!this.field.Formula) {
|
|
45
|
+
this.recordChange.emit(this.record);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
package/src/lib/components/private/form-records/add-form-record/add-form-record.component.html
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<div class="row eqp-dynamic-module-title" *ngIf="showTitle">
|
|
2
|
+
<div class="col-md-12">
|
|
3
|
+
<h4><b>{{form.Name}}</b></h4>
|
|
4
|
+
</div>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<form [formGroup]="formForm">
|
|
8
|
+
|
|
9
|
+
<!-- VISUALIZZAZIONE SEMPLICE -->
|
|
10
|
+
<ng-container *ngIf="form.FormScalarType == FormScalarTypeEnum.Semplice" [ngTemplateOutlet]="fieldTemplates"
|
|
11
|
+
[ngTemplateOutletContext]="{ fields: form.Fields }">
|
|
12
|
+
</ng-container>
|
|
13
|
+
|
|
14
|
+
<!-- VISUALIZZAZIONE A STEPPER -->
|
|
15
|
+
<mat-horizontal-stepper linear *ngIf="form.FormScalarType == FormScalarTypeEnum['A step']">
|
|
16
|
+
<mat-step *ngFor="let group of form.FormFieldsGroups">
|
|
17
|
+
<ng-template matStepLabel>
|
|
18
|
+
{{group.Name}}
|
|
19
|
+
</ng-template>
|
|
20
|
+
|
|
21
|
+
<ng-container [ngTemplateOutlet]="fieldTemplates"
|
|
22
|
+
[ngTemplateOutletContext]="{ fields: fieldGroups[group.Name] }">
|
|
23
|
+
</ng-container>
|
|
24
|
+
</mat-step>
|
|
25
|
+
</mat-horizontal-stepper>
|
|
26
|
+
|
|
27
|
+
<!-- VISUALIZZAZIONE A TAB -->
|
|
28
|
+
<mat-tab-group *ngIf="form.FormScalarType == FormScalarTypeEnum['In tab']">
|
|
29
|
+
<mat-tab *ngFor="let group of form.FormFieldsGroups" [label]="group.Name">
|
|
30
|
+
<div class="mt-3">
|
|
31
|
+
<ng-container [ngTemplateOutlet]="fieldTemplates"
|
|
32
|
+
[ngTemplateOutletContext]="{ fields: fieldGroups[group.Name] }">
|
|
33
|
+
</ng-container>
|
|
34
|
+
</div>
|
|
35
|
+
</mat-tab>
|
|
36
|
+
</mat-tab-group>
|
|
37
|
+
|
|
38
|
+
<!-- VISUALIZZAZIONE AD ACCORDION -->
|
|
39
|
+
<mat-accordion multi *ngIf="form.FormScalarType == FormScalarTypeEnum['In accordion']">
|
|
40
|
+
<mat-expansion-panel *ngFor="let group of form.FormFieldsGroups">
|
|
41
|
+
<mat-expansion-panel-header>
|
|
42
|
+
<mat-panel-title>
|
|
43
|
+
{{group.Name}}
|
|
44
|
+
</mat-panel-title>
|
|
45
|
+
</mat-expansion-panel-header>
|
|
46
|
+
|
|
47
|
+
<ng-container [ngTemplateOutlet]="fieldTemplates"
|
|
48
|
+
[ngTemplateOutletContext]="{ fields: fieldGroups[group.Name] }">
|
|
49
|
+
</ng-container>
|
|
50
|
+
</mat-expansion-panel>
|
|
51
|
+
</mat-accordion>
|
|
52
|
+
</form>
|
|
53
|
+
|
|
54
|
+
<div class="row mt-2" *ngIf="showButtons">
|
|
55
|
+
<div class="col-sm-12 text-right">
|
|
56
|
+
<button class="mr-2" mat-raised-button (click)="saveOrExitForm(true)" type="button">
|
|
57
|
+
Annulla
|
|
58
|
+
</button>
|
|
59
|
+
<button class="mr-2" mat-raised-button color="primary" (click)="saveOrExitForm(false)"
|
|
60
|
+
[disabled]="formForm.invalid || formForm.disabled" type="button">
|
|
61
|
+
Salva
|
|
62
|
+
</button>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<!-- TEMPLATE PER LA VISUALIZZAZIONE DEI CAMPI DELLA FORM -->
|
|
67
|
+
<ng-template #fieldTemplates let-fields='fields'>
|
|
68
|
+
<div class="row">
|
|
69
|
+
<div class="mt-2" *ngFor="let field of fields" [ngClass]="utilityService.getFieldSyleClass(field)">
|
|
70
|
+
<dynamic-module-field #fieldTemplate [field]="field" [form]="form" [record]="record"
|
|
71
|
+
(recordChange)="onRecordChange()"></dynamic-module-field>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</ng-template>
|
package/src/lib/components/private/form-records/add-form-record/add-form-record.component.scss
ADDED
|
File without changes
|