@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.
@@ -5499,13 +5499,33 @@ class ActionButtonFieldTemplateComponent {
5499
5499
  fireTrigger.trigger.formulas = actionButton.formulas;
5500
5500
  fireTrigger.form = null; // Verrà impostato a livello superiore
5501
5501
  fireTrigger.formulas = actionButton.formulas;
5502
- fireTrigger.record = null;
5502
+ fireTrigger.record = this.record;
5503
5503
  fireTrigger.userPatient = null; // Verrà impostato a livello superiore
5504
5504
  fireTrigger.userMedicalExamination = null;
5505
- this.onFireTrigger(fireTrigger);
5506
- }
5507
- onFireTrigger(ev) {
5508
- this.fireTrigger.emit(ev);
5505
+ this.evaluateFormulasAndFireTrigger(fireTrigger);
5506
+ }
5507
+ evaluateFormulasAndFireTrigger(triggerToFire) {
5508
+ // Il trigger va sparato. Valuto le funzioni interne
5509
+ var formulas = JSON.parse(JSON.stringify(triggerToFire.formulas));
5510
+ GlobalService.debugLog("checkTriggers - evaluate formulas ", formulas);
5511
+ if (formulas != null && Object.keys(formulas).length > 0) {
5512
+ Object.keys(formulas).forEach((key) => {
5513
+ var formula = formulas[key].value;
5514
+ GlobalService.debugLog("checkTriggers - formulas[key] ", formulas[key]);
5515
+ var temp;
5516
+ if (formulas[key].type == TriggerPropertyTypeEnum.DMMODULE) {
5517
+ temp = formula;
5518
+ }
5519
+ else {
5520
+ temp = UtilityHelperService.EvaluateFieldFormula(formula, this.record, null);
5521
+ }
5522
+ formulas[key] = temp;
5523
+ });
5524
+ }
5525
+ // Le formule inviate in input al modulo dinamico, valutate nel contesto del trigger e del record
5526
+ triggerToFire.formulas = formulas;
5527
+ // Sparo il trigger all'esterno
5528
+ this.fireTrigger.emit(triggerToFire);
5509
5529
  }
5510
5530
  }
5511
5531
  ActionButtonFieldTemplateComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ActionButtonFieldTemplateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
@@ -5546,7 +5566,9 @@ class DynamicModuleFieldFixComponent {
5546
5566
  }
5547
5567
  updateField() {
5548
5568
  if (this.fieldTemplate && this.fieldTemplate.length > 0) {
5549
- this.fieldTemplate.forEach(f => f.updateField());
5569
+ this.fieldTemplate.forEach((f) => { if (f != null && typeof f.updateField === 'function') {
5570
+ f.updateField();
5571
+ } });
5550
5572
  }
5551
5573
  }
