@apia/execution 4.0.95 → 4.0.97

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/dist/index.d.ts CHANGED
@@ -3424,7 +3424,9 @@ declare class Grid extends Field<GridProps, GridDefinition, GridState> {
3424
3424
  protected getRow(index: number): Field<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, {
3425
3425
  definition: Omit<TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, "properties">;
3426
3426
  }>[];
3427
- protected rebuildGrid(xmlString: string | TApiaGridDefinition): Promise<void>;
3427
+ protected rebuildGrid(xmlString: string | TApiaGridDefinition, options?: {
3428
+ recreateRows?: boolean;
3429
+ }): Promise<void>;
3428
3430
  protected runAction<T extends Record<string, any>>(postData: IApiaApiPostConfig<Record<string, any>>): Promise<TApiaApiAxiosResponse<(T & ResponseSysMessages) | null> | null>;
3429
3431
  private swapRows;
3430
3432
  toggleMaximize(): void;
package/dist/index.js CHANGED
@@ -3579,7 +3579,7 @@ class Grid extends Field {
3579
3579
  }
3580
3580
  });
3581
3581
  if (res?.data?.gridXml) {
3582
- await this.rebuildGrid(res.data.gridXml);
3582
+ await this.rebuildGrid(res.data.gridXml, { recreateRows: true });
3583
3583
  } else {
3584
3584
  throw new Error("The server didn't return a valid XML response.");
3585
3585
  }
@@ -3686,7 +3686,7 @@ class Grid extends Field {
3686
3686
  getRow(index) {
3687
3687
  return this.tableController.body.getRowByIndex(index)?.cells.filter((c) => c instanceof GridCell).map((c) => c.getField());
3688
3688
  }
3689
- async rebuildGrid(xmlString) {
3689
+ async rebuildGrid(xmlString, options) {
3690
3690
  const xml = Grid.parseGridDefinition(xmlString);
3691
3691
  const fieldsArray = arrayOrArray(xml.field);
3692
3692
  const statesArray = fieldsArray.map(
@@ -3696,7 +3696,34 @@ class Grid extends Field {
3696
3696
  this.properties.pages = xml.pages || this.properties.pages;
3697
3697
  this.properties.currentPage = xml.curPage || this.properties.currentPage;
3698
3698
  this.properties.visibilityHidden = xml.properties.visibilityHidden ?? this.properties.visibilityHidden;
3699
- if (rowCount > this.controller.body.rows.length) {
3699
+ if (options?.recreateRows) {
3700
+ this.cache.clear();
3701
+ this.controller.clearSelection();
3702
+ this.controller.body.clear();
3703
+ this.fieldsDefinitions = fieldsArray.map(
3704
+ ({ fieldValue, properties, ...current }) => {
3705
+ return { ...current, properties: parseFakeJSON$1(properties) };
3706
+ }
3707
+ );
3708
+ for (let i = 0; i < rowCount; i++) {
3709
+ const parsedFieldGroups = fieldsArray.map((field, columnIndex) => {
3710
+ if (field.fieldType === "radio" || field.fieldType === "select") {
3711
+ return {
3712
+ ...field,
3713
+ ...arrayOrArray(field.row)[i]
3714
+ };
3715
+ }
3716
+ return {
3717
+ ...field,
3718
+ index: i,
3719
+ fieldValue: {
3720
+ ...statesArray[columnIndex][i]
3721
+ }
3722
+ };
3723
+ });
3724
+ await this.addRowFromDefinitions(false, parsedFieldGroups);
3725
+ }
3726
+ } else if (rowCount > this.controller.body.rows.length) {
3700
3727
  for (let i = this.controller.body.rows.length; i < rowCount; i++) {
3701
3728
  const parsedFieldGroups = fieldsArray.map((field, columnIndex) => {
3702
3729
  if (field.fieldType === "radio" || field.fieldType === "select") {
@@ -3710,8 +3737,7 @@ class Grid extends Field {
3710
3737
  ...field,
3711
3738
  index: i,
3712
3739
  fieldValue: {
3713
- properties: statesArray[columnIndex][i]?.properties,
3714
- value: statesArray[columnIndex][i]?.value
3740
+ ...statesArray[columnIndex][i]
3715
3741
  }
3716
3742
  };
3717
3743
  });
@@ -3744,7 +3770,9 @@ class Grid extends Field {
3744
3770
  );
3745
3771
  field.definition.index = this.startIndex + rowIndex;
3746
3772
  if (field instanceof File) {
3747
- field.loadFromDefinition(state.file_prp);
3773
+ field.loadFromDefinition(
3774
+ state.file_prp ?? fieldDefinition.file_prp
3775
+ );
3748
3776
  } else if (field instanceof ModalInput) {
3749
3777
  field.setValue(
3750
3778
  {