@cdmx/wappler_ag_grid 0.0.2 → 0.0.3

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
@@ -7,3 +7,7 @@ This Custom Module provides the below features:
7
7
  5. Export to CSV button
8
8
  6. Sticky header options
9
9
  7. Custom Styles (Column Data)
10
+ 8. Custom Header Names
11
+ 9. Custom min and max widths
12
+ 10. Timezone setting for Date fields
13
+ 11. Data Manipulation
@@ -91,7 +91,7 @@
91
91
  "title": "Minimum Width",
92
92
  "type": "number",
93
93
  "defaultValue": 150,
94
- "help": "The minimum width of the columns"
94
+ "help": "The minimum width of the column"
95
95
  },
96
96
  {
97
97
  "name": "resizable",
@@ -443,6 +443,76 @@
443
443
  }
444
444
  ]
445
445
  },
446
+ {
447
+ "group": "📒 Data Manipulation",
448
+ "variables": [
449
+ {
450
+ "name": "data_changes",
451
+ "attributeStartsWith": "dmx-bind",
452
+ "attribute": "data_changes",
453
+ "title": "Configure Fields",
454
+ "type": "boolean",
455
+ "display": "fieldset",
456
+ "show": [
457
+ "dataChanges"
458
+ ],
459
+ "noChangeOnHide": true,
460
+ "groupEnabler": true,
461
+ "help": "Add custom values for the field data based on value, ex: field: status, value: false, new_value: Disabled"
462
+ "children": [
463
+ {
464
+ "name": "help",
465
+ "type": "static",
466
+ "help": "Add custom values for the field data based on value, ex: field: status, value: false, new_value: Disabled"
467
+ },
468
+ {
469
+ "name": "dataChanges",
470
+ "attribute": "dmx-bind:data_changes",
471
+ "title": "Fields Data",
472
+ "type": "grid",
473
+ "dataBindings": true,
474
+ "key": "field",
475
+ "jsonFormat": true,
476
+ "encloseBT": true,
477
+ "jsonBT": true,
478
+ "initDisplay": "none",
479
+ "columns": [
480
+ {
481
+ "field": "field",
482
+ "caption": "Field",
483
+ "size": "10%",
484
+ "editable": {
485
+ "type": "text"
486
+ }
487
+ },
488
+ {
489
+ "field": "value",
490
+ "caption": "Value",
491
+ "size": "10%",
492
+ "editable": {
493
+ "type": "text"
494
+ }
495
+ },
496
+ {
497
+ field: "new_value",
498
+ caption: "New Value",
499
+ size: "10%",
500
+ editable: {
501
+ type: "text"
502
+ }
503
+ }
504
+ ],
505
+ "newRecord": {
506
+ "name": "",
507
+ "value": "",
508
+ "field": "",
509
+ "new_value": ""
510
+ }
511
+ }
512
+ ]
513
+ }
514
+ ]
515
+ },
446
516
  {
447
517
  "group": "📒 Custom Headers",
448
518
  "variables": [
package/dmx-ag-grid.js CHANGED
@@ -6,6 +6,7 @@ dmx.Component('ag-grid', {
6
6
  cstyles: null,
7
7
  cnames: null,
8
8
  cwidths: null,
9
+ data_changes: null,
9
10
  gridInstance: null,
10
11
  domLayout: 'autoHeight',
11
12
  enableCellTextSelection: true,
@@ -42,69 +43,25 @@ dmx.Component('ag-grid', {
42
43
  },
43
44
 
44
45
  attributes: {
45
- id: {
46
- default: null
47
- },
48
- rowData: {
49
- type: Array,
50
- default: []
51
- },
52
- column_defs: {
53
- type: Array,
54
- default: []
55
- },
56
- cstyles: {
57
- type: Object,
58
- default: {}
59
- },
46
+ id: { default: null },
47
+ rowData: { type: Array, default: [] },
48
+ column_defs: { type: Array, default: [] },
49
+ cstyles: { type: Object, default: {} },
60
50
  cnames: { type: Object, default: {} },
61
51
  cwidths: { type: Object, default: {} },
62
- data: {
63
- type: Array,
64
- default: []
65
- },
66
- domLayout: {
67
- default: 'autoHeight'
68
- },
69
- enableCellTextSelection: {
70
- type: Boolean,
71
- default: true
72
- },
73
- rowSelection: {
74
- type: Boolean,
75
- default: false
76
- },
77
- suppressRowDeselection: {
78
- type: Boolean,
79
- default: false
80
- },
81
- pagination: {
82
- type: Boolean,
83
- default: true
84
- },
85
- paginationPageSize: {
86
- default: 20
87
- },
88
- rowHeight: {
89
- type: Number,
90
- default: null
91
- },
92
- headerHeight: {
93
- type: Number,
94
- default: null
95
- },
96
- suppressRowClickSelection: {
97
- type: Boolean,
98
- default: false
99
- },
100
- suppressMenuHide: {
101
- type: Boolean,
102
- default: false
103
- },
104
- suppressMovableColumns: {
105
- type: Boolean,
106
- default: false
107
- },
52
+ data_changes: { type: Object, default: {} },
53
+ data: { type: Array, default: [] },
54
+ domLayout: { default: 'autoHeight' },
55
+ enableCellTextSelection: { type: Boolean, default: true },
56
+ rowSelection: { type: Boolean, default: false },
57
+ suppressRowDeselection: { type: Boolean, default: false },
58
+ pagination: { type: Boolean, default: true },
59
+ paginationPageSize: { default: 20 },
60
+ rowHeight: { type: Number, default: null },
61
+ headerHeight: { type: Number, default: null },
62
+ suppressRowClickSelection: { type: Boolean, default: false },
63
+ suppressMenuHide: { type: Boolean, default: false },
64
+ suppressMovableColumns: { type: Boolean, default: false },
108
65
  enableCellExpressions: {
109
66
  type: Boolean,
110
67
  default: false
@@ -200,6 +157,7 @@ dmx.Component('ag-grid', {
200
157
  const topbarClass = this.props.topbarClass;
201
158
  const fixedTopOffset = this.props.fixedTopOffset;
202
159
  const timezone = this.props.timezone || false;
160
+ const dataChanges = this.props.data_changes;
203
161
  let columnDefs = [];
204
162
  let exportToCSV = this.props.exportToCSV;
205
163
  if (!rowData || rowData.length === 0) {
@@ -289,6 +247,16 @@ dmx.Component('ag-grid', {
289
247
  return 'text';
290
248
  }
291
249
  }
250
+ function getValueGetter(key, dataChanges) {
251
+ return function(params) {
252
+ let value = params.data[key];
253
+ if (dataChanges.hasOwnProperty(key)) {
254
+ const change = dataChanges[key];
255
+ value = change.new_value;
256
+ }
257
+ return value;
258
+ };
259
+ }
292
260
  if (Array.isArray(this.props.column_defs) && this.props.column_defs.length > 0) {
293
261
  columnDefs = this.props.column_defs;
294
262
  } else {
@@ -337,6 +305,9 @@ dmx.Component('ag-grid', {
337
305
  filterValueGetter = eval(`(params) => ${definition.filterGetter}`);
338
306
  }
339
307
  }
308
+ else {
309
+ valueGetter = getValueGetter(key, dataChanges);
310
+ }
340
311
  function extractConditionParts(condition) {
341
312
  const parts = condition.match(/(.+?)(===|==|!=|>|<|>=|<=)(.+)/);
342
313
  if (parts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation",
6
6
  "license": "MIT",