@cdmx/wappler_ag_grid 0.2.3 → 0.2.5

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.
@@ -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",
@@ -680,10 +688,12 @@
680
688
  "display": "fieldset",
681
689
  "show": [
682
690
  "enableActions",
691
+ "editActionBtn",
683
692
  "editActionTitle",
684
693
  "editActionTooltip",
685
694
  "editActionBtnClass",
686
695
  "editActionIconClass",
696
+ "viewActionBtn",
687
697
  "viewActionTitle",
688
698
  "viewActionTooltip",
689
699
  "viewActionBtnClass",
@@ -706,6 +716,13 @@
706
716
  "defaultValue": false,
707
717
  "help": "Enable Actions"
708
718
  },
719
+ {
720
+ "name": "editActionBtn",
721
+ "attribute": "dmx-bind:edit_action_btn",
722
+ "title": "Edit Action Button",
723
+ "type": "boolean",
724
+ "defaultValue": false
725
+ },
709
726
  {
710
727
  "name": "editActionTitle",
711
728
  "attribute": "edit_action_title",
@@ -734,6 +751,13 @@
734
751
  "type": "text",
735
752
  "defaultValue": 'fas fa-pencil-alt'
736
753
  },
754
+ {
755
+ "name": "viewActionBtn",
756
+ "attribute": "dmx-bind:view_action_btn",
757
+ "title": "View Action Button",
758
+ "type": "boolean",
759
+ "defaultValue": ''
760
+ },
737
761
  {
738
762
  "name": "viewActionTitle",
739
763
  "attribute": "view_action_title",
package/dmx-ag-grid.js CHANGED
@@ -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' },
@@ -69,6 +72,10 @@ dmx.Component('ag-grid', {
69
72
  this.set('rowData', rowData);
70
73
  this.set('columnDefs', columnDefs);
71
74
  this.refreshGrid();
75
+ },
76
+ reloadGrid: function () {
77
+ this.refreshGrid()
78
+ console.log('reloadGrid');
72
79
  }
73
80
  },
74
81
 
@@ -302,6 +309,7 @@ dmx.Component('ag-grid', {
302
309
  let valueFormatter;
303
310
  let filterParams;
304
311
  let minWidth;
312
+ let hide;
305
313
 
306
314
 
307
315
  if (dataType === 'number') {
@@ -404,6 +412,12 @@ dmx.Component('ag-grid', {
404
412
  else {
405
413
  cellRenderer = undefined;
406
414
  }
415
+ if (options.hide_id_field && key == 'id') {
416
+ hide = true;
417
+ }
418
+ else {
419
+ hide = undefined;
420
+ }
407
421
 
408
422
  return {
409
423
  headerName: headerName,
@@ -412,6 +426,7 @@ dmx.Component('ag-grid', {
412
426
  valueFormatter: valueFormatter,
413
427
  valueGetter: valueGetter,
414
428
  minWidth: minWidth,
429
+ hide: hide,
415
430
  filterValueGetter: filterValueGetter,
416
431
  filterParams: filterParams,
417
432
  cellStyle: applyCellStyle,
@@ -447,43 +462,47 @@ dmx.Component('ag-grid', {
447
462
  columnDefs.unshift(checkboxColumn);
448
463
  }
449
464
  if (options.enable_actions) {
450
- actionsColumn = {
451
- headerName: 'Actions',
452
- field: 'action',
453
- filter: null,
454
- cellRenderer: actionsRenderer,
455
- pinned: options.pin_actions,
456
- cellRendererParams: {
457
- // Custom button configurations
458
- buttons: [
459
- {
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,
464
- onClick: (rowData) => {
465
- this.set('data', rowData);
466
- this.set('id', rowData.id);
467
- this.dispatchEvent('row_action_edit');
468
- },
469
- },
470
- {
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,
475
- onClick: (rowData) => {
476
- this.set('data', rowData);
477
- this.set('id', rowData.id);
478
- this.dispatchEvent('row_action_view');
479
- },
480
- },
481
- // Add more custom buttons as needed
482
- ],
483
- },
484
- }
485
- columnDefs.push(actionsColumn);
465
+ actionsColumn = {
466
+ headerName: 'Actions',
467
+ field: 'action',
468
+ filter: null,
469
+ cellRenderer: actionsRenderer,
470
+ pinned: options.pin_actions,
471
+ cellRendererParams: {
472
+ buttons: [],
473
+ },
474
+ };
475
+
476
+ if (options.edit_action_btn) {
477
+ actionsColumn.cellRendererParams.buttons.push({
478
+ action: options.edit_action_title,
479
+ classNames: options.edit_action_btn_class,
480
+ tooltip: options.edit_action_tooltip,
481
+ icon: options.edit_action_icon_class,
482
+ onClick: (rowData) => {
483
+ this.set('data', rowData);
484
+ this.set('id', rowData.id);
485
+ this.dispatchEvent('row_action_edit');
486
+ },
487
+ });
488
+ }
489
+
490
+ if (options.view_action_btn) {
491
+ actionsColumn.cellRendererParams.buttons.push({
492
+ action: options.view_action_title,
493
+ classNames: options.view_action_btn_class,
494
+ tooltip: options.view_action_tooltip,
495
+ icon: options.view_action_icon_class,
496
+ onClick: (rowData) => {
497
+ this.set('data', rowData);
498
+ this.set('id', rowData.id);
499
+ this.dispatchEvent('row_action_view');
500
+ },
501
+ });
486
502
  }
503
+
504
+ columnDefs.push(actionsColumn);
505
+ }
487
506
 
488
507
  const gridOptions = {
489
508
  columnDefs: columnDefs,
@@ -586,8 +605,36 @@ dmx.Component('ag-grid', {
586
605
 
587
606
  // Create the export button
588
607
  if (exportToCSV) {
608
+ const existingExportButton = document.getElementById('exportButton');
609
+ // If it already exists, just exit the function
610
+ if (existingExportButton) {
611
+ return;
612
+ }
589
613
  const exportButton = document.createElement('button');
590
- exportButton.innerText = 'Export to CSV';
614
+ exportButton.id = 'exportButton';
615
+
616
+ // Add the icon
617
+ const icon = document.createElement('i');
618
+ icon.classList.add('fas', 'fa-file-csv'); // Use the Font Awesome icon class here
619
+ exportButton.appendChild(icon);
620
+
621
+ // Add the button text
622
+ const buttonText = document.createElement('span');
623
+ buttonText.innerText = ' Export to CSV';
624
+ exportButton.appendChild(buttonText);
625
+ // Add some fancy styles to the button
626
+ exportButton.style.backgroundColor = '#4CAF50';
627
+ exportButton.style.border = 'none';
628
+ exportButton.style.color = 'white';
629
+ exportButton.style.padding = '5px 10px';
630
+ exportButton.style.textAlign = 'center';
631
+ exportButton.style.textDecoration = 'none';
632
+ exportButton.style.display = 'inline-block';
633
+ exportButton.style.fontSize = '14px';
634
+ exportButton.style.borderRadius = '5px';
635
+ exportButton.style.cursor = 'pointer';
636
+ exportButton.style.marginBottom = '10px';
637
+
591
638
  exportButton.addEventListener('click', () => {
592
639
  const params = {
593
640
  fileName: 'export.csv', // Set the desired file name here
@@ -606,12 +653,11 @@ dmx.Component('ag-grid', {
606
653
  };
607
654
  gridConfig.api.exportDataAsCsv(params);
608
655
  });
609
-
610
656
  // Append the export button to the grid container
611
657
  gridContainer.parentNode.insertBefore(exportButton, gridContainer);
612
-
613
658
  exportButton.style.marginBottom = '10px';
614
659
  }
660
+
615
661
  },
616
662
 
617
663
  events: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation",
6
6
  "license": "MIT",