@eqproject/eqp-dynamic-module 2.9.13 → 2.9.14

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.
@@ -5514,13 +5514,33 @@ class ActionButtonFieldTemplateComponent {
5514
5514
  fireTrigger.trigger.formulas = actionButton.formulas;
5515
5515
  fireTrigger.form = null; // Verrà impostato a livello superiore
5516
5516
  fireTrigger.formulas = actionButton.formulas;
5517
- fireTrigger.record = null;
5517
+ fireTrigger.record = this.record;
5518
5518
  fireTrigger.userPatient = null; // Verrà impostato a livello superiore
5519
5519
  fireTrigger.userMedicalExamination = null;
5520
- this.onFireTrigger(fireTrigger);
5521
- }
5522
- onFireTrigger(ev) {
5523
- this.fireTrigger.emit(ev);
5520
+ this.evaluateFormulasAndFireTrigger(fireTrigger);
5521
+ }
5522
+ evaluateFormulasAndFireTrigger(triggerToFire) {
5523
+ // Il trigger va sparato. Valuto le funzioni interne
5524
+ var formulas = JSON.parse(JSON.stringify(triggerToFire.formulas));
5525
+ GlobalService.debugLog("checkTriggers - evaluate formulas ", formulas);
5526
+ if (formulas != null && Object.keys(formulas).length > 0) {
5527
+ Object.keys(formulas).forEach((key) => {
5528
+ var formula = formulas[key].value;
5529
+ GlobalService.debugLog("checkTriggers - formulas[key] ", formulas[key]);
5530
+ var temp;
5531
+ if (formulas[key].type == TriggerPropertyTypeEnum.DMMODULE) {
5532
+ temp = formula;
5533
+ }
5534
+ else {
5535
+ temp = UtilityHelperService.EvaluateFieldFormula(formula, this.record, null);
5536
+ }
5537
+ formulas[key] = temp;
5538
+ });
5539
+ }
5540
+ // Le formule inviate in input al modulo dinamico, valutate nel contesto del trigger e del record
5541
+ triggerToFire.formulas = formulas;
5542
+ // Sparo il trigger all'esterno
5543
+ this.fireTrigger.emit(triggerToFire);
5524
5544
  }
5525
5545
  }
5526
5546
  ActionButtonFieldTemplateComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ActionButtonFieldTemplateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
@@ -5561,7 +5581,11 @@ class DynamicModuleFieldFixComponent {
5561
5581
  }
5562
5582
  updateField() {
5563
5583
  if (this.fieldTemplate && this.fieldTemplate.length > 0) {
5564
- this.fieldTemplate.forEach(f => f.updateField());
5584
+ this.fieldTemplate.forEach((f) => {
5585
+ if (f != null && typeof f.updateField === 'function') {
5586
+ f.updateField();
5587
+ }
5588
+ });
5565
5589
  }
5566
5590
  }
