@cdmx/wappler_ag_grid 0.1.9 → 0.2.1

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.
@@ -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
  ],
@@ -948,6 +1046,74 @@
948
1046
  "allowedOn": {
949
1047
  "dmx-ag-grid": true
950
1048
  }
1049
+ },
1050
+ {
1051
+ "name": "dmx-ag-grid-edit-clicked",
1052
+ "attributeStartsWith": "dmx-on",
1053
+ "attribute": "row_action_edit",
1054
+ "display": "fieldset",
1055
+ "title": "Edit Clicked",
1056
+ "icon": "fa fa-lg fa-chevron-right",
1057
+ "groupTitle": "Grid Events",
1058
+ "groupIcon": "fa fa-lg fa-cubes",
1059
+ "defaultValue": false,
1060
+ "show": [
1061
+ "rowActionEdit"
1062
+ ],
1063
+ "noChangeOnHide": true,
1064
+ "type": "boolean",
1065
+ "groupEnabler": true,
1066
+ "children": [
1067
+ {
1068
+ "name": "rowActionEdit",
1069
+ "attributeStartsWith": "dmx-on",
1070
+ "attribute": "row_action_edit",
1071
+ "isValue": true,
1072
+ "actionsPicker": true,
1073
+ "title": "Action:",
1074
+ "type": "text",
1075
+ "help": "Choose the action to execute.",
1076
+ "defaultValue": "",
1077
+ "initDisplay": "none"
1078
+ }
1079
+ ],
1080
+ "allowedOn": {
1081
+ "dmx-ag-grid": true
1082
+ }
1083
+ },
1084
+ {
1085
+ "name": "dmx-ag-grid-view-clicked",
1086
+ "attributeStartsWith": "dmx-on",
1087
+ "attribute": "row_action_view",
1088
+ "display": "fieldset",
1089
+ "title": "View Clicked",
1090
+ "icon": "fa fa-lg fa-chevron-right",
1091
+ "groupTitle": "Grid Events",
1092
+ "groupIcon": "fa fa-lg fa-cubes",
1093
+ "defaultValue": false,
1094
+ "show": [
1095
+ "rowActionView"
1096
+ ],
1097
+ "noChangeOnHide": true,
1098
+ "type": "boolean",
1099
+ "groupEnabler": true,
1100
+ "children": [
1101
+ {
1102
+ "name": "rowActionView",
1103
+ "attributeStartsWith": "dmx-on",
1104
+ "attribute": "row_action_view",
1105
+ "isValue": true,
1106
+ "actionsPicker": true,
1107
+ "title": "Action:",
1108
+ "type": "text",
1109
+ "help": "Choose the action to execute.",
1110
+ "defaultValue": "",
1111
+ "initDisplay": "none"
1112
+ }
1113
+ ],
1114
+ "allowedOn": {
1115
+ "dmx-ag-grid": true
1116
+ }
951
1117
  }
952
1118
  ],
953
1119
  "static_events": []
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,9 +122,19 @@ 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
-
118
138
  this.$node.innerHTML = `<div id=${gridId}-grid class="${grid_theme}"></div>`;
