@undp/carbon-library 1.0.16-CARBON-363.57 → 1.0.16-CARBON-363.62
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/index.js +22 -72
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +22 -72
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
@@ -24759,6 +24759,21 @@ var NdcDetailsComponent = function (props) {
|
|
24759
24759
|
ndcDetail.actionType === NdcActionType.mainAction);
|
24760
24760
|
})
|
24761
24761
|
: [];
|
24762
|
+
var getSubNdcDetailsForPeriod = function (id) {
|
24763
|
+
var subNdcDetails = ndcDetailsData.filter(function (ndcDetail) {
|
24764
|
+
return (ndcDetail.parentActionId === id &&
|
24765
|
+
ndcDetail.actionType === NdcActionType.subAction);
|
24766
|
+
});
|
24767
|
+
var emptySubNdcRow = {
|
24768
|
+
actionType: NdcActionType.subAction,
|
24769
|
+
nationalPlanObjective: "",
|
24770
|
+
kpi: 0,
|
24771
|
+
ministryName: governmentMinistry,
|
24772
|
+
status: NdcDetailsActionStatus.pending,
|
24773
|
+
parentActionId: id,
|
24774
|
+
};
|
24775
|
+
return __spreadArray(__spreadArray([], subNdcDetails, true), [emptySubNdcRow], false);
|
24776
|
+
};
|
24762
24777
|
var isAddNdcActionVisible = function () {
|
24763
24778
|
return ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT &&
|
24764
24779
|
(userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly);
|
@@ -24767,22 +24782,19 @@ var NdcDetailsComponent = function (props) {
|
|
24767
24782
|
return num >= min && num <= max;
|
24768
24783
|
};
|
24769
24784
|
var handleSave = function (row) { return __awaiter(void 0, void 0, void 0, function () {
|
24770
|
-
var updatedItemIndex
|
24785
|
+
var updatedItemIndex;
|
24771
24786
|
return __generator(this, function (_a) {
|
24772
24787
|
switch (_a.label) {
|
24773
24788
|
case 0:
|
24774
|
-
console.log("handleSave", row);
|
24775
24789
|
updatedItemIndex = ndcDetailsData.findIndex(function (item) { return item.id === row.id; });
|
24776
24790
|
if (!(updatedItemIndex === -1)) return [3 /*break*/, 2];
|
24777
24791
|
return [4 /*yield*/, post("national/programme/addNdcDetailsAction", __assign(__assign({}, row), { kpi: parseInt(row.kpi) }))];
|
24778
24792
|
case 1:
|
24779
|
-
|
24780
|
-
console.log("handleSave created", response);
|
24793
|
+
_a.sent();
|
24781
24794
|
return [3 /*break*/, 4];
|
24782
24795
|
case 2: return [4 /*yield*/, put("national/programme/updateNdcDetailsAction", __assign(__assign({}, row), { kpi: parseInt(row.kpi) }))];
|
24783
24796
|
case 3:
|
24784
|
-
|
24785
|
-
console.log("handleSave updated", response);
|
24797
|
+
_a.sent();
|
24786
24798
|
_a.label = 4;
|
24787
24799
|
case 4:
|
24788
24800
|
fetchNdcDetailActions();
|
@@ -24790,64 +24802,6 @@ var NdcDetailsComponent = function (props) {
|
|
24790
24802
|
}
|
24791
24803
|
});
|
24792
24804
|
}); };
|
24793
|
-
// const getNdcDetailsForPeriod = () => {
|
24794
|
-
// //const range = selectedPeriod.split("-");
|
24795
|
-
// const range: any = [];
|
24796
|
-
// if (range.length > 1) {
|
24797
|
-
// const filteredData = ndcDetailsData.filter((item: NdcDetail) => {
|
24798
|
-
// return inRange(
|
24799
|
-
// Number(moment(item.startDate).year()),
|
24800
|
-
// Number(range[0]),
|
24801
|
-
// Number(range[1])
|
24802
|
-
// );
|
24803
|
-
// });
|
24804
|
-
// return filteredData;
|
24805
|
-
// } else {
|
24806
|
-
// return [];
|
24807
|
-
// }
|
24808
|
-
// };
|
24809
|
-
var getSubNdcDetailsForPeriod = function (id) {
|
24810
|
-
ndcDetailsData.find(function (item) { return item.id === id; });
|
24811
|
-
var subNdcDetails = ndcDetailsData.filter(function (ndcDetail) {
|
24812
|
-
return (ndcDetail.parentActionId === id &&
|
24813
|
-
ndcDetail.actionType === NdcActionType.subAction);
|
24814
|
-
});
|
24815
|
-
var emptySubNdcRow = {
|
24816
|
-
actionType: NdcActionType.subAction,
|
24817
|
-
nationalPlanObjective: "",
|
24818
|
-
kpi: 0,
|
24819
|
-
ministryName: governmentMinistry,
|
24820
|
-
status: NdcDetailsActionStatus.pending,
|
24821
|
-
parentActionId: id,
|
24822
|
-
};
|
24823
|
-
return __spreadArray(__spreadArray([], subNdcDetails, true), [emptySubNdcRow], false);
|
24824
|
-
// if (ndcDetail) {
|
24825
|
-
// if (
|
24826
|
-
// ndcDetail?.subNdcDetails[
|
24827
|
-
// ndcDetail?.subNdcDetails?.length - 1
|
24828
|
-
// ]?.ministryName.trim() !== "" &&
|
24829
|
-
// ndcDetail?.subNdcDetails[ndcDetail?.subNdcDetails?.length - 1]
|
24830
|
-
// ?.ministryName &&
|
24831
|
-
// ndcDetail?.subNdcDetails[
|
24832
|
-
// ndcDetail?.subNdcDetails?.length - 1
|
24833
|
-
// ]?.nationalPlanObjective.trim() !== "" &&
|
24834
|
-
// ndcDetail?.subNdcDetails[ndcDetail?.subNdcDetails?.length - 1]
|
24835
|
-
// ?.nationalPlanObjective &&
|
24836
|
-
// String(
|
24837
|
-
// ndcDetail?.subNdcDetails[ndcDetail?.subNdcDetails?.length - 1]?.kpi
|
24838
|
-
// ).trim() !== "" &&
|
24839
|
-
// String(
|
24840
|
-
// ndcDetail?.subNdcDetails[ndcDetail?.subNdcDetails?.length - 1]?.kpi
|
24841
|
-
// )
|
24842
|
-
// ) {
|
24843
|
-
// onAddNewSubNdcDetail();
|
24844
|
-
// }
|
24845
|
-
// return ndcDetail.subNdcDetails;
|
24846
|
-
// } else {
|
24847
|
-
// return [];
|
24848
|
-
// }
|
24849
|
-
//return [];
|
24850
|
-
};
|
24851
24805
|
var defaultColumns = [
|
24852
24806
|
{
|
24853
24807
|
title: t("ndc:ndcColumnsNationalPlanObj"),
|
@@ -24913,7 +24867,6 @@ var NdcDetailsComponent = function (props) {
|
|
24913
24867
|
response = _a.sent();
|
24914
24868
|
if (response && response.data) {
|
24915
24869
|
newlyCreatedNdcAction_1 = response.data;
|
24916
|
-
newlyCreatedNdcAction_1.key = newlyCreatedNdcAction_1.id;
|
24917
24870
|
setNdcDetailsData(function (ndcDetailsData) { return __spreadArray(__spreadArray([], ndcDetailsData, true), [
|
24918
24871
|
newlyCreatedNdcAction_1,
|
24919
24872
|
], false); });
|
@@ -24954,7 +24907,7 @@ var NdcDetailsComponent = function (props) {
|
|
24954
24907
|
return (React.createElement("div", null,
|
24955
24908
|
React.createElement(Row, null,
|
24956
24909
|
React.createElement(Col, { span: 24 },
|
24957
|
-
React.createElement(Table, { key: tableKey, components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: ndcMainDetailsForPeriod, columns: columns, expandable: {
|
24910
|
+
React.createElement(Table, { key: tableKey, rowKey: "id", components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: ndcMainDetailsForPeriod, columns: columns, expandable: {
|
24958
24911
|
expandedRowRender: function (record) { return getSubNdcActionContent(record); },
|
24959
24912
|
indentSize: 0,
|
24960
24913
|
//defaultExpandedRowKeys: [parseInt(selectedNdcDetail.current.id)],
|
@@ -25024,7 +24977,7 @@ var NdcDetailsComponent = function (props) {
|
|
25024
24977
|
}
|
25025
24978
|
function getSubNdcActionContent(record) {
|
25026
24979
|
selectedNdcDetail.current = record;
|
25027
|
-
return (React.createElement(Table, { components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getSubNdcDetailsForPeriod(record.id), columns: columns, showHeader: false, pagination: false }));
|
24980
|
+
return (React.createElement(Table, { rowKey: "id", components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getSubNdcDetailsForPeriod(record.id), columns: columns, showHeader: false, pagination: false }));
|
25028
24981
|
}
|
25029
24982
|
var onTabChange = function (key) {
|
25030
24983
|
var selectedPeriod = periodItems.find(function (item) { return item.key === key; });
|
@@ -25064,17 +25017,14 @@ var NdcDetailsComponent = function (props) {
|
|
25064
25017
|
});
|
25065
25018
|
}); };
|
25066
25019
|
var fetchNdcDetailActions = function () { return __awaiter(void 0, void 0, void 0, function () {
|
25067
|
-
var response
|
25020
|
+
var response;
|
25068
25021
|
return __generator(this, function (_a) {
|
25069
25022
|
switch (_a.label) {
|
25070
25023
|
case 0: return [4 /*yield*/, get("national/programme/queryNdcDetailsAction")];
|
25071
25024
|
case 1:
|
25072
25025
|
response = _a.sent();
|
25073
25026
|
if (response && response.data) {
|
25074
|
-
|
25075
|
-
return __assign(__assign({}, item), { key: item.id });
|
25076
|
-
});
|
25077
|
-
setNdcDetailsData(updatedData);
|
25027
|
+
setNdcDetailsData(response.data);
|
25078
25028
|
}
|
25079
25029
|
return [2 /*return*/];
|
25080
25030
|
}
|