@cdmx/wappler_ag_grid 0.0.2 → 0.0.4
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 +4 -0
- package/app_connect/components.hjson +72 -31
- package/dmx-ag-grid.js +40 -67
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"icon": "fa fa-lg fa-table",
|
|
10
10
|
"state": "opened",
|
|
11
11
|
"anyParent": true,
|
|
12
|
-
"template": "<dmx-ag-grid id=\"@@id
|
|
12
|
+
"template": "<dmx-ag-grid id=\"@@id@@\"></dmx-ag-grid>",
|
|
13
13
|
"baseName": "aggrid",
|
|
14
14
|
"help": "AG Grid component for data display",
|
|
15
15
|
"dataScheme": [
|
|
@@ -56,42 +56,13 @@
|
|
|
56
56
|
{
|
|
57
57
|
"group": "AG Grid Options",
|
|
58
58
|
"variables": [
|
|
59
|
-
{
|
|
60
|
-
"name": "defaultColDef",
|
|
61
|
-
"attribute": "defaultColDef",
|
|
62
|
-
"title": "Default Column Definition",
|
|
63
|
-
"type": "object",
|
|
64
|
-
"defaultValue": {},
|
|
65
|
-
"help": "Default properties for all columns"
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
"name": "columnTypes",
|
|
69
|
-
"attribute": "columnTypes",
|
|
70
|
-
"title": "Column Types",
|
|
71
|
-
"type": "object",
|
|
72
|
-
"defaultValue": {},
|
|
73
|
-
"help": "Map of custom column types"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"name": "rowSelection",
|
|
77
|
-
"attribute": "rowSelection",
|
|
78
|
-
"title": "Row Selection",
|
|
79
|
-
"type": "string",
|
|
80
|
-
"defaultValue": "single",
|
|
81
|
-
"options": [
|
|
82
|
-
"single",
|
|
83
|
-
"multiple",
|
|
84
|
-
"none"
|
|
85
|
-
],
|
|
86
|
-
"help": "Defines the row selection mode"
|
|
87
|
-
},
|
|
88
59
|
{
|
|
89
60
|
"name": "minWidth",
|
|
90
61
|
"attribute": "minWidth",
|
|
91
62
|
"title": "Minimum Width",
|
|
92
63
|
"type": "number",
|
|
93
64
|
"defaultValue": 150,
|
|
94
|
-
"help": "The minimum width of the
|
|
65
|
+
"help": "The minimum width of the column"
|
|
95
66
|
},
|
|
96
67
|
{
|
|
97
68
|
"name": "resizable",
|
|
@@ -443,6 +414,76 @@
|
|
|
443
414
|
}
|
|
444
415
|
]
|
|
445
416
|
},
|
|
417
|
+
{
|
|
418
|
+
"group": "📒 Data Manipulation",
|
|
419
|
+
"variables": [
|
|
420
|
+
{
|
|
421
|
+
"name": "data_changes",
|
|
422
|
+
"attributeStartsWith": "dmx-bind",
|
|
423
|
+
"attribute": "data_changes",
|
|
424
|
+
"title": "Configure Fields",
|
|
425
|
+
"type": "boolean",
|
|
426
|
+
"display": "fieldset",
|
|
427
|
+
"show": [
|
|
428
|
+
"dataChanges"
|
|
429
|
+
],
|
|
430
|
+
"noChangeOnHide": true,
|
|
431
|
+
"groupEnabler": true,
|
|
432
|
+
"help": "Add custom values for the field data based on value, ex: field: status, value: false, new_value: Disabled"
|
|
433
|
+
"children": [
|
|
434
|
+
{
|
|
435
|
+
"name": "help",
|
|
436
|
+
"type": "static",
|
|
437
|
+
"help": "Add custom values for the field data based on value, ex: field: status, value: false, new_value: Disabled"
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
"name": "dataChanges",
|
|
441
|
+
"attribute": "dmx-bind:data_changes",
|
|
442
|
+
"title": "Fields Data",
|
|
443
|
+
"type": "grid",
|
|
444
|
+
"dataBindings": true,
|
|
445
|
+
"key": "field",
|
|
446
|
+
"jsonFormat": true,
|
|
447
|
+
"encloseBT": true,
|
|
448
|
+
"jsonBT": true,
|
|
449
|
+
"initDisplay": "none",
|
|
450
|
+
"columns": [
|
|
451
|
+
{
|
|
452
|
+
"field": "field",
|
|
453
|
+
"caption": "Field",
|
|
454
|
+
"size": "10%",
|
|
455
|
+
"editable": {
|
|
456
|
+
"type": "text"
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
"field": "value",
|
|
461
|
+
"caption": "Value",
|
|
462
|
+
"size": "10%",
|
|
463
|
+
"editable": {
|
|
464
|
+
"type": "text"
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
field: "new_value",
|
|
469
|
+
caption: "New Value",
|
|
470
|
+
size: "10%",
|
|
471
|
+
editable: {
|
|
472
|
+
type: "text"
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
],
|
|
476
|
+
"newRecord": {
|
|
477
|
+
"name": "",
|
|
478
|
+
"value": "",
|
|
479
|
+
"field": "",
|
|
480
|
+
"new_value": ""
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
]
|
|
484
|
+
}
|
|
485
|
+
]
|
|
486
|
+
},
|
|
446
487
|
{
|
|
447
488
|
"group": "📒 Custom Headers",
|
|
448
489
|
"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
|
-
|
|
47
|
-
},
|
|
48
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
|
|
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,8 +157,12 @@ 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;
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
this.$node.innerHTML = `<div id=${gridId +'-grid'}></div>`
|
|
205
166
|
if (!rowData || rowData.length === 0) {
|
|
206
167
|
console.error('No row data provided.');
|
|
207
168
|
return;
|
|
@@ -289,6 +250,16 @@ dmx.Component('ag-grid', {
|
|
|
289
250
|
return 'text';
|
|
290
251
|
}
|
|
291
252
|
}
|
|
253
|
+
function getValueGetter(key, dataChanges) {
|
|
254
|
+
return function(params) {
|
|
255
|
+
let value = params.data[key];
|
|
256
|
+
if (dataChanges.hasOwnProperty(key)) {
|
|
257
|
+
const change = dataChanges[key];
|
|
258
|
+
value = change.new_value;
|
|
259
|
+
}
|
|
260
|
+
return value;
|
|
261
|
+
};
|
|
262
|
+
}
|
|
292
263
|
if (Array.isArray(this.props.column_defs) && this.props.column_defs.length > 0) {
|
|
293
264
|
columnDefs = this.props.column_defs;
|
|
294
265
|
} else {
|
|
@@ -337,6 +308,9 @@ dmx.Component('ag-grid', {
|
|
|
337
308
|
filterValueGetter = eval(`(params) => ${definition.filterGetter}`);
|
|
338
309
|
}
|
|
339
310
|
}
|
|
311
|
+
else {
|
|
312
|
+
valueGetter = getValueGetter(key, dataChanges);
|
|
313
|
+
}
|
|
340
314
|
function extractConditionParts(condition) {
|
|
341
315
|
const parts = condition.match(/(.+?)(===|==|!=|>|<|>=|<=)(.+)/);
|
|
342
316
|
if (parts) {
|
|
@@ -452,10 +426,9 @@ const cstyles = this.props.cstyles
|
|
|
452
426
|
rowData: rowData,
|
|
453
427
|
...gridOptions
|
|
454
428
|
};
|
|
455
|
-
|
|
456
429
|
// Create ag-Grid instance
|
|
457
430
|
new agGrid.Grid(gridDiv, gridConfig);
|
|
458
|
-
const gridElement = document.
|
|
431
|
+
const gridElement = document.getElementById(gridId+'-grid');
|
|
459
432
|
const gridContainer = gridElement.parentNode;
|
|
460
433
|
|
|
461
434
|
if (!gridContainer) {
|
|
@@ -515,13 +488,13 @@ const cstyles = this.props.cstyles
|
|
|
515
488
|
'dmx-ag-grid-row-data-updated': Event
|
|
516
489
|
},
|
|
517
490
|
|
|
518
|
-
render: function
|
|
519
|
-
|
|
491
|
+
render: function(node) {
|
|
492
|
+
if (this.$node) {
|
|
493
|
+
this.$parse();
|
|
494
|
+
}
|
|
520
495
|
},
|
|
521
496
|
|
|
522
497
|
update: function (props) {
|
|
523
|
-
// dmx.equal is a helper function the does a deep compare
|
|
524
|
-
// which is useful when comparing arrays and objects
|
|
525
498
|
if (!dmx.equal(this.props.data, props.data)) {
|
|
526
499
|
this.refreshGrid();
|
|
527
500
|
}
|