@cellaware/utils 8.10.2 → 8.11.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.
@@ -16,6 +16,8 @@ export interface VisualDatagridState extends DatagridState {
16
16
  chartRows: any[];
17
17
  html: string;
18
18
  teamsRows: any[];
19
+ htmlTranspose: string;
20
+ teamsTranspose: any[];
19
21
  }
20
22
  export declare function initVisualDatagridState(): VisualDatagridState;
21
23
  export type ColumnState = {
@@ -13,7 +13,9 @@ export function initVisualDatagridState() {
13
13
  ...initDatagridState(),
14
14
  chartRows: [],
15
15
  html: '',
16
- teamsRows: []
16
+ teamsRows: [],
17
+ htmlTranspose: '',
18
+ teamsTranspose: []
17
19
  };
18
20
  }
19
21
  export const DEFAULT_VALUE_FORMAT_VALUE = 'none';
@@ -835,6 +837,20 @@ function processHtmlStyles(value, columnName, columnFormat, rowStyles, columnSty
835
837
  columnStyles.push(columnStyle);
836
838
  return [rowStyles, columnStyles];
837
839
  }
840
+ function processHtmlTransposeStyles(value, columnName, columnFormat, columnStyles) {
841
+ let columnStyle = {
842
+ columnName,
843
+ styles: []
844
+ };
845
+ // Everything is the same as ^^^ except for row styles -- we will consolidate those into columns styles.
846
+ for (const condFmt of columnFormat.conditionalFormats.slice().reverse()) {
847
+ if (evaluateConditionalFormat(condFmt, columnFormat.type, formatNumberEnabled(columnFormat.valueFormat) ? stripNumericValueFormat(value) : value)) {
848
+ columnStyle.styles.push(condFmt.style);
849
+ }
850
+ }
851
+ columnStyles.push(columnStyle);
852
+ return columnStyles;
853
+ }
838
854
  export function mapTeamsStyles(columnNames, htmlRowStyles, htmlColumnStyles, teamsRowStyles, teamsColumnStyles) {
839
855
  // IMPORTANT: both column/row style sorting have **already** been reversed (line 1170).
840
856
  // We can simply iterate over all the matched styles and accumulate them.
@@ -970,6 +986,9 @@ function buildHtmlTableHeader(columnNames) {
970
986
  buf += '\n\t<tbody>';
971
987
  return buf;
972
988
  }
989
+ function buildHtmlTableTransposeHeader() {
990
+ return '<table>\n\t<thead></thead>\n\t<tbody>';
991
+ }
973
992
  function buildHtmlTableFooter() {
974
993
  return '\n\t</tbody>\n</table>';
975
994
  }
@@ -1000,6 +1019,19 @@ function buildHtmlRow(rowValues, rowStyles, columnStyles, columnCount) {
1000
1019
  buf += '\n\t\t</tr>';
1001
1020
  return buf;
1002
1021
  }
1022
+ function buildHtmlTransposeRow(row, columnStyle) {
1023
+ let buf = '';
1024
+ buf += `\n\t\t\t<td>${truncateValue(row.key, 24)}</td>`;
1025
+ const truncValue = truncateValue(row.value, 24);
1026
+ if (columnStyle.styles.length > 0) {
1027
+ buf += `\n\t\t\t<td class="${columnStyle.styles.join(' ')}">${truncValue}</td>`;
1028
+ }
1029
+ else {
1030
+ buf += `\n\t\t\t<td>${truncValue}</td>`;
1031
+ }
1032
+ buf += '\n\t\t</tr>';
1033
+ return buf;
1034
+ }
1003
1035
  function createTeamsTableColumnText(columnName) {
1004
1036
  return {
1005
1037
  type: "TextBlock",
@@ -1085,8 +1117,10 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
1085
1117
  rows = filterRows(rows, filterModel);
1086
1118
  const chartRows = [];
1087
1119
  let htmlBuf = '';
1120
+ let htmlTransposeBuf = '';
1088
1121
  const htmlColumnNames = [];
1089
1122
  const teamsRows = [];
1123
+ const teamsTranspose = [];
1090
1124
  // IMPORTANT: we evaluate the datagrid condition AFTER we are done with all transformations.
1091
1125
  // NOTE: we do not need any pivot columns for pivot mode to be valid.
1092
1126
  // https://chatwms.io/user-manual/chatwms/faq#q-do-i-have-to-have-a-group-column-to-just-display-a-count-in-the-datagrid
@@ -1102,6 +1136,7 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
1102
1136
  let htmlRowValues = [];
1103
1137
  let htmlRowStyles = [];
1104
1138
  let htmlColumnStyles = [];
1139
+ let htmlTransposeColumnStyles = [];
1105
1140
  let teamsRowStyles = [];
1106
1141
  let teamsColumnStyles = [];
1107
1142
  columnFormats.forEach(columnFormat => {
@@ -1112,6 +1147,7 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
1112
1147
  chartRow[columnFormat.displayName] = formatNumberEnabled(columnFormat.valueFormat) ? value : formattedValue;
1113
1148
  htmlRowValues.push(formattedValue);
1114
1149
  [htmlRowStyles, htmlColumnStyles] = processHtmlStyles(formattedValue, columnFormat.displayName, columnFormat, htmlRowStyles, htmlColumnStyles);
1150
+ htmlTransposeColumnStyles = processHtmlTransposeStyles(formattedValue, columnFormat.displayName, columnFormat, htmlTransposeColumnStyles);
1115
1151
  if (rowIdx === 0) {
1116
1152
  htmlColumnNames.push(columnFormat.displayName);
1117
1153
  }
@@ -1133,6 +1169,7 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
1133
1169
  chartRow[adjDisplayName] = formatNumberEnabled(columnFormat.valueFormat) ? value : formattedValue;
1134
1170
  htmlRowValues.push(formattedValue);
1135
1171
  [htmlRowStyles, htmlColumnStyles] = processHtmlStyles(formattedValue, adjDisplayName, columnFormat, htmlRowStyles, htmlColumnStyles);
1172
+ htmlTransposeColumnStyles = processHtmlTransposeStyles(formattedValue, adjDisplayName, columnFormat, htmlTransposeColumnStyles);
1136
1173
  if (rowIdx === 0) {
1137
1174
  htmlColumnNames.push(adjDisplayName);
1138
1175
  }
@@ -1161,6 +1198,16 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
1161
1198
  teamsRows.push(createTeamsTableRow(htmlColumnNames, htmlRowValues, teamsRowStyles, teamsColumnStyles));
1162
1199
  }
1163
1200
  }
1201
+ if (rowIdx === 0) {
1202
+ const transposedRows = htmlColumnNames.map((key, index) => ({
1203
+ key,
1204
+ value: htmlRowValues[index],
1205
+ }));
1206
+ for (let i = 0; i < transposedRows.length; i++) {
1207
+ htmlTransposeBuf += buildHtmlTransposeRow(transposedRows[i], htmlTransposeColumnStyles[i]);
1208
+ // TODO: Teams
1209
+ }
1210
+ }
1164
1211
  rowIdx++;
1165
1212
  });
1166
1213
  if (!!condition) {
@@ -1180,6 +1227,7 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
1180
1227
  let htmlRowValues = [];
1181
1228
  let htmlRowStyles = [];
1182
1229
  let htmlColumnStyles = [];
1230
+ let htmlTransposeColumnStyles = [];
1183
1231
  let teamsRowStyles = [];
1184
1232
  let teamsColumnStyles = [];
1185
1233
  hiddenColumnNames.forEach(columnName => {
@@ -1192,6 +1240,7 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
1192
1240
  chartRow[columnFormat.displayName] = formatNumberEnabled(columnFormat.valueFormat) ? value : formattedValue;
1193
1241
  htmlRowValues.push(formattedValue);
1194
1242
  [htmlRowStyles, htmlColumnStyles] = processHtmlStyles(formattedValue, columnFormat.displayName, columnFormat, htmlRowStyles, htmlColumnStyles);
1243
+ htmlTransposeColumnStyles = processHtmlTransposeStyles(formattedValue, columnFormat.displayName, columnFormat, htmlTransposeColumnStyles);
1195
1244
  if (rowIdx === 0) {
1196
1245
  htmlColumnNames.push(columnFormat.displayName);
1197
1246
  }
@@ -1208,6 +1257,16 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
1208
1257
  teamsRows.push(createTeamsTableRow(htmlColumnNames, htmlRowValues, teamsRowStyles, teamsColumnStyles));
1209
1258
  }
1210
1259
  }
1260
+ if (rowIdx === 0) {
1261
+ const transposedRows = htmlColumnNames.map((key, index) => ({
1262
+ key,
1263
+ value: htmlRowValues[index],
1264
+ }));
1265
+ for (let i = 0; i < transposedRows.length; i++) {
1266
+ htmlTransposeBuf += buildHtmlTransposeRow(transposedRows[i], htmlTransposeColumnStyles[i]);
1267
+ // TODO: Teams
1268
+ }
1269
+ }
1211
1270
  rowIdx++;
1212
1271
  });
