@cdmx/wappler_ag_grid 0.5.9 → 0.6.1

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/README.md CHANGED
@@ -148,10 +148,34 @@ Enter the names of fields you want to hide separated by commas. The specified fi
148
148
  Enter the names of filters you want to hide separated by commas. The specified filters will be hidden from the view.
149
149
 
150
150
  **Hide Sort Filters**
151
- Enter the names of sort filters you want to hide separated by commas. The specified sort filters will be hidden from the view.
151
+ Enter the names of the sort filters you want to hide separated by commas. The specified sort filters will be hidden from the view.
152
152
 
153
153
  ---
154
154
 
155
+ # Amount Fields
156
+ The amount fields configuration consists of the following parameters:
157
+
158
+ - **Amount Fields** (Type: checkbox, Default: false)
159
+ - Enable or disable the comma-separation for amount fields.
160
+
161
+ - **Amount Fields** (Type: textbox, Default: null)
162
+ - Define the fields where the comma-separation and float parsing need to be applied.
163
+ ---
164
+
165
+ # Compact View
166
+ The compact view configuration consists of the following parameters:
167
+
168
+ - **Compact View** (Type: checkbox, Default: false)
169
+ - Enable or disable the compact view for the grid.
170
+
171
+ - **Grid Size** (Type: number, Default: 3)
172
+ - Specify the grid size for the compact view. This determines the number of columns in each row.
173
+
174
+ - **Grid Item Height** (Type: number, Default: 20)
175
+ - Set the height of each item in the compact view.
176
+
177
+ ---
178
+
155
179
  # Configure Actions Column
156
180
  The Configure Actions Column feature allows you to configure actions for the buttons in the Actions Column.
157
181
 
@@ -202,6 +226,17 @@ Specify the tooltip text for the Delete Action button.
202
226
  Specify the CSS class for styling the Delete Action button.
203
227
  Specify the CSS class for styling the icon of the Delete Action button.
204
228
 
229
+ # Action Attributes
230
+
231
+ **Load**
232
+ - Mainly to be used in conjunction with "No Auto Load" enabled so that you can load only when certain conditions are met.
233
+ - Use Case: Used when you're awaiting the population of specific elements or data before loading the grid. It's also useful for refreshing the grid intentionally.
234
+
235
+ **Reload** (Beta)
236
+ - To be used in conjunction with "No Auto Load" enabled
237
+ - This performs a transactional update of the client-side data in the grid after comparing the existing and updated datasets
238
+ - To use this: Enable "No Auto Load", On Edit or update actions, perform an SC load, On Success of SC load perform the AG Grid Module Reload Action.
239
+
205
240
  ## License
206
241
 
207
242
  The AG Grid module is licensed under the MIT License. Please refer to the license file for more details.
@@ -1098,6 +1098,68 @@
1098
1098
  }
1099
1099
  ]
1100
1100
  },