5567
5591
  ngOnInit() {
@@ -5922,7 +5946,11 @@ class AddFormRecordComponent {
5922
5946
  */
5923
5947
  onRecordChange() {
5924
5948
  if (this.fieldTemplate && this.fieldTemplate.length > 0) {
5925
- this.fieldTemplate.forEach((f) => f.updateField());
5949
+ this.fieldTemplate.forEach((f) => {
5950
+ if (f != null && typeof f.updateField === 'function') {
5951
+ f.updateField();
5952
+ }
5953
+ });
5926
5954
  }
5927
5955
  }
5928
5956
  //#endregion onRecordChange
@@ -10841,17 +10869,31 @@ class ActionButtonCreatorComponent {
10841
10869
  if (this.actionButton != null && this.actionButton.execution != null) {
10842
10870
  this.selectedFormula = {};
10843
10871
  this.selectedFormula.key = this.actionButton.execution;
10872
+ /*
10873
+ if (this.actionButtonField == null){
10874
+ this.formulaFieldsStructure = new Array<any>();
10875
+ this.formulas.forEach((res) => {
10876
+ this.formulaFieldsStructure.push({"key": res.key, "type": this.formulas[this.selectedFormula.key][res].type, "tooltip": this.formulas[this.selectedFormula.key][res].tooltip});
10877
+ });
10878
+
10879
+ Object.keys(this.actionButton.formulasTemp).forEach((res) => {
10880
+ this.formulaFieldsStructure.find(x => x.key == res).value = this.actionButton.formulasTemp[res].value;
10881
+ });
10882
+ } else {
10883
+ this.formulaFieldsStructure.push(this.actionButton.formulas);
10884
+ }
10885
+
10886
+ */
10844
10887
  if (this.actionButtonField == null) {
10845
- this.formulaFieldsStructure = new Array();
10846
- Object.keys(this.formulas[this.selectedFormula.key]).forEach((res) => {
10847
- this.formulaFieldsStructure.push({ "key": res, "type": this.formulas[this.selectedFormula.key][res].type, "tooltip": this.formulas[this.selectedFormula.key][res].tooltip });
10848
- });
10849
- Object.keys(this.actionButton.formulasTemp).forEach((res) => {
10850
- this.formulaFieldsStructure.find(x => x.key == res).value = this.actionButton.formulasTemp[res].value;
10888
+ Object.keys(this.actionButton.formulasTemp).forEach((key) => {
10889
+ if (!this.isAnActionKey(key, this.actionButton, this.formulas)) {
10890
+ return;
10891
+ }
10892
+ this.formulaFieldsStructure.push(this.actionButton.formulasTemp[key]);
10851
10893
  });
10852
10894
  }
10853
10895
  else {
10854
- this.formulaFieldsStructure.push(this.actionButton.formulas);
10896
+ this.formulaFieldsStructure = this.actionButtonField.formulas;
10855
10897
  }
10856
10898
  }
10857
10899
  if (this.actionButton == null) {
@@ -10899,6 +10941,9 @@ class ActionButtonCreatorComponent {
10899
10941
  this.onSaveRecord.emit(null);
10900
10942
  }
10901
10943
  else {
10944
+ if (this.actionButton.ButtonUniqueId == null) {
10945
+ this.actionButton.ButtonUniqueId = this.generateGUID();
10946
+ }
10902
10947
  this.actionButton.ButtonCode = this.selectedFormula.key;
10903
10948
  this.formulaFieldsStructure.forEach((formulaField) => {
10904
10949
  if (typeof this.actionButton.formulas == "undefined") {
@@ -10908,15 +10953,20 @@ class ActionButtonCreatorComponent {
10908
10953
  this.actionButton.execution = this.selectedFormula.key;
10909
10954
  });
10910
10955
  this.isSaving = true;
10956
+ console.log("ActionButtonCreatorComponent saveOrExitForm()", this.actionButton);
10911
10957
  this.onSaveRecord.emit(this.actionButton);
10912
10958
  }
10913
10959
  }
10960
+ generateGUID() {
10961
+ const timestamp = new Date().getTime();
10962
+ const randomNum = Math.floor(Math.random() * 1000000);
10963
+ return `${timestamp}-${randomNum}`;
10964
+ }
10914
10965
  changeSomething() {
10915
10966
  this.actionButton.ButtonCode = this.selectedFormula.key;
10916
10967
  if (!this.actionButton.formulasTemp) {
10917
10968
  this.actionButton.formulasTemp = {};
10918
10969
  }
10919
- console.log("CHANGE SOMETHING", this.actionButton, this.formulaFieldsStructure);
10920
10970
  this.formulaFieldsStructure.forEach((formulaField) => {
10921
10971
  if (typeof this.actionButton.formulas == "undefined") {
10922
10972
  this.actionButton.formulas = {};
@@ -10967,6 +11017,11 @@ class ActionButtonCreatorComponent {
10967
11017
  GlobalService.debugLog('@@trigger-creator:onChangeFormula formulaFieldsStructure', this.formulaFieldsStructure);
10968
11018
  this.changeSomething();
10969
11019
  }
11020
+ isAnActionKey(key, field, formulas) {
11021
+ var code = field.ButtonCode;
11022
+ var els = formulas[code];
11023
+ return (Object.keys(els).find(x => x == key) != null);
11024
+ }
10970
11025
  }
10971
11026
  ActionButtonCreatorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ActionButtonCreatorComponent, deps: [{ token: i1$3.MatDialog }, { token: UtilityHelperService }], target: i0.ɵɵFactoryTarget.Component });
10972
11027
  ActionButtonCreatorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: ActionButtonCreatorComponent, selector: "action-button-creator", inputs: { form: "form", actionButton: "actionButton", actionButtonField: "actionButtonField", formulas: "formulas", endPointConfiguration: "endPointConfiguration", InField: "InField" }, outputs: { onSaveRecord: "onSaveRecord", onChangeSomething: "onChangeSomething" }, viewQueries: [{ propertyName: "dialogFormula", first: true, predicate: ["dialogFormula"], descendants: true, static: true }], ngImport: i0, template: "\r\n<mat-card class=\"add-form-field\">\r\n <mat-card-header *ngIf=\"!InField\">\r\n <mat-card-title>\r\n {{actionButton != null ? \"Modifica\" : \"Aggiungi\"}} actionButton\r\n </mat-card-title>\r\n </mat-card-header>\r\n\r\n <mat-card-content>\r\n\r\n <div class=\"container-fluid containerContent padder\">\r\n\r\n <div class=\"row\">\r\n <div class=\"col-3\">Tipo Action Button</div>\r\n <div class=\"col-9\">\r\n <eqp-select [arrayData]=\"formulaKeys\" [(ngModelInput)]=\"selectedFormula\"\r\n [arrayKeyProperty]=\"'key'\" [arrayValueProperty]=\"'key'\" [showCancelButton]=\"true\" (ngModelInputChange)=\"onChangeFormula($event)\">\r\n </eqp-select> \r\n </div>\r\n </div>\r\n \r\n <div class=\"row\">\r\n <div class=\"col-3\">Etichetta</div>\r\n <div class=\"col-9\">\r\n <mat-form-field>\r\n <mat-label class=\"pt-1\"> Etichetta </mat-label>\r\n <input matInput [(ngModel)]=\"actionButton.ButtonLabel\" [readonly]=\"false\" [required]=\"true\" (keyup)=\"changeSomething()\">\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n \r\n <div class=\"row\">\r\n <div class=\"col-3\">Icona (<a href='https://www.angularjswiki.com/angular/angular-material-icons-list-mat-icon-list' target=\"_blank\">lista</a>)</div>\r\n <div class=\"col-9\">\r\n <mat-form-field>\r\n <mat-label class=\"pt-1\"> Icona Material (<a href='https://www.angularjswiki.com/angular/angular-material-icons-list-mat-icon-list' target=\"_blank\">lista</a>) </mat-label>\r\n <input matInput [(ngModel)]=\"actionButton.Icon\" [readonly]=\"false\" [required]=\"true\" (keyup)=\"changeSomething()\">\r\n </mat-form-field>\r\n </div>\r\n </div> \r\n \r\n <div class=\"row\" *ngIf=\"!InField\">\r\n <div class=\"col-3\">Sezioni</div>\r\n <div class=\"col-9\">\r\n <mat-label class=\"pt-1\"> Sezioni </mat-label>\r\n <eqp-select\r\n [enumData]=\"actionsFlag\"\r\n [isSearchable]=\"true\"\r\n [isMultiSelect] = \"true\"\r\n [(ngModelInput)]=\"actionButton.ShowIn\" \r\n (ngModelInputChange)=\"changeSomething()\" \r\n >\r\n </eqp-select>\r\n </div>\r\n </div> \r\n\r\n <div class=\"row\" *ngFor=\"let formulaField of formulaFieldsStructure\">\r\n <div class=\"col-3\">{{formulaField.key}}</div>\r\n <div class=\"col-9\" *ngIf=\"formulaField.type == triggerPropertyType.STRING\">\r\n <mat-form-field>\r\n <mat-label class=\"pt-1\"> {{formulaField.key}}</mat-label>\r\n <input matInput [readonly]=\"false\" [required]=\"false\" [matTooltip]=\"formulaField.tooltip\" (click)=\"openFormulaDialog(formulaField)\" [(ngModel)]=\"formulaField.value\" (ngModelChange)=\"onFormulaFieldChange(formulaField)\">\r\n </mat-form-field>\r\n </div>\r\n <div class=\"col-9\" *ngIf=\"formulaField.type == triggerPropertyType.DMMODULE\">\r\n <eqp-select [placeholder]=\"'Seleziona modulo'\" [arrayData]=\"forms\" [(ngModelInput)]=\"formulaField.object\" [isSearchable]=\"true\"\r\n [arrayKeyProperty]=\"'ID'\" [arrayValueProperty]=\"'Name'\" [ngModelOptions]=\"{ standalone: true }\" (ngModelInputChange)=\"onEqpSelectModule($event, formulaField)\">\r\n </eqp-select>\r\n </div>\r\n </div>\r\n\r\n </div>\r\n\r\n </mat-card-content>\r\n <mat-card-footer *ngIf=\"!InField\">\r\n <div class=\"d-flex justify-content-end mt-2 mb-1 me-3\"> \r\n <button class=\"mr-2\" mat-raised-button type=\"button\" (click)=\"saveOrExitForm(true)\">\r\n Annulla\r\n </button>\r\n <button class=\"mr-2\" mat-raised-button color=\"primary\" type=\"button\"\r\n (click)=\"saveOrExitForm(false)\" [disabled]=\"isSaving\">\r\n <span *ngIf=\"!isSaving\">Salva</span>\r\n <span *ngIf=\"isSaving\">Salvataggio in Corso...</span>\r\n </button>\r\n </div>\r\n </mat-card-footer>\r\n\r\n</mat-card>\r\n\r\n<!--DIALOG PER SEMPLIFICARE LA SCRITTURA DEL CAMPO FORMULA-->\r\n<ng-template #dialogFormula>\r\n <eqp-dynamic-module-add-formula-component>\r\n </eqp-dynamic-module-add-formula-component>\r\n</ng-template>", styles: [""], dependencies: [{ kind: "component", type: i2.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "directive", type: i1$1.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i2$2.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i2$2.MatLabel, selector: "mat-label" }, { kind: "component", type: i6.MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "directive", type: i6.MatCardContent, selector: "mat-card-content" }, { kind: "directive", type: i6.MatCardFooter, selector: "mat-card-footer" }, { kind: "component", type: i6.MatCardHeader, selector: "mat-card-header" }, { kind: "directive", type: i6.MatCardTitle, selector: "mat-card-title, [mat-card-title], [matCardTitle]" }, { kind: "directive", type: i3$4.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { kind: "directive", type: i3.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i2$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2$3.EqpSelectComponent, selector: "eqp-select", inputs: ["placeholder", "enumData", "enumDataToExclude", "arrayData", "arrayKeyProperty", "arrayValueProperty", "ngModelOptions", "ngModelInput", "formGroupInput", "formControlNameInput", "isRequired", "isDisabled", "isMultiLanguage", "multilanguagePrefixKey", "isAlphabeticalOrderable", "suffixIcon", "prefixIcon", "isMultiSelect", "includeFullObject", "showCancelButton", "isSearchable", "searchText", "noResultSearchText", "data"], outputs: ["ngModelInputChange"] }, { kind: "component", type: AddFormulaComponent, selector: "eqp-dynamic-module-add-formula-component" }] });
@@ -11844,15 +11899,22 @@ class AddFormFieldComponent {
11844
11899
  }
11845
11900
  if (this.field.FieldType == FieldTypeEnum["Bottone azione"]) {
11846
11901
  if ((this.field.formulasTemp != null)) {
11902
+ this.field.formulas = new Array();
11847
11903
  var formulas = this.field.formulasTemp;
11848
11904
  var keys = Object.keys(formulas);
11849
- var key = keys[0];
11850
- var ktv = new KeyTypeValue();
11851
- ktv.key = key;
11852
- ktv.tooltip = formulas[key].tooltip;
11853
- ktv.type = formulas[key].type;
11854
- ktv.value = formulas[key].value;
11855
- this.field.formulas = ktv;
11905
+ if (keys.length > 0) {
11906
+ keys.forEach((key) => {
11907
+ if (!this.isAnActionKey(key, this.field, formulas)) {
11908
+ return;
11909
+ }
11910
+ var ktv = new KeyTypeValue();
11911
+ ktv.key = key;
11912
+ ktv.tooltip = formulas[key].tooltip;
11913
+ ktv.type = formulas[key].type;
11914
+ ktv.value = formulas[key].value;
11915
+ this.field.formulas.push(ktv);
11916
+ });
11917
+ }
11856
11918
  }
11857
11919
  }
11858
11920
  this.setCodeToExtraFields();
@@ -11864,19 +11926,30 @@ class AddFormFieldComponent {
11864
11926
  }
11865
11927
  }
11866
11928
  //#endregion saveAndExitAddField
11929
+ isAnActionKey(key, field, formulas) {
11930
+ console.log("isAnActionKey", key, field, formulas);
11931
+ return true;
11932
+ /*var code = field.ButtonCode;
11933
+ var els = formulas[code];
11934
+ return (Object.keys(els).find(x => x == key) != null);*/
11935
+ }
11867
11936
  setCodeToExtraFields() {
11868
- this.form.FldExtraConfigValues.filter(x => x.FieldConfigParentFieldCode === undefined).forEach((ufields) => {
11869
- ufields.FieldConfigParentFieldCode = this.field.Name;
11870
- if (typeof ufields.FieldConfigValue == "boolean") {
11871
- ufields.FieldConfigValue = ufields.FieldConfigValue ? "true" : "false";
11872
- }
11873
- });
11874
- this.form.ObjectFldExtraConfigValues.filter(x => x.FieldConfigParentFieldCode === undefined).forEach((ufields) => {
11875
- ufields.FieldConfigParentFieldCode = this.field.Name;
11876
- if (typeof ufields.FieldConfigValue == "boolean") {
11877
- ufields.FieldConfigValue = ufields.FieldConfigValue ? "true" : "false";
11878
- }
11879
- });
11937
+ if (this.form.FldExtraConfigValues != null && this.form.FldExtraConfigValues.length > 0) {
11938
+ this.form.FldExtraConfigValues.filter(x => x.FieldConfigParentFieldCode === undefined).forEach((ufields) => {
11939
+ ufields.FieldConfigParentFieldCode = this.field.Name;
11940
+ if (typeof ufields.FieldConfigValue == "boolean") {
11941
+ ufields.FieldConfigValue = ufields.FieldConfigValue ? "true" : "false";
11942
+ }
11943
+ });
11944
+ }
11945
+ if (this.form.ObjectFldExtraConfigValues != null && this.form.ObjectFldExtraConfigValues.length > 0) {
11946
+ this.form.ObjectFldExtraConfigValues.filter(x => x.FieldConfigParentFieldCode === undefined).forEach((ufields) => {
11947
+ ufields.FieldConfigParentFieldCode = this.field.Name;
11948
+ if (typeof ufields.FieldConfigValue == "boolean") {
11949
+ ufields.FieldConfigValue = ufields.FieldConfigValue ? "true" : "false";
11950
+ }
11951
+ });
11952
+ }
11880
11953
  }
11881
11954
  //#region restoreBaseFieldProperties
11882
11955
  /**
@@ -13466,7 +13539,7 @@ class EqpDynamicModuleConfiguratorComponent {
13466
13539
  saveActionButtons(element) {
13467
13540
  if (element != null) {
13468
13541
  if (this.form.ActionButtons != null) {
13469
- var existsActionButtons = this.form.ActionButtons.find(x => x.ButtonCode == element.ButtonCode);
13542
+ var existsActionButtons = this.form.ActionButtons.find(x => x.ButtonUniqueId == element.ButtonUniqueId);
13470
13543
  if (existsActionButtons == null) {
13471
13544
  // Nuovo trigger
13472
13545
  this.form.ActionButtons.push(element);