1213
1272
  if (!!condition) {
@@ -1222,6 +1281,8 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
1222
1281
  teamsRows: [
1223
1282
  createTeamsTableColumns(htmlColumnNames),
1224
1283
  ...teamsRows
1225
- ]
1284
+ ],
1285
+ htmlTranspose: `${buildHtmlTableTransposeHeader()}${htmlTransposeBuf}${buildHtmlTableFooter()}`,
1286
+ teamsTranspose
1226
1287
  };
1227
1288
  }
@@ -78,6 +78,8 @@ export interface ReportLineResult {
78
78
  teamsRows: any[];
79
79
  markdownRows: string;
80
80
  chartRows: any[];
81
+ htmlTranspose: string;
82
+ teamsTranspose: any[];
81
83
  }
82
84
  export declare function initReportLineResult(): ReportLineResult;
83
85
  export interface ReportUsage {
@@ -29,7 +29,9 @@ export function initReportLineResult() {
29
29
  htmlRows: '',
30
30
  teamsRows: [],
31
31
  markdownRows: '',
32
- chartRows: []
32
+ chartRows: [],
33
+ htmlTranspose: '',
34
+ teamsTranspose: []
33
35
  };
34
36
  }
35
37
  export function initReportSchedule() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cellaware/utils",
3
- "version": "8.10.2",
3
+ "version": "8.11.1",
4
4
  "description": "Cellaware Utilities for Node.js",
5
5
  "author": "Cellaware Technologies",
6
6
  "type": "module",