@cdmx/wappler_ag_grid 0.8.5 → 0.8.6

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.
@@ -1153,26 +1153,41 @@
1153
1153
  "display": "fieldset",
1154
1154
  "show": [
1155
1155
  "columnsToCount",
1156
- "columnValueMatchCount",
1157
1156
  "columnsToSum"
1158
1157
  ],
1159
1158
  "noChangeOnHide": true,
1160
1159
  "groupEnabler": true,
1161
1160
  "help": "Define the Columns to Count and Sum in the Footer row"
1162
1161
  "children": [
1163
- {
1164
- "name": "columnsToCount",
1165
- "attribute": "columns_to_count",
1166
- "title": "Columns To Count",
1167
- "type": "text",
1168
- "initDisplay": "none"
1169
- },
1170
- {
1171
- "name": "columnValueMatchCount",
1172
- "attribute": "column_value_match_count",
1173
- "title": "Unique Value To Count",
1174
- "type": "text",
1175
- "initDisplay": "none"
1162
+ {
1163
+ "name": "columnsToCount",
1164
+ "attribute": "columns_to_count",
1165
+ "title": "Columns to Count",
1166
+ "type": "grid",
1167
+ "jsonFormat": true,
1168
+ "encloseBT": true,
1169
+ "jsonBT": true,
1170
+ "initDisplay": "none",
1171
+ "columns": [
1172
+ {
1173
+ "field": "field",
1174
+ "caption": "Field",
1175
+ "editable": {
1176
+ "type": "text"
1177
+ }
1178
+ },
1179
+ {
1180
+ field: "unique_values",
1181
+ caption: "Unique Values",
1182
+ editable: {
1183
+ type: "text"
1184
+ }
1185
+ }
1186
+ ],
1187
+ "newRecord": {
1188
+ "field": "",
1189
+ "unique_values": ""
1190
+ }
1176
1191
  },
1177
1192
  {
1178
1193
  "name": "columnsToSum",
package/dmx-ag-grid.js CHANGED
@@ -141,8 +141,7 @@ dmx.Component('ag-grid', {
141
141
  compact_view_grid_size: { type: Number, default: 3 },
142
142
  compact_view_item_height: { type: Number, default: 20 },
143
143
  group_config: { type: Array, default: [] },
144
- columns_to_count: { type: String, default: null },
145
- column_value_match_count: { type: String, default: null },
144
+ columns_to_count: { type: Array, default: [] },
146
145
  columns_to_sum: { type: String, default: null }
147
146
  },
148
147
 
@@ -1003,7 +1002,7 @@ dmx.Component('ag-grid', {
1003
1002
  actionsRenderer: actionsRenderer
1004
1003
  }
1005
1004
  };
1006
- const totalRow = function (api, columnsToSum, columnsToCount, columnValueMatchCount) {
1005
+ const totalRow = function (api, columnsToSum, columnsToCount) {
1007
1006
  if (!columnsToSum && !columnsToCount) {
1008
1007
  return;
1009
1008
  }
@@ -1026,38 +1025,26 @@ dmx.Component('ag-grid', {
1026
1025
  }
1027
1026
 
1028
1027
  if (columnsToCount) {
1029
- if (columnValueMatchCount) {
1030
- // Count unique entries for a specific column
1031
- columnsToCount.forEach(function (col) {
1032
- result[0][col] = 0;
1033
- rowData.forEach(function (line) {
1034
- if (line.index < rowData.length) {
1035
- const value = line.data[col];
1036
- if (value == columnValueMatchCount) {
1037
- result[0][col]++;
1038
- }
1039
- }
1040
- });
1041
- });
1042
- }
1043
- else {
1044
- // Initialize and calculate count columns
1045
- columnsToCount.forEach(function (col) {
1028
+ columnsToCount.forEach(function (colObj) {
1029
+ const col = colObj.field;
1030
+ const uniqueValuesToCount = colObj.unique_values.split(',');
1031
+
1046
1032
  result[0][col] = 0;
1047
1033
  let uniqueValues = new Set();
1034
+
1048
1035
  rowData.forEach(function (line) {
1049
1036
  if (line.index < rowData.length) {
1050
1037
  const value = line.data[col];
1051
- if (!uniqueValues.has(value)) {
1038
+ if (uniqueValuesToCount.includes(value) && !uniqueValues.has(value)) {
1052
1039
  uniqueValues.add(value);
1053
1040
  result[0][col]++;
1054
1041
  }
1055
1042
  }
1056
1043
  });
1044
+
1057
1045
  result[0][col + '_unique_count'] = uniqueValues.size;
1058
1046
  });
1059
1047
  }
1060
- }
1061
1048
  api.setPinnedBottomRowData(result);
1062
1049
  }
1063
1050
 
@@ -1079,19 +1066,18 @@ dmx.Component('ag-grid', {
1079
1066
  ...gridOptions
1080
1067
  };
1081
1068
  // Conditionally add event listeners based on whether columnsToSum or columnsToCount are defined
1082
- if ((options.columns_to_sum && options.columns_to_sum.split(',').length > 0) || (options.columns_to_count && options.columns_to_count.split(',').length > 0)) {
1069
+ if ((options.columns_to_sum && options.columns_to_sum.split(',').length > 0) || (options.columns_to_count.length > 0)) {
1083
1070
  let columnsToSum = options.columns_to_sum ? options.columns_to_sum.split(',') : [];
1084
- let columnsToCount = options.columns_to_count ? options.columns_to_count.split(',') : [];
1085
- let columnValueMatchCount = options.column_value_match_count
1071
+ let columnsToCount = options.columns_to_count;
1086
1072
 
1087
1073
  gridConfig.onFilterChanged = function (e) {
1088
- totalRow(e.api, columnsToSum, columnsToCount, columnValueMatchCount);
1074
+ totalRow(e.api, columnsToSum, columnsToCount);
1089
1075
  };
1090
1076
  gridConfig.onFirstDataRendered = function (e) {
1091
- totalRow(e.api, columnsToSum, columnsToCount, columnValueMatchCount);
1077
+ totalRow(e.api, columnsToSum, columnsToCount);
1092
1078
  };
1093
1079
  gridConfig.postSortRows = function (e) {
1094
- totalRow(e.api, columnsToSum, columnsToCount,columnValueMatchCount);
1080
+ totalRow(e.api, columnsToSum, columnsToCount);
1095
1081
  };
1096
1082
  }
1097
1083
  // Create ag-Grid instance
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "0.8.5",
3
+ "version": "0.8.6",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation.",
6
6
  "license": "MIT",