logitude-dashboard-library 3.2.61 → 3.2.63
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/assets/styles/dl-dashboard.scss +107 -1
- package/dist/features/Dashboard/ChartsComponents/CustomCharts/AgPivotGrid.d.ts +10 -0
- package/dist/features/Dashboard/ChartsComponents/CustomCharts/CustomChart.d.ts +1 -0
- package/dist/features/Dashboard/ChartsComponents/CustomCharts/PivotAgGridSupport.d.ts +45 -0
- package/dist/features/Dashboard/DashboardDesigner.d.ts +1 -0
- package/dist/features/Dashboard/WidgetCard.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +976 -6
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +976 -6
- package/dist/index.modern.js.map +1 -1
- package/dist/services/session.d.ts +2 -0
- package/dist/styles/dl-dashboard.scss +107 -1
- package/package.json +8 -2
package/dist/index.modern.js
CHANGED
|
@@ -8,6 +8,10 @@ import { DataTable } from 'primereact/datatable';
|
|
|
8
8
|
import { Column } from 'primereact/column';
|
|
9
9
|
import PivotGrid, { FieldPanel, FieldChooser, Scrolling } from 'devextreme-react/pivot-grid';
|
|
10
10
|
import PivotGridDataSource from 'devextreme/ui/pivot_grid/data_source';
|
|
11
|
+
import { AgGridReact } from 'ag-grid-react';
|
|
12
|
+
import { LicenseManager } from 'ag-grid-enterprise';
|
|
13
|
+
import 'ag-grid-community/dist/styles/ag-grid.css';
|
|
14
|
+
import 'ag-grid-community/dist/styles/ag-theme-balham.css';
|
|
11
15
|
import ReactFC from 'react-fusioncharts';
|
|
12
16
|
import FusionCharts from 'fusioncharts';
|
|
13
17
|
import Charts from 'fusioncharts/fusioncharts.charts';
|
|
@@ -77,6 +81,7 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
var Session = function Session() {};
|
|
84
|
+
Session.UseAgGridPivot = false;
|
|
80
85
|
|
|
81
86
|
var Tools = /*#__PURE__*/function () {
|
|
82
87
|
function Tools() {}
|
|
@@ -1848,12 +1853,25 @@ var TableChart = function TableChart(props) {
|
|
|
1848
1853
|
return "unset";
|
|
1849
1854
|
};
|
|
1850
1855
|
|
|
1851
|
-
var
|
|
1852
|
-
if (
|
|
1853
|
-
|
|
1856
|
+
var isRowTenantMatched = function isRowTenantMatched(rowData) {
|
|
1857
|
+
if (rowData === void 0) {
|
|
1858
|
+
rowData = null;
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
if (!rowData) return true;
|
|
1862
|
+
return Number(rowData.Tenant) === Number(Session.Tenant);
|
|
1863
|
+
};
|
|
1864
|
+
|
|
1865
|
+
var isClickableCell = function isClickableCell(fieldCode, rowData) {
|
|
1866
|
+
if (rowData === void 0) {
|
|
1867
|
+
rowData = null;
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
if (!isRowTenantMatched(rowData)) {
|
|
1871
|
+
return false;
|
|
1854
1872
|
}
|
|
1855
1873
|
|
|
1856
|
-
return fieldCode == "ShipmentNumber" && objectTableName == "Shipment" || IsShipmentMasterFieldClickable(fieldCode,
|
|
1874
|
+
return fieldCode == "ShipmentNumber" && objectTableName == "Shipment" || IsShipmentMasterFieldClickable(fieldCode, rowData) || fieldCode == "InvoiceNumber" && objectTableName == "APInvoice" || fieldCode == "InvoiceNumber" && objectTableName == "ARInvoice" || fieldCode == "ContainerNumber" && objectTableName == "Container" || fieldCode == "QuoteNumber" && objectTableName == "Quote" || fieldCode == "Subject" && objectTableName == "Opportunity" || fieldCode == "EnglishName" && objectTableName == "Customer" || fieldCode == "TaskNumber" && objectTableName == "Task" || fieldCode == "Subject" && objectTableName == "Activity" || fieldCode == "TicketNumber" && objectTableName == "Ticket" || fieldCode == "ReleaseNumber" && objectTableName == "WarehouseRelease" || fieldCode == "EntryNumber" && objectTableName == "WarehouseEntry";
|
|
1857
1875
|
};
|
|
1858
1876
|
|
|
1859
1877
|
var IsShipmentMasterFieldClickable = function IsShipmentMasterFieldClickable(fieldCode, rowData) {
|
|
@@ -2356,6 +2374,943 @@ var PivotTable = forwardRef(function (props, comRef) {
|
|
|
2356
2374
|
})));
|
|
2357
2375
|
});
|
|
2358
2376
|
|
|
2377
|
+
var isRowPivotField = function isRowPivotField(field) {
|
|
2378
|
+
return !!(field.PivotCode && field.PivotCode.indexOf('Row') !== -1);
|
|
2379
|
+
};
|
|
2380
|
+
var truncateToTwoDecimals = function truncateToTwoDecimals(value) {
|
|
2381
|
+
var numericValue = isNullOrUndefinedOrEmpty(value) ? 0 : Number(value);
|
|
2382
|
+
var safeValue = isNaN(numericValue) ? 0 : numericValue;
|
|
2383
|
+
var decimalParts = safeValue.toString().split('.');
|
|
2384
|
+
var firstPart = decimalParts[0] ? decimalParts[0] : '0';
|
|
2385
|
+
var secondPart = decimalParts[1] ? decimalParts[1].toString().substr(0, 2) : '0';
|
|
2386
|
+
return Number(firstPart + '.' + secondPart);
|
|
2387
|
+
};
|
|
2388
|
+
var isPivotMeasureValueEmpty = function isPivotMeasureValueEmpty(value) {
|
|
2389
|
+
return value === null || value === undefined || value === '';
|
|
2390
|
+
};
|
|
2391
|
+
var logitudeSumAgg = function logitudeSumAgg(params) {
|
|
2392
|
+
var values = params && params.values ? params.values : [];
|
|
2393
|
+
if (values.length === 0) return null;
|
|
2394
|
+
var total = 0;
|
|
2395
|
+
var hasValue = false;
|
|
2396
|
+
|
|
2397
|
+
for (var i = 0; i < values.length; i++) {
|
|
2398
|
+
if (isPivotMeasureValueEmpty(values[i])) continue;
|
|
2399
|
+
hasValue = true;
|
|
2400
|
+
total += truncateToTwoDecimals(values[i]);
|
|
2401
|
+
}
|
|
2402
|
+
|
|
2403
|
+
return hasValue ? total : null;
|
|
2404
|
+
};
|
|
2405
|
+
var formatPivotMeasureValue = function formatPivotMeasureValue(value, measure) {
|
|
2406
|
+
if (isPivotMeasureValueEmpty(value)) return '';
|
|
2407
|
+
var isInteger = isValueInteger(measure.MeasureCode, measure.MeasureFieldDataType);
|
|
2408
|
+
var minimumFraction = isInteger ? 0 : 2;
|
|
2409
|
+
return getNumberInSystemLocalFormat(value, 2, minimumFraction);
|
|
2410
|
+
};
|
|
2411
|
+
var getPivotGroupFooterLabel = function getPivotGroupFooterLabel(node, fieldCode, rawValue, lookupDisplayName) {
|
|
2412
|
+
if (!node || !node.footer) return '';
|
|
2413
|
+
|
|
2414
|
+
if (node.level === -1) {
|
|
2415
|
+
return 'Grand Total';
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2418
|
+
if (!fieldCode) return '';
|
|
2419
|
+
var displayName = lookupDisplayName(fieldCode, rawValue);
|
|
2420
|
+
return displayName ? displayName + " Total" : '';
|
|
2421
|
+
};
|
|
2422
|
+
var compareDimensionValues = function compareDimensionValues(aValue, bValue, dateCode, aText, bText) {
|
|
2423
|
+
if (dateCode === 'Month') {
|
|
2424
|
+
var aNumber = aValue == null ? -1 : Number(aValue);
|
|
2425
|
+
var bNumber = bValue == null ? -1 : Number(bValue);
|
|
2426
|
+
if (aNumber < bNumber) return -1;
|
|
2427
|
+
if (aNumber > bNumber) return 1;
|
|
2428
|
+
return 0;
|
|
2429
|
+
}
|
|
2430
|
+
|
|
2431
|
+
if (dateCode != null) {
|
|
2432
|
+
var aCompare = aValue == null ? '' : aValue;
|
|
2433
|
+
var bCompare = bValue == null ? '' : bValue;
|
|
2434
|
+
if (aCompare < bCompare) return -1;
|
|
2435
|
+
if (aCompare > bCompare) return 1;
|
|
2436
|
+
return 0;
|
|
2437
|
+
}
|
|
2438
|
+
|
|
2439
|
+
var aDisplay = aText == null || aText === '' ? aValue == null ? '' : aValue : aText;
|
|
2440
|
+
var bDisplay = bText == null || bText === '' ? bValue == null ? '' : bValue : bText;
|
|
2441
|
+
if (aDisplay < bDisplay) return -1;
|
|
2442
|
+
if (aDisplay > bDisplay) return 1;
|
|
2443
|
+
return 0;
|
|
2444
|
+
};
|
|
2445
|
+
var getPivotDisplayName = function getPivotDisplayName(pivotData, fieldName, dataField, dataFieldValue) {
|
|
2446
|
+
if (!pivotData || pivotData.length === 0) return '';
|
|
2447
|
+
var data = pivotData.find(function (el) {
|
|
2448
|
+
return el[dataField] == dataFieldValue;
|
|
2449
|
+
});
|
|
2450
|
+
return data ? ConvertStringToPascalCaseHelper(data[fieldName]) : '';
|
|
2451
|
+
};
|
|
2452
|
+
var isPivotRowGrandTotalColumnDef = function isPivotRowGrandTotalColumnDef(colDef) {
|
|
2453
|
+
if (!colDef || !colDef.colId) {
|
|
2454
|
+
return false;
|
|
2455
|
+
}
|
|
2456
|
+
|
|
2457
|
+
return String(colDef.colId).indexOf('PivotRowTotal_') === 0;
|
|
2458
|
+
};
|
|
2459
|
+
var isPivotRowGrandTotalGroupDef = function isPivotRowGrandTotalGroupDef(colGroupDef) {
|
|
2460
|
+
if (!colGroupDef) {
|
|
2461
|
+
return false;
|
|
2462
|
+
}
|
|
2463
|
+
|
|
2464
|
+
var groupId = colGroupDef.groupId || colGroupDef.colId || '';
|
|
2465
|
+
|
|
2466
|
+
if (String(groupId).indexOf('PivotRowTotal') >= 0) {
|
|
2467
|
+
return true;
|
|
2468
|
+
}
|
|
2469
|
+
|
|
2470
|
+
var children = colGroupDef.children;
|
|
2471
|
+
|
|
2472
|
+
if (!children || children.length === 0) {
|
|
2473
|
+
return false;
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
return children.every(function (child) {
|
|
2477
|
+
if (child && child.children) {
|
|
2478
|
+
return isPivotRowGrandTotalGroupDef(child);
|
|
2479
|
+
}
|
|
2480
|
+
|
|
2481
|
+
return isPivotRowGrandTotalColumnDef(child);
|
|
2482
|
+
});
|
|
2483
|
+
};
|
|
2484
|
+
var resolvePivotGroupHeaderName = function resolvePivotGroupHeaderName(colGroupDef, columnFields, lookupDisplayName) {
|
|
2485
|
+
if (isPivotRowGrandTotalGroupDef(colGroupDef)) {
|
|
2486
|
+
return 'Grand Total';
|
|
2487
|
+
}
|
|
2488
|
+
|
|
2489
|
+
var pivotKeys = colGroupDef && colGroupDef.pivotKeys ? colGroupDef.pivotKeys : [];
|
|
2490
|
+
|
|
2491
|
+
if (pivotKeys.length === 0) {
|
|
2492
|
+
return null;
|
|
2493
|
+
}
|
|
2494
|
+
|
|
2495
|
+
var field = columnFields[pivotKeys.length - 1];
|
|
2496
|
+
|
|
2497
|
+
if (!field) {
|
|
2498
|
+
return null;
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2501
|
+
return lookupDisplayName(field, pivotKeys[pivotKeys.length - 1]);
|
|
2502
|
+
};
|
|
2503
|
+
var getPivotValueColumnId = function getPivotValueColumnId(pivotValueColumn) {
|
|
2504
|
+
if (!pivotValueColumn) {
|
|
2505
|
+
return null;
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2508
|
+
if (typeof pivotValueColumn.getId === 'function') {
|
|
2509
|
+
return pivotValueColumn.getId();
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2512
|
+
if (typeof pivotValueColumn.getColId === 'function') {
|
|
2513
|
+
return pivotValueColumn.getColId();
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2516
|
+
if (pivotValueColumn.colId) {
|
|
2517
|
+
return String(pivotValueColumn.colId);
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2520
|
+
if (pivotValueColumn.field) {
|
|
2521
|
+
return String(pivotValueColumn.field);
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
return null;
|
|
2525
|
+
};
|
|
2526
|
+
var resolveMeasureFromPivotValueColumn = function resolveMeasureFromPivotValueColumn(colDef, measures) {
|
|
2527
|
+
if (!colDef || measures.length === 0) {
|
|
2528
|
+
return undefined;
|
|
2529
|
+
}
|
|
2530
|
+
|
|
2531
|
+
if (measures.length === 1) {
|
|
2532
|
+
return measures[0];
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
var valueColumnId = getPivotValueColumnId(colDef.pivotValueColumn);
|
|
2536
|
+
|
|
2537
|
+
if (valueColumnId) {
|
|
2538
|
+
var measureByValueColumn = measures.find(function (measure) {
|
|
2539
|
+
return measure.PivotMeasureCode === valueColumnId;
|
|
2540
|
+
});
|
|
2541
|
+
|
|
2542
|
+
if (measureByValueColumn) {
|
|
2543
|
+
return measureByValueColumn;
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
|
|
2547
|
+
var colId = colDef.colId ? String(colDef.colId) : '';
|
|
2548
|
+
|
|
2549
|
+
if (colId) {
|
|
2550
|
+
var sortedMeasures = [].concat(measures).sort(function (left, right) {
|
|
2551
|
+
return right.PivotMeasureCode.length - left.PivotMeasureCode.length;
|
|
2552
|
+
});
|
|
2553
|
+
|
|
2554
|
+
for (var index = 0; index < sortedMeasures.length; index++) {
|
|
2555
|
+
var measureCode = sortedMeasures[index].PivotMeasureCode;
|
|
2556
|
+
|
|
2557
|
+
if (colId.endsWith('_' + measureCode)) {
|
|
2558
|
+
return sortedMeasures[index];
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
return undefined;
|
|
2564
|
+
};
|
|
2565
|
+
var resolvePivotLeafHeaderName = function resolvePivotLeafHeaderName(colDef, columnFields, lookupDisplayName, measureCount, measures) {
|
|
2566
|
+
if (isPivotRowGrandTotalColumnDef(colDef)) {
|
|
2567
|
+
return null;
|
|
2568
|
+
}
|
|
2569
|
+
|
|
2570
|
+
if (measureCount > 1 && colDef.pivotValueColumn) {
|
|
2571
|
+
return null;
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
var pivotKeys = colDef && colDef.pivotKeys ? colDef.pivotKeys : [];
|
|
2575
|
+
|
|
2576
|
+
if (pivotKeys.length === 0) {
|
|
2577
|
+
return null;
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2580
|
+
var field = columnFields[pivotKeys.length - 1];
|
|
2581
|
+
|
|
2582
|
+
if (!field) {
|
|
2583
|
+
return null;
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
return lookupDisplayName(field, pivotKeys[pivotKeys.length - 1]);
|
|
2587
|
+
};
|
|
2588
|
+
var resolveMeasureForSecondaryColDef = function resolveMeasureForSecondaryColDef(colDef, measures) {
|
|
2589
|
+
return resolveMeasureFromPivotValueColumn(colDef, measures);
|
|
2590
|
+
};
|
|
2591
|
+
|
|
2592
|
+
var getColumnGroupAtHeaderLevel = function getColumnGroupAtHeaderLevel(column, targetLevel) {
|
|
2593
|
+
if (!column || typeof column.getParent !== 'function') {
|
|
2594
|
+
return null;
|
|
2595
|
+
}
|
|
2596
|
+
|
|
2597
|
+
var groupPointer = column.getParent();
|
|
2598
|
+
|
|
2599
|
+
while (groupPointer) {
|
|
2600
|
+
var providedColumnGroup = typeof groupPointer.getProvidedColumnGroup === 'function' ? groupPointer.getProvidedColumnGroup() : null;
|
|
2601
|
+
|
|
2602
|
+
if (!providedColumnGroup) {
|
|
2603
|
+
groupPointer = typeof groupPointer.getParent === 'function' ? groupPointer.getParent() : null;
|
|
2604
|
+
continue;
|
|
2605
|
+
}
|
|
2606
|
+
|
|
2607
|
+
var originalGroupLevel = typeof providedColumnGroup.getLevel === 'function' ? providedColumnGroup.getLevel() : 0;
|
|
2608
|
+
var groupPointerLevel = typeof groupPointer.getPaddingLevel === 'function' ? groupPointer.getPaddingLevel() : 0;
|
|
2609
|
+
|
|
2610
|
+
if (originalGroupLevel + groupPointerLevel <= targetLevel) {
|
|
2611
|
+
return groupPointer;
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
groupPointer = typeof groupPointer.getParent === 'function' ? groupPointer.getParent() : null;
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
return null;
|
|
2618
|
+
};
|
|
2619
|
+
|
|
2620
|
+
var escapeColumnIdSelector = function escapeColumnIdSelector(columnId) {
|
|
2621
|
+
if (typeof CSS !== 'undefined' && typeof CSS.escape === 'function') {
|
|
2622
|
+
return CSS.escape(columnId);
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
return columnId.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
2626
|
+
};
|
|
2627
|
+
|
|
2628
|
+
var findHeaderGroupCellByColumnGroup = function findHeaderGroupCellByColumnGroup(headerContainer, groupRows, targetGroupLevel, columnGroup) {
|
|
2629
|
+
if (!columnGroup || typeof columnGroup.getUniqueId !== 'function') {
|
|
2630
|
+
return null;
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2633
|
+
var groupId = columnGroup.getUniqueId();
|
|
2634
|
+
var groupRowIndex = Math.min(Math.max(targetGroupLevel, 0), groupRows.length - 1);
|
|
2635
|
+
var targetGroupRow = groupRows[groupRowIndex];
|
|
2636
|
+
|
|
2637
|
+
if (!targetGroupRow) {
|
|
2638
|
+
return null;
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
return targetGroupRow.querySelector("[col-id=\"" + escapeColumnIdSelector(groupId) + "\"]");
|
|
2642
|
+
};
|
|
2643
|
+
|
|
2644
|
+
var applyPivotRowGrandTotalGroupHeaderLabel = function applyPivotRowGrandTotalGroupHeaderLabel(gridRootElement, columnApi, measureCount, columnPivotFieldCount) {
|
|
2645
|
+
if (!gridRootElement || !columnApi || measureCount <= 1) {
|
|
2646
|
+
return;
|
|
2647
|
+
}
|
|
2648
|
+
|
|
2649
|
+
clearPivotRowGrandTotalGroupHeaderMarkup(gridRootElement);
|
|
2650
|
+
var displayedColumns = typeof columnApi.getAllDisplayedColumns === 'function' ? columnApi.getAllDisplayedColumns() : [];
|
|
2651
|
+
var rowGrandTotalColumns = displayedColumns.filter(function (column) {
|
|
2652
|
+
return String(column.getColId()).indexOf('PivotRowTotal_') === 0;
|
|
2653
|
+
});
|
|
2654
|
+
|
|
2655
|
+
if (rowGrandTotalColumns.length <= 1) {
|
|
2656
|
+
return;
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2659
|
+
var centerHeaderContainer = gridRootElement.querySelector('.ag-header-viewport .ag-header-container');
|
|
2660
|
+
|
|
2661
|
+
if (!centerHeaderContainer) {
|
|
2662
|
+
return;
|
|
2663
|
+
}
|
|
2664
|
+
|
|
2665
|
+
var groupRows = Array.from(centerHeaderContainer.querySelectorAll('.ag-header-row-column-group'));
|
|
2666
|
+
|
|
2667
|
+
if (groupRows.length === 0) {
|
|
2668
|
+
return;
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2671
|
+
var targetGroupLevel = columnPivotFieldCount > 0 ? columnPivotFieldCount - 1 : 0;
|
|
2672
|
+
var rowGrandTotalGroupCells = findRowGrandTotalGroupHeaderCells(centerHeaderContainer, groupRows, targetGroupLevel, rowGrandTotalColumns);
|
|
2673
|
+
|
|
2674
|
+
if (rowGrandTotalGroupCells.length === 0) {
|
|
2675
|
+
return;
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2678
|
+
applyGrandTotalLabelToGroupHeaderCells(rowGrandTotalGroupCells);
|
|
2679
|
+
};
|
|
2680
|
+
|
|
2681
|
+
var clearPivotRowGrandTotalGroupHeaderMarkup = function clearPivotRowGrandTotalGroupHeaderMarkup(gridRootElement) {
|
|
2682
|
+
gridRootElement.querySelectorAll('.dl-pivot-row-grand-total-group-header, .dl-pivot-row-grand-total-group-header-sibling').forEach(function (element) {
|
|
2683
|
+
element.classList.remove('dl-pivot-row-grand-total-group-header', 'dl-pivot-row-grand-total-group-header-sibling');
|
|
2684
|
+
});
|
|
2685
|
+
gridRootElement.querySelectorAll('.dl-pivot-row-grand-total-group-header-label').forEach(function (label) {
|
|
2686
|
+
label.classList.remove('dl-pivot-row-grand-total-group-header-label');
|
|
2687
|
+
var labelElement = label;
|
|
2688
|
+
labelElement.textContent = '';
|
|
2689
|
+
labelElement.style.width = '';
|
|
2690
|
+
labelElement.style.display = '';
|
|
2691
|
+
labelElement.style.textAlign = '';
|
|
2692
|
+
});
|
|
2693
|
+
};
|
|
2694
|
+
|
|
2695
|
+
var findRowGrandTotalGroupHeaderCells = function findRowGrandTotalGroupHeaderCells(centerHeaderContainer, groupRows, targetGroupLevel, rowGrandTotalColumns) {
|
|
2696
|
+
var cellsByColumnGroup = [];
|
|
2697
|
+
rowGrandTotalColumns.forEach(function (column) {
|
|
2698
|
+
var columnGroup = getColumnGroupAtHeaderLevel(column, targetGroupLevel);
|
|
2699
|
+
var matchingCell = findHeaderGroupCellByColumnGroup(centerHeaderContainer, groupRows, targetGroupLevel, columnGroup);
|
|
2700
|
+
|
|
2701
|
+
if (matchingCell) {
|
|
2702
|
+
cellsByColumnGroup.push(matchingCell);
|
|
2703
|
+
}
|
|
2704
|
+
});
|
|
2705
|
+
|
|
2706
|
+
if (cellsByColumnGroup.length === rowGrandTotalColumns.length) {
|
|
2707
|
+
return cellsByColumnGroup;
|
|
2708
|
+
}
|
|
2709
|
+
|
|
2710
|
+
var groupRowIndex = Math.min(Math.max(targetGroupLevel, 0), groupRows.length - 1);
|
|
2711
|
+
var targetGroupRow = groupRows[groupRowIndex];
|
|
2712
|
+
|
|
2713
|
+
if (!targetGroupRow) {
|
|
2714
|
+
return cellsByColumnGroup;
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
var paddingCells = Array.from(targetGroupRow.querySelectorAll('.ag-header-group-cell-no-group'));
|
|
2718
|
+
var trailingPaddingCells = paddingCells.slice(-rowGrandTotalColumns.length);
|
|
2719
|
+
|
|
2720
|
+
if (trailingPaddingCells.length === rowGrandTotalColumns.length) {
|
|
2721
|
+
return trailingPaddingCells;
|
|
2722
|
+
}
|
|
2723
|
+
|
|
2724
|
+
return cellsByColumnGroup;
|
|
2725
|
+
};
|
|
2726
|
+
|
|
2727
|
+
var applyGrandTotalLabelToGroupHeaderCells = function applyGrandTotalLabelToGroupHeaderCells(rowGrandTotalGroupCells) {
|
|
2728
|
+
var firstCell = rowGrandTotalGroupCells[0];
|
|
2729
|
+
var firstLabel = firstCell.querySelector('.ag-header-group-text, .ag-header-cell-text');
|
|
2730
|
+
|
|
2731
|
+
if (!firstLabel) {
|
|
2732
|
+
return;
|
|
2733
|
+
}
|
|
2734
|
+
|
|
2735
|
+
var combinedWidth = rowGrandTotalGroupCells.reduce(function (totalWidth, cell) {
|
|
2736
|
+
return totalWidth + cell.offsetWidth;
|
|
2737
|
+
}, 0);
|
|
2738
|
+
firstLabel.textContent = 'Grand Total';
|
|
2739
|
+
firstLabel.style.width = combinedWidth + "px";
|
|
2740
|
+
firstLabel.style.display = 'inline-block';
|
|
2741
|
+
firstLabel.style.textAlign = 'center';
|
|
2742
|
+
firstLabel.classList.add('dl-pivot-row-grand-total-group-header-label');
|
|
2743
|
+
firstCell.classList.add('dl-pivot-row-grand-total-group-header');
|
|
2744
|
+
|
|
2745
|
+
for (var index = 1; index < rowGrandTotalGroupCells.length; index++) {
|
|
2746
|
+
rowGrandTotalGroupCells[index].classList.add('dl-pivot-row-grand-total-group-header-sibling');
|
|
2747
|
+
var siblingLabel = rowGrandTotalGroupCells[index].querySelector('.ag-header-group-text, .ag-header-cell-text');
|
|
2748
|
+
|
|
2749
|
+
if (siblingLabel) {
|
|
2750
|
+
siblingLabel.textContent = '';
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
};
|
|
2754
|
+
|
|
2755
|
+
var applyPivotRowGrandTotalHeader = function applyPivotRowGrandTotalHeader(colDef, measureCount, measures) {
|
|
2756
|
+
if (!isPivotRowGrandTotalColumnDef(colDef)) {
|
|
2757
|
+
return;
|
|
2758
|
+
}
|
|
2759
|
+
|
|
2760
|
+
if (measureCount <= 1) {
|
|
2761
|
+
colDef.headerName = 'Grand Total';
|
|
2762
|
+
return;
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2765
|
+
var measure = resolveMeasureFromPivotValueColumn(colDef, measures);
|
|
2766
|
+
|
|
2767
|
+
if (measure) {
|
|
2768
|
+
colDef.headerName = getMeasureCaption(measure);
|
|
2769
|
+
}
|
|
2770
|
+
|
|
2771
|
+
delete colDef.headerValueGetter;
|
|
2772
|
+
};
|
|
2773
|
+
var collectPivotRowPath = function collectPivotRowPath(startNode) {
|
|
2774
|
+
var path = [];
|
|
2775
|
+
|
|
2776
|
+
if (!startNode) {
|
|
2777
|
+
return path;
|
|
2778
|
+
}
|
|
2779
|
+
|
|
2780
|
+
if (startNode.footer) {
|
|
2781
|
+
if (startNode.level === -1) {
|
|
2782
|
+
return path;
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2785
|
+
if (startNode.field != null && startNode.key !== undefined) {
|
|
2786
|
+
path.unshift({
|
|
2787
|
+
field: startNode.field,
|
|
2788
|
+
key: startNode.key
|
|
2789
|
+
});
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
|
|
2793
|
+
var node = startNode.parent;
|
|
2794
|
+
|
|
2795
|
+
while (node && node.level >= 0) {
|
|
2796
|
+
if (!node.footer && node.field != null && node.key !== undefined) {
|
|
2797
|
+
path.unshift({
|
|
2798
|
+
field: node.field,
|
|
2799
|
+
key: node.key
|
|
2800
|
+
});
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2803
|
+
node = node.parent;
|
|
2804
|
+
}
|
|
2805
|
+
|
|
2806
|
+
return path;
|
|
2807
|
+
};
|
|
2808
|
+
var buildPivotDrillDownPivotFields = function buildPivotDrillDownPivotFields(colDef, startNode, apiFields) {
|
|
2809
|
+
var columnFields = apiFields.filter(function (field) {
|
|
2810
|
+
return !isRowPivotField(field);
|
|
2811
|
+
});
|
|
2812
|
+
var rowFields = apiFields.filter(isRowPivotField);
|
|
2813
|
+
var pivotFields = [];
|
|
2814
|
+
var columnKeys = colDef && colDef.pivotKeys ? colDef.pivotKeys : [];
|
|
2815
|
+
columnKeys.forEach(function (key, index) {
|
|
2816
|
+
if (key === undefined) {
|
|
2817
|
+
return;
|
|
2818
|
+
}
|
|
2819
|
+
|
|
2820
|
+
var field = columnFields[index];
|
|
2821
|
+
|
|
2822
|
+
if (!field) {
|
|
2823
|
+
return;
|
|
2824
|
+
}
|
|
2825
|
+
|
|
2826
|
+
pivotFields.push({
|
|
2827
|
+
FieldId: field.FieldId,
|
|
2828
|
+
FieldType: field.FieldType ? field.FieldType : 'Field',
|
|
2829
|
+
FieldValue: key,
|
|
2830
|
+
DateCode: field.DateCode
|
|
2831
|
+
});
|
|
2832
|
+
});
|
|
2833
|
+
collectPivotRowPath(startNode).forEach(function (pathItem) {
|
|
2834
|
+
var field = rowFields.find(function (f) {
|
|
2835
|
+
return f.PivotCode === pathItem.field;
|
|
2836
|
+
}) || apiFields.find(function (f) {
|
|
2837
|
+
return f.PivotCode === pathItem.field;
|
|
2838
|
+
});
|
|
2839
|
+
|
|
2840
|
+
if (!field) {
|
|
2841
|
+
return;
|
|
2842
|
+
}
|
|
2843
|
+
|
|
2844
|
+
pivotFields.push({
|
|
2845
|
+
FieldId: field.FieldId,
|
|
2846
|
+
FieldType: field.FieldType ? field.FieldType : 'Field',
|
|
2847
|
+
FieldValue: pathItem.key,
|
|
2848
|
+
DateCode: field.DateCode
|
|
2849
|
+
});
|
|
2850
|
+
});
|
|
2851
|
+
return pivotFields;
|
|
2852
|
+
};
|
|
2853
|
+
var getMeasureCaption = function getMeasureCaption(measure) {
|
|
2854
|
+
var displayName = typeof measure.DisplayName == 'string' ? measure.DisplayName : '';
|
|
2855
|
+
|
|
2856
|
+
if (measure.MeasureCode == 'Sum') {
|
|
2857
|
+
return ConvertStringToPascalCaseHelper(displayName.replace('Sum of ', ''));
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2860
|
+
return ConvertStringToPascalCaseHelper(displayName);
|
|
2861
|
+
};
|
|
2862
|
+
var parseJsonArray = function parseJsonArray(json) {
|
|
2863
|
+
if (isNullOrUndefinedOrEmpty(json)) return [];
|
|
2864
|
+
|
|
2865
|
+
try {
|
|
2866
|
+
var parsed = JSON.parse(json);
|
|
2867
|
+
return parsed || [];
|
|
2868
|
+
} catch (error) {
|
|
2869
|
+
return [];
|
|
2870
|
+
}
|
|
2871
|
+
};
|
|
2872
|
+
var parsePivotTotalsSettings = function parsePivotTotalsSettings(json) {
|
|
2873
|
+
if (isNullOrUndefinedOrEmpty(json)) return {};
|
|
2874
|
+
|
|
2875
|
+
try {
|
|
2876
|
+
return JSON.parse(json) || {};
|
|
2877
|
+
} catch (error) {
|
|
2878
|
+
return {};
|
|
2879
|
+
}
|
|
2880
|
+
};
|
|
2881
|
+
|
|
2882
|
+
var ROW_GROUP_COLUMN_MIN_WIDTH = 100;
|
|
2883
|
+
|
|
2884
|
+
var applyAgGridLicense = function applyAgGridLicense() {
|
|
2885
|
+
if (!Session.AgGridLicenseKey) return;
|
|
2886
|
+
LicenseManager.setLicenseKey(Session.AgGridLicenseKey);
|
|
2887
|
+
};
|
|
2888
|
+
|
|
2889
|
+
var AgPivotGrid = forwardRef(function (props, _comRef) {
|
|
2890
|
+
var _useState = useState(),
|
|
2891
|
+
widget = _useState[0],
|
|
2892
|
+
setWidget = _useState[1];
|
|
2893
|
+
|
|
2894
|
+
var _useState2 = useState(true),
|
|
2895
|
+
isLoading = _useState2[0],
|
|
2896
|
+
setIsLoading = _useState2[1];
|
|
2897
|
+
|
|
2898
|
+
var _useState3 = useState([]),
|
|
2899
|
+
rowData = _useState3[0],
|
|
2900
|
+
setRowData = _useState3[1];
|
|
2901
|
+
|
|
2902
|
+
var _useState4 = useState([]),
|
|
2903
|
+
columnDefs = _useState4[0],
|
|
2904
|
+
setColumnDefs = _useState4[1];
|
|
2905
|
+
|
|
2906
|
+
var _useState5 = useState(0),
|
|
2907
|
+
measureCount = _useState5[0],
|
|
2908
|
+
setMeasureCount = _useState5[1];
|
|
2909
|
+
|
|
2910
|
+
var widgetRefData = useRef(null);
|
|
2911
|
+
var tabledata = useRef();
|
|
2912
|
+
var gridApiRef = useRef(null);
|
|
2913
|
+
var columnApiRef = useRef(null);
|
|
2914
|
+
var gridContainerRef = useRef(null);
|
|
2915
|
+
var pivotFieldsRef = useRef([]);
|
|
2916
|
+
var pivotMeasuresRef = useRef([]);
|
|
2917
|
+
useEffect(function () {
|
|
2918
|
+
var _props$customChartPro;
|
|
2919
|
+
|
|
2920
|
+
applyAgGridLicense();
|
|
2921
|
+
|
|
2922
|
+
if (props.customChartProps && props.customChartProps.widget) {
|
|
2923
|
+
setWidget(props.customChartProps.widget);
|
|
2924
|
+
widgetRefData.current = props.customChartProps.widget;
|
|
2925
|
+
getPivotTableData(props.customChartProps.widget);
|
|
2926
|
+
}
|
|
2927
|
+
|
|
2928
|
+
(_props$customChartPro = props.customChartProps.dataBinding) === null || _props$customChartPro === void 0 ? void 0 : _props$customChartPro.widgetUpdated.subscribe(function (updatedWidget) {
|
|
2929
|
+
var _widgetRefData$curren;
|
|
2930
|
+
|
|
2931
|
+
if ((updatedWidget === null || updatedWidget === void 0 ? void 0 : updatedWidget.key) != ((_widgetRefData$curren = widgetRefData.current) === null || _widgetRefData$curren === void 0 ? void 0 : _widgetRefData$curren.key)) return;
|
|
2932
|
+
setWidget(_extends({}, updatedWidget));
|
|
2933
|
+
});
|
|
2934
|
+
document.addEventListener('resizeStop', handleResize);
|
|
2935
|
+
return function () {
|
|
2936
|
+
document.removeEventListener('resizeStop', handleResize);
|
|
2937
|
+
};
|
|
2938
|
+
}, []);
|
|
2939
|
+
useEffect(function () {
|
|
2940
|
+
if (!props.customChartProps.isInEditMode) return;
|
|
2941
|
+
|
|
2942
|
+
if (gridContainerRef.current && gridContainerRef.current.classList) {
|
|
2943
|
+
gridContainerRef.current.classList.add('force-overflow-hidden');
|
|
2944
|
+
}
|
|
2945
|
+
|
|
2946
|
+
setTimeout(function () {
|
|
2947
|
+
handleResize();
|
|
2948
|
+
|
|
2949
|
+
if (gridContainerRef.current && gridContainerRef.current.classList) {
|
|
2950
|
+
gridContainerRef.current.classList.remove('force-overflow-hidden');
|
|
2951
|
+
}
|
|
2952
|
+
}, 5);
|
|
2953
|
+
}, [props.customChartProps.isInEditMode]);
|
|
2954
|
+
|
|
2955
|
+
var handleResize = function handleResize() {
|
|
2956
|
+
if (gridApiRef.current && gridApiRef.current.resetRowHeights) {
|
|
2957
|
+
gridApiRef.current.resetRowHeights();
|
|
2958
|
+
}
|
|
2959
|
+
};
|
|
2960
|
+
|
|
2961
|
+
var getPivotTableData = function getPivotTableData(widgetPm) {
|
|
2962
|
+
if (Session.Tenant == 0) {
|
|
2963
|
+
tabledata.current = [];
|
|
2964
|
+
setRowData([]);
|
|
2965
|
+
setIsLoading(false);
|
|
2966
|
+
return;
|
|
2967
|
+
}
|
|
2968
|
+
|
|
2969
|
+
var dashboardAnalyticsService = new DashboardAnalyticsService();
|
|
2970
|
+
var widgetLoadLogger = new WidgetLoadLogger(props.customChartProps.widget, props.customChartProps.isPreviewModeActive, 'PostGetPivotData');
|
|
2971
|
+
dashboardAnalyticsService.getPivotData(widgetPm).then(function (res) {
|
|
2972
|
+
tabledata.current = res.data;
|
|
2973
|
+
buildGridFromPivotResponse();
|
|
2974
|
+
setIsLoading(false);
|
|
2975
|
+
widgetLoadLogger.log(res);
|
|
2976
|
+
})["catch"](function (err) {
|
|
2977
|
+
console.log('Error while Getting Pivot Table Data: ', err);
|
|
2978
|
+
tabledata.current = null;
|
|
2979
|
+
setRowData([]);
|
|
2980
|
+
setIsLoading(false);
|
|
2981
|
+
});
|
|
2982
|
+
};
|
|
2983
|
+
|
|
2984
|
+
var lookupDisplayName = function lookupDisplayName(field, rawValue) {
|
|
2985
|
+
var pivotData = tabledata.current && tabledata.current.PivotData ? tabledata.current.PivotData : [];
|
|
2986
|
+
return getPivotDisplayName(pivotData, field.PivotName, field.PivotCode, rawValue);
|
|
2987
|
+
};
|
|
2988
|
+
|
|
2989
|
+
var lookupDisplayNameByFieldCode = function lookupDisplayNameByFieldCode(fieldCode, rawValue) {
|
|
2990
|
+
var field = pivotFieldsRef.current.find(function (f) {
|
|
2991
|
+
return f.PivotCode === fieldCode;
|
|
2992
|
+
});
|
|
2993
|
+
if (!field) return rawValue == null ? '' : String(rawValue);
|
|
2994
|
+
return lookupDisplayName(field, rawValue);
|
|
2995
|
+
};
|
|
2996
|
+
|
|
2997
|
+
var applyPivotDataCellFormatting = function applyPivotDataCellFormatting(colDef) {
|
|
2998
|
+
colDef.sortable = false;
|
|
2999
|
+
colDef.filter = false;
|
|
3000
|
+
colDef.cellClass = 'dl-ag-pivot-data-cell';
|
|
3001
|
+
colDef.type = 'numericColumn';
|
|
3002
|
+
};
|
|
3003
|
+
|
|
3004
|
+
var buildGridFromPivotResponse = function buildGridFromPivotResponse() {
|
|
3005
|
+
if (!tabledata.current || !tabledata.current.PivoFields || !tabledata.current.PivotMeasures) {
|
|
3006
|
+
setRowData([]);
|
|
3007
|
+
return;
|
|
3008
|
+
}
|
|
3009
|
+
|
|
3010
|
+
var apiFields = tabledata.current.PivoFields;
|
|
3011
|
+
var apiMeasures = tabledata.current.PivotMeasures;
|
|
3012
|
+
pivotFieldsRef.current = apiFields;
|
|
3013
|
+
pivotMeasuresRef.current = apiMeasures;
|
|
3014
|
+
setMeasureCount(apiMeasures.length);
|
|
3015
|
+
var rowFields = apiFields.filter(isRowPivotField);
|
|
3016
|
+
var columnFields = apiFields.filter(function (field) {
|
|
3017
|
+
return !isRowPivotField(field);
|
|
3018
|
+
});
|
|
3019
|
+
var defs = [];
|
|
3020
|
+
rowFields.forEach(function (field, index) {
|
|
3021
|
+
defs.push(createRowGroupColDef(field, index));
|
|
3022
|
+
});
|
|
3023
|
+
columnFields.forEach(function (field, index) {
|
|
3024
|
+
defs.push(createPivotColDef(field, index));
|
|
3025
|
+
});
|
|
3026
|
+
apiMeasures.forEach(function (measure) {
|
|
3027
|
+
defs.push(createMeasureColDef(measure));
|
|
3028
|
+
});
|
|
3029
|
+
setColumnDefs(defs);
|
|
3030
|
+
setRowData(tabledata.current.PivotData || []);
|
|
3031
|
+
};
|
|
3032
|
+
|
|
3033
|
+
var createRowGroupColDef = function createRowGroupColDef(field, index) {
|
|
3034
|
+
return {
|
|
3035
|
+
field: field.PivotCode,
|
|
3036
|
+
headerName: field.DisplayName,
|
|
3037
|
+
rowGroup: true,
|
|
3038
|
+
rowGroupIndex: index,
|
|
3039
|
+
enableRowGroup: true,
|
|
3040
|
+
hide: true,
|
|
3041
|
+
width: ROW_GROUP_COLUMN_MIN_WIDTH,
|
|
3042
|
+
wrapText: true,
|
|
3043
|
+
autoHeight: true,
|
|
3044
|
+
sortable: false,
|
|
3045
|
+
filter: false,
|
|
3046
|
+
comparator: function comparator(a, b) {
|
|
3047
|
+
return compareDimensionValues(a, b, field.DateCode, lookupDisplayName(field, a), lookupDisplayName(field, b));
|
|
3048
|
+
},
|
|
3049
|
+
valueFormatter: function valueFormatter(params) {
|
|
3050
|
+
return lookupDisplayName(field, params.value);
|
|
3051
|
+
}
|
|
3052
|
+
};
|
|
3053
|
+
};
|
|
3054
|
+
|
|
3055
|
+
var createPivotColDef = function createPivotColDef(field, index) {
|
|
3056
|
+
return {
|
|
3057
|
+
field: field.PivotCode,
|
|
3058
|
+
headerName: field.DisplayName,
|
|
3059
|
+
pivot: true,
|
|
3060
|
+
pivotIndex: index,
|
|
3061
|
+
enablePivot: true,
|
|
3062
|
+
hide: true,
|
|
3063
|
+
sortable: false,
|
|
3064
|
+
filter: false,
|
|
3065
|
+
pivotComparator: function pivotComparator(a, b) {
|
|
3066
|
+
return compareDimensionValues(a, b, field.DateCode, lookupDisplayName(field, a), lookupDisplayName(field, b));
|
|
3067
|
+
}
|
|
3068
|
+
};
|
|
3069
|
+
};
|
|
3070
|
+
|
|
3071
|
+
var createMeasureColDef = function createMeasureColDef(measure) {
|
|
3072
|
+
return {
|
|
3073
|
+
field: measure.PivotMeasureCode,
|
|
3074
|
+
headerName: getMeasureCaption(measure),
|
|
3075
|
+
aggFunc: 'logitudeSum',
|
|
3076
|
+
enableValue: true,
|
|
3077
|
+
wrapText: true,
|
|
3078
|
+
autoHeight: true,
|
|
3079
|
+
sortable: false,
|
|
3080
|
+
filter: false,
|
|
3081
|
+
cellClass: 'dl-ag-pivot-data-cell',
|
|
3082
|
+
type: 'numericColumn',
|
|
3083
|
+
valueFormatter: function valueFormatter(params) {
|
|
3084
|
+
return formatPivotMeasureValue(params.value, measure);
|
|
3085
|
+
}
|
|
3086
|
+
};
|
|
3087
|
+
};
|
|
3088
|
+
|
|
3089
|
+
var isRowsEmptyAndColumnsNotEmpty = function isRowsEmptyAndColumnsNotEmpty() {
|
|
3090
|
+
var pivotRows = parseJsonArray(widget === null || widget === void 0 ? void 0 : widget.PivotRows);
|
|
3091
|
+
var pivotColumns = parseJsonArray(widget === null || widget === void 0 ? void 0 : widget.PivotColumns);
|
|
3092
|
+
return pivotRows.length === 0 && pivotColumns.length > 0;
|
|
3093
|
+
};
|
|
3094
|
+
|
|
3095
|
+
var isRowsNotEmptyAndColumnsEmpty = function isRowsNotEmptyAndColumnsEmpty() {
|
|
3096
|
+
var pivotRows = parseJsonArray(widget === null || widget === void 0 ? void 0 : widget.PivotRows);
|
|
3097
|
+
var pivotColumns = parseJsonArray(widget === null || widget === void 0 ? void 0 : widget.PivotColumns);
|
|
3098
|
+
return pivotRows.length > 0 && pivotColumns.length === 0;
|
|
3099
|
+
};
|
|
3100
|
+
|
|
3101
|
+
var canShowRowsGrandTotal = function canShowRowsGrandTotal() {
|
|
3102
|
+
if (isRowsEmptyAndColumnsNotEmpty()) return true;
|
|
3103
|
+
var settings = parsePivotTotalsSettings(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings);
|
|
3104
|
+
return !isNullOrUndefinedOrEmpty(settings.ShowRowsGrandTotal) ? !!settings.ShowRowsGrandTotal : false;
|
|
3105
|
+
};
|
|
3106
|
+
|
|
3107
|
+
var canShowColumnsGrandTotal = function canShowColumnsGrandTotal() {
|
|
3108
|
+
if (isRowsNotEmptyAndColumnsEmpty()) return true;
|
|
3109
|
+
var settings = parsePivotTotalsSettings(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings);
|
|
3110
|
+
return !isNullOrUndefinedOrEmpty(settings.ShowColumnsGrandTotal) ? !!settings.ShowColumnsGrandTotal : false;
|
|
3111
|
+
};
|
|
3112
|
+
|
|
3113
|
+
var canShowRowsTotal = function canShowRowsTotal() {
|
|
3114
|
+
var settings = parsePivotTotalsSettings(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings);
|
|
3115
|
+
return !isNullOrUndefinedOrEmpty(settings.ShowRowsTotal) ? !!settings.ShowRowsTotal : false;
|
|
3116
|
+
};
|
|
3117
|
+
|
|
3118
|
+
var canShowColumnsTotal = function canShowColumnsTotal() {
|
|
3119
|
+
var settings = parsePivotTotalsSettings(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings);
|
|
3120
|
+
return !isNullOrUndefinedOrEmpty(settings.ShowColumnsTotal) ? !!settings.ShowColumnsTotal : false;
|
|
3121
|
+
};
|
|
3122
|
+
|
|
3123
|
+
var isSingleMeasurePivot = measureCount <= 1;
|
|
3124
|
+
var processSecondaryColGroupDef = useCallback(function (colGroupDef) {
|
|
3125
|
+
var columnFields = pivotFieldsRef.current.filter(function (field) {
|
|
3126
|
+
return !isRowPivotField(field);
|
|
3127
|
+
});
|
|
3128
|
+
var headerName = resolvePivotGroupHeaderName(colGroupDef, columnFields, lookupDisplayName);
|
|
3129
|
+
|
|
3130
|
+
if (headerName) {
|
|
3131
|
+
colGroupDef.headerName = headerName;
|
|
3132
|
+
}
|
|
3133
|
+
}, []);
|
|
3134
|
+
var processSecondaryColDef = useCallback(function (colDef) {
|
|
3135
|
+
var columnFields = pivotFieldsRef.current.filter(function (field) {
|
|
3136
|
+
return !isRowPivotField(field);
|
|
3137
|
+
});
|
|
3138
|
+
var colDefAny = colDef;
|
|
3139
|
+
|
|
3140
|
+
if (colDefAny.colId && String(colDefAny.colId).indexOf('PivotRowTotal_') === 0) {
|
|
3141
|
+
applyPivotRowGrandTotalHeader(colDefAny, pivotMeasuresRef.current.length, pivotMeasuresRef.current);
|
|
3142
|
+
} else {
|
|
3143
|
+
var headerName = resolvePivotLeafHeaderName(colDefAny, columnFields, lookupDisplayName, pivotMeasuresRef.current.length);
|
|
3144
|
+
|
|
3145
|
+
if (headerName) {
|
|
3146
|
+
colDef.headerName = headerName;
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
|
|
3150
|
+
applyPivotDataCellFormatting(colDef);
|
|
3151
|
+
|
|
3152
|
+
colDef.valueFormatter = function (params) {
|
|
3153
|
+
var measure = resolveMeasureForSecondaryColDef(params.colDef, pivotMeasuresRef.current);
|
|
3154
|
+
if (!measure) return '';
|
|
3155
|
+
return formatPivotMeasureValue(params.value, measure);
|
|
3156
|
+
};
|
|
3157
|
+
}, []);
|
|
3158
|
+
var onCellClicked = useCallback(function (event) {
|
|
3159
|
+
var colDef = event.colDef;
|
|
3160
|
+
if (!colDef || !colDef.pivotValueColumn) return;
|
|
3161
|
+
if (isPivotMeasureValueEmpty(event.value)) return;
|
|
3162
|
+
var pivotFields = buildPivotDrillDownPivotFields(colDef, event.node, pivotFieldsRef.current);
|
|
3163
|
+
props.customChartProps.onSelectDataPoint({
|
|
3164
|
+
MeasureFieldId: '',
|
|
3165
|
+
MeasureFieldType: '',
|
|
3166
|
+
Widget: props.customChartProps.widget,
|
|
3167
|
+
MeasureCode: '',
|
|
3168
|
+
Formula: '',
|
|
3169
|
+
GroupById: '',
|
|
3170
|
+
PivotFields: pivotFields
|
|
3171
|
+
});
|
|
3172
|
+
}, []);
|
|
3173
|
+
var defaultColDef = useMemo(function () {
|
|
3174
|
+
return {
|
|
3175
|
+
sortable: false,
|
|
3176
|
+
filter: false,
|
|
3177
|
+
resizable: false,
|
|
3178
|
+
suppressMenu: true,
|
|
3179
|
+
wrapText: true,
|
|
3180
|
+
autoHeight: true
|
|
3181
|
+
};
|
|
3182
|
+
}, []);
|
|
3183
|
+
var autoGroupColumnDef = useMemo(function () {
|
|
3184
|
+
return {
|
|
3185
|
+
minWidth: ROW_GROUP_COLUMN_MIN_WIDTH,
|
|
3186
|
+
width: ROW_GROUP_COLUMN_MIN_WIDTH,
|
|
3187
|
+
sortable: false,
|
|
3188
|
+
filter: false,
|
|
3189
|
+
wrapText: true,
|
|
3190
|
+
autoHeight: true,
|
|
3191
|
+
cellClass: 'dl-ag-pivot-row-label-cell',
|
|
3192
|
+
headerValueGetter: function headerValueGetter(params) {
|
|
3193
|
+
var colDef = params.colDef;
|
|
3194
|
+
var showRowGroup = colDef && colDef.showRowGroup;
|
|
3195
|
+
if (!showRowGroup) return '';
|
|
3196
|
+
var field = pivotFieldsRef.current.find(function (f) {
|
|
3197
|
+
return f.PivotCode === showRowGroup;
|
|
3198
|
+
});
|
|
3199
|
+
return field ? field.DisplayName : '';
|
|
3200
|
+
},
|
|
3201
|
+
valueFormatter: function valueFormatter(params) {
|
|
3202
|
+
var colDef = params.colDef;
|
|
3203
|
+
var showRowGroup = colDef && colDef.showRowGroup;
|
|
3204
|
+
var field = pivotFieldsRef.current.find(function (f) {
|
|
3205
|
+
return f.PivotCode === showRowGroup;
|
|
3206
|
+
});
|
|
3207
|
+
if (!field) return params.value == null ? '' : String(params.value);
|
|
3208
|
+
return lookupDisplayName(field, params.value);
|
|
3209
|
+
},
|
|
3210
|
+
cellRendererParams: {
|
|
3211
|
+
suppressCount: true,
|
|
3212
|
+
footerValueGetter: function footerValueGetter(params) {
|
|
3213
|
+
var fieldCode = params.node && params.node.field ? params.node.field : params.colDef && params.colDef.showRowGroup ? params.colDef.showRowGroup : null;
|
|
3214
|
+
return getPivotGroupFooterLabel(params.node, fieldCode, params.value, lookupDisplayNameByFieldCode);
|
|
3215
|
+
}
|
|
3216
|
+
}
|
|
3217
|
+
};
|
|
3218
|
+
}, []);
|
|
3219
|
+
var aggFuncs = useMemo(function () {
|
|
3220
|
+
return {
|
|
3221
|
+
logitudeSum: logitudeSumAgg
|
|
3222
|
+
};
|
|
3223
|
+
}, []);
|
|
3224
|
+
var scheduleRowGrandTotalHeaderLabel = useCallback(function () {
|
|
3225
|
+
var columnPivotFieldCount = pivotFieldsRef.current.filter(function (field) {
|
|
3226
|
+
return !isRowPivotField(field);
|
|
3227
|
+
}).length;
|
|
3228
|
+
|
|
3229
|
+
var applyLabel = function applyLabel() {
|
|
3230
|
+
applyPivotRowGrandTotalGroupHeaderLabel(gridContainerRef.current, columnApiRef.current, measureCount, columnPivotFieldCount);
|
|
3231
|
+
};
|
|
3232
|
+
|
|
3233
|
+
window.requestAnimationFrame(function () {
|
|
3234
|
+
window.requestAnimationFrame(function () {
|
|
3235
|
+
applyLabel();
|
|
3236
|
+
window.setTimeout(applyLabel, 150);
|
|
3237
|
+
});
|
|
3238
|
+
});
|
|
3239
|
+
}, [measureCount]);
|
|
3240
|
+
|
|
3241
|
+
var onGridReady = function onGridReady(event) {
|
|
3242
|
+
gridApiRef.current = event.api;
|
|
3243
|
+
columnApiRef.current = event.columnApi;
|
|
3244
|
+
};
|
|
3245
|
+
|
|
3246
|
+
var onFirstDataRendered = function onFirstDataRendered(event) {
|
|
3247
|
+
columnApiRef.current = event.columnApi;
|
|
3248
|
+
var columnApi = event.columnApi;
|
|
3249
|
+
if (!columnApi || !columnApi.getAllDisplayedColumns) return;
|
|
3250
|
+
var autoGroupColumnIds = columnApi.getAllDisplayedColumns().map(function (col) {
|
|
3251
|
+
return col.getColId();
|
|
3252
|
+
}).filter(function (colId) {
|
|
3253
|
+
return colId.indexOf('ag-Grid-AutoColumn') === 0;
|
|
3254
|
+
});
|
|
3255
|
+
|
|
3256
|
+
if (autoGroupColumnIds.length > 0 && columnApi.autoSizeColumns) {
|
|
3257
|
+
columnApi.autoSizeColumns(autoGroupColumnIds, false);
|
|
3258
|
+
}
|
|
3259
|
+
|
|
3260
|
+
scheduleRowGrandTotalHeaderLabel();
|
|
3261
|
+
};
|
|
3262
|
+
|
|
3263
|
+
var onColumnPivotChanged = function onColumnPivotChanged() {
|
|
3264
|
+
scheduleRowGrandTotalHeaderLabel();
|
|
3265
|
+
};
|
|
3266
|
+
|
|
3267
|
+
var onColumnResized = function onColumnResized() {
|
|
3268
|
+
scheduleRowGrandTotalHeaderLabel();
|
|
3269
|
+
};
|
|
3270
|
+
|
|
3271
|
+
var gridWrapperClassName = 'ag-theme-balham pivot-grid-element dl-ag-pivot-grid';
|
|
3272
|
+
return React__default.createElement(React__default.Fragment, null, isLoading ? React__default.createElement("div", {
|
|
3273
|
+
className: 'dl-full-hight dl-flex-content-center spinner-custome'
|
|
3274
|
+
}, React__default.createElement(ProgressSpinner, {
|
|
3275
|
+
style: {
|
|
3276
|
+
width: '40px',
|
|
3277
|
+
height: '40px'
|
|
3278
|
+
},
|
|
3279
|
+
strokeWidth: "4",
|
|
3280
|
+
animationDuration: "2s"
|
|
3281
|
+
})) : React__default.createElement("div", {
|
|
3282
|
+
ref: gridContainerRef,
|
|
3283
|
+
className: gridWrapperClassName
|
|
3284
|
+
}, React__default.createElement(AgGridReact, {
|
|
3285
|
+
rowData: rowData,
|
|
3286
|
+
columnDefs: columnDefs,
|
|
3287
|
+
defaultColDef: defaultColDef,
|
|
3288
|
+
autoGroupColumnDef: autoGroupColumnDef,
|
|
3289
|
+
aggFuncs: aggFuncs,
|
|
3290
|
+
pivotMode: true,
|
|
3291
|
+
groupDisplayType: "multipleColumns",
|
|
3292
|
+
groupDefaultExpanded: -1,
|
|
3293
|
+
suppressAggFuncInHeader: true,
|
|
3294
|
+
removePivotHeaderRowWhenSingleValueColumn: isSingleMeasurePivot,
|
|
3295
|
+
groupIncludeFooter: canShowRowsTotal(),
|
|
3296
|
+
groupIncludeTotalFooter: canShowRowsGrandTotal(),
|
|
3297
|
+
pivotRowTotals: canShowColumnsGrandTotal() ? 'after' : undefined,
|
|
3298
|
+
pivotColumnGroupTotals: canShowColumnsTotal() ? 'after' : undefined,
|
|
3299
|
+
processSecondaryColGroupDef: processSecondaryColGroupDef,
|
|
3300
|
+
processSecondaryColDef: processSecondaryColDef,
|
|
3301
|
+
onCellClicked: onCellClicked,
|
|
3302
|
+
onGridReady: onGridReady,
|
|
3303
|
+
onFirstDataRendered: onFirstDataRendered,
|
|
3304
|
+
onColumnPivotChanged: onColumnPivotChanged,
|
|
3305
|
+
onColumnResized: onColumnResized,
|
|
3306
|
+
animateRows: false,
|
|
3307
|
+
suppressContextMenu: true,
|
|
3308
|
+
suppressMovableColumns: true,
|
|
3309
|
+
headerHeight: 36,
|
|
3310
|
+
rowHeight: 36
|
|
3311
|
+
})));
|
|
3312
|
+
});
|
|
3313
|
+
|
|
2359
3314
|
var parseSelectedQueries = function parseSelectedQueries(widgetJson) {
|
|
2360
3315
|
if (!widgetJson) {
|
|
2361
3316
|
return [];
|
|
@@ -2436,7 +3391,9 @@ var CustomChart = function CustomChart(props) {
|
|
|
2436
3391
|
});
|
|
2437
3392
|
|
|
2438
3393
|
case "pivot":
|
|
2439
|
-
return React__default.createElement(
|
|
3394
|
+
return props.useAgGridPivot ? React__default.createElement(AgPivotGrid, {
|
|
3395
|
+
customChartProps: props
|
|
3396
|
+
}) : React__default.createElement(PivotTable, {
|
|
2440
3397
|
customChartProps: props
|
|
2441
3398
|
});
|
|
2442
3399
|
|
|
@@ -4279,6 +5236,7 @@ var WidgetCard = forwardRef(function (props, comRef) {
|
|
|
4279
5236
|
if (((_widget$current7 = widget.current) === null || _widget$current7 === void 0 ? void 0 : _widget$current7.TypeCode) == "kpi") return React__default.createElement(CustomChart, {
|
|
4280
5237
|
isInEditMode: props.isInEditMode,
|
|
4281
5238
|
isPreviewModeActive: props.isPreviewModeActive,
|
|
5239
|
+
useAgGridPivot: props.useAgGridPivot,
|
|
4282
5240
|
dataBinding: props.dataBinding,
|
|
4283
5241
|
widget: widget.current,
|
|
4284
5242
|
widgetRef: props.widgetRef,
|
|
@@ -4290,6 +5248,7 @@ var WidgetCard = forwardRef(function (props, comRef) {
|
|
|
4290
5248
|
if (((_widget$current8 = widget.current) === null || _widget$current8 === void 0 ? void 0 : _widget$current8.TypeCode) == "table" || ((_widget$current9 = widget.current) === null || _widget$current9 === void 0 ? void 0 : _widget$current9.TypeCode) == "pivot" || ((_widget$current10 = widget.current) === null || _widget$current10 === void 0 ? void 0 : _widget$current10.TypeCode) == "views") return React__default.createElement(CustomChart, {
|
|
4291
5249
|
isInEditMode: props.isInEditMode,
|
|
4292
5250
|
isPreviewModeActive: props.isPreviewModeActive,
|
|
5251
|
+
useAgGridPivot: props.useAgGridPivot,
|
|
4293
5252
|
dataBinding: props.dataBinding,
|
|
4294
5253
|
widget: widget.current,
|
|
4295
5254
|
widgetRef: props.widgetRef,
|
|
@@ -4734,6 +5693,7 @@ var DashboardDesigner = function DashboardDesigner(props) {
|
|
|
4734
5693
|
editBtnClicked: editWidget,
|
|
4735
5694
|
deleteBtnClicked: confirmDeleteWidget,
|
|
4736
5695
|
onSelectDataPoint: props.onSelectDataPoint,
|
|
5696
|
+
useAgGridPivot: props.useAgGridPivot,
|
|
4737
5697
|
duplicateBtnClicked: copyWidget,
|
|
4738
5698
|
copyToClipboardBtnClicked: copyWidgetToClipboard,
|
|
4739
5699
|
ref: function ref(el) {
|
|
@@ -4764,6 +5724,8 @@ var layoutGridProps = {
|
|
|
4764
5724
|
var Dashboard = function Dashboard(props) {
|
|
4765
5725
|
var _previewWidget$Layout, _previewWidget$Layout2;
|
|
4766
5726
|
|
|
5727
|
+
Session.UseAgGridPivot = !!props.useAgGridPivot;
|
|
5728
|
+
Session.AgGridLicenseKey = props.agGridLicenseKey;
|
|
4767
5729
|
var Widgetlayouts = useRef({
|
|
4768
5730
|
lg: []
|
|
4769
5731
|
});
|
|
@@ -4792,6 +5754,8 @@ var Dashboard = function Dashboard(props) {
|
|
|
4792
5754
|
Session.Token = props === null || props === void 0 ? void 0 : props.token;
|
|
4793
5755
|
Session.NumberFormatCode = props === null || props === void 0 ? void 0 : props.numberFormatCode;
|
|
4794
5756
|
Session.isMasterNumberClickable = props === null || props === void 0 ? void 0 : props.isMasterNumberClickable;
|
|
5757
|
+
Session.UseAgGridPivot = !!props.useAgGridPivot;
|
|
5758
|
+
Session.AgGridLicenseKey = props.agGridLicenseKey;
|
|
4795
5759
|
setIsPreviewModeActive(props.isPreviewMode);
|
|
4796
5760
|
props.dataBinding.onGetLayouts.subscribe(function (layouts) {
|
|
4797
5761
|
Widgetlayouts.current = layouts;
|
|
@@ -4805,6 +5769,10 @@ var Dashboard = function Dashboard(props) {
|
|
|
4805
5769
|
setWidgetlayoutsState(deepClone(Widgetlayouts.current));
|
|
4806
5770
|
});
|
|
4807
5771
|
}, []);
|
|
5772
|
+
useEffect(function () {
|
|
5773
|
+
Session.UseAgGridPivot = !!props.useAgGridPivot;
|
|
5774
|
+
Session.AgGridLicenseKey = props.agGridLicenseKey;
|
|
5775
|
+
}, [props.useAgGridPivot, props.agGridLicenseKey]);
|
|
4808
5776
|
useEffect(function () {
|
|
4809
5777
|
if (props.widgetData) {
|
|
4810
5778
|
setPreviewWidget(JSON.parse(JSON.stringify(props.widgetData)));
|
|
@@ -4875,13 +5843,15 @@ var Dashboard = function Dashboard(props) {
|
|
|
4875
5843
|
},
|
|
4876
5844
|
onSelectDataPoint: function onSelectDataPoint() {
|
|
4877
5845
|
return true;
|
|
4878
|
-
}
|
|
5846
|
+
},
|
|
5847
|
+
useAgGridPivot: props.useAgGridPivot
|
|
4879
5848
|
}))) : createElement("div", {
|
|
4880
5849
|
className: 'dl-full-hight'
|
|
4881
5850
|
}, createElement("div", {
|
|
4882
5851
|
className: 'dl-dashboard-body'
|
|
4883
5852
|
}, createElement(DashboardDesigner, {
|
|
4884
5853
|
onSelectDataPoint: props.onSelectDataPoint,
|
|
5854
|
+
useAgGridPivot: props.useAgGridPivot,
|
|
4885
5855
|
Widgetlayouts: widgetlayoutsState,
|
|
4886
5856
|
dataBinding: props.dataBinding,
|
|
4887
5857
|
editMode: isInEditMode,
|