@cellaware/utils 8.11.14 → 8.11.16
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.
- package/dist/chatwms/datagrid.js +26 -33
- package/package.json +1 -1
package/dist/chatwms/datagrid.js
CHANGED
|
@@ -1235,6 +1235,7 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
|
|
|
1235
1235
|
const columnFormats = datagridState.columnFormats ?? [];
|
|
1236
1236
|
const { rowGroupCols, pivotCols, valueCols, sortModel } = parseColumnState(columnState);
|
|
1237
1237
|
rows = filterRows(rows, filterModel);
|
|
1238
|
+
let adjRows = [];
|
|
1238
1239
|
const chartRows = [];
|
|
1239
1240
|
let htmlBuf = '';
|
|
1240
1241
|
let htmlTransposeBuf = '';
|
|
@@ -1250,8 +1251,10 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
|
|
|
1250
1251
|
rows = sortModel.length > 0 ? sortRows(rows, sortModel) : rows;
|
|
1251
1252
|
let mappedDisplayColumnNames = new Map();
|
|
1252
1253
|
// Should not need to do hidden/visible column analysis -- pivoting creates new results with only the necessary columns.
|
|
1254
|
+
// Also should not need to analyze column sequence -- our newly created results *should* respect the correct sequence.
|
|
1253
1255
|
let rowIdx = 0;
|
|
1254
|
-
rows.forEach(row => {
|
|
1256
|
+
rows.forEach((row) => {
|
|
1257
|
+
let adjRow = {};
|
|
1255
1258
|
let chartRow = {};
|
|
1256
1259
|
let htmlRowValues = [];
|
|
1257
1260
|
let htmlRowStyles = [];
|
|
@@ -1263,7 +1266,7 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
|
|
|
1263
1266
|
if (columnFormat.name in row) {
|
|
1264
1267
|
const value = row[columnFormat.name];
|
|
1265
1268
|
const formattedValue = evaluateValueFormat(columnFormat, value, locale);
|
|
1266
|
-
|
|
1269
|
+
adjRow[columnFormat.displayName] = formattedValue;
|
|
1267
1270
|
chartRow[columnFormat.displayName] = formatNumberEnabled(columnFormat.valueFormat) ? value : formattedValue;
|
|
1268
1271
|
htmlRowValues.push(formattedValue);
|
|
1269
1272
|
[htmlRowStyles, htmlColumnStyles] = processHtmlStyles(formattedValue, columnFormat.displayName, columnFormat, htmlRowStyles, htmlColumnStyles);
|
|
@@ -1271,10 +1274,6 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
|
|
|
1271
1274
|
if (rowIdx === 0) {
|
|
1272
1275
|
htmlColumnNames.push(columnFormat.displayName);
|
|
1273
1276
|
}
|
|
1274
|
-
// Remove name in favor of display name.
|
|
1275
|
-
if (columnFormat.displayName !== columnFormat.name) {
|
|
1276
|
-
delete row[columnFormat.name];
|
|
1277
|
-
}
|
|
1278
1277
|
}
|
|
1279
1278
|
else {
|
|
1280
1279
|
const mappedColumnNamesSet = pivotOutput.mappedColumnNames.get(columnFormat.name);
|
|
@@ -1285,7 +1284,7 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
|
|
|
1285
1284
|
const adjDisplayName = mappedColumnName.replace(columnFormat.name, columnFormat.displayName);
|
|
1286
1285
|
const value = row[mappedColumnName];
|
|
1287
1286
|
const formattedValue = evaluateValueFormat(columnFormat, value, locale);
|
|
1288
|
-
|
|
1287
|
+
adjRow[adjDisplayName] = formattedValue;
|
|
1289
1288
|
chartRow[adjDisplayName] = formatNumberEnabled(columnFormat.valueFormat) ? value : formattedValue;
|
|
1290
1289
|
htmlRowValues.push(formattedValue);
|
|
1291
1290
|
[htmlRowStyles, htmlColumnStyles] = processHtmlStyles(formattedValue, adjDisplayName, columnFormat, htmlRowStyles, htmlColumnStyles);
|
|
@@ -1293,10 +1292,6 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
|
|
|
1293
1292
|
if (rowIdx === 0) {
|
|
1294
1293
|
htmlColumnNames.push(adjDisplayName);
|
|
1295
1294
|
}
|
|
1296
|
-
// Remove name in favor of display name.
|
|
1297
|
-
if (adjDisplayName !== mappedColumnName) {
|
|
1298
|
-
delete row[mappedColumnName];
|
|
1299
|
-
}
|
|
1300
1295
|
let displayColumnNames = mappedDisplayColumnNames.get(columnFormat.displayName);
|
|
1301
1296
|
if (!!displayColumnNames) {
|
|
1302
1297
|
displayColumnNames.add(adjDisplayName);
|
|
@@ -1339,10 +1334,10 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
|
|
|
1339
1334
|
rows = groupAndAggregate(rows, rowGroupCols, [], valueCols);
|
|
1340
1335
|
}
|
|
1341
1336
|
rows = sortModel.length > 0 ? sortRows(rows, sortModel) : rows;
|
|
1342
|
-
const
|
|
1343
|
-
const visibleColumnFormats = columnFormats.filter(column => !hiddenColumnNames.includes(column.name)) ?? [];
|
|
1337
|
+
const visibleColumnState = columnState.filter(column => !column.hide);
|
|
1344
1338
|
let rowIdx = 0;
|
|
1345
|
-
rows.forEach(row => {
|
|
1339
|
+
rows.forEach((row) => {
|
|
1340
|
+
let adjRow = {};
|
|
1346
1341
|
let chartRow = {};
|
|
1347
1342
|
let htmlRowValues = [];
|
|
1348
1343
|
let htmlRowStyles = [];
|
|
@@ -1350,25 +1345,23 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
|
|
|
1350
1345
|
let htmlTransposeColumnStyles = [];
|
|
1351
1346
|
let teamsRowStyles = [];
|
|
1352
1347
|
let teamsColumnStyles = [];
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
// Remove name in favor of display name.
|
|
1368
|
-
if (columnFormat.displayName !== columnFormat.name) {
|
|
1369
|
-
delete row[columnFormat.name];
|
|
1348
|
+
// Important: anchoring to column state will ensure we add columns in the correct sequence.
|
|
1349
|
+
visibleColumnState.forEach(column => {
|
|
1350
|
+
const columnFormat = columnFormats.find(columnFormat => columnFormat.name === column.colId);
|
|
1351
|
+
if (!!columnFormat) {
|
|
1352
|
+
const value = row[columnFormat.name];
|
|
1353
|
+
const formattedValue = evaluateValueFormat(columnFormat, value, locale);
|
|
1354
|
+
adjRow[columnFormat.displayName] = formattedValue;
|
|
1355
|
+
chartRow[columnFormat.displayName] = formatNumberEnabled(columnFormat.valueFormat) ? value : formattedValue;
|
|
1356
|
+
htmlRowValues.push(formattedValue);
|
|
1357
|
+
[htmlRowStyles, htmlColumnStyles] = processHtmlStyles(formattedValue, columnFormat.displayName, columnFormat, htmlRowStyles, htmlColumnStyles);
|
|
1358
|
+
htmlTransposeColumnStyles = processHtmlTransposeStyles(formattedValue, columnFormat.displayName, columnFormat, htmlTransposeColumnStyles);
|
|
1359
|
+
if (rowIdx === 0) {
|
|
1360
|
+
htmlColumnNames.push(columnFormat.displayName);
|
|
1361
|
+
}
|
|
1370
1362
|
}
|
|
1371
1363
|
});
|
|
1364
|
+
adjRows.push(adjRow);
|
|
1372
1365
|
chartRows.push(chartRow);
|
|
1373
1366
|
if (rowIdx < DATAGRID_HTML_ROWS) {
|
|
1374
1367
|
htmlBuf += buildHtmlRow(htmlRowValues, htmlRowStyles, htmlColumnStyles, DATAGRID_HTML_COLS);
|
|
@@ -1390,12 +1383,12 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
|
|
|
1390
1383
|
rowIdx++;
|
|
1391
1384
|
});
|
|
1392
1385
|
if (!!condition) {
|
|
1393
|
-
|
|
1386
|
+
adjRows = evaluateDatagridCondition(rows, condition);
|
|
1394
1387
|
}
|
|
1395
1388
|
}
|
|
1396
1389
|
return {
|
|
1397
1390
|
...datagridState,
|
|
1398
|
-
adjRows
|
|
1391
|
+
adjRows,
|
|
1399
1392
|
chartRows,
|
|
1400
1393
|
html: `<p style="font-size: 12px;">Displaying first <b>${DATAGRID_HTML_ROWS} rows</b> and <b>${DATAGRID_HTML_COLS} columns</b></p>\n\n${buildHtmlTableHeader(htmlColumnNames.slice(0, DATAGRID_HTML_COLS))}${htmlBuf}${buildHtmlTableFooter()}`,
|
|
1401
1394
|
teamsRows: [
|