@cdmx/wappler_ag_grid 0.6.1 → 0.6.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.
@@ -264,6 +264,7 @@
264
264
  {
265
265
  "name": "fixedHeader",
266
266
  "title": "Sticky Header and Horizontal Scrollbar",
267
+ "attribute": "f_header",
267
268
  "type": "boolean",
268
269
  "display": "fieldset",
269
270
  "noChangeOnHide": true,
@@ -791,7 +792,8 @@
791
792
  "defaultValue": false,
792
793
  "display": "fieldset",
793
794
  "show": [
794
- "dataChanges"
795
+ "dataChanges",
796
+ "amountFields"
795
797
  ],
796
798
  "noChangeOnHide": true,
797
799
  "groupEnabler": true,
@@ -847,6 +849,13 @@
847
849
  "new_value": "",
848
850
  "area": "cell"
849
851
  }
852
+ },
853
+ {
854
+ "name": "amountFields",
855
+ "attribute": "amount_fields",
856
+ "title": "Amount Fields",
857
+ "type": "text",
858
+ "initDisplay": "none"
850
859
  }
851
860
  ]
852
861
  }
@@ -994,7 +1003,7 @@
994
1003
  "show": [
995
1004
  "hideFields",
996
1005
  "hideFilters",
997
- "hideSort",
1006
+ "hideSort"
998
1007
  ],
999
1008
  "noChangeOnHide": true,
1000
1009
  "groupEnabler": true,
@@ -1025,39 +1034,13 @@
1025
1034
  }
1026
1035
  ]
1027
1036
  },
