@cdmx/wappler_ag_grid 0.2.4 → 0.2.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 +24 -10
- package/dmx-ag-grid.js +74 -52
- package/package.json +1 -1
|
@@ -360,6 +360,14 @@
|
|
|
360
360
|
"defaultValue": false,
|
|
361
361
|
"help": "Disables checking for duplicate property names"
|
|
362
362
|
},
|
|
363
|
+
{
|
|
364
|
+
"name": "hideIdField",
|
|
365
|
+
"attribute": "dmx-bind:hide_id_field",
|
|
366
|
+
"title": "Hide ID Field",
|
|
367
|
+
"type": "boolean",
|
|
368
|
+
"defaultValue": false,
|
|
369
|
+
"help": "Hides the ID Field in Grid"
|
|
370
|
+
},
|
|
363
371
|
{
|
|
364
372
|
"name": "localeText",
|
|
365
373
|
"attribute": "localeText",
|
|
@@ -399,8 +407,6 @@
|
|
|
399
407
|
"variables": [
|
|
400
408
|
{
|
|
401
409
|
"name": "cstyles",
|
|
402
|
-
"attributeStartsWith": "dmx-bind",
|
|
403
|
-
"attribute": "cstyles",
|
|
404
410
|
"title": "Configure Colors",
|
|
405
411
|
"type": "boolean",
|
|
406
412
|
"display": "fieldset",
|
|
@@ -422,7 +428,6 @@
|
|
|
422
428
|
"title": "Colors",
|
|
423
429
|
"type": "grid",
|
|
424
430
|
"dataBindings": true,
|
|
425
|
-
"key": "field",
|
|
426
431
|
"jsonFormat": true,
|
|
427
432
|
"encloseBT": true,
|
|
428
433
|
"jsonBT": true,
|
|
@@ -471,8 +476,6 @@
|
|
|
471
476
|
"variables": [
|
|
472
477
|
{
|
|
473
478
|
"name": "data_changes",
|
|
474
|
-
"attributeStartsWith": "dmx-bind",
|
|
475
|
-
"attribute": "data_changes",
|
|
476
479
|
"title": "Configure Fields",
|
|
477
480
|
"type": "boolean",
|
|
478
481
|
"display": "fieldset",
|
|
@@ -494,7 +497,6 @@
|
|
|
494
497
|
"title": "Fields Data",
|
|
495
498
|
"type": "grid",
|
|
496
499
|
"dataBindings": true,
|
|
497
|
-
"key": "field",
|
|
498
500
|
"jsonFormat": true,
|
|
499
501
|
"encloseBT": true,
|
|
500
502
|
"jsonBT": true,
|
|
@@ -538,8 +540,6 @@
|
|
|
538
540
|
"variables": [
|
|
539
541
|
{
|
|
540
542
|
"name": "cnames",
|
|
541
|
-
"attributeStartsWith": "dmx-bind",
|
|
542
|
-
"attribute": "cnames",
|
|
543
543
|
"title": "Configure Header Names",
|
|
544
544
|
"type": "boolean",
|
|
545
545
|
"display": "fieldset",
|
|
@@ -601,8 +601,6 @@
|
|
|
601
601
|
"variables": [
|
|
602
602
|
{
|
|
603
603
|
"name": "cwidths",
|
|
604
|
-
"attributeStartsWith": "dmx-bind",
|
|
605
|
-
"attribute": "cwidths",
|
|
606
604
|
"title": "Configure Custom Widths",
|
|
607
605
|
"type": "boolean",
|
|
608
606
|
"display": "fieldset",
|
|
@@ -680,10 +678,12 @@
|
|
|
680
678
|
"display": "fieldset",
|
|
681
679
|
"show": [
|
|
682
680
|
"enableActions",
|
|
681
|
+
"editActionBtn",
|
|
683
682
|
"editActionTitle",
|
|
684
683
|
"editActionTooltip",
|
|
685
684
|
"editActionBtnClass",
|
|
686
685
|
"editActionIconClass",
|
|
686
|
+
"viewActionBtn",
|
|
687
687
|
"viewActionTitle",
|
|
688
688
|
"viewActionTooltip",
|
|
689
689
|
"viewActionBtnClass",
|
|
@@ -706,6 +706,13 @@
|
|
|
706
706
|
"defaultValue": false,
|
|
707
707
|
"help": "Enable Actions"
|
|
708
708
|
},
|
|
709
|
+
{
|
|
710
|
+
"name": "editActionBtn",
|
|
711
|
+
"attribute": "dmx-bind:edit_action_btn",
|
|
712
|
+
"title": "Edit Action Button",
|
|
713
|
+
"type": "boolean",
|
|
714
|
+
"defaultValue": false
|
|
715
|
+
},
|
|
709
716
|
{
|
|
710
717
|
"name": "editActionTitle",
|
|
711
718
|
"attribute": "edit_action_title",
|
|
@@ -734,6 +741,13 @@
|
|
|
734
741
|
"type": "text",
|
|
735
742
|
"defaultValue": 'fas fa-pencil-alt'
|
|
736
743
|
},
|
|
744
|
+
{
|
|
745
|
+
"name": "viewActionBtn",
|
|
746
|
+
"attribute": "dmx-bind:view_action_btn",
|
|
747
|
+
"title": "View Action Button",
|
|
748
|
+
"type": "boolean",
|
|
749
|
+
"defaultValue": ''
|
|
750
|
+
},
|
|
737
751
|
{
|
|
738
752
|
"name": "viewActionTitle",
|
|
739
753
|
"attribute": "view_action_title",
|
package/dmx-ag-grid.js
CHANGED
|
@@ -10,10 +10,10 @@ dmx.Component('ag-grid', {
|
|
|
10
10
|
rowData: { type: Array, default: [] },
|
|
11
11
|
grid_theme: { type: String, default: 'ag-theme-alpine' },
|
|
12
12
|
column_defs: { type: Array, default: [] },
|
|
13
|
-
cstyles: { type:
|
|
13
|
+
cstyles: { type: Array, default: [] },
|
|
14
14
|
cnames: { type: Object, default: {} },
|
|
15
15
|
cwidths: { type: Object, default: {} },
|
|
16
|
-
data_changes: { type:
|
|
16
|
+
data_changes: { type: Array, default: [] },
|
|
17
17
|
data: { type: Array, default: [] },
|
|
18
18
|
domLayout: { default: 'autoHeight' },
|
|
19
19
|
enableCellTextSelection: { type: Boolean, default: true },
|
|
@@ -33,6 +33,7 @@ dmx.Component('ag-grid', {
|
|
|
33
33
|
suppressClipboardPaste: { type: Boolean, default: false },
|
|
34
34
|
suppressScrollOnNewData: { type: Boolean, default: false },
|
|
35
35
|
suppressPropertyNamesCheck: { type: Boolean, default: false },
|
|
36
|
+
hide_id_field: { type: Boolean, default: false },
|
|
36
37
|
localeText: { default: null },
|
|
37
38
|
minWidth: { type: Number, default: 150 },
|
|
38
39
|
sortable: { type: Boolean, default: true },
|
|
@@ -53,8 +54,10 @@ dmx.Component('ag-grid', {
|
|
|
53
54
|
row_status_event: {type: Boolean, default: false },
|
|
54
55
|
enable_actions: {type: Boolean, default: false },
|
|
55
56
|
pin_actions: {type: String, default: 'right' },
|
|
57
|
+
edit_action_btn: { type: Boolean, default: false },
|
|
56
58
|
edit_action_title: {type: String, default: '' },
|
|
57
59
|
edit_action_tooltip: {type: String, default: 'Edit' },
|
|
60
|
+
view_action_btn: { type: Boolean, default: false },
|
|
58
61
|
view_action_title: {type: String, default: '' },
|
|
59
62
|
view_action_tooltip: {type: String, default: 'View' },
|
|
60
63
|
edit_action_icon_class: {type: String, default: 'fas fa-pencil-alt' },
|
|
@@ -72,6 +75,7 @@ dmx.Component('ag-grid', {
|
|
|
72
75
|
},
|
|
73
76
|
reloadGrid: function () {
|
|
74
77
|
this.refreshGrid()
|
|
78
|
+
console.log('reloadGrid');
|
|
75
79
|
}
|
|
76
80
|
},
|
|
77
81
|
|
|
@@ -280,11 +284,11 @@ dmx.Component('ag-grid', {
|
|
|
280
284
|
}
|
|
281
285
|
}
|
|
282
286
|
function getValueGetter(key, dataChanges) {
|
|
283
|
-
return function(params) {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
287
|
+
return function (params) {
|
|
288
|
+
const value = params.data[key];
|
|
289
|
+
const matchingChange = dataChanges.find((change) => change.field === key && change.value === String(originalValue));
|
|
290
|
+
if (matchingChange) {
|
|
291
|
+
return matchingChange.new_value;
|
|
288
292
|
}
|
|
289
293
|
return value;
|
|
290
294
|
};
|
|
@@ -305,6 +309,7 @@ dmx.Component('ag-grid', {
|
|
|
305
309
|
let valueFormatter;
|
|
306
310
|
let filterParams;
|
|
307
311
|
let minWidth;
|
|
312
|
+
let hide;
|
|
308
313
|
|
|
309
314
|
|
|
310
315
|
if (dataType === 'number') {
|
|
@@ -378,16 +383,22 @@ dmx.Component('ag-grid', {
|
|
|
378
383
|
const cstyles = this.props.cstyles
|
|
379
384
|
// Check if custom color exists for the current field and condition
|
|
380
385
|
function applyCellStyle(params) {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
386
|
+
const field = params.colDef.field.toString();
|
|
387
|
+
const styles = cstyles.filter((cs) => cs.field === field);
|
|
388
|
+
|
|
389
|
+
for (const style of styles) {
|
|
390
|
+
const condition = style.condition;
|
|
391
|
+
const customColor = style.customColor;
|
|
392
|
+
const [left, operator, right] = extractConditionParts(condition);
|
|
393
|
+
if (
|
|
394
|
+
params.data.hasOwnProperty(left) &&
|
|
395
|
+
evaluateCondition(params.data[left], operator, right)
|
|
396
|
+
) {
|
|
397
|
+
return { color: customColor };
|
|
389
398
|
}
|
|
390
|
-
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
return null;
|
|
391
402
|
}
|
|
392
403
|
cnames = this.props.cnames
|
|
393
404
|
cwidths = this.props.cwidths
|
|
@@ -407,6 +418,12 @@ dmx.Component('ag-grid', {
|
|
|
407
418
|
else {
|
|
408
419
|
cellRenderer = undefined;
|
|
409
420
|
}
|
|
421
|
+
if (options.hide_id_field && key == 'id') {
|
|
422
|
+
hide = true;
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
hide = undefined;
|
|
426
|
+
}
|
|
410
427
|
|
|
411
428
|
return {
|
|
412
429
|
headerName: headerName,
|
|
@@ -415,6 +432,7 @@ dmx.Component('ag-grid', {
|
|
|
415
432
|
valueFormatter: valueFormatter,
|
|
416
433
|
valueGetter: valueGetter,
|
|
417
434
|
minWidth: minWidth,
|
|
435
|
+
hide: hide,
|
|
418
436
|
filterValueGetter: filterValueGetter,
|
|
419
437
|
filterParams: filterParams,
|
|
420
438
|
cellStyle: applyCellStyle,
|
|
@@ -450,43 +468,47 @@ dmx.Component('ag-grid', {
|
|
|
450
468
|
columnDefs.unshift(checkboxColumn);
|
|
451
469
|
}
|
|
452
470
|
if (options.enable_actions) {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
tooltip: options.view_action_tooltip,
|
|
477
|
-
icon: options.view_action_icon_class,
|
|
478
|
-
onClick: (rowData) => {
|
|
479
|
-
this.set('data', rowData);
|
|
480
|
-
this.set('id', rowData.id);
|
|
481
|
-
this.dispatchEvent('row_action_view');
|
|
482
|
-
},
|
|
483
|
-
},
|
|
484
|
-
// Add more custom buttons as needed
|
|
485
|
-
],
|
|
486
|
-
},
|
|
487
|
-
}
|
|
488
|
-
columnDefs.push(actionsColumn);
|
|
471
|
+
actionsColumn = {
|
|
472
|
+
headerName: 'Actions',
|
|
473
|
+
field: 'action',
|
|
474
|
+
filter: null,
|
|
475
|
+
cellRenderer: actionsRenderer,
|
|
476
|
+
pinned: options.pin_actions,
|
|
477
|
+
cellRendererParams: {
|
|
478
|
+
buttons: [],
|
|
479
|
+
},
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
if (options.edit_action_btn) {
|
|
483
|
+
actionsColumn.cellRendererParams.buttons.push({
|
|
484
|
+
action: options.edit_action_title,
|
|
485
|
+
classNames: options.edit_action_btn_class,
|
|
486
|
+
tooltip: options.edit_action_tooltip,
|
|
487
|
+
icon: options.edit_action_icon_class,
|
|
488
|
+
onClick: (rowData) => {
|
|
489
|
+
this.set('data', rowData);
|
|
490
|
+
this.set('id', rowData.id);
|
|
491
|
+
this.dispatchEvent('row_action_edit');
|
|
492
|
+
},
|
|
493
|
+
});
|
|
489
494
|
}
|
|
495
|
+
|
|
496
|
+
if (options.view_action_btn) {
|
|
497
|
+
actionsColumn.cellRendererParams.buttons.push({
|
|
498
|
+
action: options.view_action_title,
|
|
499
|
+
classNames: options.view_action_btn_class,
|
|
500
|
+
tooltip: options.view_action_tooltip,
|
|
501
|
+
icon: options.view_action_icon_class,
|
|
502
|
+
onClick: (rowData) => {
|
|
503
|
+
this.set('data', rowData);
|
|
504
|
+
this.set('id', rowData.id);
|
|
505
|
+
this.dispatchEvent('row_action_view');
|
|
506
|
+
},
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
columnDefs.push(actionsColumn);
|
|
511
|
+
}
|
|
490
512
|
|
|
491
513
|
const gridOptions = {
|
|
492
514
|
columnDefs: columnDefs,
|