ui-soxo-bootstrap-core 2.6.1-dev.12 → 2.6.1-dev.13
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.
|
@@ -861,6 +861,40 @@ function GuestList({
|
|
|
861
861
|
const handleCloseEdit = () => {
|
|
862
862
|
setShowEdit(false);
|
|
863
863
|
};
|
|
864
|
+
/**
|
|
865
|
+
*
|
|
866
|
+
*/
|
|
867
|
+
function calculateSummaryValues(summaryCols, pageData) {
|
|
868
|
+
const summaryValues = {};
|
|
869
|
+
|
|
870
|
+
summaryCols.forEach((col) => {
|
|
871
|
+
const field = col.field;
|
|
872
|
+
|
|
873
|
+
if (col.function === 'sum') {
|
|
874
|
+
summaryValues[field] = pageData.reduce((total, row) => total + Number(row[field] || 0), 0);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
if (col.function === 'count') {
|
|
878
|
+
summaryValues[field] = pageData.length;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
if (col.function === 'avg') {
|
|
882
|
+
const total = pageData.reduce((sum, row) => sum + Number(row[field] || 0), 0);
|
|
883
|
+
summaryValues[field] = pageData.length ? total / pageData.length : 0;
|
|
884
|
+
}
|
|
885
|
+
if (col.function === 'min') {
|
|
886
|
+
const values = pageData.map((row) => Number(row[field] || 0));
|
|
887
|
+
summaryValues[field] = values.length ? Math.min(...values) : 0;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
if (col.function === 'max') {
|
|
891
|
+
const values = pageData.map((row) => Number(row[field] || 0));
|
|
892
|
+
summaryValues[field] = values.length ? Math.max(...values) : 0;
|
|
893
|
+
}
|
|
894
|
+
});
|
|
895
|
+
|
|
896
|
+
return summaryValues;
|
|
897
|
+
}
|
|
864
898
|
return (
|
|
865
899
|
<>
|
|
866
900
|
<div className="table-header">
|
|
@@ -936,46 +970,131 @@ function GuestList({
|
|
|
936
970
|
sticky
|
|
937
971
|
pagination={false}
|
|
938
972
|
// title={config.caption}
|
|
973
|
+
// summary={(pageData) => {
|
|
974
|
+
// // Variable to save the summary data
|
|
975
|
+
// let summary = {};
|
|
976
|
+
|
|
977
|
+
// let summaryColumns = [
|
|
978
|
+
// { field: 'opb_amt', title: 'Amount' },
|
|
979
|
+
// { field: 'opb_netamt', title: 'Net Amount' },
|
|
980
|
+
// ];
|
|
981
|
+
|
|
982
|
+
// let tableColumns = cols;
|
|
983
|
+
|
|
984
|
+
// // Creating a copy of columns to append the summary configuration that is needed to set
|
|
985
|
+
// tableColumns.forEach((record, index) => {
|
|
986
|
+
// summaryColumns.forEach((inner) => {
|
|
987
|
+
// if (record.field === inner.field) {
|
|
988
|
+
// tableColumns[index].summary = inner;
|
|
989
|
+
// }
|
|
990
|
+
// });
|
|
991
|
+
// });
|
|
992
|
+
|
|
993
|
+
// // Initialize
|
|
994
|
+
// summaryColumns.map((item) => {
|
|
995
|
+
// return (summary[item.field] = 0);
|
|
996
|
+
// });
|
|
997
|
+
|
|
998
|
+
// // Find the total
|
|
999
|
+
// summaryColumns.map((item) => {
|
|
1000
|
+
// pageData.forEach((entry) => {
|
|
1001
|
+
// return (summary[item.field] = summary[item.field] + entry[item.field]);
|
|
1002
|
+
// });
|
|
1003
|
+
// });
|
|
1004
|
+
|
|
1005
|
+
// return (
|
|
1006
|
+
// <>
|
|
1007
|
+
// <Table.Summary.Row>
|
|
1008
|
+
// {tableColumns.map((column, key) => {
|
|
1009
|
+
// return <Table.Summary.Cell key={key}>{column.summary ? <>{summary[column.summary.field]}</> : null}</Table.Summary.Cell>;
|
|
1010
|
+
// })}
|
|
1011
|
+
// </Table.Summary.Row>
|
|
1012
|
+
// </>
|
|
1013
|
+
// );
|
|
1014
|
+
// }}
|
|
1015
|
+
// summary={(pageData) => {
|
|
1016
|
+
// const summaryCols = columns.filter((col) => col.enable_summary);
|
|
1017
|
+
// if (!summaryCols.length) return null;
|
|
1018
|
+
|
|
1019
|
+
// const summaryValues = {};
|
|
1020
|
+
|
|
1021
|
+
// summaryCols.forEach((col) => {
|
|
1022
|
+
// const field = col.field;
|
|
1023
|
+
|
|
1024
|
+
// if (col.function === 'sum') {
|
|
1025
|
+
// summaryValues[field] = pageData.reduce((total, row) => total + Number(row[field] || 0), 0);
|
|
1026
|
+
// }
|
|
1027
|
+
|
|
1028
|
+
// if (col.function === 'count') {
|
|
1029
|
+
// summaryValues[field] = pageData.length;
|
|
1030
|
+
// }
|
|
1031
|
+
|
|
1032
|
+
// if (col.function === 'avg') {
|
|
1033
|
+
// const total = pageData.reduce((sum, row) => sum + Number(row[field] || 0), 0);
|
|
1034
|
+
// summaryValues[field] = pageData.length ? total / pageData.length : 0;
|
|
1035
|
+
// }
|
|
1036
|
+
// });
|
|
1037
|
+
|
|
1038
|
+
// return (
|
|
1039
|
+
// <Table.Summary.Row className="report-summary-row">
|
|
1040
|
+
// {cols.map((col, index) => {
|
|
1041
|
+
// // show summary value
|
|
1042
|
+
// if (summaryValues[col.field] !== undefined) {
|
|
1043
|
+
// return (
|
|
1044
|
+
// <Table.Summary.Cell key={index}>
|
|
1045
|
+
// <strong>{summaryValues[col.field]}</strong>
|
|
1046
|
+
// </Table.Summary.Cell>
|
|
1047
|
+
// );
|
|
1048
|
+
// }
|
|
1049
|
+
|
|
1050
|
+
// // caption before summary column
|
|
1051
|
+
// const nextCol = cols[index + 1];
|
|
1052
|
+
// if (nextCol && summaryValues[nextCol.field] !== undefined) {
|
|
1053
|
+
// const configCol = columns.find((c) => c.field === nextCol.field);
|
|
1054
|
+
// return (
|
|
1055
|
+
// <Table.Summary.Cell key={index}>
|
|
1056
|
+
// <strong>{configCol?.summary_caption || 'Total'}</strong>
|
|
1057
|
+
// </Table.Summary.Cell>
|
|
1058
|
+
// );
|
|
1059
|
+
// }
|
|
1060
|
+
|
|
1061
|
+
// return <Table.Summary.Cell key={index} />;
|
|
1062
|
+
// })}
|
|
1063
|
+
// </Table.Summary.Row>
|
|
1064
|
+
// );
|
|
1065
|
+
// }}
|
|
1066
|
+
|
|
939
1067
|
summary={(pageData) => {
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
{ field: 'opb_amt', title: 'Amount' },
|
|
945
|
-
{ field: 'opb_netamt', title: 'Net Amount' },
|
|
946
|
-
];
|
|
947
|
-
|
|
948
|
-
let tableColumns = cols;
|
|
949
|
-
|
|
950
|
-
// Creating a copy of columns to append the summary configuration that is needed to set
|
|
951
|
-
tableColumns.forEach((record, index) => {
|
|
952
|
-
summaryColumns.forEach((inner) => {
|
|
953
|
-
if (record.field === inner.field) {
|
|
954
|
-
tableColumns[index].summary = inner;
|
|
955
|
-
}
|
|
956
|
-
});
|
|
957
|
-
});
|
|
958
|
-
|
|
959
|
-
// Initialize
|
|
960
|
-
summaryColumns.map((item) => {
|
|
961
|
-
return (summary[item.field] = 0);
|
|
962
|
-
});
|
|
963
|
-
|
|
964
|
-
// Find the total
|
|
965
|
-
summaryColumns.map((item) => {
|
|
966
|
-
pageData.forEach((entry) => {
|
|
967
|
-
return (summary[item.field] = summary[item.field] + entry[item.field]);
|
|
968
|
-
});
|
|
969
|
-
});
|
|
1068
|
+
const summaryCols = columns.filter((col) => col.enable_summary);
|
|
1069
|
+
if (!summaryCols.length) return null;
|
|
1070
|
+
|
|
1071
|
+
const summaryValues = calculateSummaryValues(summaryCols, pageData);
|
|
970
1072
|
|
|
971
1073
|
return (
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
return
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
1074
|
+
<Table.Summary.Row>
|
|
1075
|
+
{cols.map((col, index) => {
|
|
1076
|
+
if (summaryValues[col.field] !== undefined) {
|
|
1077
|
+
return (
|
|
1078
|
+
<Table.Summary.Cell key={index}>
|
|
1079
|
+
<strong>{summaryValues[col.field]}</strong>
|
|
1080
|
+
</Table.Summary.Cell>
|
|
1081
|
+
);
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
const nextCol = cols[index + 1];
|
|
1085
|
+
if (nextCol && summaryValues[nextCol.field] !== undefined) {
|
|
1086
|
+
const configCol = columns.find((c) => c.field === nextCol.field);
|
|
1087
|
+
|
|
1088
|
+
return (
|
|
1089
|
+
<Table.Summary.Cell key={index}>
|
|
1090
|
+
<strong>{configCol?.summary_caption || 'Total'}</strong>
|
|
1091
|
+
</Table.Summary.Cell>
|
|
1092
|
+
);
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
return <Table.Summary.Cell key={index} />;
|
|
1096
|
+
})}
|
|
1097
|
+
</Table.Summary.Row>
|
|
979
1098
|
);
|
|
980
1099
|
}}
|
|
981
1100
|
/>
|