@cdmx/wappler_ag_grid 0.2.1 → 0.2.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/dmx-ag-grid.js +26 -80
- package/package.json +1 -1
package/dmx-ag-grid.js
CHANGED
|
@@ -2,45 +2,7 @@ dmx.Component('ag-grid', {
|
|
|
2
2
|
initialData: {
|
|
3
3
|
id: null,
|
|
4
4
|
data: {},
|
|
5
|
-
fields: {}
|
|
6
|
-
column_defs: [],
|
|
7
|
-
cstyles: null,
|
|
8
|
-
cnames: null,
|
|
9
|
-
cwidths: null,
|
|
10
|
-
data_changes: null,
|
|
11
|
-
gridInstance: null,
|
|
12
|
-
domLayout: 'autoHeight',
|
|
13
|
-
enableCellTextSelection: true,
|
|
14
|
-
rowSelection: null,
|
|
15
|
-
suppressRowDeselection: null,
|
|
16
|
-
pagination: null,
|
|
17
|
-
paginationPageSize: null,
|
|
18
|
-
rowHeight: null,
|
|
19
|
-
headerHeight: null,
|
|
20
|
-
suppressRowClickSelection: null,
|
|
21
|
-
suppressMenuHide: null,
|
|
22
|
-
suppressMovableColumns: null,
|
|
23
|
-
enableCellExpressions: null,
|
|
24
|
-
animateRows: null,
|
|
25
|
-
suppressAggFuncInHeader: null,
|
|
26
|
-
suppressAggAtRootLevel: null,
|
|
27
|
-
suppressClipboardPaste: null,
|
|
28
|
-
suppressScrollOnNewData: null,
|
|
29
|
-
suppressPropertyNamesCheck: null,
|
|
30
|
-
localeText: null,
|
|
31
|
-
minWidth: 150,
|
|
32
|
-
resizable: true,
|
|
33
|
-
sortable: true,
|
|
34
|
-
filter: true,
|
|
35
|
-
floatingFilter: true,
|
|
36
|
-
columnHoverHighlight: true,
|
|
37
|
-
exportToCSV: true,
|
|
38
|
-
fixedHeader: false,
|
|
39
|
-
topbarClass: null,
|
|
40
|
-
fixedHeaderOffset: 100,
|
|
41
|
-
fixedTopOffset: 80,
|
|
42
|
-
fixedHorizonatalScroll: false,
|
|
43
|
-
timezone: null
|
|
5
|
+
fields: {}
|
|
44
6
|
},
|
|
45
7
|
|
|
46
8
|
attributes: {
|
|
@@ -111,31 +73,14 @@ dmx.Component('ag-grid', {
|
|
|
111
73
|
},
|
|
112
74
|
|
|
113
75
|
refreshGrid: function () {
|
|
114
|
-
const
|
|
76
|
+
const options = this.props
|
|
115
77
|
const rowData = this.props.data;
|
|
116
|
-
const fixedHeader = this.props.fixedHeader;
|
|
117
|
-
const fixedHeaderOffset = this.props.fixedHeaderOffset;
|
|
118
|
-
const topbarClass = this.props.topbarClass;
|
|
119
|
-
const fixedTopOffset = this.props.fixedTopOffset;
|
|
120
78
|
const timezone = this.props.timezone || false;
|
|
121
79
|
const dataChanges = this.props.data_changes;
|
|
122
|
-
const grid_theme = this.props.grid_theme;
|
|
123
|
-
const enableCheckboxEvent = this.props.row_checkbox_event;
|
|
124
|
-
const enableStatusToggle = this.props.row_status_event;
|
|
125
|
-
const enableActions = this.props.enable_actions;
|
|
126
|
-
const pin_actions = this.props.pin_actions;
|
|
127
|
-
const edit_action_title = this.props.edit_action_title;
|
|
128
|
-
const edit_action_btn_class = this.props.edit_action_btn_class;
|
|
129
|
-
const edit_action_icon_class = this.props.edit_action_icon_class;
|
|
130
|
-
const view_action_title = this.props.view_action_title;
|
|
131
|
-
const view_action_btn_class = this.props.view_action_btn_class;
|
|
132
|
-
const view_action_icon_class = this.props.view_action_icon_class;
|
|
133
|
-
const edit_action_tooltip = this.props.edit_action_tooltip;
|
|
134
|
-
const view_action_tooltip = this.props.view_action_tooltip;
|
|
135
80
|
|
|
136
81
|
let columnDefs = [];
|
|
137
82
|
let exportToCSV = this.props.exportToCSV;
|
|
138
|
-
this.$node.innerHTML = `<div id=${
|
|
83
|
+
this.$node.innerHTML = `<div id=${options.id}-grid class="${options.grid_theme}"></div>`;
|
|
139
84
|
if (!rowData || rowData.length === 0) {
|
|
140
85
|
console.error('No row data provided.');
|
|
141
86
|
return;
|
|
@@ -162,8 +107,7 @@ dmx.Component('ag-grid', {
|
|
|
162
107
|
function clickCellRenderer(params) {
|
|
163
108
|
const idValue = params.data.id;
|
|
164
109
|
const columnName = params.colDef.field;
|
|
165
|
-
const
|
|
166
|
-
const value = formatValue(params.value, columnName, dataType, timezone);
|
|
110
|
+
const value = params.value
|
|
167
111
|
return `<div onclick="cellClickEvent('${columnName}', '${value}', '${idValue}')" style="cursor: pointer;">${value}</div>`;
|
|
168
112
|
}
|
|
169
113
|
|
|
@@ -174,6 +118,7 @@ dmx.Component('ag-grid', {
|
|
|
174
118
|
// Assuming `value` is a boolean representing the status
|
|
175
119
|
const checked = value==true ? "checked" : "";
|
|
176
120
|
return `
|
|
121
|
+
<div class="col pt-2 pb-1 ps-1 pe-1 d-flex justify-content-center">
|
|
177
122
|
<label class="switch switch-success">
|
|
178
123
|
<input
|
|
179
124
|
type="checkbox" class="switch-input"
|
|
@@ -189,6 +134,7 @@ dmx.Component('ag-grid', {
|
|
|
189
134
|
<i class="bx bx-x"></i>
|
|
190
135
|
</span>
|
|
191
136
|
</label>
|
|
137
|
+
</div>
|
|
192
138
|
`;
|
|
193
139
|
}
|
|
194
140
|
function actionsRenderer(params) {
|
|
@@ -451,7 +397,7 @@ dmx.Component('ag-grid', {
|
|
|
451
397
|
else {
|
|
452
398
|
headerName = humanize(key);
|
|
453
399
|
}
|
|
454
|
-
if (key =='status' &&
|
|
400
|
+
if (key =='status' && options.row_status_event) {
|
|
455
401
|
cellRenderer = 'checkboxCellRenderer';
|
|
456
402
|
filter = null;
|
|
457
403
|
}
|
|
@@ -484,7 +430,7 @@ dmx.Component('ag-grid', {
|
|
|
484
430
|
this.dispatchEvent('row_clicked')
|
|
485
431
|
}
|
|
486
432
|
let checkboxColumn;
|
|
487
|
-
if (
|
|
433
|
+
if (options.row_checkbox_event) {
|
|
488
434
|
checkboxColumn = {
|
|
489
435
|
headerCheckboxSelection: true,
|
|
490
436
|
headerCheckboxSelectionFilteredOnly: false,
|
|
@@ -500,21 +446,21 @@ dmx.Component('ag-grid', {
|
|
|
500
446
|
};
|
|
501
447
|
columnDefs.unshift(checkboxColumn);
|
|
502
448
|
}
|
|
503
|
-
if (
|
|
449
|
+
if (options.enable_actions) {
|
|
504
450
|
actionsColumn = {
|
|
505
451
|
headerName: 'Actions',
|
|
506
452
|
field: 'action',
|
|
507
453
|
filter: null,
|
|
508
454
|
cellRenderer: actionsRenderer,
|
|
509
|
-
pinned: pin_actions,
|
|
455
|
+
pinned: options.pin_actions,
|
|
510
456
|
cellRendererParams: {
|
|
511
457
|
// Custom button configurations
|
|
512
458
|
buttons: [
|
|
513
459
|
{
|
|
514
|
-
action: edit_action_title,
|
|
515
|
-
classNames: edit_action_btn_class,
|
|
516
|
-
tooltip: edit_action_tooltip,
|
|
517
|
-
icon: edit_action_icon_class,
|
|
460
|
+
action: options.edit_action_title,
|
|
461
|
+
classNames: options.edit_action_btn_class,
|
|
462
|
+
tooltip: options.edit_action_tooltip,
|
|
463
|
+
icon: options.edit_action_icon_class,
|
|
518
464
|
onClick: (rowData) => {
|
|
519
465
|
this.set('data', rowData);
|
|
520
466
|
this.set('id', rowData.id);
|
|
@@ -522,10 +468,10 @@ dmx.Component('ag-grid', {
|
|
|
522
468
|
},
|
|
523
469
|
},
|
|
524
470
|
{
|
|
525
|
-
action: view_action_title,
|
|
526
|
-
classNames: view_action_btn_class,
|
|
527
|
-
tooltip: view_action_tooltip,
|
|
528
|
-
icon: view_action_icon_class,
|
|
471
|
+
action: options.view_action_title,
|
|
472
|
+
classNames: options.view_action_btn_class,
|
|
473
|
+
tooltip: options.view_action_tooltip,
|
|
474
|
+
icon: options.view_action_icon_class,
|
|
529
475
|
onClick: (rowData) => {
|
|
530
476
|
this.set('data', rowData);
|
|
531
477
|
this.set('id', rowData.id);
|
|
@@ -579,11 +525,11 @@ dmx.Component('ag-grid', {
|
|
|
579
525
|
}
|
|
580
526
|
};
|
|
581
527
|
|
|
582
|
-
const gridDiv = document.getElementById(
|
|
528
|
+
const gridDiv = document.getElementById(options.id+'-grid');
|
|
583
529
|
|
|
584
530
|
|
|
585
531
|
if (!gridDiv) {
|
|
586
|
-
console.error(`Grid container element with ID '${
|
|
532
|
+
console.error(`Grid container element with ID '${options.id}' not found.`);
|
|
587
533
|
return;
|
|
588
534
|
}
|
|
589
535
|
|
|
@@ -597,10 +543,10 @@ dmx.Component('ag-grid', {
|
|
|
597
543
|
};
|
|
598
544
|
// Create ag-Grid instance
|
|
599
545
|
new agGrid.Grid(gridDiv, gridConfig);
|
|
600
|
-
const gridElement = document.getElementById(
|
|
546
|
+
const gridElement = document.getElementById(options.id+'-grid');
|
|
601
547
|
const gridContainer = gridElement.parentNode;
|
|
602
548
|
// Add an event listener to the grid
|
|
603
|
-
if (
|
|
549
|
+
if (options.row_checkbox_event) {
|
|
604
550
|
gridConfig.api.addEventListener('rowSelected', (event) => {
|
|
605
551
|
if (event.node && event.node.isSelected()) {
|
|
606
552
|
const rowData = event.node.data;
|
|
@@ -619,12 +565,12 @@ dmx.Component('ag-grid', {
|
|
|
619
565
|
console.error('Grid container not found.');
|
|
620
566
|
return;
|
|
621
567
|
}
|
|
622
|
-
if (fixedHeader) {
|
|
568
|
+
if (options.fixedHeader) {
|
|
623
569
|
window.addEventListener('scroll', function () {
|
|
624
570
|
const header = document.querySelector('.ag-header');
|
|
625
|
-
const topbar = document.querySelector('.' + topbarClass);
|
|
626
|
-
const topbarHeight = (topbar ? topbar.getBoundingClientRect().height : 0) + fixedTopOffset;
|
|
627
|
-
const headerPos = (topbar ? topbar.getBoundingClientRect().bottom : 0) + fixedHeaderOffset;
|
|
571
|
+
const topbar = document.querySelector('.' + options.topbarClass);
|
|
572
|
+
const topbarHeight = (topbar ? topbar.getBoundingClientRect().height : 0) + options.fixedTopOffset;
|
|
573
|
+
const headerPos = (topbar ? topbar.getBoundingClientRect().bottom : 0) + options.fixedHeaderOffset;
|
|
628
574
|
|
|
629
575
|
if (window.pageYOffset > headerPos) {
|
|
630
576
|
header.style.position = 'fixed';
|