@cdmx/wappler_ag_grid 0.2.0 → 0.2.2

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.
@@ -1046,6 +1046,74 @@
1046
1046
  "allowedOn": {
1047
1047
  "dmx-ag-grid": true
1048
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
+ }
1049
1117
  }
1050
1118
  ],
1051
1119
  "static_events": []
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,33 +73,14 @@ dmx.Component('ag-grid', {
111
73
  },
112
74
 
113
75
  refreshGrid: function () {
114
- const gridId = this.props.id;
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
- console.log(this.props)
139
-
140
- this.$node.innerHTML = `<div id=${gridId}-grid class="${grid_theme}"></div>`;
83
+ this.$node.innerHTML = `<div id=${options.id}-grid class="${options.grid_theme}"></div>`;
141
84
  if (!rowData || rowData.length === 0) {
142
85
  console.error('No row data provided.');
143
86
  return;
@@ -164,8 +107,7 @@ dmx.Component('ag-grid', {
164
107
  function clickCellRenderer(params) {
165
108
  const idValue = params.data.id;
166
109
  const columnName = params.colDef.field;
167
- const dataType = detectDataType([params.value]);
168
- const value = formatValue(params.value, columnName, dataType, timezone);
110
+ const value = params.value
169
111
  return `<div onclick="cellClickEvent('${columnName}', '${value}', '${idValue}')" style="cursor: pointer;">${value}</div>`;
170
112
  }
171
113
 
@@ -214,8 +156,12 @@ dmx.Component('ag-grid', {
214
156
  button.setAttribute('title', buttonConfig.tooltip);
215
157
  button.innerHTML = `<i class="${buttonConfig.icon}"></i> ${buttonConfig.action}`;
216
158
  container.appendChild(button);
159
+ button.addEventListener('click', function () {
160
+ if (typeof buttonConfig.onClick === 'function') {
161
+ buttonConfig.onClick(params.data);
162
+ }
163
+ });
217
164
  });
218
-
219
165
  // Add spacing between buttons (margin-right)
220
166
  const buttonSpacing = '5px'; // You can adjust the spacing as needed
221
167
  const buttonsInContainer = container.querySelectorAll('button');
@@ -449,7 +395,7 @@ dmx.Component('ag-grid', {
449
395
  else {
450
396
  headerName = humanize(key);
451
397
  }
452
- if (key =='status' && enableStatusToggle) {
398
+ if (key =='status' && options.row_status_event) {
453
399
  cellRenderer = 'checkboxCellRenderer';
454
400
  filter = null;
455
401
  }
@@ -482,7 +428,7 @@ dmx.Component('ag-grid', {
482
428
  this.dispatchEvent('row_clicked')
483
429
  }
484
430
  let checkboxColumn;
485
- if (enableCheckboxEvent) {
431
+ if (options.row_checkbox_event) {
486
432
  checkboxColumn = {
487
433
  headerCheckboxSelection: true,
488
434
  headerCheckboxSelectionFilteredOnly: false,
@@ -498,38 +444,36 @@ dmx.Component('ag-grid', {
498
444
  };
499
445
  columnDefs.unshift(checkboxColumn);
500
446
  }
501
- if (enableActions) {
447
+ if (options.enable_actions) {
502
448
  actionsColumn = {
503
449
  headerName: 'Actions',
504
450
  field: 'action',
505
451
  filter: null,
506
452
  cellRenderer: actionsRenderer,
507
- pinned: pin_actions,
453
+ pinned: options.pin_actions,
508
454
  cellRendererParams: {
509
455
  // Custom button configurations
510
456
  buttons: [
511
457
  {
512
- action: edit_action_title,
513
- classNames: edit_action_btn_class,
514
- tooltip: edit_action_tooltip,
515
- icon: edit_action_icon_class,
458
+ action: options.edit_action_title,
459
+ classNames: options.edit_action_btn_class,
460
+ tooltip: options.edit_action_tooltip,
461
+ icon: options.edit_action_icon_class,
516
462
  onClick: (rowData) => {
517
463
  this.set('data', rowData);
518
464
  this.set('id', rowData.id);
519
- this.dispatchEvent('action_edit');
520
- console.log('Custom Action 1 clicked for row with ID:', rowData.id);
465
+ this.dispatchEvent('row_action_edit');
521
466
  },
522
467
  },
523
468
  {
524
- action: view_action_title,
525
- classNames: view_action_btn_class,
526
- tooltip: view_action_tooltip,
527
- icon: view_action_icon_class,
469
+ action: options.view_action_title,
470
+ classNames: options.view_action_btn_class,
471
+ tooltip: options.view_action_tooltip,
472
+ icon: options.view_action_icon_class,
528
473
  onClick: (rowData) => {
529
474
  this.set('data', rowData);
530
475
  this.set('id', rowData.id);
531
- this.dispatchEvent('action_view');
532
- console.log('Custom Action 2 clicked for row with ID:', rowData.id);
476
+ this.dispatchEvent('row_action_view');
533
477
  },
534
478
  },
535
479
  // Add more custom buttons as needed
@@ -579,11 +523,11 @@ dmx.Component('ag-grid', {
579
523
  }
580
524
  };
581
525
 
582
- const gridDiv = document.getElementById(gridId+'-grid');
526
+ const gridDiv = document.getElementById(options.id+'-grid');
583
527
 
584
528
 
585
529
  if (!gridDiv) {
586
- console.error(`Grid container element with ID '${gridId}' not found.`);
530
+ console.error(`Grid container element with ID '${options.id}' not found.`);
587
531
  return;
588
532
  }
589
533
 
@@ -597,10 +541,10 @@ dmx.Component('ag-grid', {
597
541
  };
598
542
  // Create ag-Grid instance
599
543
  new agGrid.Grid(gridDiv, gridConfig);
600
- const gridElement = document.getElementById(gridId+'-grid');
544
+ const gridElement = document.getElementById(options.id+'-grid');
601
545
  const gridContainer = gridElement.parentNode;
602
546
  // Add an event listener to the grid
603
- if (enableCheckboxEvent) {
547
+ if (options.row_checkbox_event) {
604
548
  gridConfig.api.addEventListener('rowSelected', (event) => {
605
549
  if (event.node && event.node.isSelected()) {
606
550
  const rowData = event.node.data;
@@ -619,12 +563,12 @@ dmx.Component('ag-grid', {
619
563
  console.error('Grid container not found.');
620
564
  return;
621
565
  }
622
- if (fixedHeader) {
566
+ if (options.fixedHeader) {
623
567
  window.addEventListener('scroll', function () {
624
568
  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;
569
+ const topbar = document.querySelector('.' + options.topbarClass);
570
+ const topbarHeight = (topbar ? topbar.getBoundingClientRect().height : 0) + options.fixedTopOffset;
571
+ const headerPos = (topbar ? topbar.getBoundingClientRect().bottom : 0) + options.fixedHeaderOffset;
628
572
 
629
573
  if (window.pageYOffset > headerPos) {
630
574
  header.style.position = 'fixed';
@@ -675,8 +619,8 @@ dmx.Component('ag-grid', {
675
619
  row_checkbox_unchecked: Event,
676
620
  row_status_enabled: Event,
677
621
  row_status_disabled: Event,
678
- action_edit: Event,
679
- action_view: Event
622
+ row_action_edit: Event,
623
+ row_action_view: Event
680
624
  },
681
625
 
682
626
  render: function(node) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation",
6
6
  "license": "MIT",