@cdmx/wappler_ag_grid 0.1.8 → 0.2.0
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 +98 -0
- package/dmx-ag-grid.js +116 -40
- package/package.json +1 -1
|
@@ -667,6 +667,104 @@
|
|
|
667
667
|
]
|
|
668
668
|
}
|
|
669
669
|
]
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
"group": "📒 Configure Actions Column",
|
|
673
|
+
"variables": [
|
|
674
|
+
{
|
|
675
|
+
"name": "action_column",
|
|
676
|
+
"attributeStartsWith": "dmx-bind",
|
|
677
|
+
"attribute": "action_column",
|
|
678
|
+
"title": "Configure Actions",
|
|
679
|
+
"type": "boolean",
|
|
680
|
+
"display": "fieldset",
|
|
681
|
+
"show": [
|
|
682
|
+
"enableActions",
|
|
683
|
+
"editActionTitle",
|
|
684
|
+
"editActionTooltip",
|
|
685
|
+
"editActionBtnClass",
|
|
686
|
+
"editActionIconClass",
|
|
687
|
+
"viewActionTitle",
|
|
688
|
+
"viewActionTooltip",
|
|
689
|
+
"viewActionBtnClass",
|
|
690
|
+
"viewActionIconClass"
|
|
691
|
+
],
|
|
692
|
+
"noChangeOnHide": true,
|
|
693
|
+
"groupEnabler": true,
|
|
694
|
+
"help": "Configure Actions for the buttons in Actions Column"
|
|
695
|
+
"children": [
|
|
696
|
+
{
|
|
697
|
+
"name": "help",
|
|
698
|
+
"type": "static",
|
|
699
|
+
"help": "Configure Actions for the buttons"
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
"name": "enableActions",
|
|
703
|
+
"attribute": "dmx-bind:enable_actions",
|
|
704
|
+
"title": "Enable Actions",
|
|
705
|
+
"type": "boolean",
|
|
706
|
+
"defaultValue": false,
|
|
707
|
+
"help": "Enable Actions"
|
|
708
|
+
},
|
|
709
|
+
{
|
|
710
|
+
"name": "editActionTitle",
|
|
711
|
+
"attribute": "edit_action_title",
|
|
712
|
+
"title": "Edit Action Button Title",
|
|
713
|
+
"type": "text",
|
|
714
|
+
"defaultValue": ''
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
"name": "editActionTooltip",
|
|
718
|
+
"attribute": "edit_action_tooltip",
|
|
719
|
+
"title": "Edit Action Button Tooltip",
|
|
720
|
+
"type": "text",
|
|
721
|
+
"defaultValue": ''
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
"name": "editActionBtnClass",
|
|
725
|
+
"attribute": "edit_action_btn_class",
|
|
726
|
+
"title": "Edit Action Button Class",
|
|
727
|
+
"type": "text",
|
|
728
|
+
"defaultValue": 'btn-primary btn-xs'
|
|
729
|
+
},
|
|
730
|
+
{
|
|
731
|
+
"name": "editActionIconClass",
|
|
732
|
+
"attribute": "edit_action_icon_class",
|
|
733
|
+
"title": "Edit Action IconClass",
|
|
734
|
+
"type": "text",
|
|
735
|
+
"defaultValue": 'fas fa-pencil-alt'
|
|
736
|
+
},
|
|
737
|
+
{
|
|
738
|
+
"name": "viewActionTitle",
|
|
739
|
+
"attribute": "view_action_title",
|
|
740
|
+
"title": "View Action Button Title",
|
|
741
|
+
"type": "text",
|
|
742
|
+
"defaultValue": ''
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
"name": "viewActionTooltip",
|
|
746
|
+
"attribute": "view_action_tooltip",
|
|
747
|
+
"title": "View Action Button Tooltip",
|
|
748
|
+
"type": "text",
|
|
749
|
+
"defaultValue": ''
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
"name": "viewActionBtnClass",
|
|
753
|
+
"attribute": "view_action_btn_class",
|
|
754
|
+
"title": "View Action Button Class",
|
|
755
|
+
"type": "text",
|
|
756
|
+
"defaultValue": 'btn-info btn-xs'
|
|
757
|
+
},
|
|
758
|
+
{
|
|
759
|
+
"name": "viewActionIconClass",
|
|
760
|
+
"attribute": "edit_action_icon_class",
|
|
761
|
+
"title": "View Action IconClass",
|
|
762
|
+
"type": "text",
|
|
763
|
+
"defaultValue": 'fas fa-eye'
|
|
764
|
+
}
|
|
765
|
+
]
|
|
766
|
+
}
|
|
767
|
+
]
|
|
670
768
|
}
|
|
671
769
|
|
|
672
770
|
],
|
package/dmx-ag-grid.js
CHANGED
|
@@ -88,7 +88,17 @@ dmx.Component('ag-grid', {
|
|
|
88
88
|
cell_click_event: {type: Boolean, default: false },
|
|
89
89
|
row_click_event: {type: Boolean, default: false },
|
|
90
90
|
row_checkbox_event: {type: Boolean, default: false },
|
|
91
|
-
row_status_event: {type: Boolean, default: false }
|
|
91
|
+
row_status_event: {type: Boolean, default: false },
|
|
92
|
+
enable_actions: {type: Boolean, default: false },
|
|
93
|
+
pin_actions: {type: String, default: 'right' },
|
|
94
|
+
edit_action_title: {type: String, default: '' },
|
|
95
|
+
edit_action_tooltip: {type: String, default: 'Edit' },
|
|
96
|
+
view_action_title: {type: String, default: '' },
|
|
97
|
+
view_action_tooltip: {type: String, default: 'View' },
|
|
98
|
+
edit_action_icon_class: {type: String, default: 'fas fa-pencil-alt' },
|
|
99
|
+
edit_action_btn_class: {type: String, default: 'btn-primary btn-xs' },
|
|
100
|
+
view_action_icon_class: {type: String, default: 'fas fa-eye' },
|
|
101
|
+
view_action_btn_class: {type: String, default: 'btn-info btn-xs' },
|
|
92
102
|
|
|
93
103
|
},
|
|
94
104
|
|
|
@@ -112,33 +122,26 @@ dmx.Component('ag-grid', {
|
|
|
112
122
|
const grid_theme = this.props.grid_theme;
|
|
113
123
|
const enableCheckboxEvent = this.props.row_checkbox_event;
|
|
114
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
|
+
|
|
115
136
|
let columnDefs = [];
|
|
116
137
|
let exportToCSV = this.props.exportToCSV;
|
|
117
|
-
|
|
138
|
+
console.log(this.props)
|
|
118
139
|
|
|
119
140
|
this.$node.innerHTML = `<div id=${gridId}-grid class="${grid_theme}"></div>`;
|
|
120
141
|
if (!rowData || rowData.length === 0) {
|
|
121
142
|
console.error('No row data provided.');
|
|
122
143
|
return;
|
|
123
144
|
}
|
|
124
|
-
// function formatValue(value, key, dataType, timezone) {
|
|
125
|
-
// params = {"value":value}
|
|
126
|
-
// if (dataType === 'number') {
|
|
127
|
-
// if (/(amount|amt)$/.test(key)) {
|
|
128
|
-
// return Number(value).toLocaleString("en-US", {
|
|
129
|
-
// minimumFractionDigits: 2,
|
|
130
|
-
// maximumFractionDigits: 2,
|
|
131
|
-
// });
|
|
132
|
-
// } else {
|
|
133
|
-
// return blankOrNullValueFormatter(params);
|
|
134
|
-
// }
|
|
135
|
-
// } else if (dataType === 'date') {
|
|
136
|
-
// return formatTime(params, timezone);
|
|
137
|
-
// }
|
|
138
|
-
// else {
|
|
139
|
-
// return blankOrNullValueFormatter(params);
|
|
140
|
-
// }
|
|
141
|
-
// }
|
|
142
145
|
window.cellClickEvent = (columnName, value, idValue) => {
|
|
143
146
|
this.set('fields', {"field": columnName, "data": value});
|
|
144
147
|
this.set('id', idValue);
|
|
@@ -190,6 +193,38 @@ dmx.Component('ag-grid', {
|
|
|
190
193
|
</label>
|
|
191
194
|
`;
|
|
192
195
|
}
|
|
196
|
+
function actionsRenderer(params) {
|
|
197
|
+
// Default button configurations (Edit and View)
|
|
198
|
+
const defaultButtons = [
|
|
199
|
+
{ action: 'Edit', classNames: 'btn-primary btn-xs', tooltip: 'Edit', icon: 'fas fa-pencil-alt' },
|
|
200
|
+
{ action: 'View', classNames: 'btn-info btn-xs', tooltip: 'View', icon: 'fas fa-eye' },
|
|
201
|
+
];
|
|
202
|
+
// User-defined button configurations (if any)
|
|
203
|
+
const buttons = params.buttons || defaultButtons;
|
|
204
|
+
|
|
205
|
+
// Create a new container element to hold the buttons
|
|
206
|
+
const container = document.createElement('div');
|
|
207
|
+
|
|
208
|
+
buttons.forEach((buttonConfig) => {
|
|
209
|
+
const button = document.createElement('button');
|
|
210
|
+
button.classList.add('btn');
|
|
211
|
+
const classNames = buttonConfig.classNames.split(' ');
|
|
212
|
+
classNames.forEach((className) => button.classList.add(className));
|
|
213
|
+
button.setAttribute('data-toggle', 'tooltip');
|
|
214
|
+
button.setAttribute('title', buttonConfig.tooltip);
|
|
215
|
+
button.innerHTML = `<i class="${buttonConfig.icon}"></i> ${buttonConfig.action}`;
|
|
216
|
+
container.appendChild(button);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// Add spacing between buttons (margin-right)
|
|
220
|
+
const buttonSpacing = '5px'; // You can adjust the spacing as needed
|
|
221
|
+
const buttonsInContainer = container.querySelectorAll('button');
|
|
222
|
+
for (let i = 0; i < buttonsInContainer.length - 1; i++) {
|
|
223
|
+
buttonsInContainer[i].style.marginRight = buttonSpacing;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return container;
|
|
227
|
+
}
|
|
193
228
|
|
|
194
229
|
|
|
195
230
|
function humanize(str) {
|
|
@@ -416,6 +451,7 @@ dmx.Component('ag-grid', {
|
|
|
416
451
|
}
|
|
417
452
|
if (key =='status' && enableStatusToggle) {
|
|
418
453
|
cellRenderer = 'checkboxCellRenderer';
|
|
454
|
+
filter = null;
|
|
419
455
|
}
|
|
420
456
|
else {
|
|
421
457
|
cellRenderer = undefined;
|
|
@@ -462,7 +498,47 @@ dmx.Component('ag-grid', {
|
|
|
462
498
|
};
|
|
463
499
|
columnDefs.unshift(checkboxColumn);
|
|
464
500
|
}
|
|
465
|
-
|
|
501
|
+
if (enableActions) {
|
|
502
|
+
actionsColumn = {
|
|
503
|
+
headerName: 'Actions',
|
|
504
|
+
field: 'action',
|
|
505
|
+
filter: null,
|
|
506
|
+
cellRenderer: actionsRenderer,
|
|
507
|
+
pinned: pin_actions,
|
|
508
|
+
cellRendererParams: {
|
|
509
|
+
// Custom button configurations
|
|
510
|
+
buttons: [
|
|
511
|
+
{
|
|
512
|
+
action: edit_action_title,
|
|
513
|
+
classNames: edit_action_btn_class,
|
|
514
|
+
tooltip: edit_action_tooltip,
|
|
515
|
+
icon: edit_action_icon_class,
|
|
516
|
+
onClick: (rowData) => {
|
|
517
|
+
this.set('data', rowData);
|
|
518
|
+
this.set('id', rowData.id);
|
|
519
|
+
this.dispatchEvent('action_edit');
|
|
520
|
+
console.log('Custom Action 1 clicked for row with ID:', rowData.id);
|
|
521
|
+
},
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
action: view_action_title,
|
|
525
|
+
classNames: view_action_btn_class,
|
|
526
|
+
tooltip: view_action_tooltip,
|
|
527
|
+
icon: view_action_icon_class,
|
|
528
|
+
onClick: (rowData) => {
|
|
529
|
+
this.set('data', rowData);
|
|
530
|
+
this.set('id', rowData.id);
|
|
531
|
+
this.dispatchEvent('action_view');
|
|
532
|
+
console.log('Custom Action 2 clicked for row with ID:', rowData.id);
|
|
533
|
+
},
|
|
534
|
+
},
|
|
535
|
+
// Add more custom buttons as needed
|
|
536
|
+
],
|
|
537
|
+
},
|
|
538
|
+
}
|
|
539
|
+
columnDefs.push(actionsColumn);
|
|
540
|
+
}
|
|
541
|
+
|
|
466
542
|
const gridOptions = {
|
|
467
543
|
columnDefs: columnDefs,
|
|
468
544
|
onRowClicked: enableRowClickEvent ? onRowClicked : undefined,
|
|
@@ -498,7 +574,8 @@ dmx.Component('ag-grid', {
|
|
|
498
574
|
localeText: this.props.localeText,
|
|
499
575
|
components: {
|
|
500
576
|
clickCellRenderer: clickCellRenderer,
|
|
501
|
-
checkboxCellRenderer: checkboxCellRenderer
|
|
577
|
+
checkboxCellRenderer: checkboxCellRenderer,
|
|
578
|
+
actionsRenderer: actionsRenderer
|
|
502
579
|
}
|
|
503
580
|
};
|
|
504
581
|
|
|
@@ -523,19 +600,21 @@ dmx.Component('ag-grid', {
|
|
|
523
600
|
const gridElement = document.getElementById(gridId+'-grid');
|
|
524
601
|
const gridContainer = gridElement.parentNode;
|
|
525
602
|
// Add an event listener to the grid
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
603
|
+
if (enableCheckboxEvent) {
|
|
604
|
+
gridConfig.api.addEventListener('rowSelected', (event) => {
|
|
605
|
+
if (event.node && event.node.isSelected()) {
|
|
606
|
+
const rowData = event.node.data;
|
|
607
|
+
this.set('data', rowData);
|
|
608
|
+
this.set('id', rowData.id);
|
|
609
|
+
this.dispatchEvent('row_checkbox_checked');
|
|
610
|
+
} else {
|
|
611
|
+
const rowData = event.node.data;
|
|
612
|
+
this.set('data', rowData);
|
|
613
|
+
this.set('id', rowData.id);
|
|
614
|
+
this.dispatchEvent('row_checkbox_unchecked');
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
}
|
|
539
618
|
if (!gridContainer) {
|
|
540
619
|
console.error('Grid container not found.');
|
|
541
620
|
return;
|
|
@@ -596,6 +675,8 @@ dmx.Component('ag-grid', {
|
|
|
596
675
|
row_checkbox_unchecked: Event,
|
|
597
676
|
row_status_enabled: Event,
|
|
598
677
|
row_status_disabled: Event,
|
|
678
|
+
action_edit: Event,
|
|
679
|
+
action_view: Event
|
|
599
680
|
},
|
|
600
681
|
|
|
601
682
|
render: function(node) {
|
|
@@ -606,11 +687,6 @@ dmx.Component('ag-grid', {
|
|
|
606
687
|
|
|
607
688
|
update: function (props) {
|
|
608
689
|
if (!dmx.equal(this.props.data, props.data)) {
|
|
609
|
-
this.set("id", {
|
|
610
|
-
status: 0,
|
|
611
|
-
message: 'tedt',
|
|
612
|
-
response: null
|
|
613
|
-
})
|
|
614
690
|
this.refreshGrid();
|
|
615
691
|
}
|
|
616
692
|
},
|