5552
5574
  ngOnInit() {
@@ -5907,7 +5929,9 @@ class AddFormRecordComponent {
5907
5929
  */
5908
5930
  onRecordChange() {
5909
5931
  if (this.fieldTemplate && this.fieldTemplate.length > 0) {
5910
- this.fieldTemplate.forEach((f) => f.updateField());
5932
+ this.fieldTemplate.forEach((f) => { if (f != null && typeof f.updateField === 'function') {
5933
+ f.updateField();
5934
+ } });
5911
5935
  }
5912
5936
  }
5913
5937
  //#endregion onRecordChange
@@ -10808,17 +10832,31 @@ class ActionButtonCreatorComponent {
10808
10832
  if (this.actionButton != null && this.actionButton.execution != null) {
10809
10833
  this.selectedFormula = {};
10810
10834
  this.selectedFormula.key = this.actionButton.execution;
10835
+ /*
10836
+ if (this.actionButtonField == null){
10837
+ this.formulaFieldsStructure = new Array<any>();
10838
+ this.formulas.forEach((res) => {
10839
+ this.formulaFieldsStructure.push({"key": res.key, "type": this.formulas[this.selectedFormula.key][res].type, "tooltip": this.formulas[this.selectedFormula.key][res].tooltip});
10840
+ });
10841
+
10842
+ Object.keys(this.actionButton.formulasTemp).forEach((res) => {
10843
+ this.formulaFieldsStructure.find(x => x.key == res).value = this.actionButton.formulasTemp[res].value;
10844
+ });
10845
+ } else {
10846
+ this.formulaFieldsStructure.push(this.actionButton.formulas);
10847
+ }
10848
+
10849
+ */
10811
10850
  if (this.actionButtonField == null) {
10812
- this.formulaFieldsStructure = new Array();
10813
- Object.keys(this.formulas[this.selectedFormula.key]).forEach((res) => {
10814
- this.formulaFieldsStructure.push({ "key": res, "type": this.formulas[this.selectedFormula.key][res].type, "tooltip": this.formulas[this.selectedFormula.key][res].tooltip });
10815
- });
10816
- Object.keys(this.actionButton.formulasTemp).forEach((res) => {
10817
- this.formulaFieldsStructure.find(x => x.key == res).value = this.actionButton.formulasTemp[res].value;
10851
+ Object.keys(this.actionButton.formulasTemp).forEach((key) => {
10852
+ if (!this.isAnActionKey(key, this.actionButton, this.formulas)) {
10853
+ return;
10854
+ }
10855
+ this.formulaFieldsStructure.push(this.actionButton.formulasTemp[key]);
10818
10856
  });
10819
10857
  }
10820
10858
  else {
10821
- this.formulaFieldsStructure.push(this.actionButton.formulas);
10859
+ this.formulaFieldsStructure = this.actionButtonField.formulas;
10822
10860
  }
10823
10861
  }
10824
10862
  if (this.actionButton == null) {
@@ -10866,6 +10904,9 @@ class ActionButtonCreatorComponent {
10866
10904
  this.onSaveRecord.emit(null);
10867
10905
  }
10868
10906
  else {
10907
+ if (this.actionButton.ButtonUniqueId == null) {
10908
+ this.actionButton.ButtonUniqueId = this.generateGUID();
10909
+ }
10869
10910
  this.actionButton.ButtonCode = this.selectedFormula.key;
10870
10911
  this.formulaFieldsStructure.forEach((formulaField) => {
10871
10912
  if (typeof this.actionButton.formulas == "undefined") {
@@ -10875,15 +10916,20 @@ class ActionButtonCreatorComponent {
10875
10916
  this.actionButton.execution = this.selectedFormula.key;
10876
10917
  });
10877
10918
  this.isSaving = true;
10919
+ console.log("ActionButtonCreatorComponent saveOrExitForm()", this.actionButton);
10878
10920
  this.onSaveRecord.emit(this.actionButton);
10879
10921
  }
10880
10922
  }
10923
+ generateGUID() {
10924
+ const timestamp = new Date().getTime();
10925
+ const randomNum = Math.floor(Math.random() * 1000000);
10926
+ return `${timestamp}-${randomNum}`;
10927
+ }
10881
10928
  changeSomething() {
10882
10929
  this.actionButton.ButtonCode = this.selectedFormula.key;
10883
10930
  if (!this.actionButton.formulasTemp) {
10884
10931
  this.actionButton.formulasTemp = {};
10885
10932
  }
10886
- console.log("CHANGE SOMETHING", this.actionButton, this.formulaFieldsStructure);
10887
10933
  this.formulaFieldsStructure.forEach((formulaField) => {
10888
10934
  if (typeof this.actionButton.formulas == "undefined") {
10889
10935
  this.actionButton.formulas = {};
@@ -10934,6 +10980,11 @@ class ActionButtonCreatorComponent {
10934
10980
  GlobalService.debugLog('@@trigger-creator:onChangeFormula formulaFieldsStructure', this.formulaFieldsStructure);
10935
10981
  this.changeSomething();
10936
10982
  }
10983
+ isAnActionKey(key, field, formulas) {
10984
+ var code = field.ButtonCode;
10985
+ var els = formulas[code];
10986
+ return (Object.keys(els).find(x => x == key) != null);
10987
+ }
10937
10988
  }
10938
10989
  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 });
10939
10990
  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" }] });
@@ -11807,15 +11858,22 @@ class AddFormFieldComponent {
11807
11858
  }
11808
11859
  if (this.field.FieldType == FieldTypeEnum["Bottone azione"]) {
11809
11860
  if ((this.field.formulasTemp != null)) {
11861
+ this.field.formulas = new Array();
11810
11862
  var formulas = this.field.formulasTemp;
11811
11863
  var keys = Object.keys(formulas);
11812
- var key = keys[0];
11813
- var ktv = new KeyTypeValue();
11814
- ktv.key = key;
11815
- ktv.tooltip = formulas[key].tooltip;
11816
- ktv.type = formulas[key].type;
11817
- ktv.value = formulas[key].value;
11818
- this.field.formulas = ktv;
11864
+ if (keys.length > 0) {
11865
+ keys.forEach((key) => {
11866
+ if (!this.isAnActionKey(key, this.field, formulas)) {
11867
+ return;
11868
+ }
11869
+ var ktv = new KeyTypeValue();
11870
+ ktv.key = key;
11871
+ ktv.tooltip = formulas[key].tooltip;
11872
+ ktv.type = formulas[key].type;
11873
+ ktv.value = formulas[key].value;
11874
+ this.field.formulas.push(ktv);
11875
+ });
11876
+ }
11819
11877
  }
11820
11878
  }
11821
11879
  this.setCodeToExtraFields();
@@ -11827,19 +11885,30 @@ class AddFormFieldComponent {
11827
11885
  }
11828
11886
  }
11829
11887
  //#endregion saveAndExitAddField
11888
+ isAnActionKey(key, field, formulas) {
11889
+ console.log("isAnActionKey", key, field, formulas);
11890
+ return true;
11891
+ /*var code = field.ButtonCode;
11892
+ var els = formulas[code];
11893
+ return (Object.keys(els).find(x => x == key) != null);*/
11894
+ }
11830
11895
  setCodeToExtraFields() {
11831
- this.form.FldExtraConfigValues.filter(x => x.FieldConfigParentFieldCode === undefined).forEach((ufields) => {
11832
- ufields.FieldConfigParentFieldCode = this.field.Name;
11833
- if (typeof ufields.FieldConfigValue == "boolean") {
11834
- ufields.FieldConfigValue = ufields.FieldConfigValue ? "true" : "false";
11835
- }
11836
- });
11837
- this.form.ObjectFldExtraConfigValues.filter(x => x.FieldConfigParentFieldCode === undefined).forEach((ufields) => {
11838
- ufields.FieldConfigParentFieldCode = this.field.Name;
11839
- if (typeof ufields.FieldConfigValue == "boolean") {
11840
- ufields.FieldConfigValue = ufields.FieldConfigValue ? "true" : "false";
11841
- }
11842
- });
11896
+ if (this.form.FldExtraConfigValues != null && this.form.FldExtraConfigValues.length > 0) {
11897
+ this.form.FldExtraConfigValues.filter(x => x.FieldConfigParentFieldCode === undefined).forEach((ufields) => {
11898
+ ufields.FieldConfigParentFieldCode = this.field.Name;
11899
+ if (typeof ufields.FieldConfigValue == "boolean") {
11900
+ ufields.FieldConfigValue = ufields.FieldConfigValue ? "true" : "false";
11901
+ }
11902
+ });
11903
+ }
11904
+ if (this.form.ObjectFldExtraConfigValues != null && this.form.ObjectFldExtraConfigValues.length > 0) {
11905
+ this.form.ObjectFldExtraConfigValues.filter(x => x.FieldConfigParentFieldCode === undefined).forEach((ufields) => {
11906
+ ufields.FieldConfigParentFieldCode = this.field.Name;
11907
+ if (typeof ufields.FieldConfigValue == "boolean") {
11908
+ ufields.FieldConfigValue = ufields.FieldConfigValue ? "true" : "false";
11909
+ }
11910
+ });
11911
+ }
11843
11912
  }
11844
11913
  //#region restoreBaseFieldProperties
11845
11914
  /**
@@ -13429,7 +13498,7 @@ class EqpDynamicModuleConfiguratorComponent {
13429
13498
  saveActionButtons(element) {
13430
13499
  if (element != null) {
13431
13500
  if (this.form.ActionButtons != null) {
13432
- var existsActionButtons = this.form.ActionButtons.find(x => x.ButtonCode == element.ButtonCode);
13501
+ var existsActionButtons = this.form.ActionButtons.find(x => x.ButtonUniqueId == element.ButtonUniqueId);
13433
13502
  if (existsActionButtons == null) {
13434
13503
  // Nuovo trigger
13435
13504
  this.form.ActionButtons.push(element);