@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/cjs/index.js
CHANGED
@@ -24779,6 +24779,21 @@ var NdcDetailsComponent = function (props) {
|
|
24779
24779
|
ndcDetail.actionType === NdcActionType.mainAction);
|
24780
24780
|
})
|
24781
24781
|
: [];
|
24782
|
+
var getSubNdcDetailsForPeriod = function (id) {
|
24783
|
+
var subNdcDetails = ndcDetailsData.filter(function (ndcDetail) {
|
24784
|
+
return (ndcDetail.parentActionId === id &&
|
24785
|
+
ndcDetail.actionType === NdcActionType.subAction);
|
24786
|
+
});
|
24787
|
+
var emptySubNdcRow = {
|
24788
|
+
actionType: NdcActionType.subAction,
|
24789
|
+
nationalPlanObjective: "",
|
24790
|
+
kpi: 0,
|
24791
|
+
ministryName: governmentMinistry,
|
24792
|
+
status: NdcDetailsActionStatus.pending,
|
24793
|
+
parentActionId: id,
|
24794
|
+
};
|
24795
|
+
return __spreadArray(__spreadArray([], subNdcDetails, true), [emptySubNdcRow], false);
|
24796
|
+
};
|
24782
24797
|
var isAddNdcActionVisible = function () {
|
24783
24798
|
return ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT &&
|
24784
24799
|
(userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly);
|
@@ -24787,22 +24802,19 @@ var NdcDetailsComponent = function (props) {
|
|
24787
24802
|
return num >= min && num <= max;
|
24788
24803
|
};
|
24789
24804
|
var handleSave = function (row) { return __awaiter(void 0, void 0, void 0, function () {
|
24790
|
-
var updatedItemIndex
|
24805
|
+
var updatedItemIndex;
|
24791
24806
|
return __generator(this, function (_a) {
|
24792
24807
|
switch (_a.label) {
|
24793
24808
|
case 0:
|
24794
|
-
console.log("handleSave", row);
|
24795
24809
|
updatedItemIndex = ndcDetailsData.findIndex(function (item) { return item.id === row.id; });
|
24796
24810
|
if (!(updatedItemIndex === -1)) return [3 /*break*/, 2];
|
24797
24811
|
return [4 /*yield*/, post("national/programme/addNdcDetailsAction", __assign(__assign({}, row), { kpi: parseInt(row.kpi) }))];
|
24798
24812
|
case 1:
|
24799
|
-
|
24800
|
-
console.log("handleSave created", response);
|
24813
|
+
_a.sent();
|
24801
24814
|
return [3 /*break*/, 4];
|
24802
24815
|
case 2: return [4 /*yield*/, put("national/programme/updateNdcDetailsAction", __assign(__assign({}, row), { kpi: parseInt(row.kpi) }))];
|
24803
24816
|
case 3:
|
24804
|
-
|
24805
|
-
console.log("handleSave updated", response);
|
24817
|
+
_a.sent();
|
24806
24818
|
_a.label = 4;
|
24807
24819
|
case 4:
|
24808
24820
|
fetchNdcDetailActions();
|
@@ -24810,64 +24822,6 @@ var NdcDetailsComponent = function (props) {
|
|
24810
24822
|
}
|
24811
24823
|
});
|
24812
24824
|
}); };
|
24813
|
-
// const getNdcDetailsForPeriod = () => {
|
24814
|
-
// //const range = selectedPeriod.split("-");
|
24815
|
-
// const range: any = [];
|
24816
|
-
// if (range.length > 1) {
|
24817
|
-
// const filteredData = ndcDetailsData.filter((item: NdcDetail) => {
|
24818
|
-
// return inRange(
|
24819
|
-
// Number(moment(item.startDate).year()),
|
24820
|
-
// Number(range[0]),
|
24821
|
-
// Number(range[1])
|
24822
|
-
// );
|
24823
|
-
// });
|
24824
|
-
// return filteredData;
|
24825
|
-
// } else {
|
24826
|
-
// return [];
|
24827
|
-
// }
|
24828
|
-
// };
|
24829
|
-
var getSubNdcDetailsForPeriod = function (id) {
|
24830
|
-
ndcDetailsData.find(function (item) { return item.id === id; });
|
24831
|
-
var subNdcDetails = ndcDetailsData.filter(function (ndcDetail) {
|
24832
|
-
return (ndcDetail.parentActionId === id &&
|
24833
|
-
ndcDetail.actionType === NdcActionType.subAction);
|
24834
|
-
});
|
24835
|
-
var emptySubNdcRow = {
|
24836
|
-
actionType: NdcActionType.subAction,
|
24837
|
-
nationalPlanObjective: "",
|
24838
|
-
kpi: 0,
|
24839
|
-
ministryName: governmentMinistry,
|
24840
|
-
status: NdcDetailsActionStatus.pending,
|
24841
|
-
parentActionId: id,
|
24842
|
-
};
|
24843
|
-
return __spreadArray(__spreadArray([], subNdcDetails, true), [emptySubNdcRow], false);
|
24844
|
-
// if (ndcDetail) {
|
24845
|
-
// if (
|
24846
|
-
// ndcDetail?.subNdcDetails[
|
24847
|
-
// ndcDetail?.subNdcDetails?.length - 1
|
24848
|
-
// ]?.ministryName.trim() !== "" &&
|
24849
|
-
// ndcDetail?.subNdcDetails[ndcDetail?.subNdcDetails?.length - 1]
|
24850
|
-
// ?.ministryName &&
|
24851
|
-
// ndcDetail?.subNdcDetails[
|
24852
|
-
// ndcDetail?.subNdcDetails?.length - 1
|
24853
|
-
// ]?.nationalPlanObjective.trim() !== "" &&
|
24854
|
-
// ndcDetail?.subNdcDetails[ndcDetail?.subNdcDetails?.length - 1]
|
24855
|
-
// ?.nationalPlanObjective &&
|
24856
|
-
// String(
|
24857
|
-
// ndcDetail?.subNdcDetails[ndcDetail?.subNdcDetails?.length - 1]?.kpi
|
24858
|
-
// ).trim() !== "" &&
|
24859
|
-
// String(
|
24860
|
-
// ndcDetail?.subNdcDetails[ndcDetail?.subNdcDetails?.length - 1]?.kpi
|
24861
|
-
// )
|
24862
|
-
// ) {
|
24863
|
-
// onAddNewSubNdcDetail();
|
24864
|
-
// }
|
24865
|
-
// return ndcDetail.subNdcDetails;
|
24866
|
-
// } else {
|
24867
|
-
// return [];
|
24868
|
-
// }
|
24869
|
-
//return [];
|
24870
|
-
};
|
24871
24825
|
var defaultColumns = [
|
24872
24826
|
{
|
24873
24827
|
title: t("ndc:ndcColumnsNationalPlanObj"),
|
@@ -24933,7 +24887,6 @@ var NdcDetailsComponent = function (props) {
|
|
24933
24887
|
response = _a.sent();
|
24934
24888
|
if (response && response.data) {
|
24935
24889
|
newlyCreatedNdcAction_1 = response.data;
|
24936
|
-
newlyCreatedNdcAction_1.key = newlyCreatedNdcAction_1.id;
|
24937
24890
|
setNdcDetailsData(function (ndcDetailsData) { return __spreadArray(__spreadArray([], ndcDetailsData, true), [
|
24938
24891
|
newlyCreatedNdcAction_1,
|
24939
24892
|
], false); });
|
@@ -24974,7 +24927,7 @@ var NdcDetailsComponent = function (props) {
|
|
24974
24927
|
return (React.createElement("div", null,
|
24975
24928
|
React.createElement(antd.Row, null,
|
24976
24929
|
React.createElement(antd.Col, { span: 24 },
|
24977
|
-
React.createElement(antd.Table, { key: tableKey, components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: ndcMainDetailsForPeriod, columns: columns, expandable: {
|
24930
|
+
React.createElement(antd.Table, { key: tableKey, rowKey: "id", components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: ndcMainDetailsForPeriod, columns: columns, expandable: {
|
24978
24931
|
expandedRowRender: function (record) { return getSubNdcActionContent(record); },
|
24979
24932
|
indentSize: 0,
|
24980
24933
|
//defaultExpandedRowKeys: [parseInt(selectedNdcDetail.current.id)],
|
@@ -25044,7 +24997,7 @@ var NdcDetailsComponent = function (props) {
|
|
25044
24997
|
}
|
25045
24998
|
function getSubNdcActionContent(record) {
|
25046
24999
|
selectedNdcDetail.current = record;
|
25047
|
-
return (React.createElement(antd.Table, { components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getSubNdcDetailsForPeriod(record.id), columns: columns, showHeader: false, pagination: false }));
|
25000
|
+
return (React.createElement(antd.Table, { rowKey: "id", components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getSubNdcDetailsForPeriod(record.id), columns: columns, showHeader: false, pagination: false }));
|
25048
25001
|
}
|
25049
25002
|
var onTabChange = function (key) {
|
25050
25003
|
var selectedPeriod = periodItems.find(function (item) { return item.key === key; });
|
@@ -25084,17 +25037,14 @@ var NdcDetailsComponent = function (props) {
|
|
25084
25037
|
});
|
25085
25038
|
}); };
|
25086
25039
|
var fetchNdcDetailActions = function () { return __awaiter(void 0, void 0, void 0, function () {
|
25087
|
-
var response
|
25040
|
+
var response;
|
25088
25041
|
return __generator(this, function (_a) {
|
25089
25042
|
switch (_a.label) {
|
25090
25043
|
case 0: return [4 /*yield*/, get("national/programme/queryNdcDetailsAction")];
|
25091
25044
|
case 1:
|
25092
25045
|
response = _a.sent();
|
25093
25046
|
if (response && response.data) {
|
25094
|
-
|
25095
|
-
return __assign(__assign({}, item), { key: item.id });
|
25096
|
-
});
|
25097
|
-
setNdcDetailsData(updatedData);
|
25047
|
+
setNdcDetailsData(response.data);
|
25098
25048
|
}
|
25099
25049
|
return [2 /*return*/];
|
25100
25050
|
}
|