@eqproject/eqp-dynamic-module 2.4.8 → 2.4.9

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.
@@ -8697,7 +8697,9 @@ class AddFormFieldComponent {
8697
8697
  attachment.ImageWidthPx = img.width;
8698
8698
  attachment.ImageHeightPx = img.height;
8699
8699
  attachment.AttachmentFieldType = AttachmentFieldTypeEnum.ELENCO_IMMAGINI;
8700
- self.imageSelectorAttachments.reloadData();
8700
+ if (self.imageSelectorAttachments) {
8701
+ self.imageSelectorAttachments.reloadData();
8702
+ }
8701
8703
  });
8702
8704
  }
8703
8705
  });
@@ -8956,6 +8958,10 @@ class AddFormFieldComponent {
8956
8958
  */
8957
8959
  saveAndExitAddField(save) {
8958
8960
  this.setResizedImagesHeightPx();
8961
+ this.setFieldOrdinalPosition();
8962
+ if (this.imageSelectorAttachments) {
8963
+ this.imageSelectorAttachments.reloadData();
8964
+ }
8959
8965
  if (save) {
8960
8966
  // retrocompatibilità con valuepairs per Elenco Generico
8961
8967
  if (this.field.FieldType == FieldTypeEnum["Elenco generico"]) {
@@ -9025,6 +9031,18 @@ class AddFormFieldComponent {
9025
9031
  key: 'action', display: '', type: TypeColumn.MenuAction, buttonMenuIcon: 'more_vert', styles: { flex: '0 0 6%' },
9026
9032
  actions: [
9027
9033
  { name: 'Elimina', icon: 'delete', fn: (element, index, col) => this.deleteListImage(element, index, col) },
9034
+ {
9035
+ name: "Sposta su",
9036
+ icon: "arrow_upward",
9037
+ fn: (element, index, col) => this.moveElement(element, true),
9038
+ disabled: (element) => this.field.AttachmentList.indexOf(element) === 0,
9039
+ },
9040
+ {
9041
+ name: "Sposta giù",
9042
+ icon: "arrow_downward",
9043
+ fn: (element, index, col) => this.moveElement(element, false),
9044
+ disabled: (element) => this.field.AttachmentList.indexOf(element) >= this.field.AttachmentList.length - 1,
9045
+ },
9028
9046
  ]
9029
9047
  });
9030
9048
  this.configColumnListImages.push({
@@ -9054,13 +9072,32 @@ class AddFormFieldComponent {
9054
9072
  display: "Altezza"
9055
9073
  });
9056
9074
  }
9075
+ moveElement(element, moveUp) {
9076
+ const startingIndex = this.field.AttachmentList.indexOf(element);
9077
+ const endingIndex = startingIndex + (moveUp ? -1 : 1);
9078
+ this.field.AttachmentList.splice(startingIndex, 1);
9079
+ this.field.AttachmentList.splice(endingIndex, 0, element);
9080
+ this.setFieldOrdinalPosition();
9081
+ if (this.imageSelectorAttachments) {
9082
+ this.imageSelectorAttachments.reloadData();
9083
+ }
9084
+ }
9085
+ setFieldOrdinalPosition() {
9086
+ if (this.field.AttachmentList) {
9087
+ this.field.AttachmentList.forEach((field) => {
9088
+ field.OrdinalPosition = this.field.AttachmentList.indexOf(field);
9089
+ });
9090
+ }
9091
+ }
9057
9092
  setResizedImagesHeightPx() {
9058
9093
  this.resizedImagesHeightPx = this.field.ResizedImagesHeightPx;
9059
9094
  }
9060
9095
  deleteListImage(el, i, col) {
9061
9096
  EqpDynamicModuleDialogService.Confirm('Eliminare questa immagine?', () => {
9062
9097
  this.field.AttachmentList.splice(el.originalIndex, 1);
9063
- this.imageSelectorAttachments.reloadData();
9098
+ if (this.imageSelectorAttachments) {
9099
+ this.imageSelectorAttachments.reloadData();
9100
+ }
9064
9101
  }, false, 'Richiesta conferma');
9065
9102
  }
9066
9103
  deleteImage(el) {