119
139
  if (!rowData || rowData.length === 0) {
120
140
  console.error('No row data provided.');
@@ -171,6 +191,42 @@ dmx.Component('ag-grid', {
171
191
  </label>
172
192
  `;
173
193
  }
194
+ function actionsRenderer(params) {
195
+ // Default button configurations (Edit and View)
196
+ const defaultButtons = [
197
+ { action: 'Edit', classNames: 'btn-primary btn-xs', tooltip: 'Edit', icon: 'fas fa-pencil-alt' },
198
+ { action: 'View', classNames: 'btn-info btn-xs', tooltip: 'View', icon: 'fas fa-eye' },
199
+ ];
200
+ // User-defined button configurations (if any)
201
+ const buttons = params.buttons || defaultButtons;
202
+
203
+ // Create a new container element to hold the buttons
204
+ const container = document.createElement('div');
205
+
206
+ buttons.forEach((buttonConfig) => {
207
+ const button = document.createElement('button');
208
+ button.classList.add('btn');
209
+ const classNames = buttonConfig.classNames.split(' ');
210
+ classNames.forEach((className) => button.classList.add(className));
211
+ button.setAttribute('data-toggle', 'tooltip');
212
+ button.setAttribute('title', buttonConfig.tooltip);
213
+ button.innerHTML = `<i class="${buttonConfig.icon}"></i> ${buttonConfig.action}`;
214
+ container.appendChild(button);
215
+ button.addEventListener('click', function () {
216
+ if (typeof buttonConfig.onClick === 'function') {
217
+ buttonConfig.onClick(params.data);
218
+ }
219
+ });
220
+ });
221
+ // Add spacing between buttons (margin-right)
222
+ const buttonSpacing = '5px'; // You can adjust the spacing as needed
223
+ const buttonsInContainer = container.querySelectorAll('button');
224
+ for (let i = 0; i < buttonsInContainer.length - 1; i++) {
225
+ buttonsInContainer[i].style.marginRight = buttonSpacing;
226
+ }
227
+
228
+ return container;
229
+ }
174
230
 
175
231
 
176
232
  function humanize(str) {
@@ -397,6 +453,7 @@ dmx.Component('ag-grid', {
397
453
  }
398
454
  if (key =='status' && enableStatusToggle) {
399
455
  cellRenderer = 'checkboxCellRenderer';
456
+ filter = null;
400
457
  }
401
458
  else {
402
459
  cellRenderer = undefined;
@@ -443,7 +500,45 @@ dmx.Component('ag-grid', {
443
500
  };
444
501
  columnDefs.unshift(checkboxColumn);
445
502
  }
446
-
503
+ if (enableActions) {
504
+ actionsColumn = {
505
+ headerName: 'Actions',
506
+ field: 'action',
507
+ filter: null,
508
+ cellRenderer: actionsRenderer,
509
+ pinned: pin_actions,
510
+ cellRendererParams: {
511
+ // Custom button configurations
512
+ buttons: [
513
+ {
514
+ action: edit_action_title,
515
+ classNames: edit_action_btn_class,
516
+ tooltip: edit_action_tooltip,
517
+ icon: edit_action_icon_class,
518
+ onClick: (rowData) => {
519
+ this.set('data', rowData);
520
+ this.set('id', rowData.id);
521
+ this.dispatchEvent('row_action_edit');
522
+ },
523
+ },
524
+ {
525
+ action: view_action_title,
526
+ classNames: view_action_btn_class,
527
+ tooltip: view_action_tooltip,
528
+ icon: view_action_icon_class,
529
+ onClick: (rowData) => {
530
+ this.set('data', rowData);
531
+ this.set('id', rowData.id);
532
+ this.dispatchEvent('row_action_view');
533
+ },
534
+ },
535
+ // Add more custom buttons as needed
536
+ ],
537
+ },
538
+ }
539
+ columnDefs.push(actionsColumn);
540
+ }
541
+
447
542
  const gridOptions = {
448
543
  columnDefs: columnDefs,
449
544
  onRowClicked: enableRowClickEvent ? onRowClicked : undefined,
@@ -479,7 +574,8 @@ dmx.Component('ag-grid', {
479
574
  localeText: this.props.localeText,
480
575
  components: {
481
576
  clickCellRenderer: clickCellRenderer,
482
- checkboxCellRenderer: checkboxCellRenderer
577
+ checkboxCellRenderer: checkboxCellRenderer,
578
+ actionsRenderer: actionsRenderer
483
579
  }
484
580
  };
485
581
 
@@ -504,19 +600,21 @@ dmx.Component('ag-grid', {
504
600
  const gridElement = document.getElementById(gridId+'-grid');
505
601
  const gridContainer = gridElement.parentNode;
506
602
  // Add an event listener to the grid
507
- gridConfig.api.addEventListener('rowSelected', (event) => {
508
- if (event.node && event.node.isSelected()) {
509
- const rowData = event.node.data;
510
- this.set('data', rowData);
511
- this.set('id', rowData.id);
512
- this.dispatchEvent('row_checkbox_checked');
513
- } else {
514
- const rowData = event.node.data;
515
- this.set('data', rowData);
516
- this.set('id', rowData.id);
517
- this.dispatchEvent('row_checkbox_unchecked');
518
- }
519
- });
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
+ }
520
618
  if (!gridContainer) {
521
619
  console.error('Grid container not found.');
522
620
  return;
@@ -577,6 +675,8 @@ dmx.Component('ag-grid', {
577
675
  row_checkbox_unchecked: Event,
578
676
  row_status_enabled: Event,
579
677
  row_status_disabled: Event,
678
+ row_action_edit: Event,
679
+ row_action_view: Event
580
680
  },
581
681
 
582
682
  render: function(node) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "0.1.9",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation",
6
6
  "license": "MIT",