@cdmx/wappler_ag_grid 0.5.8 → 0.6.0

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" being 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.
@@ -1052,6 +1052,52 @@
1052
1052
  }
1053
1053
  ]
1054
1054
  },
1055
+ {
1056
+ "group": "📒 Compact View",
1057
+ "variables": [
1058
+ {
1059
+ "name": "compact_view",
1060
+ "title": "Compact View Config",
1061
+ "type": "boolean",
1062
+ "defaultValue": false,
1063
+ "display": "fieldset",
1064
+ "show": [
1065
+ "compactView",
1066
+ "compactViewGridSize",
1067
+ "compactViewItemHeight"
1068
+ ],
1069
+ "noChangeOnHide": true,
1070
+ "groupEnabler": true,
1071
+ "help": "Configure amount fields to have comma-seperation implemented"
1072
+ "children": [
1073
+ {
1074
+ "name": "compactView",
1075
+ "attribute": "dmx-bind:compact_view",
1076
+ "title": "Compact View",
1077
+ "type": "boolean",
1078
+ "defaultValue": false,
1079
+ "initDisplay": "none"
1080
+ },
1081
+ {
1082
+ "name": "compactViewGridSize",
1083
+ "attribute": "compact_view_grid_size",
1084
+ "title": "Grid Size",
1085
+ "type": "number",
1086
+ "defaultValue": 3,
1087
+ "initDisplay": "none"
1088
+ },
1089
+ {
1090
+ "name": "compactViewItemHeight",
1091
+ "attribute": "compact_view_item_height",
1092
+ "title": "Grid Item Height",
1093
+ "type": "number",
1094
+ "defaultValue": 20,
1095
+ "initDisplay": "none"
1096
+ }
1097
+ ]
1098
+ }
1099
+ ]
1100
+ },
1055
1101
  {
1056
1102
  "group": "📒 Configure Actions Column",
1057
1103
  "variables": [
package/dmx-ag-grid.js CHANGED
@@ -82,7 +82,10 @@ dmx.Component('ag-grid', {
82
82
  data_binded_changes: {type: Array, default: [] },
83
83
  hide_fields: {type: Array, default: [] },
84
84
  hide_filters: {type: Array, default: [] },
85
- hide_sort: {type: Array, default: [] }
85
+ hide_sort: {type: Array, default: [] },
86
+ compact_view: { type: Boolean, default: false },
87
+ compact_view_grid_size: { type: Number, default: 3 },
88
+ compact_view_item_height: { type: Number, default: 20 }
86
89
  },
87
90
 
88
91
  methods: {
@@ -93,16 +96,48 @@ dmx.Component('ag-grid', {
93
96
  },
94
97
  reloadGrid: function () {
95
98
  dmx.nextTick(function() {
96
- this.refreshGrid();
99
+ this.transactionUpdate();
97
100
  }, this);
98
101
  },
99
102
  loadGrid: function () {
100
103
  dmx.nextTick(function() {
101
- this.refreshGrid();
104
+ let gridInstance = this.refreshGrid();
105
+ this.set('gridInstance', gridInstance);
102
106
  }, this);
103
107
  }
104
108
  },
105
109
 
110
+ transactionUpdate: function () {
111
+ // const oldRowData = this.get('oldData');
112
+ const gridInstance = this.get('gridInstance');
113
+ const oldRowData = gridInstance.gridOptions.api.getModel().rowsToDisplay.map(row => row.data);
114
+ const newRowData = this.props.data;
115
+ let transaction;
116
+
117
+ if (oldRowData && oldRowData.length > 0) {
118
+ const addedRows = newRowData.filter(newRow => !oldRowData.some(oldRow => newRow.id === oldRow.id));
119
+ const removedRows = oldRowData.filter(oldRow => !newRowData.some(newRow => oldRow.id === newRow.id));
120
+ const updatedRows = newRowData.filter(newRow => {
121
+ const oldRow = oldRowData.find(old => old.id === newRow.id);
122
+ return oldRow && JSON.stringify(oldRow) !== JSON.stringify(newRow);
123
+ });
124
+
125
+ // Apply transactional updates to AG Grid
126
+ transaction = {
127
+ add: addedRows,
128
+ remove: removedRows,
129
+ update: updatedRows,
130
+ };
131
+ }
132
+
133
+ if (gridInstance && gridInstance.gridOptions && transaction) {
134
+ gridInstance.gridOptions.api.applyTransaction(transaction);
135
+ gridInstance.gridOptions.api.refreshCells();
136
+ } else {
137
+ console.error('AG Grid instance or transaction not found.');
138
+ }
139
+ },
140
+
106
141
  refreshGrid: function () {
107
142
  const options = this.props
108
143
  const rowData = this.props.data;
@@ -537,6 +572,7 @@ dmx.Component('ag-grid', {
537
572
  let filterParams;
538
573
  let minWidth;
539
574
  let hide;
575
+ let type;
540
576
  let colId;
541
577
 
542
578
  if (dataType === 'number') {
@@ -859,6 +895,10 @@ dmx.Component('ag-grid', {
859
895
  // Create ag-Grid instance
860
896
  gridInstance = new agGrid.Grid(gridDiv, gridConfig);
861
897
  const gridElement = document.getElementById(options.id+'-grid');
898
+ if (options.compact_view) {
899
+ gridElement.style.setProperty('--ag-grid-size', `${options.compact_view_grid_size}`+'px');
900
+ gridElement.style.setProperty('--ag-list-item-height', `${options.compact_view_item_height}`+'px');
901
+ }
862
902
  const gridContainer = gridElement.parentNode;
863
903
  // Add an event listener to the grid
864
904
  if (options.row_checkbox_event) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "0.5.8",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation",
6
6
  "license": "MIT",