@cdmx/wappler_ag_grid 0.2.7 → 0.2.9
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 +2 -1
- package/app_connect/components.hjson +82 -12
- package/dmx-ag-grid.js +38 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,4 +16,5 @@ This Custom Module provides the below features:
|
|
|
16
16
|
13. Row Click Event Handling
|
|
17
17
|
14. Options to enable checkboxes for IDs for bulk select Operations
|
|
18
18
|
15. Options to enable Toggle Sliders for status fields
|
|
19
|
-
16. Added Action Buttons feature
|
|
19
|
+
16. Added Action Buttons feature
|
|
20
|
+
17. Advanced Data Manipulation using Arrays and SC bindings
|
|
@@ -22,7 +22,12 @@
|
|
|
22
22
|
"name": "data",
|
|
23
23
|
"title": "Data",
|
|
24
24
|
"type": "object"
|
|
25
|
-
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "count",
|
|
28
|
+
"title": "Count",
|
|
29
|
+
"type": "number"
|
|
30
|
+
},
|
|
26
31
|
{
|
|
27
32
|
"name": "fields",
|
|
28
33
|
"title": "Fields",
|
|
@@ -450,11 +455,11 @@
|
|
|
450
455
|
}
|
|
451
456
|
},
|
|
452
457
|
{
|
|
453
|
-
field: "customColor",
|
|
454
|
-
caption: "Color",
|
|
455
|
-
size: "20%",
|
|
456
|
-
editable: {
|
|
457
|
-
type: "text"
|
|
458
|
+
"field": "customColor",
|
|
459
|
+
"caption": "Color",
|
|
460
|
+
"size": "20%",
|
|
461
|
+
"editable": {
|
|
462
|
+
"type": "text"
|
|
458
463
|
},
|
|
459
464
|
help: "Example: '#FF0000' or 'red'"
|
|
460
465
|
}
|
|
@@ -471,6 +476,76 @@
|
|
|
471
476
|
}
|
|
472
477
|
]
|
|
473
478
|
},
|
|
479
|
+
{
|
|
480
|
+
"group": "📒 Data Advanced Manipulation",
|
|
481
|
+
"variables": [
|
|
482
|
+
{
|
|
483
|
+
"name": "data_binded_changes",
|
|
484
|
+
"title": "Configure Fields",
|
|
485
|
+
"type": "boolean",
|
|
486
|
+
"display": "fieldset",
|
|
487
|
+
"show": [
|
|
488
|
+
"dataBindedChanges"
|
|
489
|
+
],
|
|
490
|
+
"noChangeOnHide": true,
|
|
491
|
+
"groupEnabler": true,
|
|
492
|
+
"help": "Add custom values for the field data based on value, ex: field: status, value: false, new_value: Disabled"
|
|
493
|
+
"children": [
|
|
494
|
+
{
|
|
495
|
+
"name": "dataBindedChanges",
|
|
496
|
+
"attribute": "dmx-bind:data_binded_changes",
|
|
497
|
+
"title": "Fields Data",
|
|
498
|
+
"type": "grid",
|
|
499
|
+
"dataBindings": true,
|
|
500
|
+
"jsonFormat": true,
|
|
501
|
+
"encloseBT": true,
|
|
502
|
+
"jsonBT": true,
|
|
503
|
+
"initDisplay": "none",
|
|
504
|
+
"columns": [
|
|
505
|
+
{
|
|
506
|
+
"field": "field",
|
|
507
|
+
"caption": "Field",
|
|
508
|
+
"size": "5%",
|
|
509
|
+
"editable": {
|
|
510
|
+
"type": "text"
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
"field": "data_source",
|
|
515
|
+
"caption": "Value",
|
|
516
|
+
"size": "5%",
|
|
517
|
+
"editable": {
|
|
518
|
+
"type": "datapicker"
|
|
519
|
+
}
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
"field": "property",
|
|
523
|
+
"caption": "Property",
|
|
524
|
+
"size": "5%",
|
|
525
|
+
"editable": {
|
|
526
|
+
"type": "text"
|
|
527
|
+
}
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
"field": "output",
|
|
531
|
+
"caption": "Output",
|
|
532
|
+
"size": "5%",
|
|
533
|
+
"editable": {
|
|
534
|
+
"type": "text"
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
],
|
|
538
|
+
"newRecord": {
|
|
539
|
+
"field": "",
|
|
540
|
+
"data_source": "",
|
|
541
|
+
"property": "",
|
|
542
|
+
"output": ""
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
]
|
|
546
|
+
}
|
|
547
|
+
]
|
|
548
|
+
},
|
|
474
549
|
{
|
|
475
550
|
"group": "📒 Data Manipulation",
|
|
476
551
|
"variables": [
|
|
@@ -486,11 +561,6 @@
|
|
|
486
561
|
"groupEnabler": true,
|
|
487
562
|
"help": "Add custom values for the field data based on value, ex: field: status, value: false, new_value: Disabled"
|
|
488
563
|
"children": [
|
|
489
|
-
{
|
|
490
|
-
"name": "help",
|
|
491
|
-
"type": "static",
|
|
492
|
-
"help": "Add custom values for the field data based on value, ex: field: status, value: false, new_value: Disabled"
|
|
493
|
-
},
|
|
494
564
|
{
|
|
495
565
|
"name": "dataChanges",
|
|
496
566
|
"attribute": "dmx-bind:data_changes",
|
|
@@ -560,7 +630,6 @@
|
|
|
560
630
|
"attribute": "dmx-bind:cnames",
|
|
561
631
|
"title": "Header Names",
|
|
562
632
|
"type": "grid",
|
|
563
|
-
"dataBindings": true,
|
|
564
633
|
"key": "field",
|
|
565
634
|
"jsonFormat": true,
|
|
566
635
|
"encloseBT": true,
|
|
@@ -579,6 +648,7 @@
|
|
|
579
648
|
field: "custom_name",
|
|
580
649
|
caption: "Name",
|
|
581
650
|
size: "20%",
|
|
651
|
+
dataBindings: true,
|
|
582
652
|
editable: {
|
|
583
653
|
type: "text"
|
|
584
654
|
},
|
package/dmx-ag-grid.js
CHANGED
|
@@ -2,6 +2,7 @@ dmx.Component('ag-grid', {
|
|
|
2
2
|
initialData: {
|
|
3
3
|
id: null,
|
|
4
4
|
data: {},
|
|
5
|
+
count: Number,
|
|
5
6
|
fields: {}
|
|
6
7
|
},
|
|
7
8
|
|
|
@@ -64,6 +65,7 @@ dmx.Component('ag-grid', {
|
|
|
64
65
|
edit_action_btn_class: {type: String, default: 'btn-primary btn-xs' },
|
|
65
66
|
view_action_icon_class: {type: String, default: 'fas fa-eye' },
|
|
66
67
|
view_action_btn_class: {type: String, default: 'btn-info btn-xs' },
|
|
68
|
+
data_binded_changes: {type: Array, default: [] }
|
|
67
69
|
|
|
68
70
|
},
|
|
69
71
|
|
|
@@ -83,7 +85,6 @@ dmx.Component('ag-grid', {
|
|
|
83
85
|
const options = this.props
|
|
84
86
|
const rowData = this.props.data;
|
|
85
87
|
const timezone = this.props.timezone || false;
|
|
86
|
-
const dataChanges = this.props.data_changes;
|
|
87
88
|
|
|
88
89
|
let columnDefs = [];
|
|
89
90
|
let exportToCSV = this.props.exportToCSV;
|
|
@@ -283,13 +284,43 @@ dmx.Component('ag-grid', {
|
|
|
283
284
|
return 'text';
|
|
284
285
|
}
|
|
285
286
|
}
|
|
286
|
-
|
|
287
|
+
createCombinedValueGetter = (key, dataChanges, dataBindedChanges) => {
|
|
288
|
+
const keyLookup = {};
|
|
289
|
+
|
|
290
|
+
dataBindedChanges.forEach(change => {
|
|
291
|
+
if (!keyLookup[change.field]) {
|
|
292
|
+
const data_source = change.data_source;
|
|
293
|
+
const property = change.property;
|
|
294
|
+
const output = change.output;
|
|
295
|
+
let dataArray;
|
|
296
|
+
this.$addBinding(data_source, (function (e) {
|
|
297
|
+
dataArray = e;
|
|
298
|
+
}));
|
|
299
|
+
keyLookup[change.field] = { dataArray, property, output };
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
|
|
287
303
|
return function (params) {
|
|
288
304
|
const value = params.data[key];
|
|
289
|
-
|
|
305
|
+
|
|
306
|
+
// Check if there's a matching change in dataChanges
|
|
307
|
+
const matchingChange = dataChanges.find(change => change.field === key && change.value === String(value));
|
|
290
308
|
if (matchingChange) {
|
|
291
309
|
return matchingChange.new_value;
|
|
292
310
|
}
|
|
311
|
+
|
|
312
|
+
// Check if there's a matching change in dataBindedChanges
|
|
313
|
+
const matchingKeyData = keyLookup[key];
|
|
314
|
+
if (matchingKeyData) {
|
|
315
|
+
const { dataArray, property, output } = matchingKeyData;
|
|
316
|
+
const matchingItem = dataArray.find(item => item[property] === value);
|
|
317
|
+
|
|
318
|
+
if (matchingItem) {
|
|
319
|
+
return matchingItem[output];
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Return the original value if no matching changes were found
|
|
293
324
|
return value;
|
|
294
325
|
};
|
|
295
326
|
}
|
|
@@ -310,8 +341,6 @@ dmx.Component('ag-grid', {
|
|
|
310
341
|
let filterParams;
|
|
311
342
|
let minWidth;
|
|
312
343
|
let hide;
|
|
313
|
-
|
|
314
|
-
|
|
315
344
|
if (dataType === 'number') {
|
|
316
345
|
filter = 'agNumberColumnFilter';
|
|
317
346
|
if (/(amount|amt)$/.test(key)) {
|
|
@@ -349,7 +378,8 @@ dmx.Component('ag-grid', {
|
|
|
349
378
|
}
|
|
350
379
|
}
|
|
351
380
|
else {
|
|
352
|
-
valueGetter = getValueGetter(key, dataChanges);
|
|
381
|
+
// valueGetter = getValueGetter(key, dataChanges);
|
|
382
|
+
valueGetter = createCombinedValueGetter(key, options.data_changes, options.data_binded_changes);
|
|
353
383
|
}
|
|
354
384
|
function extractConditionParts(condition) {
|
|
355
385
|
const parts = condition.match(/(.+?)(===|==|!=|>|<|>=|<=)(.+)/);
|
|
@@ -512,6 +542,7 @@ dmx.Component('ag-grid', {
|
|
|
512
542
|
|
|
513
543
|
const gridOptions = {
|
|
514
544
|
columnDefs: columnDefs,
|
|
545
|
+
noRowsOverlayComponent: '<div>No Records Found.</div>',
|
|
515
546
|
onRowClicked: enableRowClickEvent ? onRowClicked : undefined,
|
|
516
547
|
rowStyle: enableRowClickEvent ? { cursor: 'pointer' } : undefined,
|
|
517
548
|
defaultColDef: {
|
|
@@ -684,6 +715,7 @@ dmx.Component('ag-grid', {
|
|
|
684
715
|
},
|
|
685
716
|
|
|
686
717
|
update: function (props) {
|
|
718
|
+
this.set('count', this.props.data.length);
|
|
687
719
|
if (!dmx.equal(this.props.data, props.data)) {
|
|
688
720
|
this.refreshGrid();
|
|
689
721
|
}
|