1101
+ {
1102
+ "group": "📒 Column Groups",
1103
+ "variables": [
1104
+ {
1105
+ "name": "groupConfig",
1106
+ "title": "Configure Column Groups",
1107
+ "type": "boolean",
1108
+ "defaultValue": false,
1109
+ "display": "fieldset",
1110
+ "show": [
1111
+ "listGroupConfig",
1112
+ ],
1113
+ "noChangeOnHide": true,
1114
+ "groupEnabler": true,
1115
+ "help": "Apply Column grouping"
1116
+ "children": [
1117
+ {
1118
+ "name": "listGroupConfig",
1119
+ "attribute": "dmx-bind:group_config",
1120
+ "title": "Group Config",
1121
+ "type": "grid",
1122
+ "dataBindings": true,
1123
+ "jsonFormat": true,
1124
+ "encloseBT": true,
1125
+ "jsonBT": true,
1126
+ "initDisplay": "none",
1127
+ "columns": [
1128
+ {
1129
+ "field": "name",
1130
+ "caption": "Group Name",
1131
+ "size": "25%",
1132
+ "editable": {
1133
+ "type": "text"
1134
+ }
1135
+ },
1136
+ {
1137
+ field: "start_field",
1138
+ caption: "Start Field",
1139
+ size: "25%",
1140
+ editable: {
1141
+ type: "text"
1142
+ }
1143
+ },
1144
+ {
1145
+ field: "end_field",
1146
+ caption: "Start Field",
1147
+ size: "25%",
1148
+ editable: {
1149
+ type: "text"
1150
+ }
1151
+ }
1152
+ ],
1153
+ "newRecord": {
1154
+ "name": "",
1155
+ "start_field": "",
1156
+ "end_field": ""
1157
+ }
1158
+ }
1159
+ ]
1160
+ }
1161
+ ]
1162
+ },
1101
1163
  {
1102
1164
  "group": "📒 Configure Actions Column",
1103
1165
  "variables": [
package/dmx-ag-grid.js CHANGED
@@ -85,7 +85,8 @@ dmx.Component('ag-grid', {
85
85
  hide_sort: {type: Array, default: [] },
86
86
  compact_view: { type: Boolean, default: false },
87
87
  compact_view_grid_size: { type: Number, default: 3 },
88
- compact_view_item_height: { type: Number, default: 20 }
88
+ compact_view_item_height: { type: Number, default: 20 },
89
+ group_config: { type: Array, default: [] }
89
90
  },
90
91
 
91
92
  methods: {
@@ -96,16 +97,48 @@ dmx.Component('ag-grid', {
96
97
  },
97
98
  reloadGrid: function () {
98
99
  dmx.nextTick(function() {
99
- this.refreshGrid();
100
+ this.transactionUpdate();
100
101
  }, this);
101
102
  },
102
103
  loadGrid: function () {
103
104
  dmx.nextTick(function() {
104
- this.refreshGrid();
105
+ let gridInstance = this.refreshGrid();
106
+ this.set('gridInstance', gridInstance);
105
107
  }, this);
106
108
  }
107
109
  },
108
110
 
111
+ transactionUpdate: function () {
112
+ // const oldRowData = this.get('oldData');
113
+ const gridInstance = this.get('gridInstance');
114
+ const oldRowData = gridInstance.gridOptions.api.getModel().rowsToDisplay.map(row => row.data);
115
+ const newRowData = this.props.data;
116
+ let transaction;
117
+
118
+ if (oldRowData && oldRowData.length > 0) {
119
+ const addedRows = newRowData.filter(newRow => !oldRowData.some(oldRow => newRow.id === oldRow.id));
120
+ const removedRows = oldRowData.filter(oldRow => !newRowData.some(newRow => oldRow.id === newRow.id));
121
+ const updatedRows = newRowData.filter(newRow => {
122
+ const oldRow = oldRowData.find(old => old.id === newRow.id);
123
+ return oldRow && JSON.stringify(oldRow) !== JSON.stringify(newRow);
124
+ });
125
+
126
+ // Apply transactional updates to AG Grid
127
+ transaction = {
128
+ add: addedRows,
129
+ remove: removedRows,
130
+ update: updatedRows,
131
+ };
132
+ }
133
+
134
+ if (gridInstance && gridInstance.gridOptions && transaction) {
135
+ gridInstance.gridOptions.api.applyTransaction(transaction);
136
+ gridInstance.gridOptions.api.refreshCells();
137
+ } else {
138
+ console.error('AG Grid instance or transaction not found.');
139
+ }
140
+ },
141
+
109
142
  refreshGrid: function () {
110
143
  const options = this.props
111
144
  const rowData = this.props.data;
@@ -117,6 +150,7 @@ dmx.Component('ag-grid', {
117
150
  const enableCellClickEvent = this.props.row_click_event && (this.props.enable_actions || this.props.row_checkbox_event);
118
151
  let localeText;
119
152
  let columnDefs = [];
153
+ let groupedColumnDefs = [];
120
154
  let exportToCSV = this.props.export_to_csv;
121
155
  let gridInstance = null;
122
156
  this.$node.innerHTML = `<div id=${options.id}-grid class="${options.grid_theme}"></div>`;
@@ -527,7 +561,6 @@ dmx.Component('ag-grid', {
527
561
  columnDefs = this.props.column_defs;
528
562
  } else {
529
563
  const firstRow = rowData[0];
530
-
531
564
  columnDefs = Object.keys(firstRow).map(key => {
532
565
  // Assuming rowData is an array of objects
533
566
  const values = rowData.map(row => row[key]);
@@ -540,6 +573,7 @@ dmx.Component('ag-grid', {
540
573
  let filterParams;
541
574
  let minWidth;
542
575
  let hide;
576
+ let type;
543
577
  let colId;
544
578
 
545
579
  if (dataType === 'number') {
@@ -693,7 +727,6 @@ dmx.Component('ag-grid', {
693
727
  else {
694
728
  hide = undefined;
695
729
  }
696
-
697
730
  return {
698
731
  headerName: headerName,
699
732
  field: key,
@@ -715,6 +748,27 @@ dmx.Component('ag-grid', {
715
748
  cellRenderer: cellRenderer
716
749
  };
717
750
  });
751
+ if (options.group_config && options.group_config.length > 0) {
752
+ groupedColumnDefs = options.group_config.map(group => {
753
+ const startFieldIndex = columnDefs.findIndex(colDef => colDef.field === group.start_field);
754
+ const endFieldIndex = columnDefs.findIndex(colDef => colDef.field === group.end_field);
755
+
756
+ if (startFieldIndex === -1 || endFieldIndex === -1 || startFieldIndex > endFieldIndex) {
757
+ return null;
758
+ }
759
+
760
+ const groupColumns = columnDefs.slice(startFieldIndex, endFieldIndex + 1)
761
+ .map(col => ({
762
+ ...col,
763
+ columnGroupShow: 'open'
764
+ }));
765
+
766
+ return {
767
+ headerName: group.name,
768
+ children: groupColumns
769
+ };
770
+ }).filter(group => group !== null);
771
+ }
718
772
  }
719
773
  window.onRowClicked = (event) => {
720
774
  const rowData = event.data;
@@ -801,7 +855,7 @@ dmx.Component('ag-grid', {
801
855
  localeText = AG_GRID_LOCALE_HE
802
856
  }
803
857
  const gridOptions = {
804
- columnDefs: columnDefs,
858
+ columnDefs: (groupedColumnDefs && groupedColumnDefs.length > 0) ? groupedColumnDefs : columnDefs,
805
859
  localeText: localeText,
806
860
  enableRtl: options.enable_rtl,
807
861
  noRowsOverlayComponent: '<div>No Records Found.</div>',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "0.5.9",
3
+ "version": "0.6.1",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation",
6
6
  "license": "MIT",