logitude-dashboard-library 3.2.63 → 3.2.65
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/Utils/DateHelper.d.ts +1 -1
- package/dist/assets/styles/dl-dashboard.scss +11 -0
- package/dist/features/Dashboard/ChartsComponents/CustomCharts/KpiChart.d.ts +1 -0
- package/dist/features/Dashboard/ChartsComponents/CustomCharts/PivotAgGridSupport.d.ts +13 -0
- package/dist/index.js +769 -400
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +769 -400
- package/dist/index.modern.js.map +1 -1
- package/dist/styles/dl-dashboard.scss +11 -0
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -593,7 +593,103 @@ var getLast30DaysDates = function getLast30DaysDates(format) {
|
|
|
593
593
|
return dateValues;
|
|
594
594
|
};
|
|
595
595
|
|
|
596
|
-
var
|
|
596
|
+
var getDateRangesByPeriod = function getDateRangesByPeriod(_operator, _interval, _range, _format) {
|
|
597
|
+
if (_format === void 0) {
|
|
598
|
+
_format = "YYYYMMDD000000";
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
if (!_operator || !_interval || !_range) return null;
|
|
602
|
+
var result = {
|
|
603
|
+
date1: null,
|
|
604
|
+
date2: null
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
if (_operator.toLowerCase() == 'current') {
|
|
608
|
+
switch (_range) {
|
|
609
|
+
case "Day":
|
|
610
|
+
result.date1 = getTodayDates()[0];
|
|
611
|
+
result.date2 = getTodayDates()[1];
|
|
612
|
+
break;
|
|
613
|
+
|
|
614
|
+
case "Week":
|
|
615
|
+
result.date1 = getCurrentWeekDates()[0];
|
|
616
|
+
result.date2 = getCurrentWeekDates()[1];
|
|
617
|
+
break;
|
|
618
|
+
|
|
619
|
+
case "Month":
|
|
620
|
+
result.date1 = getCurrentMonthDates()[0];
|
|
621
|
+
result.date2 = getCurrentMonthDates()[1];
|
|
622
|
+
break;
|
|
623
|
+
|
|
624
|
+
case "Current_Month_To_Date":
|
|
625
|
+
case "Month To Date":
|
|
626
|
+
result.date1 = getCurrentMonthToDateDates()[0];
|
|
627
|
+
result.date2 = getCurrentMonthToDateDates()[1];
|
|
628
|
+
break;
|
|
629
|
+
|
|
630
|
+
case "Quarter":
|
|
631
|
+
result.date1 = getCurrentQuarterDates()[0];
|
|
632
|
+
result.date2 = getCurrentQuarterDates()[1];
|
|
633
|
+
break;
|
|
634
|
+
|
|
635
|
+
case "Current_Quarter_To_Date":
|
|
636
|
+
case "Quarter To Date":
|
|
637
|
+
result.date1 = getCurrentQuarterToDateDates()[0];
|
|
638
|
+
result.date2 = getCurrentQuarterToDateDates()[1];
|
|
639
|
+
break;
|
|
640
|
+
|
|
641
|
+
case "Year":
|
|
642
|
+
result.date1 = getCurrentYearDates()[0];
|
|
643
|
+
result.date2 = getCurrentYearDates()[1];
|
|
644
|
+
break;
|
|
645
|
+
|
|
646
|
+
case "Current_Year_To_Date":
|
|
647
|
+
case "Year To Date":
|
|
648
|
+
result.date1 = getCurrentYearToDateDates()[0];
|
|
649
|
+
result.date2 = getCurrentYearToDateDates()[1];
|
|
650
|
+
break;
|
|
651
|
+
}
|
|
652
|
+
} else {
|
|
653
|
+
var dateGroupCodes = {
|
|
654
|
+
'Day': 'days',
|
|
655
|
+
'Week': 'weeks',
|
|
656
|
+
'Month': 'months',
|
|
657
|
+
'Quarter': 'quarters',
|
|
658
|
+
'Year': 'years',
|
|
659
|
+
'Year To Date': 'years',
|
|
660
|
+
'Quarter To Date': 'quarters',
|
|
661
|
+
'Month To Date': 'months'
|
|
662
|
+
};
|
|
663
|
+
var customDateGroupCodes = ['Year To Date', 'Quarter To Date', 'Month To Date'];
|
|
664
|
+
|
|
665
|
+
if (_operator.toLowerCase() == 'next') {
|
|
666
|
+
result.date1 = moment().startOf(dateGroupCodes[_range]).add(1, dateGroupCodes[_range]).format(_format);
|
|
667
|
+
result.date2 = moment().startOf(dateGroupCodes[_range]).add(Number(_interval), dateGroupCodes[_range]).endOf(dateGroupCodes[_range]).format(_format);
|
|
668
|
+
} else if (_operator.toLowerCase() == 'previous' && !customDateGroupCodes.includes(_range)) {
|
|
669
|
+
result.date1 = moment().subtract(Number(_interval), dateGroupCodes[_range]).startOf(dateGroupCodes[_range]).format(_format);
|
|
670
|
+
result.date2 = moment().subtract(1, dateGroupCodes[_range]).endOf(dateGroupCodes[_range]).format(_format);
|
|
671
|
+
} else if (_operator.toLowerCase() == 'previous' && customDateGroupCodes.includes(_range)) {
|
|
672
|
+
result.date1 = moment().subtract(Number(_interval), dateGroupCodes[_range]).startOf(dateGroupCodes[_range]).format(_format);
|
|
673
|
+
result.date2 = moment().format(_format);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
return result;
|
|
678
|
+
};
|
|
679
|
+
|
|
680
|
+
var getDateRangesByCode = function getDateRangesByCode(code, _fromDate, _toDate, _operator, _interval, _range) {
|
|
681
|
+
if (_operator === void 0) {
|
|
682
|
+
_operator = null;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
if (_interval === void 0) {
|
|
686
|
+
_interval = null;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
if (_range === void 0) {
|
|
690
|
+
_range = null;
|
|
691
|
+
}
|
|
692
|
+
|
|
597
693
|
var result = {
|
|
598
694
|
fromDate: null,
|
|
599
695
|
toDate: null
|
|
@@ -701,6 +797,12 @@ var getDateRangesByCode = function getDateRangesByCode(code, _fromDate, _toDate)
|
|
|
701
797
|
result.fromDate = getCurrentWeekDates()[0];
|
|
702
798
|
result.toDate = getCurrentWeekDates()[1];
|
|
703
799
|
break;
|
|
800
|
+
|
|
801
|
+
case "Previous_Next":
|
|
802
|
+
var previousNextDates = getDateRangesByPeriod(_operator || "", _interval || "", _range || "");
|
|
803
|
+
result.fromDate = previousNextDates && previousNextDates.date1 ? previousNextDates.date1 : null;
|
|
804
|
+
result.toDate = previousNextDates && previousNextDates.date2 ? previousNextDates.date2 : null;
|
|
805
|
+
break;
|
|
704
806
|
}
|
|
705
807
|
|
|
706
808
|
return result;
|
|
@@ -1099,11 +1201,18 @@ var KpiChart = function KpiChart(props) {
|
|
|
1099
1201
|
|
|
1100
1202
|
if (isKPISettingsActivated) {
|
|
1101
1203
|
var PeriodDateFilterDates = getDateRangesByCode(kpiSettings.PeriodDateFilter.DateTimeValueCode, null, null);
|
|
1102
|
-
var
|
|
1204
|
+
var comparePeriodOperator = kpiSettings.ComparePeriodDateFilter.DateRangeOperator || kpiSettings.ComparePeriodDateFilter.Operator;
|
|
1205
|
+
var comparePeriodInterval = kpiSettings.ComparePeriodDateFilter.DatePickerTextFieldValue != null ? String(kpiSettings.ComparePeriodDateFilter.DatePickerTextFieldValue) : null;
|
|
1206
|
+
var ComparePeriodDateFilterDates = kpiSettings.ComparisonPeriodType == 'Manually' ? getDateRangesByCode(kpiSettings.ComparePeriodDateFilter.DateTimeValueCode, kpiSettings.ComparePeriodDateFilter.FieldValue, kpiSettings.ComparePeriodDateFilter.FieldValue2, comparePeriodOperator, comparePeriodInterval, kpiSettings.ComparePeriodDateFilter.DateGroupCode) : getDateRangesByCode(null, null, null);
|
|
1103
1207
|
kpiSettings.PeriodDateFilter.FieldValue = PeriodDateFilterDates.fromDate;
|
|
1104
1208
|
kpiSettings.PeriodDateFilter.FieldValue2 = PeriodDateFilterDates.toDate;
|
|
1105
1209
|
kpiSettings.ComparePeriodDateFilter.FieldValue = ComparePeriodDateFilterDates.fromDate;
|
|
1106
1210
|
kpiSettings.ComparePeriodDateFilter.FieldValue2 = ComparePeriodDateFilterDates.toDate;
|
|
1211
|
+
|
|
1212
|
+
if (kpiSettings.ComparisonPeriodType == 'Manually' && kpiSettings.ComparePeriodDateFilter.DateTimeValueCode == 'Previous_Next') {
|
|
1213
|
+
kpiSettings.ComparePeriodDateFilter.Operator = 'Between';
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1107
1216
|
_updatedWidget.KPIComparisonSettings = JSON.stringify(kpiSettings);
|
|
1108
1217
|
}
|
|
1109
1218
|
|
|
@@ -2037,373 +2146,194 @@ var TableChart = function TableChart(props) {
|
|
|
2037
2146
|
}));
|
|
2038
2147
|
};
|
|
2039
2148
|
|
|
2040
|
-
var
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2149
|
+
var PIVOT_DATE_DATA_CELL_CLASS = 'dl-pivot-date-data-cell';
|
|
2150
|
+
var getPivotDataCellClassNames = function getPivotDataCellClassNames(measure) {
|
|
2151
|
+
if (isPivotDateMinMaxMeasure(measure)) {
|
|
2152
|
+
return "dl-ag-pivot-data-cell " + PIVOT_DATE_DATA_CELL_CLASS;
|
|
2153
|
+
}
|
|
2044
2154
|
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2155
|
+
return 'dl-ag-pivot-data-cell';
|
|
2156
|
+
};
|
|
2157
|
+
var isPivotDateMinMaxMeasure = function isPivotDateMinMaxMeasure(measure) {
|
|
2158
|
+
if (!measure) return false;
|
|
2159
|
+
if (measure.MeasureCode !== 'Min' && measure.MeasureCode !== 'Max') return false;
|
|
2160
|
+
return FieldDataType.isDateOrDateTimeType(measure.MeasureFieldDataType);
|
|
2161
|
+
};
|
|
2048
2162
|
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
var
|
|
2163
|
+
var toValidDate = function toValidDate(value) {
|
|
2164
|
+
if (isPivotMeasureValueEmpty(value)) return null;
|
|
2165
|
+
var date = moment(value);
|
|
2166
|
+
if (!date || !date.isValid()) return null;
|
|
2167
|
+
return date.toDate();
|
|
2168
|
+
};
|
|
2052
2169
|
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2170
|
+
var formatPivotDateMeasureValue = function formatPivotDateMeasureValue(value) {
|
|
2171
|
+
if (isPivotMeasureValueEmpty(value)) return '';
|
|
2172
|
+
var date = moment(value);
|
|
2173
|
+
if (!date || !date.isValid()) return '';
|
|
2174
|
+
return date.format('DD.MM.YYYY');
|
|
2175
|
+
};
|
|
2176
|
+
var isRowPivotField = function isRowPivotField(field) {
|
|
2177
|
+
return !!(field.PivotCode && field.PivotCode.indexOf('Row') !== -1);
|
|
2178
|
+
};
|
|
2179
|
+
var truncateToTwoDecimals = function truncateToTwoDecimals(value) {
|
|
2180
|
+
var numericValue = isNullOrUndefinedOrEmpty(value) ? 0 : Number(value);
|
|
2181
|
+
var safeValue = isNaN(numericValue) ? 0 : numericValue;
|
|
2182
|
+
var decimalParts = safeValue.toString().split('.');
|
|
2183
|
+
var firstPart = decimalParts[0] ? decimalParts[0] : '0';
|
|
2184
|
+
var secondPart = decimalParts[1] ? decimalParts[1].toString().substr(0, 2) : '0';
|
|
2185
|
+
return Number(firstPart + '.' + secondPart);
|
|
2186
|
+
};
|
|
2187
|
+
var isPivotMeasureValueEmpty = function isPivotMeasureValueEmpty(value) {
|
|
2188
|
+
return value === null || value === undefined || value === '';
|
|
2189
|
+
};
|
|
2190
|
+
var logitudeSumAgg = function logitudeSumAgg(params) {
|
|
2191
|
+
var values = params && params.values ? params.values : [];
|
|
2192
|
+
if (values.length === 0) return null;
|
|
2193
|
+
var total = 0;
|
|
2194
|
+
var hasValue = false;
|
|
2059
2195
|
|
|
2060
|
-
|
|
2061
|
-
|
|
2196
|
+
for (var i = 0; i < values.length; i++) {
|
|
2197
|
+
if (isPivotMeasureValueEmpty(values[i])) continue;
|
|
2198
|
+
hasValue = true;
|
|
2199
|
+
total += truncateToTwoDecimals(values[i]);
|
|
2200
|
+
}
|
|
2062
2201
|
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
widgetRefData.current = props.customChartProps.widget;
|
|
2066
|
-
getPivotTableData();
|
|
2067
|
-
}
|
|
2202
|
+
return hasValue ? total : null;
|
|
2203
|
+
};
|
|
2068
2204
|
|
|
2069
|
-
|
|
2070
|
-
|
|
2205
|
+
var isAgGridDateMeasureTotalAggregation = function isAgGridDateMeasureTotalAggregation(params) {
|
|
2206
|
+
var aggParams = params;
|
|
2207
|
+
var rowNode = aggParams.rowNode;
|
|
2071
2208
|
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
document.addEventListener("resizeStop", handleResize);
|
|
2076
|
-
return function () {
|
|
2077
|
-
document.removeEventListener("resizeStop", handleResize);
|
|
2078
|
-
};
|
|
2079
|
-
}, []);
|
|
2080
|
-
useEffect(function () {
|
|
2081
|
-
if (props.customChartProps.isInEditMode) {
|
|
2082
|
-
var _pivotGridRef$current;
|
|
2209
|
+
if (rowNode && rowNode.footer) {
|
|
2210
|
+
return true;
|
|
2211
|
+
}
|
|
2083
2212
|
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2213
|
+
if (rowNode && rowNode.group && rowNode.leafGroup === false) {
|
|
2214
|
+
return true;
|
|
2215
|
+
}
|
|
2087
2216
|
|
|
2088
|
-
|
|
2089
|
-
var _pivotGridRef$current2;
|
|
2217
|
+
var colDef = aggParams.colDef || aggParams.column && aggParams.column.getColDef && aggParams.column.getColDef();
|
|
2090
2218
|
|
|
2091
|
-
|
|
2219
|
+
if (!colDef) {
|
|
2220
|
+
return false;
|
|
2221
|
+
}
|
|
2092
2222
|
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
}, 5);
|
|
2097
|
-
}
|
|
2098
|
-
}, [props.customChartProps.isInEditMode]);
|
|
2223
|
+
if (colDef.pivotTotalColumnIds !== undefined && colDef.pivotTotalColumnIds !== null) {
|
|
2224
|
+
return true;
|
|
2225
|
+
}
|
|
2099
2226
|
|
|
2100
|
-
var
|
|
2101
|
-
|
|
2227
|
+
var colId = colDef.colId || aggParams.column && aggParams.column.getColId && aggParams.column.getColId();
|
|
2228
|
+
return !!(colId && String(colId).indexOf('PivotRowTotal_') === 0);
|
|
2229
|
+
};
|
|
2102
2230
|
|
|
2103
|
-
|
|
2104
|
-
|
|
2231
|
+
var isDevExtremePivotDataCellTotalOrGrandTotal = function isDevExtremePivotDataCellTotalOrGrandTotal(cell, hasRowFields, hasColumnFields) {
|
|
2232
|
+
if (!cell) {
|
|
2233
|
+
return false;
|
|
2234
|
+
}
|
|
2105
2235
|
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
}
|
|
2236
|
+
if (hasRowFields && (cell.rowType === 'T' || cell.rowType === 'GT')) {
|
|
2237
|
+
return true;
|
|
2238
|
+
}
|
|
2109
2239
|
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
setIsLoading(false);
|
|
2114
|
-
return;
|
|
2115
|
-
}
|
|
2240
|
+
if (hasColumnFields && (cell.columnType === 'T' || cell.columnType === 'GT')) {
|
|
2241
|
+
return true;
|
|
2242
|
+
}
|
|
2116
2243
|
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
widgetLoadLogger.log(res);
|
|
2124
|
-
})["catch"](function (err) {
|
|
2125
|
-
console.log("Error while Getting Pivot Table Data: ", err);
|
|
2126
|
-
tabledata.current = null;
|
|
2127
|
-
setPivotDataSourceFields();
|
|
2128
|
-
setIsLoading(false);
|
|
2129
|
-
});
|
|
2130
|
-
};
|
|
2244
|
+
return false;
|
|
2245
|
+
};
|
|
2246
|
+
var isDevExtremeSummaryCellTotalOrGrandTotal = function isDevExtremeSummaryCellTotalOrGrandTotal(cell, hasRowFields, hasColumnFields) {
|
|
2247
|
+
if (!cell) {
|
|
2248
|
+
return false;
|
|
2249
|
+
}
|
|
2131
2250
|
|
|
2132
|
-
var
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
e.cellElement.children[0].style.backgroundColor = "#f4433673";
|
|
2137
|
-
}
|
|
2251
|
+
var rowPath = cell._rowPath;
|
|
2252
|
+
var columnPath = cell._columnPath;
|
|
2253
|
+
var rowType = rowPath && rowPath[0] ? rowPath[0].type : null;
|
|
2254
|
+
var columnType = columnPath && columnPath[0] ? columnPath[0].type : null;
|
|
2138
2255
|
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
e.cellElement.children[0].style.backgroundColor = "#03a9f4ad";
|
|
2143
|
-
}
|
|
2144
|
-
}, []);
|
|
2145
|
-
var onCellClick = useCallback(function (e) {
|
|
2146
|
-
if (e.area === 'data') {
|
|
2147
|
-
var pivotFields = [];
|
|
2148
|
-
e.columnFields.forEach(function (c, index) {
|
|
2149
|
-
var fieldValue = e.cell.columnPath[index];
|
|
2256
|
+
if (hasRowFields && (rowType === 'T' || rowType === 'GT')) {
|
|
2257
|
+
return true;
|
|
2258
|
+
}
|
|
2150
2259
|
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
}));
|
|
2155
|
-
}
|
|
2156
|
-
});
|
|
2157
|
-
e.rowFields.forEach(function (r, index) {
|
|
2158
|
-
var fieldValue = e.cell.rowPath[index];
|
|
2260
|
+
if (hasColumnFields && (columnType === 'T' || columnType === 'GT')) {
|
|
2261
|
+
return true;
|
|
2262
|
+
}
|
|
2159
2263
|
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
});
|
|
2166
|
-
props.customChartProps.onSelectDataPoint({
|
|
2167
|
-
MeasureFieldId: '',
|
|
2168
|
-
Widget: props.customChartProps.widget,
|
|
2169
|
-
MeasureCode: '',
|
|
2170
|
-
Formula: '',
|
|
2171
|
-
GroupById: '',
|
|
2172
|
-
PivotFields: pivotFields
|
|
2173
|
-
});
|
|
2174
|
-
}
|
|
2175
|
-
}, []);
|
|
2264
|
+
return false;
|
|
2265
|
+
};
|
|
2266
|
+
var isAgGridPivotDateMeasureTotalDisplayCell = function isAgGridPivotDateMeasureTotalDisplayCell(params) {
|
|
2267
|
+
var node = params && params.node;
|
|
2268
|
+
var colDef = params && params.colDef;
|
|
2176
2269
|
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
});
|
|
2181
|
-
return data ? ConvertStringToPascalCaseHelper(data[fieldName]) : '';
|
|
2182
|
-
};
|
|
2270
|
+
if (node && node.footer) {
|
|
2271
|
+
return true;
|
|
2272
|
+
}
|
|
2183
2273
|
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
var bValue = b.value == null ? -1 : Number(b.value);
|
|
2274
|
+
if (node && node.group && node.leafGroup === false) {
|
|
2275
|
+
return true;
|
|
2276
|
+
}
|
|
2188
2277
|
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2278
|
+
if (!colDef) {
|
|
2279
|
+
return false;
|
|
2280
|
+
}
|
|
2192
2281
|
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2282
|
+
if (colDef.pivotTotalColumnIds !== undefined && colDef.pivotTotalColumnIds !== null) {
|
|
2283
|
+
return true;
|
|
2284
|
+
}
|
|
2196
2285
|
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2286
|
+
return isPivotRowGrandTotalColumnDef(colDef);
|
|
2287
|
+
};
|
|
2288
|
+
var logitudeMinAgg = function logitudeMinAgg(params) {
|
|
2289
|
+
if (isAgGridDateMeasureTotalAggregation(params)) {
|
|
2290
|
+
return null;
|
|
2291
|
+
}
|
|
2200
2292
|
|
|
2201
|
-
|
|
2293
|
+
var values = params && params.values ? params.values : [];
|
|
2294
|
+
var minDate = null;
|
|
2295
|
+
var minValue = null;
|
|
2202
2296
|
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2297
|
+
for (var i = 0; i < values.length; i++) {
|
|
2298
|
+
var currentDate = toValidDate(values[i]);
|
|
2299
|
+
if (!currentDate) continue;
|
|
2206
2300
|
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2301
|
+
if (!minDate || currentDate.getTime() < minDate.getTime()) {
|
|
2302
|
+
minDate = currentDate;
|
|
2303
|
+
minValue = values[i];
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2210
2306
|
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2307
|
+
return minValue;
|
|
2308
|
+
};
|
|
2309
|
+
var logitudeMaxAgg = function logitudeMaxAgg(params) {
|
|
2310
|
+
if (isAgGridDateMeasureTotalAggregation(params)) {
|
|
2311
|
+
return null;
|
|
2312
|
+
}
|
|
2215
2313
|
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2314
|
+
var values = params && params.values ? params.values : [];
|
|
2315
|
+
var maxDate = null;
|
|
2316
|
+
var maxValue = null;
|
|
2219
2317
|
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2318
|
+
for (var i = 0; i < values.length; i++) {
|
|
2319
|
+
var currentDate = toValidDate(values[i]);
|
|
2320
|
+
if (!currentDate) continue;
|
|
2223
2321
|
|
|
2224
|
-
|
|
2322
|
+
if (!maxDate || currentDate.getTime() > maxDate.getTime()) {
|
|
2323
|
+
maxDate = currentDate;
|
|
2324
|
+
maxValue = values[i];
|
|
2225
2325
|
}
|
|
2226
|
-
};
|
|
2227
|
-
|
|
2228
|
-
var setPivotDataSourceFields = function setPivotDataSourceFields() {
|
|
2229
|
-
if (tabledata.current && tabledata.current.PivoFields && tabledata.current.PivotMeasures) {
|
|
2230
|
-
var pivotRowsAndColumnsFields = tabledata.current.PivoFields.map(function (field) {
|
|
2231
|
-
return {
|
|
2232
|
-
dataField: field.PivotCode,
|
|
2233
|
-
caption: field.DisplayName,
|
|
2234
|
-
name: field.PivotName,
|
|
2235
|
-
width: 100,
|
|
2236
|
-
allowSorting: false,
|
|
2237
|
-
allowFiltering: false,
|
|
2238
|
-
area: field.PivotCode && field.PivotCode.includes('Row') ? 'row' : 'column',
|
|
2239
|
-
sortingMethod: function sortingMethod(a, b) {
|
|
2240
|
-
return SortRowAndColumnHeaders(a, b, field);
|
|
2241
|
-
},
|
|
2242
|
-
expanded: true,
|
|
2243
|
-
wordWrapEnabled: true,
|
|
2244
|
-
fieldData: {
|
|
2245
|
-
FieldId: field.FieldId,
|
|
2246
|
-
FieldType: field.FieldType ? field.FieldType : "Field",
|
|
2247
|
-
FieldValue: '',
|
|
2248
|
-
DateCode: field.DateCode
|
|
2249
|
-
},
|
|
2250
|
-
customizeText: function customizeText(cellInfo) {
|
|
2251
|
-
return getColumnNameByColumnId(field.PivotName, field.PivotCode, cellInfo.value);
|
|
2252
|
-
}
|
|
2253
|
-
};
|
|
2254
|
-
});
|
|
2255
|
-
var pivotDataCellsFields = tabledata.current.PivotMeasures.map(function (measure) {
|
|
2256
|
-
return {
|
|
2257
|
-
dataField: measure.PivotMeasureCode,
|
|
2258
|
-
area: 'data',
|
|
2259
|
-
dataType: 'number',
|
|
2260
|
-
wordWrapEnabled: true,
|
|
2261
|
-
caption: measure.MeasureCode == 'Sum' && typeof measure.DisplayName == 'string' ? ConvertStringToPascalCaseHelper(measure.DisplayName.replace("Sum of ", "")) : ConvertStringToPascalCaseHelper(measure.DisplayName),
|
|
2262
|
-
summaryType: 'custom',
|
|
2263
|
-
calculateCustomSummary: function calculateCustomSummary(options) {
|
|
2264
|
-
if (options.summaryProcess == 'calculate') {
|
|
2265
|
-
var _value = !isNullOrUndefinedOrEmpty(options.value) ? options.value : 0;
|
|
2266
|
-
|
|
2267
|
-
var decimalParts = _value.toString().split(".");
|
|
2268
|
-
|
|
2269
|
-
var firstPart = decimalParts[0] ? decimalParts[0] : 0;
|
|
2270
|
-
var secondPart = decimalParts[1] ? decimalParts[1] : 0;
|
|
2271
|
-
secondPart = secondPart.toString().substr(0, 2);
|
|
2272
|
-
|
|
2273
|
-
var _finalVal = firstPart + "." + secondPart;
|
|
2274
|
-
|
|
2275
|
-
options.value = Number(_finalVal);
|
|
2276
|
-
options.totalValue = (!isNullOrUndefinedOrEmpty(options.totalValue) ? options.totalValue : 0) + options.value;
|
|
2277
|
-
}
|
|
2278
|
-
},
|
|
2279
|
-
format: function format(value) {
|
|
2280
|
-
var isInteger = isValueInteger(measure.MeasureCode, measure.MeasureFieldDataType);
|
|
2281
|
-
var minimumFraction = isInteger ? 0 : 2;
|
|
2282
|
-
|
|
2283
|
-
var _value = isNullOrUndefinedOrEmpty(value) ? 0 : value;
|
|
2284
|
-
|
|
2285
|
-
return getNumberInSystemLocalFormat(_value, 2, minimumFraction);
|
|
2286
|
-
}
|
|
2287
|
-
};
|
|
2288
|
-
});
|
|
2289
|
-
var AllfieldsData = [].concat(pivotRowsAndColumnsFields, pivotDataCellsFields);
|
|
2290
|
-
setDataSource(new PivotGridDataSource({
|
|
2291
|
-
store: tabledata.current.PivotData,
|
|
2292
|
-
fields: AllfieldsData
|
|
2293
|
-
}));
|
|
2294
|
-
}
|
|
2295
|
-
};
|
|
2296
|
-
|
|
2297
|
-
var isRowsEmptyAndColumnsNotEmpty = function isRowsEmptyAndColumnsNotEmpty() {
|
|
2298
|
-
var pivotRows = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotRows) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotRows) : [];
|
|
2299
|
-
var pivotColumns = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotColumns) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotColumns) : [];
|
|
2300
|
-
return (pivotRows === null || pivotRows === void 0 ? void 0 : pivotRows.length) === 0 && (pivotColumns === null || pivotColumns === void 0 ? void 0 : pivotColumns.length) > 0;
|
|
2301
|
-
};
|
|
2302
|
-
|
|
2303
|
-
var canShowRowsGrandTotal = function canShowRowsGrandTotal() {
|
|
2304
|
-
if (isRowsEmptyAndColumnsNotEmpty()) {
|
|
2305
|
-
return true;
|
|
2306
|
-
}
|
|
2307
|
-
|
|
2308
|
-
var pivotTotalsSettings = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) : {};
|
|
2309
|
-
return !isNullOrUndefinedOrEmpty(pivotTotalsSettings.ShowRowsGrandTotal) ? pivotTotalsSettings.ShowRowsGrandTotal : false;
|
|
2310
|
-
};
|
|
2311
|
-
|
|
2312
|
-
var isRowsNotEmptyAndColumnsEmpty = function isRowsNotEmptyAndColumnsEmpty() {
|
|
2313
|
-
var pivotRows = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotRows) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotRows) : [];
|
|
2314
|
-
var pivotColumns = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotColumns) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotColumns) : [];
|
|
2315
|
-
return (pivotRows === null || pivotRows === void 0 ? void 0 : pivotRows.length) > 0 && (pivotColumns === null || pivotColumns === void 0 ? void 0 : pivotColumns.length) === 0;
|
|
2316
|
-
};
|
|
2317
|
-
|
|
2318
|
-
var canShowColumnsGrandTotal = function canShowColumnsGrandTotal() {
|
|
2319
|
-
if (isRowsNotEmptyAndColumnsEmpty()) {
|
|
2320
|
-
return true;
|
|
2321
|
-
}
|
|
2322
|
-
|
|
2323
|
-
var pivotTotalsSettings = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) : {};
|
|
2324
|
-
return !isNullOrUndefinedOrEmpty(pivotTotalsSettings.ShowColumnsGrandTotal) ? pivotTotalsSettings.ShowColumnsGrandTotal : false;
|
|
2325
|
-
};
|
|
2326
|
-
|
|
2327
|
-
var canShowRowsTotal = function canShowRowsTotal() {
|
|
2328
|
-
var pivotTotalsSettings = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) : {};
|
|
2329
|
-
return !isNullOrUndefinedOrEmpty(pivotTotalsSettings.ShowRowsTotal) ? pivotTotalsSettings.ShowRowsTotal : false;
|
|
2330
|
-
};
|
|
2331
|
-
|
|
2332
|
-
var canShowColumnsTotal = function canShowColumnsTotal() {
|
|
2333
|
-
var pivotTotalsSettings = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) : {};
|
|
2334
|
-
return !isNullOrUndefinedOrEmpty(pivotTotalsSettings.ShowColumnsTotal) ? pivotTotalsSettings.ShowColumnsTotal : false;
|
|
2335
|
-
};
|
|
2336
|
-
|
|
2337
|
-
return React__default.createElement(React__default.Fragment, null, isLoading ? React__default.createElement("div", {
|
|
2338
|
-
className: 'dl-full-hight dl-flex-content-center spinner-custome'
|
|
2339
|
-
}, React__default.createElement(ProgressSpinner, {
|
|
2340
|
-
style: {
|
|
2341
|
-
width: '40px',
|
|
2342
|
-
height: '40px'
|
|
2343
|
-
},
|
|
2344
|
-
strokeWidth: "4",
|
|
2345
|
-
animationDuration: "2s"
|
|
2346
|
-
})) : React__default.createElement(PivotGrid, {
|
|
2347
|
-
id: "pivotGridId",
|
|
2348
|
-
ref: pivotGridRef,
|
|
2349
|
-
dataSource: dataSource,
|
|
2350
|
-
allowExpandAll: true,
|
|
2351
|
-
showBorders: true,
|
|
2352
|
-
className: 'pivot-grid-element',
|
|
2353
|
-
onCellClick: onCellClick,
|
|
2354
|
-
showRowGrandTotals: canShowRowsGrandTotal(),
|
|
2355
|
-
showColumnGrandTotals: canShowColumnsGrandTotal(),
|
|
2356
|
-
showRowTotals: canShowRowsTotal(),
|
|
2357
|
-
showColumnTotals: canShowColumnsTotal(),
|
|
2358
|
-
showTotalsPrior: 'none',
|
|
2359
|
-
wordWrapEnabled: true
|
|
2360
|
-
}, React__default.createElement(FieldPanel, {
|
|
2361
|
-
showColumnFields: false,
|
|
2362
|
-
showDataFields: false,
|
|
2363
|
-
showFilterFields: false,
|
|
2364
|
-
showRowFields: false,
|
|
2365
|
-
texts: {
|
|
2366
|
-
rowFieldArea: ""
|
|
2367
|
-
},
|
|
2368
|
-
allowFieldDragging: false,
|
|
2369
|
-
visible: true
|
|
2370
|
-
}), React__default.createElement(FieldChooser, {
|
|
2371
|
-
enabled: false
|
|
2372
|
-
}), React__default.createElement(Scrolling, {
|
|
2373
|
-
mode: "virtual"
|
|
2374
|
-
})));
|
|
2375
|
-
});
|
|
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
2326
|
}
|
|
2402
2327
|
|
|
2403
|
-
return
|
|
2328
|
+
return maxValue;
|
|
2404
2329
|
};
|
|
2405
2330
|
var formatPivotMeasureValue = function formatPivotMeasureValue(value, measure) {
|
|
2406
2331
|
if (isPivotMeasureValueEmpty(value)) return '';
|
|
2332
|
+
|
|
2333
|
+
if (isPivotDateMinMaxMeasure(measure)) {
|
|
2334
|
+
return formatPivotDateMeasureValue(value);
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2407
2337
|
var isInteger = isValueInteger(measure.MeasureCode, measure.MeasureFieldDataType);
|
|
2408
2338
|
var minimumFraction = isInteger ? 0 : 2;
|
|
2409
2339
|
return getNumberInSystemLocalFormat(value, 2, minimumFraction);
|
|
@@ -2879,14 +2809,7 @@ var parsePivotTotalsSettings = function parsePivotTotalsSettings(json) {
|
|
|
2879
2809
|
}
|
|
2880
2810
|
};
|
|
2881
2811
|
|
|
2882
|
-
var
|
|
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) {
|
|
2812
|
+
var PivotTable = forwardRef(function (props, comRef) {
|
|
2890
2813
|
var _useState = useState(),
|
|
2891
2814
|
widget = _useState[0],
|
|
2892
2815
|
setWidget = _useState[1];
|
|
@@ -2895,34 +2818,27 @@ var AgPivotGrid = forwardRef(function (props, _comRef) {
|
|
|
2895
2818
|
isLoading = _useState2[0],
|
|
2896
2819
|
setIsLoading = _useState2[1];
|
|
2897
2820
|
|
|
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
2821
|
var widgetRefData = useRef(null);
|
|
2911
2822
|
var tabledata = useRef();
|
|
2912
|
-
var
|
|
2913
|
-
var
|
|
2914
|
-
var
|
|
2915
|
-
var
|
|
2916
|
-
|
|
2823
|
+
var pivotGridRef = useRef(null);
|
|
2824
|
+
var dateMeasureDataFieldsRef = useRef(new Set());
|
|
2825
|
+
var pivotHasRowFieldsRef = useRef(false);
|
|
2826
|
+
var pivotHasColumnFieldsRef = useRef(false);
|
|
2827
|
+
|
|
2828
|
+
var _useState3 = useState(new PivotGridDataSource({
|
|
2829
|
+
store: [],
|
|
2830
|
+
fields: []
|
|
2831
|
+
})),
|
|
2832
|
+
dataSource = _useState3[0],
|
|
2833
|
+
setDataSource = _useState3[1];
|
|
2834
|
+
|
|
2917
2835
|
useEffect(function () {
|
|
2918
2836
|
var _props$customChartPro;
|
|
2919
2837
|
|
|
2920
|
-
applyAgGridLicense();
|
|
2921
|
-
|
|
2922
2838
|
if (props.customChartProps && props.customChartProps.widget) {
|
|
2923
2839
|
setWidget(props.customChartProps.widget);
|
|
2924
2840
|
widgetRefData.current = props.customChartProps.widget;
|
|
2925
|
-
getPivotTableData(
|
|
2841
|
+
getPivotTableData();
|
|
2926
2842
|
}
|
|
2927
2843
|
|
|
2928
2844
|
(_props$customChartPro = props.customChartProps.dataBinding) === null || _props$customChartPro === void 0 ? void 0 : _props$customChartPro.widgetUpdated.subscribe(function (updatedWidget) {
|
|
@@ -2931,58 +2847,493 @@ var AgPivotGrid = forwardRef(function (props, _comRef) {
|
|
|
2931
2847
|
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
2848
|
setWidget(_extends({}, updatedWidget));
|
|
2933
2849
|
});
|
|
2934
|
-
document.addEventListener(
|
|
2850
|
+
document.addEventListener("resizeStop", handleResize);
|
|
2935
2851
|
return function () {
|
|
2936
|
-
document.removeEventListener(
|
|
2852
|
+
document.removeEventListener("resizeStop", handleResize);
|
|
2937
2853
|
};
|
|
2938
2854
|
}, []);
|
|
2939
2855
|
useEffect(function () {
|
|
2940
|
-
if (
|
|
2856
|
+
if (props.customChartProps.isInEditMode) {
|
|
2857
|
+
var _pivotGridRef$current;
|
|
2941
2858
|
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2859
|
+
if (pivotGridRef.current && (_pivotGridRef$current = pivotGridRef.current) !== null && _pivotGridRef$current !== void 0 && _pivotGridRef$current.instance && pivotGridRef.current.instance.element && pivotGridRef.current.instance.element().classList) {
|
|
2860
|
+
pivotGridRef.current.instance.element().classList.add('force-overflow-hidden');
|
|
2861
|
+
}
|
|
2945
2862
|
|
|
2946
|
-
|
|
2947
|
-
|
|
2863
|
+
setTimeout(function () {
|
|
2864
|
+
var _pivotGridRef$current2;
|
|
2948
2865
|
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2866
|
+
handleResize();
|
|
2867
|
+
|
|
2868
|
+
if (pivotGridRef.current && (_pivotGridRef$current2 = pivotGridRef.current) !== null && _pivotGridRef$current2 !== void 0 && _pivotGridRef$current2.instance && pivotGridRef.current.instance.element && pivotGridRef.current.instance.element().classList) {
|
|
2869
|
+
pivotGridRef.current.instance.element().classList.remove('force-overflow-hidden');
|
|
2870
|
+
}
|
|
2871
|
+
}, 5);
|
|
2872
|
+
}
|
|
2953
2873
|
}, [props.customChartProps.isInEditMode]);
|
|
2954
2874
|
|
|
2955
2875
|
var handleResize = function handleResize() {
|
|
2956
|
-
|
|
2957
|
-
|
|
2876
|
+
var _pivotGridRef$current3, _pivotGridRef$current4;
|
|
2877
|
+
|
|
2878
|
+
if (pivotGridRef.current && (_pivotGridRef$current3 = pivotGridRef.current) !== null && _pivotGridRef$current3 !== void 0 && _pivotGridRef$current3.instance && (_pivotGridRef$current4 = pivotGridRef.current) !== null && _pivotGridRef$current4 !== void 0 && _pivotGridRef$current4.instance.repaint) {
|
|
2879
|
+
var _pivotGridRef$current5;
|
|
2880
|
+
|
|
2881
|
+
(_pivotGridRef$current5 = pivotGridRef.current) === null || _pivotGridRef$current5 === void 0 ? void 0 : _pivotGridRef$current5.instance.repaint();
|
|
2958
2882
|
}
|
|
2959
2883
|
};
|
|
2960
2884
|
|
|
2961
|
-
var getPivotTableData = function getPivotTableData(
|
|
2885
|
+
var getPivotTableData = function getPivotTableData(widget) {
|
|
2962
2886
|
if (Session.Tenant == 0) {
|
|
2963
2887
|
tabledata.current = [];
|
|
2964
|
-
setRowData([]);
|
|
2965
2888
|
setIsLoading(false);
|
|
2966
2889
|
return;
|
|
2967
2890
|
}
|
|
2968
2891
|
|
|
2969
2892
|
var dashboardAnalyticsService = new DashboardAnalyticsService();
|
|
2970
|
-
var widgetLoadLogger = new WidgetLoadLogger(props.customChartProps.widget, props.customChartProps.isPreviewModeActive,
|
|
2971
|
-
dashboardAnalyticsService.getPivotData(
|
|
2893
|
+
var widgetLoadLogger = new WidgetLoadLogger(props.customChartProps.widget, props.customChartProps.isPreviewModeActive, "PostGetPivotData");
|
|
2894
|
+
dashboardAnalyticsService.getPivotData(props.customChartProps.widget).then(function (res) {
|
|
2972
2895
|
tabledata.current = res.data;
|
|
2973
|
-
|
|
2896
|
+
setPivotDataSourceFields();
|
|
2974
2897
|
setIsLoading(false);
|
|
2975
2898
|
widgetLoadLogger.log(res);
|
|
2976
2899
|
})["catch"](function (err) {
|
|
2977
|
-
console.log(
|
|
2900
|
+
console.log("Error while Getting Pivot Table Data: ", err);
|
|
2978
2901
|
tabledata.current = null;
|
|
2979
|
-
|
|
2902
|
+
setPivotDataSourceFields();
|
|
2980
2903
|
setIsLoading(false);
|
|
2981
2904
|
});
|
|
2982
2905
|
};
|
|
2983
2906
|
|
|
2984
|
-
var
|
|
2985
|
-
|
|
2907
|
+
var customizeCells = useCallback(function (e) {
|
|
2908
|
+
if (e.cell.rowPath && e.cell.rowPath[0] === "Germany" && e.cell.columnPath && e.cell.columnPath[0] === "Export" && e.cell.columnPath[1] === "Air") {
|
|
2909
|
+
e.cellElement.children[0].style.padding = "6px";
|
|
2910
|
+
e.cellElement.children[0].style.borderRadius = "6px";
|
|
2911
|
+
e.cellElement.children[0].style.backgroundColor = "#f4433673";
|
|
2912
|
+
}
|
|
2913
|
+
|
|
2914
|
+
if (e.cell.rowPath && e.cell.rowPath[0] === "USA" && e.cell.columnPath && e.cell.columnPath[0] === "Import" && e.cell.columnPath[1] === "Inland") {
|
|
2915
|
+
e.cellElement.children[0].style.padding = "6px";
|
|
2916
|
+
e.cellElement.children[0].style.borderRadius = "6px";
|
|
2917
|
+
e.cellElement.children[0].style.backgroundColor = "#03a9f4ad";
|
|
2918
|
+
}
|
|
2919
|
+
}, []);
|
|
2920
|
+
var onCellClick = useCallback(function (e) {
|
|
2921
|
+
if (e.area === 'data') {
|
|
2922
|
+
var pivotFields = [];
|
|
2923
|
+
e.columnFields.forEach(function (c, index) {
|
|
2924
|
+
var fieldValue = e.cell.columnPath[index];
|
|
2925
|
+
|
|
2926
|
+
if (fieldValue !== undefined) {
|
|
2927
|
+
pivotFields.push(_extends({}, c.fieldData, {
|
|
2928
|
+
FieldValue: fieldValue
|
|
2929
|
+
}));
|
|
2930
|
+
}
|
|
2931
|
+
});
|
|
2932
|
+
e.rowFields.forEach(function (r, index) {
|
|
2933
|
+
var fieldValue = e.cell.rowPath[index];
|
|
2934
|
+
|
|
2935
|
+
if (fieldValue !== undefined) {
|
|
2936
|
+
pivotFields.push(_extends({}, r.fieldData, {
|
|
2937
|
+
FieldValue: fieldValue
|
|
2938
|
+
}));
|
|
2939
|
+
}
|
|
2940
|
+
});
|
|
2941
|
+
props.customChartProps.onSelectDataPoint({
|
|
2942
|
+
MeasureFieldId: '',
|
|
2943
|
+
Widget: props.customChartProps.widget,
|
|
2944
|
+
MeasureCode: '',
|
|
2945
|
+
Formula: '',
|
|
2946
|
+
GroupById: '',
|
|
2947
|
+
PivotFields: pivotFields
|
|
2948
|
+
});
|
|
2949
|
+
}
|
|
2950
|
+
}, []);
|
|
2951
|
+
var onCellPrepared = useCallback(function (e) {
|
|
2952
|
+
if (e.area !== 'data') {
|
|
2953
|
+
return;
|
|
2954
|
+
}
|
|
2955
|
+
|
|
2956
|
+
var dataFields = e.component.getDataSource().getAreaFields('data');
|
|
2957
|
+
var dataField = dataFields && dataFields[e.cell.dataIndex];
|
|
2958
|
+
|
|
2959
|
+
if (!dataField || !dateMeasureDataFieldsRef.current.has(dataField.dataField)) {
|
|
2960
|
+
return;
|
|
2961
|
+
}
|
|
2962
|
+
|
|
2963
|
+
e.cellElement.classList.add(PIVOT_DATE_DATA_CELL_CLASS);
|
|
2964
|
+
|
|
2965
|
+
if (isDevExtremePivotDataCellTotalOrGrandTotal(e.cell, pivotHasRowFieldsRef.current, pivotHasColumnFieldsRef.current)) {
|
|
2966
|
+
e.cell.text = '';
|
|
2967
|
+
var contentSpan = e.cellElement ? e.cellElement.querySelector('span') : null;
|
|
2968
|
+
|
|
2969
|
+
if (contentSpan) {
|
|
2970
|
+
contentSpan.textContent = '';
|
|
2971
|
+
}
|
|
2972
|
+
}
|
|
2973
|
+
}, []);
|
|
2974
|
+
|
|
2975
|
+
var getColumnNameByColumnId = function getColumnNameByColumnId(fieldName, dataField, datafieldValue) {
|
|
2976
|
+
var data = tabledata.current.PivotData.find(function (el) {
|
|
2977
|
+
return el[dataField] == datafieldValue;
|
|
2978
|
+
});
|
|
2979
|
+
return data ? ConvertStringToPascalCaseHelper(data[fieldName]) : '';
|
|
2980
|
+
};
|
|
2981
|
+
|
|
2982
|
+
var SortRowAndColumnHeaders = function SortRowAndColumnHeaders(a, b, field) {
|
|
2983
|
+
if (field.DateCode == 'Month') {
|
|
2984
|
+
var aValue = a.value == null ? -1 : Number(a.value);
|
|
2985
|
+
var bValue = b.value == null ? -1 : Number(b.value);
|
|
2986
|
+
|
|
2987
|
+
if (aValue < bValue) {
|
|
2988
|
+
return -1;
|
|
2989
|
+
}
|
|
2990
|
+
|
|
2991
|
+
if (aValue > bValue) {
|
|
2992
|
+
return 1;
|
|
2993
|
+
}
|
|
2994
|
+
|
|
2995
|
+
return 0;
|
|
2996
|
+
} else if (field.DateCode != null) {
|
|
2997
|
+
var _aValue = a.value == null ? '' : a.value;
|
|
2998
|
+
|
|
2999
|
+
var _bValue = b.value == null ? '' : b.value;
|
|
3000
|
+
|
|
3001
|
+
if (_aValue < _bValue) {
|
|
3002
|
+
return -1;
|
|
3003
|
+
}
|
|
3004
|
+
|
|
3005
|
+
if (_aValue > _bValue) {
|
|
3006
|
+
return 1;
|
|
3007
|
+
}
|
|
3008
|
+
|
|
3009
|
+
return 0;
|
|
3010
|
+
} else {
|
|
3011
|
+
var aText = a.text == null ? '' : a.text;
|
|
3012
|
+
var bText = b.text == null ? '' : b.text;
|
|
3013
|
+
|
|
3014
|
+
if (aText < bText) {
|
|
3015
|
+
return -1;
|
|
3016
|
+
}
|
|
3017
|
+
|
|
3018
|
+
if (aText > bText) {
|
|
3019
|
+
return 1;
|
|
3020
|
+
}
|
|
3021
|
+
|
|
3022
|
+
return 0;
|
|
3023
|
+
}
|
|
3024
|
+
};
|
|
3025
|
+
|
|
3026
|
+
var setPivotDataSourceFields = function setPivotDataSourceFields() {
|
|
3027
|
+
if (tabledata.current && tabledata.current.PivoFields && tabledata.current.PivotMeasures) {
|
|
3028
|
+
var pivotRowsAndColumnsFields = tabledata.current.PivoFields.map(function (field) {
|
|
3029
|
+
return {
|
|
3030
|
+
dataField: field.PivotCode,
|
|
3031
|
+
caption: field.DisplayName,
|
|
3032
|
+
name: field.PivotName,
|
|
3033
|
+
width: 100,
|
|
3034
|
+
allowSorting: false,
|
|
3035
|
+
allowFiltering: false,
|
|
3036
|
+
area: field.PivotCode && field.PivotCode.includes('Row') ? 'row' : 'column',
|
|
3037
|
+
sortingMethod: function sortingMethod(a, b) {
|
|
3038
|
+
return SortRowAndColumnHeaders(a, b, field);
|
|
3039
|
+
},
|
|
3040
|
+
expanded: true,
|
|
3041
|
+
wordWrapEnabled: true,
|
|
3042
|
+
fieldData: {
|
|
3043
|
+
FieldId: field.FieldId,
|
|
3044
|
+
FieldType: field.FieldType ? field.FieldType : "Field",
|
|
3045
|
+
FieldValue: '',
|
|
3046
|
+
DateCode: field.DateCode
|
|
3047
|
+
},
|
|
3048
|
+
customizeText: function customizeText(cellInfo) {
|
|
3049
|
+
return getColumnNameByColumnId(field.PivotName, field.PivotCode, cellInfo.value);
|
|
3050
|
+
}
|
|
3051
|
+
};
|
|
3052
|
+
});
|
|
3053
|
+
var hasRowFields = tabledata.current.PivoFields.some(function (field) {
|
|
3054
|
+
return field.PivotCode && field.PivotCode.includes('Row');
|
|
3055
|
+
});
|
|
3056
|
+
var hasColumnFields = tabledata.current.PivoFields.some(function (field) {
|
|
3057
|
+
return field.PivotCode && !field.PivotCode.includes('Row');
|
|
3058
|
+
});
|
|
3059
|
+
pivotHasRowFieldsRef.current = hasRowFields;
|
|
3060
|
+
pivotHasColumnFieldsRef.current = hasColumnFields;
|
|
3061
|
+
dateMeasureDataFieldsRef.current = new Set(tabledata.current.PivotMeasures.filter(function (measure) {
|
|
3062
|
+
return (measure.MeasureCode === 'Min' || measure.MeasureCode === 'Max') && FieldDataType.isDateOrDateTimeType(measure.MeasureFieldDataType);
|
|
3063
|
+
}).map(function (measure) {
|
|
3064
|
+
return measure.PivotMeasureCode;
|
|
3065
|
+
}));
|
|
3066
|
+
var pivotDataCellsFields = tabledata.current.PivotMeasures.map(function (measure) {
|
|
3067
|
+
var isDateMinMaxMeasure = (measure.MeasureCode === 'Min' || measure.MeasureCode === 'Max') && FieldDataType.isDateOrDateTimeType(measure.MeasureFieldDataType);
|
|
3068
|
+
return _extends({
|
|
3069
|
+
dataField: measure.PivotMeasureCode,
|
|
3070
|
+
area: 'data',
|
|
3071
|
+
dataType: isDateMinMaxMeasure ? 'string' : 'number',
|
|
3072
|
+
wordWrapEnabled: true,
|
|
3073
|
+
caption: measure.MeasureCode == 'Sum' && typeof measure.DisplayName == 'string' ? ConvertStringToPascalCaseHelper(measure.DisplayName.replace("Sum of ", "")) : ConvertStringToPascalCaseHelper(measure.DisplayName),
|
|
3074
|
+
summaryType: 'custom',
|
|
3075
|
+
calculateCustomSummary: function calculateCustomSummary(options) {
|
|
3076
|
+
if (options.summaryProcess == 'start') {
|
|
3077
|
+
options.totalValue = null;
|
|
3078
|
+
return;
|
|
3079
|
+
}
|
|
3080
|
+
|
|
3081
|
+
if (options.summaryProcess != 'calculate') {
|
|
3082
|
+
return;
|
|
3083
|
+
}
|
|
3084
|
+
|
|
3085
|
+
if (isDateMinMaxMeasure) {
|
|
3086
|
+
if (isNullOrUndefinedOrEmpty(options.value)) {
|
|
3087
|
+
return;
|
|
3088
|
+
}
|
|
3089
|
+
|
|
3090
|
+
var currentDate = moment(options.value);
|
|
3091
|
+
|
|
3092
|
+
if (!currentDate || !currentDate.isValid()) {
|
|
3093
|
+
return;
|
|
3094
|
+
}
|
|
3095
|
+
|
|
3096
|
+
if (isNullOrUndefinedOrEmpty(options.totalValue)) {
|
|
3097
|
+
options.totalValue = options.value;
|
|
3098
|
+
return;
|
|
3099
|
+
}
|
|
3100
|
+
|
|
3101
|
+
var totalDate = moment(options.totalValue);
|
|
3102
|
+
|
|
3103
|
+
if (!totalDate || !totalDate.isValid()) {
|
|
3104
|
+
options.totalValue = options.value;
|
|
3105
|
+
return;
|
|
3106
|
+
}
|
|
3107
|
+
|
|
3108
|
+
if (measure.MeasureCode === 'Max') {
|
|
3109
|
+
if (currentDate.isAfter(totalDate)) {
|
|
3110
|
+
options.totalValue = options.value;
|
|
3111
|
+
}
|
|
3112
|
+
} else if (currentDate.isBefore(totalDate)) {
|
|
3113
|
+
options.totalValue = options.value;
|
|
3114
|
+
}
|
|
3115
|
+
|
|
3116
|
+
return;
|
|
3117
|
+
}
|
|
3118
|
+
|
|
3119
|
+
var _value = !isNullOrUndefinedOrEmpty(options.value) ? options.value : 0;
|
|
3120
|
+
|
|
3121
|
+
var decimalParts = _value.toString().split(".");
|
|
3122
|
+
|
|
3123
|
+
var firstPart = decimalParts[0] ? decimalParts[0] : 0;
|
|
3124
|
+
var secondPart = decimalParts[1] ? decimalParts[1] : 0;
|
|
3125
|
+
secondPart = secondPart.toString().substr(0, 2);
|
|
3126
|
+
|
|
3127
|
+
var _finalVal = firstPart + "." + secondPart;
|
|
3128
|
+
|
|
3129
|
+
options.value = Number(_finalVal);
|
|
3130
|
+
options.totalValue = (!isNullOrUndefinedOrEmpty(options.totalValue) ? options.totalValue : 0) + options.value;
|
|
3131
|
+
}
|
|
3132
|
+
}, isDateMinMaxMeasure ? {
|
|
3133
|
+
calculateSummaryValue: function calculateSummaryValue(cell) {
|
|
3134
|
+
if (isDevExtremeSummaryCellTotalOrGrandTotal(cell, hasRowFields, hasColumnFields)) {
|
|
3135
|
+
return null;
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3138
|
+
return cell.value();
|
|
3139
|
+
},
|
|
3140
|
+
customizeText: function customizeText(cellInfo) {
|
|
3141
|
+
return formatPivotDateMeasureValue(cellInfo.value);
|
|
3142
|
+
}
|
|
3143
|
+
} : {
|
|
3144
|
+
format: function format(value) {
|
|
3145
|
+
var isInteger = isValueInteger(measure.MeasureCode, measure.MeasureFieldDataType);
|
|
3146
|
+
var minimumFraction = isInteger ? 0 : 2;
|
|
3147
|
+
|
|
3148
|
+
var _value = isNullOrUndefinedOrEmpty(value) ? 0 : value;
|
|
3149
|
+
|
|
3150
|
+
return getNumberInSystemLocalFormat(_value, 2, minimumFraction);
|
|
3151
|
+
}
|
|
3152
|
+
});
|
|
3153
|
+
});
|
|
3154
|
+
var AllfieldsData = [].concat(pivotRowsAndColumnsFields, pivotDataCellsFields);
|
|
3155
|
+
setDataSource(new PivotGridDataSource({
|
|
3156
|
+
store: tabledata.current.PivotData,
|
|
3157
|
+
fields: AllfieldsData
|
|
3158
|
+
}));
|
|
3159
|
+
}
|
|
3160
|
+
};
|
|
3161
|
+
|
|
3162
|
+
var canShowRowsGrandTotal = function canShowRowsGrandTotal() {
|
|
3163
|
+
var pivotTotalsSettings = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) : {};
|
|
3164
|
+
return !isNullOrUndefinedOrEmpty(pivotTotalsSettings.ShowRowsGrandTotal) ? pivotTotalsSettings.ShowRowsGrandTotal : false;
|
|
3165
|
+
};
|
|
3166
|
+
|
|
3167
|
+
var isRowsNotEmptyAndColumnsEmpty = function isRowsNotEmptyAndColumnsEmpty() {
|
|
3168
|
+
var pivotRows = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotRows) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotRows) : [];
|
|
3169
|
+
var pivotColumns = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotColumns) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotColumns) : [];
|
|
3170
|
+
return (pivotRows === null || pivotRows === void 0 ? void 0 : pivotRows.length) > 0 && (pivotColumns === null || pivotColumns === void 0 ? void 0 : pivotColumns.length) === 0;
|
|
3171
|
+
};
|
|
3172
|
+
|
|
3173
|
+
var canShowColumnsGrandTotal = function canShowColumnsGrandTotal() {
|
|
3174
|
+
if (isRowsNotEmptyAndColumnsEmpty()) {
|
|
3175
|
+
return true;
|
|
3176
|
+
}
|
|
3177
|
+
|
|
3178
|
+
var pivotTotalsSettings = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) : {};
|
|
3179
|
+
return !isNullOrUndefinedOrEmpty(pivotTotalsSettings.ShowColumnsGrandTotal) ? pivotTotalsSettings.ShowColumnsGrandTotal : false;
|
|
3180
|
+
};
|
|
3181
|
+
|
|
3182
|
+
var canShowRowsTotal = function canShowRowsTotal() {
|
|
3183
|
+
var pivotTotalsSettings = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) : {};
|
|
3184
|
+
return !isNullOrUndefinedOrEmpty(pivotTotalsSettings.ShowRowsTotal) ? pivotTotalsSettings.ShowRowsTotal : false;
|
|
3185
|
+
};
|
|
3186
|
+
|
|
3187
|
+
var canShowColumnsTotal = function canShowColumnsTotal() {
|
|
3188
|
+
var pivotTotalsSettings = widget && !isNullOrUndefinedOrEmpty(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) ? JSON.parse(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings) : {};
|
|
3189
|
+
return !isNullOrUndefinedOrEmpty(pivotTotalsSettings.ShowColumnsTotal) ? pivotTotalsSettings.ShowColumnsTotal : false;
|
|
3190
|
+
};
|
|
3191
|
+
|
|
3192
|
+
return React__default.createElement(React__default.Fragment, null, isLoading ? React__default.createElement("div", {
|
|
3193
|
+
className: 'dl-full-hight dl-flex-content-center spinner-custome'
|
|
3194
|
+
}, React__default.createElement(ProgressSpinner, {
|
|
3195
|
+
style: {
|
|
3196
|
+
width: '40px',
|
|
3197
|
+
height: '40px'
|
|
3198
|
+
},
|
|
3199
|
+
strokeWidth: "4",
|
|
3200
|
+
animationDuration: "2s"
|
|
3201
|
+
})) : React__default.createElement(PivotGrid, {
|
|
3202
|
+
id: "pivotGridId",
|
|
3203
|
+
ref: pivotGridRef,
|
|
3204
|
+
dataSource: dataSource,
|
|
3205
|
+
allowExpandAll: true,
|
|
3206
|
+
showBorders: true,
|
|
3207
|
+
className: 'pivot-grid-element',
|
|
3208
|
+
onCellClick: onCellClick,
|
|
3209
|
+
onCellPrepared: onCellPrepared,
|
|
3210
|
+
showRowGrandTotals: canShowRowsGrandTotal(),
|
|
3211
|
+
showColumnGrandTotals: canShowColumnsGrandTotal(),
|
|
3212
|
+
showRowTotals: canShowRowsTotal(),
|
|
3213
|
+
showColumnTotals: canShowColumnsTotal(),
|
|
3214
|
+
showTotalsPrior: 'none',
|
|
3215
|
+
wordWrapEnabled: true
|
|
3216
|
+
}, React__default.createElement(FieldPanel, {
|
|
3217
|
+
showColumnFields: false,
|
|
3218
|
+
showDataFields: false,
|
|
3219
|
+
showFilterFields: false,
|
|
3220
|
+
showRowFields: false,
|
|
3221
|
+
texts: {
|
|
3222
|
+
rowFieldArea: ""
|
|
3223
|
+
},
|
|
3224
|
+
allowFieldDragging: false,
|
|
3225
|
+
visible: true
|
|
3226
|
+
}), React__default.createElement(FieldChooser, {
|
|
3227
|
+
enabled: false
|
|
3228
|
+
}), React__default.createElement(Scrolling, {
|
|
3229
|
+
mode: "virtual"
|
|
3230
|
+
})));
|
|
3231
|
+
});
|
|
3232
|
+
|
|
3233
|
+
var ROW_GROUP_COLUMN_MIN_WIDTH = 100;
|
|
3234
|
+
|
|
3235
|
+
var applyAgGridLicense = function applyAgGridLicense() {
|
|
3236
|
+
if (!Session.AgGridLicenseKey) return;
|
|
3237
|
+
LicenseManager.setLicenseKey(Session.AgGridLicenseKey);
|
|
3238
|
+
};
|
|
3239
|
+
|
|
3240
|
+
var AgPivotGrid = forwardRef(function (props, _comRef) {
|
|
3241
|
+
var _useState = useState(),
|
|
3242
|
+
widget = _useState[0],
|
|
3243
|
+
setWidget = _useState[1];
|
|
3244
|
+
|
|
3245
|
+
var _useState2 = useState(true),
|
|
3246
|
+
isLoading = _useState2[0],
|
|
3247
|
+
setIsLoading = _useState2[1];
|
|
3248
|
+
|
|
3249
|
+
var _useState3 = useState([]),
|
|
3250
|
+
rowData = _useState3[0],
|
|
3251
|
+
setRowData = _useState3[1];
|
|
3252
|
+
|
|
3253
|
+
var _useState4 = useState([]),
|
|
3254
|
+
columnDefs = _useState4[0],
|
|
3255
|
+
setColumnDefs = _useState4[1];
|
|
3256
|
+
|
|
3257
|
+
var _useState5 = useState(0),
|
|
3258
|
+
measureCount = _useState5[0],
|
|
3259
|
+
setMeasureCount = _useState5[1];
|
|
3260
|
+
|
|
3261
|
+
var widgetRefData = useRef(null);
|
|
3262
|
+
var tabledata = useRef();
|
|
3263
|
+
var gridApiRef = useRef(null);
|
|
3264
|
+
var columnApiRef = useRef(null);
|
|
3265
|
+
var gridContainerRef = useRef(null);
|
|
3266
|
+
var pivotFieldsRef = useRef([]);
|
|
3267
|
+
var pivotMeasuresRef = useRef([]);
|
|
3268
|
+
useEffect(function () {
|
|
3269
|
+
var _props$customChartPro;
|
|
3270
|
+
|
|
3271
|
+
applyAgGridLicense();
|
|
3272
|
+
|
|
3273
|
+
if (props.customChartProps && props.customChartProps.widget) {
|
|
3274
|
+
setWidget(props.customChartProps.widget);
|
|
3275
|
+
widgetRefData.current = props.customChartProps.widget;
|
|
3276
|
+
getPivotTableData(props.customChartProps.widget);
|
|
3277
|
+
}
|
|
3278
|
+
|
|
3279
|
+
(_props$customChartPro = props.customChartProps.dataBinding) === null || _props$customChartPro === void 0 ? void 0 : _props$customChartPro.widgetUpdated.subscribe(function (updatedWidget) {
|
|
3280
|
+
var _widgetRefData$curren;
|
|
3281
|
+
|
|
3282
|
+
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;
|
|
3283
|
+
setWidget(_extends({}, updatedWidget));
|
|
3284
|
+
});
|
|
3285
|
+
document.addEventListener('resizeStop', handleResize);
|
|
3286
|
+
return function () {
|
|
3287
|
+
document.removeEventListener('resizeStop', handleResize);
|
|
3288
|
+
};
|
|
3289
|
+
}, []);
|
|
3290
|
+
useEffect(function () {
|
|
3291
|
+
if (!props.customChartProps.isInEditMode) return;
|
|
3292
|
+
|
|
3293
|
+
if (gridContainerRef.current && gridContainerRef.current.classList) {
|
|
3294
|
+
gridContainerRef.current.classList.add('force-overflow-hidden');
|
|
3295
|
+
}
|
|
3296
|
+
|
|
3297
|
+
setTimeout(function () {
|
|
3298
|
+
handleResize();
|
|
3299
|
+
|
|
3300
|
+
if (gridContainerRef.current && gridContainerRef.current.classList) {
|
|
3301
|
+
gridContainerRef.current.classList.remove('force-overflow-hidden');
|
|
3302
|
+
}
|
|
3303
|
+
}, 5);
|
|
3304
|
+
}, [props.customChartProps.isInEditMode]);
|
|
3305
|
+
|
|
3306
|
+
var handleResize = function handleResize() {
|
|
3307
|
+
if (gridApiRef.current && gridApiRef.current.resetRowHeights) {
|
|
3308
|
+
gridApiRef.current.resetRowHeights();
|
|
3309
|
+
}
|
|
3310
|
+
};
|
|
3311
|
+
|
|
3312
|
+
var getPivotTableData = function getPivotTableData(widgetPm) {
|
|
3313
|
+
if (Session.Tenant == 0) {
|
|
3314
|
+
tabledata.current = [];
|
|
3315
|
+
setRowData([]);
|
|
3316
|
+
setIsLoading(false);
|
|
3317
|
+
return;
|
|
3318
|
+
}
|
|
3319
|
+
|
|
3320
|
+
var dashboardAnalyticsService = new DashboardAnalyticsService();
|
|
3321
|
+
var widgetLoadLogger = new WidgetLoadLogger(props.customChartProps.widget, props.customChartProps.isPreviewModeActive, 'PostGetPivotData');
|
|
3322
|
+
dashboardAnalyticsService.getPivotData(widgetPm).then(function (res) {
|
|
3323
|
+
tabledata.current = res.data;
|
|
3324
|
+
buildGridFromPivotResponse();
|
|
3325
|
+
setIsLoading(false);
|
|
3326
|
+
widgetLoadLogger.log(res);
|
|
3327
|
+
})["catch"](function (err) {
|
|
3328
|
+
console.log('Error while Getting Pivot Table Data: ', err);
|
|
3329
|
+
tabledata.current = null;
|
|
3330
|
+
setRowData([]);
|
|
3331
|
+
setIsLoading(false);
|
|
3332
|
+
});
|
|
3333
|
+
};
|
|
3334
|
+
|
|
3335
|
+
var lookupDisplayName = function lookupDisplayName(field, rawValue) {
|
|
3336
|
+
var pivotData = tabledata.current && tabledata.current.PivotData ? tabledata.current.PivotData : [];
|
|
2986
3337
|
return getPivotDisplayName(pivotData, field.PivotName, field.PivotCode, rawValue);
|
|
2987
3338
|
};
|
|
2988
3339
|
|
|
@@ -2994,11 +3345,14 @@ var AgPivotGrid = forwardRef(function (props, _comRef) {
|
|
|
2994
3345
|
return lookupDisplayName(field, rawValue);
|
|
2995
3346
|
};
|
|
2996
3347
|
|
|
2997
|
-
var applyPivotDataCellFormatting = function applyPivotDataCellFormatting(colDef) {
|
|
3348
|
+
var applyPivotDataCellFormatting = function applyPivotDataCellFormatting(colDef, measure) {
|
|
2998
3349
|
colDef.sortable = false;
|
|
2999
3350
|
colDef.filter = false;
|
|
3000
|
-
colDef.cellClass = 'dl-ag-pivot-data-cell';
|
|
3001
|
-
|
|
3351
|
+
colDef.cellClass = measure ? getPivotDataCellClassNames(measure) : 'dl-ag-pivot-data-cell';
|
|
3352
|
+
|
|
3353
|
+
if (!measure || !isPivotDateMinMaxMeasure(measure)) {
|
|
3354
|
+
colDef.type = 'numericColumn';
|
|
3355
|
+
}
|
|
3002
3356
|
};
|
|
3003
3357
|
|
|
3004
3358
|
var buildGridFromPivotResponse = function buildGridFromPivotResponse() {
|
|
@@ -3068,28 +3422,36 @@ var AgPivotGrid = forwardRef(function (props, _comRef) {
|
|
|
3068
3422
|
};
|
|
3069
3423
|
};
|
|
3070
3424
|
|
|
3425
|
+
var getMeasureAggFunc = function getMeasureAggFunc(measure) {
|
|
3426
|
+
if (!isPivotDateMinMaxMeasure(measure)) return 'logitudeSum';
|
|
3427
|
+
return measure.MeasureCode === 'Max' ? 'logitudeMax' : 'logitudeMin';
|
|
3428
|
+
};
|
|
3429
|
+
|
|
3071
3430
|
var createMeasureColDef = function createMeasureColDef(measure) {
|
|
3072
|
-
|
|
3431
|
+
var colDef = {
|
|
3073
3432
|
field: measure.PivotMeasureCode,
|
|
3074
3433
|
headerName: getMeasureCaption(measure),
|
|
3075
|
-
aggFunc:
|
|
3434
|
+
aggFunc: getMeasureAggFunc(measure),
|
|
3076
3435
|
enableValue: true,
|
|
3077
3436
|
wrapText: true,
|
|
3078
3437
|
autoHeight: true,
|
|
3079
3438
|
sortable: false,
|
|
3080
3439
|
filter: false,
|
|
3081
|
-
cellClass:
|
|
3082
|
-
type: 'numericColumn',
|
|
3440
|
+
cellClass: getPivotDataCellClassNames(measure),
|
|
3083
3441
|
valueFormatter: function valueFormatter(params) {
|
|
3442
|
+
if (isPivotDateMinMaxMeasure(measure) && isAgGridPivotDateMeasureTotalDisplayCell(params)) {
|
|
3443
|
+
return '';
|
|
3444
|
+
}
|
|
3445
|
+
|
|
3084
3446
|
return formatPivotMeasureValue(params.value, measure);
|
|
3085
3447
|
}
|
|
3086
3448
|
};
|
|
3087
|
-
};
|
|
3088
3449
|
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3450
|
+
if (!isPivotDateMinMaxMeasure(measure)) {
|
|
3451
|
+
colDef.type = 'numericColumn';
|
|
3452
|
+
}
|
|
3453
|
+
|
|
3454
|
+
return colDef;
|
|
3093
3455
|
};
|
|
3094
3456
|
|
|
3095
3457
|
var isRowsNotEmptyAndColumnsEmpty = function isRowsNotEmptyAndColumnsEmpty() {
|
|
@@ -3099,7 +3461,6 @@ var AgPivotGrid = forwardRef(function (props, _comRef) {
|
|
|
3099
3461
|
};
|
|
3100
3462
|
|
|
3101
3463
|
var canShowRowsGrandTotal = function canShowRowsGrandTotal() {
|
|
3102
|
-
if (isRowsEmptyAndColumnsNotEmpty()) return true;
|
|
3103
3464
|
var settings = parsePivotTotalsSettings(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings);
|
|
3104
3465
|
return !isNullOrUndefinedOrEmpty(settings.ShowRowsGrandTotal) ? !!settings.ShowRowsGrandTotal : false;
|
|
3105
3466
|
};
|
|
@@ -3147,12 +3508,18 @@ var AgPivotGrid = forwardRef(function (props, _comRef) {
|
|
|
3147
3508
|
}
|
|
3148
3509
|
}
|
|
3149
3510
|
|
|
3150
|
-
|
|
3511
|
+
var measure = resolveMeasureForSecondaryColDef(colDef, pivotMeasuresRef.current);
|
|
3512
|
+
applyPivotDataCellFormatting(colDef, measure);
|
|
3151
3513
|
|
|
3152
3514
|
colDef.valueFormatter = function (params) {
|
|
3153
|
-
var
|
|
3154
|
-
if (!
|
|
3155
|
-
|
|
3515
|
+
var resolvedMeasure = measure || resolveMeasureForSecondaryColDef(params.colDef, pivotMeasuresRef.current);
|
|
3516
|
+
if (!resolvedMeasure) return '';
|
|
3517
|
+
|
|
3518
|
+
if (isPivotDateMinMaxMeasure(resolvedMeasure) && isAgGridPivotDateMeasureTotalDisplayCell(params)) {
|
|
3519
|
+
return '';
|
|
3520
|
+
}
|
|
3521
|
+
|
|
3522
|
+
return formatPivotMeasureValue(params.value, resolvedMeasure);
|
|
3156
3523
|
};
|
|
3157
3524
|
}, []);
|
|
3158
3525
|
var onCellClicked = useCallback(function (event) {
|
|
@@ -3218,7 +3585,9 @@ var AgPivotGrid = forwardRef(function (props, _comRef) {
|
|
|
3218
3585
|
}, []);
|
|
3219
3586
|
var aggFuncs = useMemo(function () {
|
|
3220
3587
|
return {
|
|
3221
|
-
logitudeSum: logitudeSumAgg
|
|
3588
|
+
logitudeSum: logitudeSumAgg,
|
|
3589
|
+
logitudeMin: logitudeMinAgg,
|
|
3590
|
+
logitudeMax: logitudeMaxAgg
|
|
3222
3591
|
};
|
|
3223
3592
|
}, []);
|
|
3224
3593
|
var scheduleRowGrandTotalHeaderLabel = useCallback(function () {
|