1028
- {
1029
- "group": "📒 Amount Fields",
1030
- "variables": [
1031
- {
1032
- "name": "amount_fields",
1033
- "title": "Amount Fields Config",
1034
- "type": "boolean",
1035
- "defaultValue": false,
1036
- "display": "fieldset",
1037
- "show": [
1038
- "amountFields"
1039
- ],
1040
- "noChangeOnHide": true,
1041
- "groupEnabler": true,
1042
- "help": "Configure amount fields to have comma-seperation implemented"
1043
- "children": [
1044
- {
1045
- "name": "amountFields",
1046
- "attribute": "amount_fields",
1047
- "title": "Amount Fields",
1048
- "type": "text",
1049
- "initDisplay": "none"
1050
- }
1051
- ]
1052
- }
1053
- ]
1054
- },
1055
1037
  {
1056
1038
  "group": "📒 Compact View",
1057
1039
  "variables": [
1058
1040
  {
1059
1041
  "name": "compact_view",
1060
1042
  "title": "Compact View Config",
1043
+ "attribute": "compact_views",
1061
1044
  "type": "boolean",
1062
1045
  "defaultValue": false,
1063
1046
  "display": "fieldset",
@@ -1104,6 +1087,7 @@
1104
1087
  {
1105
1088
  "name": "groupConfig",
1106
1089
  "title": "Configure Column Groups",
1090
+ "attribute": "group_configs",
1107
1091
  "type": "boolean",
1108
1092
  "defaultValue": false,
1109
1093
  "display": "fieldset",
@@ -1165,7 +1149,6 @@
1165
1149
  "variables": [
1166
1150
  {
1167
1151
  "name": "action_column",
1168
- "attributeStartsWith": "dmx-bind",
1169
1152
  "attribute": "action_column",
1170
1153
  "title": "Configure Actions",
1171
1154
  "type": "boolean",
@@ -1338,6 +1321,15 @@
1338
1321
  state : 'opened',
1339
1322
  help: 'Reload the AG Grid',
1340
1323
  properties : []
1324
+ },
1325
+ {
1326
+ addTitle: 'Export',
1327
+ title: 'Export',
1328
+ name: 'exportGrid',
1329
+ icon: 'fa fa-lg fa-download',
1330
+ state: 'opened',
1331
+ help: 'Export AG Grid Data to CSV',
1332
+ properties: []
1341
1333
  }
1342
1334
  ],
1343
1335
  "children": [],
package/dmx-ag-grid.js CHANGED
@@ -43,7 +43,7 @@ dmx.Component('ag-grid', {
43
43
  locale_text: { type: String, default: null },
44
44
  date_locale: { type: String, default: 'en-IN' },
45
45
  date_format: { type: String, default: 'dd/MM/yyyy hh:mm A' },
46
- amount_fields: { type: Array, default: [] },
46
+ amount_fields: { type: String, default: null },
47
47
  min_width: { type: Number, default: 150 },
48
48
  sortable: { type: Boolean, default: true },
49
49
  resizable: { type: Boolean, default: true },
@@ -80,9 +80,9 @@ dmx.Component('ag-grid', {
80
80
  delete_action_icon_class: {type: String, default: 'fas fa-trash' },
81
81
  delete_action_btn_class: {type: String, default: 'btn-danger btn-xs' },
82
82
  data_binded_changes: {type: Array, default: [] },
83
- hide_fields: {type: Array, default: [] },
84
- hide_filters: {type: Array, default: [] },
85
- hide_sort: {type: Array, default: [] },
83
+ hide_fields: {type: String, default: null },
84
+ hide_filters: {type: String, default: null },
85
+ hide_sort: {type: String, default: null },
86
86
  compact_view: { type: Boolean, default: false },
87
87
  compact_view_grid_size: { type: Number, default: 3 },
88
88
  compact_view_item_height: { type: Number, default: 20 },
@@ -105,6 +105,15 @@ dmx.Component('ag-grid', {
105
105
  let gridInstance = this.refreshGrid();
106
106
  this.set('gridInstance', gridInstance);
107
107
  }, this);
108
+ },
109
+ exportGrid: function () {
110
+ dmx.nextTick(function() {
111
+ if (typeof exportGridData === 'function') {
112
+ exportGridData();
113
+ } else {
114
+ console.error('Grid not loaded to perform export');
115
+ }
116
+ }, this);
108
117
  }
109
118
  },
110
119
 
@@ -458,8 +467,11 @@ dmx.Component('ag-grid', {
458
467
  return matchingItem[output];
459
468
  }
460
469
  }
461
- if (options.amount_fields && options.amount_fields.includes(key)) {
462
- return parseFloat(value)
470
+ if (options.amount_fields) {
471
+ const amountFieldsArray = options.amount_fields.split(',');
472
+ if (amountFieldsArray.includes(key)) {
473
+ return parseFloat(value);
474
+ }
463
475
  }
464
476
 
465
477
  // Return the original value if no matching changes were found
@@ -550,8 +562,11 @@ dmx.Component('ag-grid', {
550
562
  return matchingItem[output];
551
563
  }
552
564
  }
553
- if (options.amount_fields && options.amount_fields.includes(key)) {
554
- return parseFloat(value)
565
+ if (options.amount_fields) {
566
+ const amountFieldsArray = options.amount_fields.split(',');
567
+ if (amountFieldsArray.includes(key)) {
568
+ return parseFloat(value);
569
+ }
555
570
  }
556
571
  // Return the original value if no matching changes were found
557
572
  return value;
@@ -575,22 +590,26 @@ dmx.Component('ag-grid', {
575
590
  let hide;
576
591
  let type;
577
592
  let colId;
593
+ let sortable;
578
594
 
579
595
  if (dataType === 'number') {
580
596
  filter = 'agNumberColumnFilter';
581
597
  if (options.numeric_column_align){
582
598
  type = 'numericColumn';
583
599
  }
584
- if (options.amount_fields && options.amount_fields.includes(key)) {
585
- valueFormatter = function (params) {
586
- if (params.value != null) {
587
- return Number(params.value).toLocaleString("en-US", {
588
- minimumFractionDigits: 2,
589
- maximumFractionDigits: 2,
590
- });
591
- }
592
- return '-';
593
- };
600
+ if (options.amount_fields) {
601
+ const amountFieldsArray = options.amount_fields.split(',');
602
+ if (amountFieldsArray.includes(key)) {
603
+ valueFormatter = function (params) {
604
+ if (params.value != null) {
605
+ return Number(params.value).toLocaleString("en-US", {
606
+ minimumFractionDigits: 2,
607
+ maximumFractionDigits: 2,
608
+ });
609
+ }
610
+ return '-';
611
+ };
612
+ }
594
613
  } else {
595
614
  valueFormatter = blankOrNullValueFormatter;
596
615
  }
@@ -705,15 +724,22 @@ dmx.Component('ag-grid', {
705
724
  colId = 'statusColumn';
706
725
  filter = null;
707
726
  }
708
- else if (options.hide_filters && options.hide_filters.includes(key)) {
709
- filter = null;
727
+ else if (options.hide_filters) {
728
+ const hideFiltersArray = options.hide_filters.split(',');
729
+
730
+ if (hideFiltersArray.includes(key)) {
731
+ filter = null;
732
+ }
710
733
  }
711
734
  else {
712
735
  cellRenderer = undefined;
713
736
  colId = undefined;
714
737
  }
715
- if (options.hide_sort && options.hide_sort.includes(key)) {
716
- sortable = false;
738
+ if (options.hide_sort) {
739
+ const hideSortArray = options.hide_sort.split(',');
740
+ if (hideSortArray.includes(key)) {
741
+ sortable = false;
742
+ }
717
743
  }
718
744
  else {
719
745
  sortable = true;
@@ -721,8 +747,12 @@ dmx.Component('ag-grid', {
721
747
  if (options.hide_id_field && key == 'id') {
722
748
  hide = true;
723
749
  }
724
- else if (options.hide_fields && options.hide_fields.includes(key)) {
725
- hide = true;
750
+ else if (options.hide_fields) {
751
+ const hideFieldsArray = options.hide_fields.split(',');
752
+
753
+ if (hideFieldsArray.includes(key)) {
754
+ hide = true;
755
+ }
726
756
  }
727
757
  else {
728
758
  hide = undefined;
@@ -989,6 +1019,37 @@ dmx.Component('ag-grid', {
989
1019
  updateHoveringBarStyles();
990
1020
  window.addEventListener('resize', updateHoveringBarStyles);
991
1021
 
1022
+ //CSV Export Function
1023
+ exportGridData = () => {
1024
+ const excludedColumnIds = ['checkboxColumn', 'actionsColumn'];
1025
+ // Extracting fields and colIds from columnDefs
1026
+ const fieldsAndColIds = gridConfig.columnDefs.map((column) => ({
1027
+ field: column.field,
1028
+ colId: column.colId,
1029
+ }));
1030
+ // Filtering out fields based on excludedColumnIds
1031
+ const fieldsToExport = fieldsAndColIds.filter(
1032
+ (column) => !excludedColumnIds.includes(column.colId)
1033
+ ).map((column) => column.field);
1034
+ const params = {
1035
+ fileName: 'export.csv', // Set the desired file name here
1036
+ allColumns: true,
1037
+ columnKeys: fieldsToExport,
1038
+ processCellCallback: function (params) {
1039
+ const columnDef = params.column.getColDef();
1040
+ const valueFormatter = columnDef.valueFormatter;
1041
+ if (valueFormatter && typeof valueFormatter === "function") {
1042
+ const formattedValue = valueFormatter(params);
1043
+ if (formattedValue !== null && formattedValue !== undefined) {
1044
+ return formattedValue;
1045
+ }
1046
+ }
1047
+ return params.value;
1048
+ },
1049
+ };
1050
+ gridConfig.api.exportDataAsCsv(params);
1051
+ };
1052
+
992
1053
  // Create the export button
993
1054
  if (exportToCSV) {
994
1055
  const existingExportButton = document.getElementById('exportButton');
@@ -1020,37 +1081,10 @@ dmx.Component('ag-grid', {
1020
1081
  exportButton.style.borderRadius = '5px';
1021
1082
  exportButton.style.cursor = 'pointer';
1022
1083
  exportButton.style.marginBottom = '10px';
1023
-
1084
+
1024
1085
  exportButton.addEventListener('click', () => {
1025
- const excludedColumnIds = ['checkboxColumn', 'actionsColumn'];
1026
- // Extracting fields and colIds from columnDefs
1027
- const fieldsAndColIds = gridConfig.columnDefs.map((column) => ({
1028
- field: column.field,
1029
- colId: column.colId,
1030
- }));
1031
- // Filtering out fields based on excludedColumnIds
1032
- const fieldsToExport = fieldsAndColIds.filter(
1033
- (column) => !excludedColumnIds.includes(column.colId)
1034
- ).map((column) => column.field);
1035
- const params = {
1036
- fileName: 'export.csv', // Set the desired file name here
1037
- allColumns: true,
1038
- columnKeys: fieldsToExport,
1039
- processCellCallback: function (params) {
1040
- const columnDef = params.column.getColDef();
1041
- const valueFormatter = columnDef.valueFormatter;
1042
- if (valueFormatter && typeof valueFormatter === "function") {
1043
- const formattedValue = valueFormatter(params);
1044
- if (formattedValue !== null && formattedValue !== undefined) {
1045
- return formattedValue;
1046
- }
1047
- }
1048
- return params.value;
1049
- },
1050
- };
1051
- gridConfig.api.exportDataAsCsv(params);
1052
- });
1053
-
1086
+ exportGridData()
1087
+ })
1054
1088
  // Append the export button to the grid container
1055
1089
  gridContainer.parentNode.insertBefore(exportButton, gridContainer);
1056
1090
  exportButton.style.marginBottom = '10px';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation",
6
6
  "license": "MIT",