@cdmx/wappler_ag_grid 0.3.4 → 0.3.5

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.
Files changed (2) hide show
  1. package/dmx-ag-grid.js +42 -2
  2. package/package.json +1 -1
package/dmx-ag-grid.js CHANGED
@@ -75,8 +75,9 @@ dmx.Component('ag-grid', {
75
75
  this.refreshGrid();
76
76
  },
77
77
  reloadGrid: function () {
78
- this.refreshGrid()
79
- console.log('reloadGrid');
78
+ dmx.nextTick(function() {
79
+ this.refreshGrid();
80
+ }, this);
80
81
  }
81
82
  },
82
83
 
@@ -327,6 +328,44 @@ dmx.Component('ag-grid', {
327
328
  return value;
328
329
  };
329
330
  }
331
+ createCombinedFilterValueGetter = (key, dataChanges, dataBindedChanges) => {
332
+ const keyLookup = {};
333
+
334
+ dataBindedChanges.forEach(change => {
335
+ if (!keyLookup[change.field]) {
336
+ const data_source = change.data_source;
337
+ const property = change.property;
338
+ const output = change.output;
339
+ let dataArray;
340
+ this.$addBinding(data_source, (function (e) {
341
+ dataArray = e;
342
+ }));
343
+ keyLookup[change.field] = { dataArray, property, output };
344
+ }
345
+ });
346
+
347
+ return function (params) {
348
+ const value = params.data[key];
349
+
350
+ // Check if there's a matching change in dataChanges
351
+ const matchingChange = dataChanges.find(change => change.field === key && change.value === String(value));
352
+ if (matchingChange) {
353
+ return matchingChange.new_value;
354
+ }
355
+ // Check if there's a matching change in dataBindedChanges
356
+ const matchingKeyData = keyLookup[key];
357
+ if (matchingKeyData) {
358
+ const { dataArray, property, output } = matchingKeyData;
359
+ const matchingItem = dataArray.find(item => item[property] === value);
360
+
361
+ if (matchingItem) {
362
+ return matchingItem[output];
363
+ }
364
+ }
365
+ // Return the original value if no matching changes were found
366
+ return value;
367
+ };
368
+ };
330
369
  if (Array.isArray(this.props.column_defs) && this.props.column_defs.length > 0) {
331
370
  columnDefs = this.props.column_defs;
332
371
  } else {
@@ -384,6 +423,7 @@ dmx.Component('ag-grid', {
384
423
  else {
385
424
  // valueGetter = getValueGetter(key, dataChanges);
386
425
  valueGetter = createCombinedValueGetter(key, options.data_changes, options.data_binded_changes);
426
+ filterValueGetter = createCombinedFilterValueGetter(key, options.data_changes, options.data_binded_changes);
387
427
  }
388
428
  function extractConditionParts(condition) {
389
429
  const parts = condition.match(/(.+?)(===|==|!=|>|<|>=|<=)(.+)/);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation",
6
6
  "license": "MIT",