@cdmx/wappler_ag_grid 0.3.4 → 0.3.6
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/app_connect/components.hjson +78 -20
- package/dmx-ag-grid.js +49 -3
- package/package.json +1 -1
|
@@ -419,13 +419,79 @@
|
|
|
419
419
|
}
|
|
420
420
|
]
|
|
421
421
|
},
|
|
422
|
+
{
|
|
423
|
+
"group": "📒 Data Type Overrides",
|
|
424
|
+
"variables": [
|
|
425
|
+
{
|
|
426
|
+
"name": "ctypes",
|
|
427
|
+
"title": "Configure Type Overrides",
|
|
428
|
+
"attributeStartsWith": "dmx-bind",
|
|
429
|
+
"attribute": "ctypes",
|
|
430
|
+
"type": "boolean",
|
|
431
|
+
"defaultValue": false,
|
|
432
|
+
"icon": "fa fa-lg fa-database",
|
|
433
|
+
"groupIcon": "fa fa-lg fa-exchange",
|
|
434
|
+
"display": "fieldset",
|
|
435
|
+
"show": [
|
|
436
|
+
"typeOverrides"
|
|
437
|
+
],
|
|
438
|
+
"noChangeOnHide": true,
|
|
439
|
+
"groupEnabler": true,
|
|
440
|
+
"help": "This allows you to override the auto-detected datatypes"
|
|
441
|
+
"children": [
|
|
442
|
+
{
|
|
443
|
+
"name": "typeOverrides",
|
|
444
|
+
"attribute": "dmx-bind:ctypes",
|
|
445
|
+
"title": "Type Overrides",
|
|
446
|
+
"type": "grid",
|
|
447
|
+
"jsonFormat": true,
|
|
448
|
+
"encloseBT": true,
|
|
449
|
+
"jsonBT": true,
|
|
450
|
+
"defaultValue": [],
|
|
451
|
+
"initDisplay": "none",
|
|
452
|
+
"columns": [
|
|
453
|
+
{
|
|
454
|
+
"field": "field",
|
|
455
|
+
"caption": "Field",
|
|
456
|
+
"size": "20%",
|
|
457
|
+
"editable": {
|
|
458
|
+
"type": "text"
|
|
459
|
+
}
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
"field": "type",
|
|
463
|
+
"caption": "Type",
|
|
464
|
+
"size": "35%",
|
|
465
|
+
"editable": {
|
|
466
|
+
"type": "list",
|
|
467
|
+
"items": [
|
|
468
|
+
{id: 'number', text: 'number'},
|
|
469
|
+
{id: 'text', text: 'text'},
|
|
470
|
+
{id: 'date', text: 'date'}
|
|
471
|
+
]
|
|
472
|
+
}
|
|
473
|
+
},
|
|
474
|
+
],
|
|
475
|
+
"newRecord": {
|
|
476
|
+
"name": "",
|
|
477
|
+
"field": "",
|
|
478
|
+
"type": ""
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
]
|
|
482
|
+
}
|
|
483
|
+
]
|
|
484
|
+
},
|
|
422
485
|
{
|
|
423
486
|
"group": "📒 Style Formatting",
|
|
424
487
|
"variables": [
|
|
425
488
|
{
|
|
426
489
|
"name": "cstyles",
|
|
427
490
|
"title": "Configure Colors",
|
|
491
|
+
"attributeStartsWith": "dmx-bind",
|
|
492
|
+
"attribute": "cstyles",
|
|
428
493
|
"type": "boolean",
|
|
494
|
+
"defaultValue": false,
|
|
429
495
|
"display": "fieldset",
|
|
430
496
|
"show": [
|
|
431
497
|
"listColors"
|
|
@@ -434,11 +500,6 @@
|
|
|
434
500
|
"groupEnabler": true,
|
|
435
501
|
"help": "Add custom colors to column data based on condition, ex: field: status, condition: status==false, Color: red"
|
|
436
502
|
"children": [
|
|
437
|
-
{
|
|
438
|
-
"name": "help",
|
|
439
|
-
"type": "static",
|
|
440
|
-
"help": "Add custom colors for the fields"
|
|
441
|
-
},
|
|
442
503
|
{
|
|
443
504
|
"name": "listColors",
|
|
444
505
|
"attribute": "dmx-bind:cstyles",
|
|
@@ -494,7 +555,10 @@
|
|
|
494
555
|
{
|
|
495
556
|
"name": "data_binded_changes",
|
|
496
557
|
"title": "Configure Fields",
|
|
558
|
+
"attributeStartsWith": "dmx-bind",
|
|
559
|
+
"attribute": "data_binded_changes",
|
|
497
560
|
"type": "boolean",
|
|
561
|
+
"defaultValue": false,
|
|
498
562
|
"display": "fieldset",
|
|
499
563
|
"show": [
|
|
500
564
|
"dataBindedChanges"
|
|
@@ -564,7 +628,10 @@
|
|
|
564
628
|
{
|
|
565
629
|
"name": "data_changes",
|
|
566
630
|
"title": "Configure Fields",
|
|
631
|
+
"attributeStartsWith": "dmx-bind",
|
|
632
|
+
"attribute": "data_changes",
|
|
567
633
|
"type": "boolean",
|
|
634
|
+
"defaultValue": false,
|
|
568
635
|
"display": "fieldset",
|
|
569
636
|
"show": [
|
|
570
637
|
"dataChanges"
|
|
@@ -623,7 +690,10 @@
|
|
|
623
690
|
{
|
|
624
691
|
"name": "cnames",
|
|
625
692
|
"title": "Configure Header Names",
|
|
693
|
+
"attributeStartsWith": "dmx-bind",
|
|
694
|
+
"attribute": "cnames",
|
|
626
695
|
"type": "boolean",
|
|
696
|
+
"defaultValue": false,
|
|
627
697
|
"display": "fieldset",
|
|
628
698
|
"show": [
|
|
629
699
|
"listCustomNames"
|
|
@@ -632,11 +702,6 @@
|
|
|
632
702
|
"groupEnabler": true,
|
|
633
703
|
"help": "Add custom headers to column"
|
|
634
704
|
"children": [
|
|
635
|
-
{
|
|
636
|
-
"name": "help",
|
|
637
|
-
"type": "static",
|
|
638
|
-
"help": "Add custom headers to column"
|
|
639
|
-
},
|
|
640
705
|
{
|
|
641
706
|
"name": "listCustomNames",
|
|
642
707
|
"attribute": "dmx-bind:cnames",
|
|
@@ -685,7 +750,10 @@
|
|
|
685
750
|
{
|
|
686
751
|
"name": "cwidths",
|
|
687
752
|
"title": "Configure Custom Widths",
|
|
753
|
+
"attributeStartsWith": "dmx-bind",
|
|
754
|
+
"attribute": "cwidths",
|
|
688
755
|
"type": "boolean",
|
|
756
|
+
"defaultValue": false,
|
|
689
757
|
"display": "fieldset",
|
|
690
758
|
"show": [
|
|
691
759
|
"listCustomWidths",
|
|
@@ -694,11 +762,6 @@
|
|
|
694
762
|
"groupEnabler": true,
|
|
695
763
|
"help": "Add custom widths for the field"
|
|
696
764
|
"children": [
|
|
697
|
-
{
|
|
698
|
-
"name": "help",
|
|
699
|
-
"type": "static",
|
|
700
|
-
"help": "Add custom widths for the field"
|
|
701
|
-
},
|
|
702
765
|
{
|
|
703
766
|
"name": "listCustomWidths",
|
|
704
767
|
"attribute": "dmx-bind:cwidths",
|
|
@@ -776,11 +839,6 @@
|
|
|
776
839
|
"groupEnabler": true,
|
|
777
840
|
"help": "Configure Actions for the buttons in Actions Column"
|
|
778
841
|
"children": [
|
|
779
|
-
{
|
|
780
|
-
"name": "help",
|
|
781
|
-
"type": "static",
|
|
782
|
-
"help": "Configure Actions for the buttons"
|
|
783
|
-
},
|
|
784
842
|
{
|
|
785
843
|
"name": "enableActions",
|
|
786
844
|
"attribute": "dmx-bind:enable_actions",
|
package/dmx-ag-grid.js
CHANGED
|
@@ -13,6 +13,7 @@ dmx.Component('ag-grid', {
|
|
|
13
13
|
cstyles: { type: Array, default: [] },
|
|
14
14
|
cnames: { type: Object, default: {} },
|
|
15
15
|
cwidths: { type: Object, default: {} },
|
|
16
|
+
ctypes: { type: Array, default: [] },
|
|
16
17
|
data_changes: { type: Array, default: [] },
|
|
17
18
|
data: { type: Array, default: [] },
|
|
18
19
|
dom_layout: { type: String, default: 'autoHeight' },
|
|
@@ -75,8 +76,9 @@ dmx.Component('ag-grid', {
|
|
|
75
76
|
this.refreshGrid();
|
|
76
77
|
},
|
|
77
78
|
reloadGrid: function () {
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
dmx.nextTick(function() {
|
|
80
|
+
this.refreshGrid();
|
|
81
|
+
}, this);
|
|
80
82
|
}
|
|
81
83
|
},
|
|
82
84
|
|
|
@@ -86,6 +88,7 @@ dmx.Component('ag-grid', {
|
|
|
86
88
|
const timezone = this.props.timezone || false;
|
|
87
89
|
const cnames = this.props.cnames
|
|
88
90
|
const cwidths = this.props.cwidths
|
|
91
|
+
const ctypes = this.props.ctypes
|
|
89
92
|
const enableRowClickEvent = this.props.row_click_event;
|
|
90
93
|
const enableCellClickEvent = this.props.cell_click_event;
|
|
91
94
|
let localeText;
|
|
@@ -262,6 +265,10 @@ dmx.Component('ag-grid', {
|
|
|
262
265
|
browserDatePicker: true,
|
|
263
266
|
}
|
|
264
267
|
// Function to detect the data type based on the values
|
|
268
|
+
function getCustomDataTypes(key) {
|
|
269
|
+
const matchingType = ctypes.find((ct) => ct.field === key);
|
|
270
|
+
return matchingType ? matchingType.type : null;
|
|
271
|
+
}
|
|
265
272
|
function detectDataType(values) {
|
|
266
273
|
let hasDate = false;
|
|
267
274
|
let hasNumber = false;
|
|
@@ -327,6 +334,44 @@ dmx.Component('ag-grid', {
|
|
|
327
334
|
return value;
|
|
328
335
|
};
|
|
329
336
|
}
|
|
337
|
+
createCombinedFilterValueGetter = (key, dataChanges, dataBindedChanges) => {
|
|
338
|
+
const keyLookup = {};
|
|
339
|
+
|
|
340
|
+
dataBindedChanges.forEach(change => {
|
|
341
|
+
if (!keyLookup[change.field]) {
|
|
342
|
+
const data_source = change.data_source;
|
|
343
|
+
const property = change.property;
|
|
344
|
+
const output = change.output;
|
|
345
|
+
let dataArray;
|
|
346
|
+
this.$addBinding(data_source, (function (e) {
|
|
347
|
+
dataArray = e;
|
|
348
|
+
}));
|
|
349
|
+
keyLookup[change.field] = { dataArray, property, output };
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
return function (params) {
|
|
354
|
+
const value = params.data[key];
|
|
355
|
+
|
|
356
|
+
// Check if there's a matching change in dataChanges
|
|
357
|
+
const matchingChange = dataChanges.find(change => change.field === key && change.value === String(value));
|
|
358
|
+
if (matchingChange) {
|
|
359
|
+
return matchingChange.new_value;
|
|
360
|
+
}
|
|
361
|
+
// Check if there's a matching change in dataBindedChanges
|
|
362
|
+
const matchingKeyData = keyLookup[key];
|
|
363
|
+
if (matchingKeyData) {
|
|
364
|
+
const { dataArray, property, output } = matchingKeyData;
|
|
365
|
+
const matchingItem = dataArray.find(item => item[property] === value);
|
|
366
|
+
|
|
367
|
+
if (matchingItem) {
|
|
368
|
+
return matchingItem[output];
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
// Return the original value if no matching changes were found
|
|
372
|
+
return value;
|
|
373
|
+
};
|
|
374
|
+
};
|
|
330
375
|
if (Array.isArray(this.props.column_defs) && this.props.column_defs.length > 0) {
|
|
331
376
|
columnDefs = this.props.column_defs;
|
|
332
377
|
} else {
|
|
@@ -336,7 +381,7 @@ dmx.Component('ag-grid', {
|
|
|
336
381
|
// Assuming rowData is an array of objects
|
|
337
382
|
const values = rowData.map(row => row[key]);
|
|
338
383
|
const nonNullValues = values.filter(value => value !== null);
|
|
339
|
-
const dataType = detectDataType(nonNullValues);
|
|
384
|
+
const dataType = (ctypes.length>0 ? getCustomDataTypes(key) : detectDataType(nonNullValues));
|
|
340
385
|
let filter;
|
|
341
386
|
let valueGetter;
|
|
342
387
|
let filterValueGetter;
|
|
@@ -384,6 +429,7 @@ dmx.Component('ag-grid', {
|
|
|
384
429
|
else {
|
|
385
430
|
// valueGetter = getValueGetter(key, dataChanges);
|
|
386
431
|
valueGetter = createCombinedValueGetter(key, options.data_changes, options.data_binded_changes);
|
|
432
|
+
filterValueGetter = createCombinedFilterValueGetter(key, options.data_changes, options.data_binded_changes);
|
|
387
433
|
}
|
|
388
434
|
function extractConditionParts(condition) {
|
|
389
435
|
const parts = condition.match(/(.+?)(===|==|!=|>|<|>=|<=)(.+)/);
|