@undp/carbon-library 1.0.170 → 1.0.171-CARBON-363.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/index.js +239 -477
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/Definitions/Definitions/ndcDetails.definitions.d.ts +30 -0
- package/dist/esm/index.js +239 -477
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/Definitions/Definitions/ndcDetails.definitions.d.ts +30 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
@@ -24698,7 +24698,7 @@ var EditableRow = function (_a) {
|
|
24698
24698
|
React.createElement("tr", __assign({}, props)))));
|
24699
24699
|
};
|
24700
24700
|
var EditableCell = function (_a) {
|
24701
|
-
|
24701
|
+
_a.title; var editable = _a.editable, children = _a.children, dataIndex = _a.dataIndex, record = _a.record, handleSave = _a.handleSave, restProps = __rest(_a, ["title", "editable", "children", "dataIndex", "record", "handleSave"]);
|
24702
24702
|
var _b = React.useState(false), editing = _b[0], setEditing = _b[1];
|
24703
24703
|
var inputRef = React.useRef(null);
|
24704
24704
|
var form = React.useContext(EditableContext);
|
@@ -24734,12 +24734,7 @@ var EditableCell = function (_a) {
|
|
24734
24734
|
}); };
|
24735
24735
|
var childNode = children;
|
24736
24736
|
if (editable) {
|
24737
|
-
childNode = editing ? (React.createElement(antd.Form.Item, { style: { margin: 0 }, name: dataIndex,
|
24738
|
-
{
|
24739
|
-
required: true,
|
24740
|
-
message: "".concat(title, " is required."),
|
24741
|
-
},
|
24742
|
-
] },
|
24737
|
+
childNode = editing ? (React.createElement(antd.Form.Item, { style: { margin: 0 }, name: dataIndex },
|
24743
24738
|
React.createElement(antd.Input, { ref: inputRef, onPressEnter: save, onBlur: save }))) : (React.createElement("div", { className: "editable-cell-value-wrap", style: { paddingRight: 24, minWidth: "100px", minHeight: "20px" }, onClick: toggleEdit }, children));
|
24744
24739
|
}
|
24745
24740
|
return React.createElement("td", __assign({}, restProps), childNode);
|
@@ -24750,26 +24745,54 @@ styleInject(css_248z$4);
|
|
24750
24745
|
|
24751
24746
|
var NdcActionType;
|
24752
24747
|
(function (NdcActionType) {
|
24753
|
-
NdcActionType[NdcActionType["
|
24754
|
-
NdcActionType[NdcActionType["
|
24748
|
+
NdcActionType[NdcActionType["mainAction"] = 0] = "mainAction";
|
24749
|
+
NdcActionType[NdcActionType["subAction"] = 1] = "subAction";
|
24755
24750
|
})(NdcActionType || (NdcActionType = {}));
|
24751
|
+
var NdcDetailsActionStatus;
|
24752
|
+
(function (NdcDetailsActionStatus) {
|
24753
|
+
NdcDetailsActionStatus[NdcDetailsActionStatus["pending"] = 0] = "pending";
|
24754
|
+
NdcDetailsActionStatus[NdcDetailsActionStatus["approved"] = 1] = "approved";
|
24755
|
+
})(NdcDetailsActionStatus || (NdcDetailsActionStatus = {}));
|
24756
|
+
|
24756
24757
|
var NdcDetailsComponent = function (props) {
|
24757
|
-
var t = props.t
|
24758
|
+
var t = props.t, useConnection = props.useConnection, useUserContext = props.useUserContext;
|
24758
24759
|
var RangePicker = antd.DatePicker.RangePicker;
|
24759
24760
|
var _a = React.useState([]), ndcDetailsData = _a[0], setNdcDetailsData = _a[1];
|
24760
24761
|
var _b = React.useState(false), loading = _b[0]; _b[1];
|
24761
|
-
var periodItemsRef = React.useRef([]);
|
24762
24762
|
var _c = React.useState([]), periodItems = _c[0], setPeriodItems = _c[1];
|
24763
|
-
var _d = React.useState(
|
24764
|
-
var
|
24765
|
-
|
24763
|
+
var _d = React.useState({}), selectedPeriod = _d[0], setSelectedPeriod = _d[1];
|
24764
|
+
var selectedDateRangeRef = React.useRef({});
|
24765
|
+
React.useRef(0);
|
24766
24766
|
var selectedNdcDetail = React.useRef({});
|
24767
24767
|
var _e = React.useState(0), tableKey = _e[0], setTableKey = _e[1];
|
24768
|
+
var _f = useConnection(), get = _f.get, post = _f.post, put = _f.put;
|
24768
24769
|
var userInfoState = useUserContext().userInfoState;
|
24769
|
-
var
|
24770
|
-
|
24771
|
-
|
24772
|
-
|
24770
|
+
var governmentMinistry = process.env.REACT_APP_GOVERNMENT_MINISTRY
|
24771
|
+
? process.env.REACT_APP_GOVERNMENT_MINISTRY
|
24772
|
+
: "Test ministryName";
|
24773
|
+
var isAddRangeVisible = ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY ||
|
24774
|
+
(userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT) &&
|
24775
|
+
(userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly;
|
24776
|
+
var ndcMainDetailsForPeriod = selectedPeriod.key !== "add_new"
|
24777
|
+
? ndcDetailsData.filter(function (ndcDetail) {
|
24778
|
+
return (ndcDetail.periodId === parseInt(selectedPeriod.key) &&
|
24779
|
+
ndcDetail.actionType === NdcActionType.mainAction);
|
24780
|
+
})
|
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);
|
24773
24796
|
};
|
24774
24797
|
var isAddNdcActionVisible = function () {
|
24775
24798
|
return ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT &&
|
@@ -24778,103 +24801,37 @@ var NdcDetailsComponent = function (props) {
|
|
24778
24801
|
var inRange = function (num, min, max) {
|
24779
24802
|
return num >= min && num <= max;
|
24780
24803
|
};
|
24781
|
-
function
|
24782
|
-
var
|
24783
|
-
|
24784
|
-
|
24785
|
-
|
24786
|
-
|
24787
|
-
|
24788
|
-
|
24789
|
-
|
24790
|
-
|
24791
|
-
|
24792
|
-
|
24793
|
-
|
24794
|
-
|
24795
|
-
|
24796
|
-
|
24797
|
-
|
24798
|
-
|
24799
|
-
ndcDetail.subNdcDetails.push(newData);
|
24800
|
-
}
|
24801
|
-
ndcDetailsData[ndcDetailItemIndex] = ndcDetail;
|
24802
|
-
setNdcDetailsData(ndcDetailsData);
|
24803
|
-
setTableKey(function (key) { return key + 1; });
|
24804
|
-
}
|
24805
|
-
var handleSave = function (row) {
|
24806
|
-
setNdcDetailsData(function (prevData) {
|
24807
|
-
var newData = JSON.parse(JSON.stringify(prevData));
|
24808
|
-
if (row.type === NdcActionType.main) {
|
24809
|
-
var index = newData.findIndex(function (item) { return row.key === item.key; });
|
24810
|
-
if (index !== -1) {
|
24811
|
-
newData[index] = __assign(__assign({}, newData[index]), row);
|
24812
|
-
}
|
24813
|
-
}
|
24814
|
-
else {
|
24815
|
-
var parentIndex = newData.findIndex(function (item) { return row.ndcActionId === item.key; });
|
24816
|
-
var parentItem = newData[parentIndex];
|
24817
|
-
if (parentItem) {
|
24818
|
-
if (parentItem.subNdcDetails) {
|
24819
|
-
var itemIndex = parentItem.subNdcDetails.findIndex(function (item) { return row.key === item.key; });
|
24820
|
-
if (itemIndex === -1) {
|
24821
|
-
parentItem.subNdcDetails.push(row);
|
24822
|
-
}
|
24823
|
-
else {
|
24824
|
-
parentItem.subNdcDetails[itemIndex] = __assign({}, row);
|
24825
|
-
}
|
24826
|
-
}
|
24827
|
-
else {
|
24828
|
-
parentItem.subNdcDetails = [row];
|
24829
|
-
}
|
24830
|
-
}
|
24831
|
-
newData[parentIndex] = __assign({}, parentItem);
|
24832
|
-
setTableKey(function (key) { return key + 1; });
|
24804
|
+
var handleSave = function (row) { return __awaiter(void 0, void 0, void 0, function () {
|
24805
|
+
var updatedItemIndex;
|
24806
|
+
return __generator(this, function (_a) {
|
24807
|
+
switch (_a.label) {
|
24808
|
+
case 0:
|
24809
|
+
updatedItemIndex = ndcDetailsData.findIndex(function (item) { return item.id === row.id; });
|
24810
|
+
if (!(updatedItemIndex === -1)) return [3 /*break*/, 2];
|
24811
|
+
return [4 /*yield*/, post("national/programme/addNdcDetailsAction", __assign(__assign({}, row), { kpi: parseInt(row.kpi) }))];
|
24812
|
+
case 1:
|
24813
|
+
_a.sent();
|
24814
|
+
return [3 /*break*/, 4];
|
24815
|
+
case 2: return [4 /*yield*/, put("national/programme/updateNdcDetailsAction", __assign(__assign({}, row), { kpi: parseInt(row.kpi) }))];
|
24816
|
+
case 3:
|
24817
|
+
_a.sent();
|
24818
|
+
_a.label = 4;
|
24819
|
+
case 4:
|
24820
|
+
fetchNdcDetailActions();
|
24821
|
+
return [2 /*return*/];
|
24833
24822
|
}
|
24834
|
-
return newData;
|
24835
24823
|
});
|
24836
|
-
};
|
24837
|
-
var getNdcDetailsForPeriod = function () {
|
24838
|
-
var range = selectedTab.split("-");
|
24839
|
-
if (range.length > 1) {
|
24840
|
-
var filteredData = ndcDetailsData.filter(function (item) {
|
24841
|
-
return inRange(Number(moment(item.startDate).year()), Number(range[0]), Number(range[1]));
|
24842
|
-
});
|
24843
|
-
return filteredData;
|
24844
|
-
}
|
24845
|
-
else {
|
24846
|
-
return [];
|
24847
|
-
}
|
24848
|
-
};
|
24849
|
-
var getSubNdcDetails = function (key) {
|
24850
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
24851
|
-
var ndcDetail = ndcDetailsData.find(function (item) { return item.key === key; });
|
24852
|
-
if (ndcDetail) {
|
24853
|
-
if (((_b = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails[((_a = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails) === null || _a === void 0 ? void 0 : _a.length) - 1]) === null || _b === void 0 ? void 0 : _b.ministry.trim()) !== '' &&
|
24854
|
-
((_d = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails[((_c = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails) === null || _c === void 0 ? void 0 : _c.length) - 1]) === null || _d === void 0 ? void 0 : _d.ministry) &&
|
24855
|
-
((_f = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails[((_e = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails) === null || _e === void 0 ? void 0 : _e.length) - 1]) === null || _f === void 0 ? void 0 : _f.nationalPlanObj.trim()) !==
|
24856
|
-
'' &&
|
24857
|
-
((_h = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails[((_g = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails) === null || _g === void 0 ? void 0 : _g.length) - 1]) === null || _h === void 0 ? void 0 : _h.nationalPlanObj) &&
|
24858
|
-
String((_k = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails[((_j = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails) === null || _j === void 0 ? void 0 : _j.length) - 1]) === null || _k === void 0 ? void 0 : _k.kpi).trim() !== '' &&
|
24859
|
-
String((_m = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails[((_l = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails) === null || _l === void 0 ? void 0 : _l.length) - 1]) === null || _m === void 0 ? void 0 : _m.kpi)) {
|
24860
|
-
onAddNewSubNdcDetail();
|
24861
|
-
}
|
24862
|
-
return ndcDetail.subNdcDetails;
|
24863
|
-
}
|
24864
|
-
else {
|
24865
|
-
return [];
|
24866
|
-
}
|
24867
|
-
};
|
24824
|
+
}); };
|
24868
24825
|
var defaultColumns = [
|
24869
24826
|
{
|
24870
24827
|
title: t("ndc:ndcColumnsNationalPlanObj"),
|
24871
|
-
dataIndex: "
|
24872
|
-
key: "
|
24828
|
+
dataIndex: "nationalPlanObjective",
|
24829
|
+
key: "nationalPlanObjective",
|
24873
24830
|
align: "left",
|
24874
24831
|
editable: true,
|
24875
24832
|
width: "50%",
|
24876
|
-
render: function (_, record) { return (React.createElement(React.Fragment, null, record.
|
24877
|
-
React.createElement("span", null, record.
|
24833
|
+
render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObjective ? (React.createElement(antd.Space, { size: "middle" },
|
24834
|
+
React.createElement("span", null, record.nationalPlanObjective))) : (React.createElement("input", { placeholder: "Please add the National Plan Objective", className: "ant-input", type: "text" })))); },
|
24878
24835
|
},
|
24879
24836
|
{
|
24880
24837
|
title: t("ndc:ndcColumnsKpi"),
|
@@ -24883,18 +24840,18 @@ var NdcDetailsComponent = function (props) {
|
|
24883
24840
|
align: "left",
|
24884
24841
|
editable: true,
|
24885
24842
|
width: "10%",
|
24886
|
-
render: function (_, record) { return (React.createElement(React.Fragment, null, record.
|
24843
|
+
render: function (_, record) { return (React.createElement(React.Fragment, null, record.kpi ? (React.createElement(antd.Space, { size: "middle" },
|
24887
24844
|
React.createElement("span", null, record.kpi))) : (React.createElement("input", { placeholder: "Enter Kpi", className: "ant-input", type: "text" })))); },
|
24888
24845
|
},
|
24889
24846
|
{
|
24890
|
-
title: "
|
24891
|
-
dataIndex: "
|
24892
|
-
key: "
|
24847
|
+
title: "ministryName",
|
24848
|
+
dataIndex: "ministryName",
|
24849
|
+
key: "ministryName",
|
24893
24850
|
align: "left",
|
24894
24851
|
editable: true,
|
24895
24852
|
width: "40%",
|
24896
|
-
render: function (_, record) { return (React.createElement(React.Fragment, null, record.
|
24897
|
-
React.createElement("span", null, record.
|
24853
|
+
render: function (_, record) { return (React.createElement(React.Fragment, null, record.ministryName ? (React.createElement(antd.Space, { size: "middle" },
|
24854
|
+
React.createElement("span", null, record.ministryName))) : (React.createElement("input", { placeholder: "Please add the ministryName name", className: "ant-input", type: "text" })))); },
|
24898
24855
|
},
|
24899
24856
|
];
|
24900
24857
|
var columns = defaultColumns.map(function (col) {
|
@@ -24909,31 +24866,37 @@ var NdcDetailsComponent = function (props) {
|
|
24909
24866
|
handleSave: handleSave,
|
24910
24867
|
}); } });
|
24911
24868
|
});
|
24912
|
-
function
|
24913
|
-
|
24914
|
-
|
24915
|
-
|
24916
|
-
|
24917
|
-
|
24918
|
-
|
24919
|
-
|
24920
|
-
|
24921
|
-
|
24922
|
-
|
24923
|
-
|
24924
|
-
|
24925
|
-
|
24926
|
-
|
24927
|
-
|
24928
|
-
|
24929
|
-
|
24930
|
-
|
24931
|
-
|
24932
|
-
|
24933
|
-
|
24934
|
-
|
24935
|
-
|
24936
|
-
|
24869
|
+
function onClickedAddNewNdcDetail() {
|
24870
|
+
return __awaiter(this, void 0, void 0, function () {
|
24871
|
+
var periodId, newData, response, newlyCreatedNdcAction_1;
|
24872
|
+
return __generator(this, function (_a) {
|
24873
|
+
switch (_a.label) {
|
24874
|
+
case 0:
|
24875
|
+
if (!(selectedPeriod.key !== "add_new")) return [3 /*break*/, 2];
|
24876
|
+
periodId = parseInt(selectedPeriod.key);
|
24877
|
+
newData = {
|
24878
|
+
actionType: NdcActionType.mainAction,
|
24879
|
+
nationalPlanObjective: "",
|
24880
|
+
kpi: 0,
|
24881
|
+
ministryName: governmentMinistry,
|
24882
|
+
periodId: periodId,
|
24883
|
+
status: NdcDetailsActionStatus.pending,
|
24884
|
+
};
|
24885
|
+
return [4 /*yield*/, post("national/programme/addNdcDetailsAction", __assign({}, newData))];
|
24886
|
+
case 1:
|
24887
|
+
response = _a.sent();
|
24888
|
+
if (response && response.data) {
|
24889
|
+
newlyCreatedNdcAction_1 = response.data;
|
24890
|
+
setNdcDetailsData(function (ndcDetailsData) { return __spreadArray(__spreadArray([], ndcDetailsData, true), [
|
24891
|
+
newlyCreatedNdcAction_1,
|
24892
|
+
], false); });
|
24893
|
+
setTableKey(function (key) { return key + 1; });
|
24894
|
+
}
|
24895
|
+
_a.label = 2;
|
24896
|
+
case 2: return [2 /*return*/];
|
24897
|
+
}
|
24898
|
+
});
|
24899
|
+
});
|
24937
24900
|
}
|
24938
24901
|
var components = {
|
24939
24902
|
body: {
|
@@ -24941,346 +24904,155 @@ var NdcDetailsComponent = function (props) {
|
|
24941
24904
|
cell: EditableCell,
|
24942
24905
|
},
|
24943
24906
|
};
|
24944
|
-
|
24945
|
-
|
24946
|
-
return (
|
24947
|
-
|
24948
|
-
|
24949
|
-
|
24950
|
-
|
24951
|
-
|
24952
|
-
|
24953
|
-
|
24954
|
-
|
24955
|
-
|
24956
|
-
|
24957
|
-
// <Table
|
24958
|
-
// components={components}
|
24959
|
-
// rowClassName={() => 'editable-row'}
|
24960
|
-
// bordered
|
24961
|
-
// dataSource={ndcDetailsData}
|
24962
|
-
// columns={columns}
|
24963
|
-
// />
|
24964
|
-
// </div>
|
24965
|
-
);
|
24966
|
-
}
|
24967
|
-
var onCancelPeriod = function () { };
|
24968
|
-
var onAddNewPeriod = function () {
|
24969
|
-
if (selectedPeriod && selectedPeriod.current) {
|
24970
|
-
var newPeriodItem_1 = {
|
24971
|
-
key: "".concat(selectedPeriod.current.start, "-").concat(selectedPeriod.current.end),
|
24972
|
-
label: "".concat(selectedPeriod.current.start, "-").concat(selectedPeriod.current.end),
|
24973
|
-
start: selectedPeriod.current.start,
|
24974
|
-
end: selectedPeriod.current.end,
|
24975
|
-
children: ndcDetailsTableContent(),
|
24976
|
-
};
|
24977
|
-
var existingIndex = periodItemsRef.current.findIndex(function (item) {
|
24978
|
-
return inRange(newPeriodItem_1.start, item.start, item.end) ||
|
24979
|
-
inRange(newPeriodItem_1.end, item.start, item.end);
|
24980
|
-
});
|
24981
|
-
if (existingIndex === -1) {
|
24982
|
-
setPeriodItems(function (items) { return __spreadArray(__spreadArray([], items, true), [newPeriodItem_1], false); });
|
24983
|
-
periodItemsRef.current = __spreadArray(__spreadArray([], periodItemsRef.current, true), [newPeriodItem_1], false);
|
24984
|
-
}
|
24985
|
-
else {
|
24986
|
-
antd.message.open({
|
24987
|
-
type: "error",
|
24988
|
-
content: t("ndc:rangeAlreadyExists"),
|
24989
|
-
duration: 3,
|
24990
|
-
style: { textAlign: "right", marginRight: 15, marginTop: 10 },
|
24991
|
-
});
|
24907
|
+
var onDeletePeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
|
24908
|
+
var result;
|
24909
|
+
return __generator(this, function (_a) {
|
24910
|
+
switch (_a.label) {
|
24911
|
+
case 0: return [4 /*yield*/, post("national/programme/deleteNdcDetailsPeriod", {
|
24912
|
+
id: selectedPeriod.key,
|
24913
|
+
})];
|
24914
|
+
case 1:
|
24915
|
+
result = _a.sent();
|
24916
|
+
if (result) {
|
24917
|
+
fetchNdcDetailPeriods();
|
24918
|
+
}
|
24919
|
+
return [2 /*return*/];
|
24992
24920
|
}
|
24993
|
-
}
|
24921
|
+
});
|
24922
|
+
}); };
|
24923
|
+
var onFinalizePeriod = function () {
|
24924
|
+
//
|
24994
24925
|
};
|
24995
|
-
|
24996
|
-
|
24997
|
-
|
24998
|
-
|
24999
|
-
|
24926
|
+
function ndcDetailsTableContent() {
|
24927
|
+
return (React.createElement("div", null,
|
24928
|
+
React.createElement(antd.Row, null,
|
24929
|
+
React.createElement(antd.Col, { span: 24 },
|
24930
|
+
React.createElement(antd.Table, { key: tableKey, rowKey: "id", components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: ndcMainDetailsForPeriod, columns: columns, expandable: {
|
24931
|
+
expandedRowRender: function (record) { return getSubNdcActionContent(record); },
|
24932
|
+
indentSize: 0,
|
24933
|
+
//defaultExpandedRowKeys: [parseInt(selectedNdcDetail.current.id)],
|
24934
|
+
}, footer: function () {
|
24935
|
+
return isAddNdcActionVisible() && (React.createElement(antd.Row, { justify: "center" },
|
24936
|
+
React.createElement(antd.Button, { onClick: onClickedAddNewNdcDetail, type: "default", style: {
|
24937
|
+
marginBottom: 16,
|
24938
|
+
width: "100%",
|
24939
|
+
} }, t("ndc:addNdcAction"))));
|
24940
|
+
} }))),
|
24941
|
+
React.createElement(antd.Row, { justify: "end" },
|
24942
|
+
React.createElement(antd.Button, { className: "mg-left-1", type: "primary", onClick: onDeletePeriod, htmlType: "submit", loading: loading }, t("ndc:delete")),
|
24943
|
+
React.createElement(antd.Button, { className: "mg-left-1", type: "primary", onClick: onFinalizePeriod, htmlType: "submit", loading: loading }, t("ndc:finalize")))));
|
24944
|
+
}
|
24945
|
+
var onAddNewPeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
|
24946
|
+
var periodItem_1, existingIndex, response, addedPeriodItem, updatedPeriodItem_1;
|
24947
|
+
return __generator(this, function (_a) {
|
24948
|
+
switch (_a.label) {
|
24949
|
+
case 0:
|
24950
|
+
if (!(selectedDateRangeRef && selectedDateRangeRef.current)) return [3 /*break*/, 3];
|
24951
|
+
periodItem_1 = {
|
24952
|
+
startYear: selectedDateRangeRef.current.startYear,
|
24953
|
+
endYear: selectedDateRangeRef.current.endYear,
|
24954
|
+
finalized: false,
|
24955
|
+
};
|
24956
|
+
existingIndex = periodItems.findIndex(function (item) {
|
24957
|
+
return inRange(periodItem_1.startYear, item.startYear, item.endYear) ||
|
24958
|
+
inRange(periodItem_1.endYear, item.startYear, item.endYear);
|
24959
|
+
});
|
24960
|
+
if (!(existingIndex === -1)) return [3 /*break*/, 2];
|
24961
|
+
return [4 /*yield*/, post("national/programme/addNdcDetailsPeriod", __assign({}, periodItem_1))];
|
24962
|
+
case 1:
|
24963
|
+
response = _a.sent();
|
24964
|
+
if (response && response.data) {
|
24965
|
+
addedPeriodItem = response.data;
|
24966
|
+
updatedPeriodItem_1 = __assign(__assign({}, addedPeriodItem), { key: addedPeriodItem.id, label: "".concat(addedPeriodItem.startYear, "-").concat(addedPeriodItem.endYear) });
|
24967
|
+
setPeriodItems(function (items) { return __spreadArray(__spreadArray([], items, true), [updatedPeriodItem_1], false); });
|
24968
|
+
setSelectedPeriod(updatedPeriodItem_1);
|
24969
|
+
}
|
24970
|
+
return [3 /*break*/, 3];
|
24971
|
+
case 2:
|
24972
|
+
antd.message.open({
|
24973
|
+
type: "error",
|
24974
|
+
content: t("ndc:rangeAlreadyExists"),
|
24975
|
+
duration: 3,
|
24976
|
+
style: { textAlign: "right", marginRight: 15, marginTop: 10 },
|
24977
|
+
});
|
24978
|
+
_a.label = 3;
|
24979
|
+
case 3: return [2 /*return*/];
|
24980
|
+
}
|
24981
|
+
});
|
24982
|
+
}); };
|
25000
24983
|
var onDateRangeChanged = function (range) {
|
25001
24984
|
var period = {
|
25002
|
-
|
25003
|
-
|
24985
|
+
startYear: Number(moment(range[0]).year()),
|
24986
|
+
endYear: Number(moment(range[1]).year()),
|
25004
24987
|
};
|
25005
|
-
|
24988
|
+
selectedDateRangeRef.current = period;
|
25006
24989
|
};
|
25007
24990
|
function addNewPeriodContent() {
|
25008
24991
|
return (React.createElement("div", null,
|
25009
|
-
React.createElement(antd.Row,
|
25010
|
-
React.createElement(
|
25011
|
-
|
25012
|
-
React.createElement(
|
25013
|
-
React.createElement(antd.Button, { type: "primary", onClick: onAddNewPeriod, htmlType: "submit", loading: loading }, t("ndc:submit"))
|
25014
|
-
React.createElement(antd.Button, { className: "back-btn", onClick: onCancelPeriod, loading: loading }, t("ndc:back"))))));
|
24992
|
+
React.createElement(antd.Row, { justify: "start", align: "middle", gutter: [16, 16] },
|
24993
|
+
React.createElement(antd.Col, { flex: "340px" },
|
24994
|
+
React.createElement(RangePicker, { onChange: onDateRangeChanged, picker: "year" })),
|
24995
|
+
React.createElement(antd.Col, { flex: "auto" },
|
24996
|
+
React.createElement(antd.Button, { type: "primary", onClick: onAddNewPeriod, htmlType: "submit", loading: loading }, t("ndc:submit"))))));
|
25015
24997
|
}
|
25016
24998
|
function getSubNdcActionContent(record) {
|
25017
24999
|
selectedNdcDetail.current = record;
|
25018
|
-
return (React.createElement(antd.Table, { components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource:
|
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 }));
|
25019
25001
|
}
|
25020
25002
|
var onTabChange = function (key) {
|
25021
|
-
|
25003
|
+
var selectedPeriod = periodItems.find(function (item) { return item.key === key; });
|
25004
|
+
if (selectedPeriod) {
|
25005
|
+
setSelectedPeriod(selectedPeriod);
|
25006
|
+
}
|
25022
25007
|
};
|
25008
|
+
var fetchNdcDetailPeriods = function () { return __awaiter(void 0, void 0, void 0, function () {
|
25009
|
+
var periods, addNewTab, response;
|
25010
|
+
return __generator(this, function (_a) {
|
25011
|
+
switch (_a.label) {
|
25012
|
+
case 0:
|
25013
|
+
periods = [];
|
25014
|
+
addNewTab = {
|
25015
|
+
key: "add_new",
|
25016
|
+
label: "Add New",
|
25017
|
+
startYear: 0,
|
25018
|
+
endYear: 0,
|
25019
|
+
finalized: false,
|
25020
|
+
deleted: false,
|
25021
|
+
};
|
25022
|
+
return [4 /*yield*/, get("national/programme/queryNdcDetailsPeriod")];
|
25023
|
+
case 1:
|
25024
|
+
response = _a.sent();
|
25025
|
+
if (response && response.data) {
|
25026
|
+
periods = response.data.map(function (period) {
|
25027
|
+
return __assign(__assign({}, period), { key: period.id, label: "".concat(period.startYear, "-").concat(period.endYear) });
|
25028
|
+
});
|
25029
|
+
}
|
25030
|
+
if (isAddRangeVisible) {
|
25031
|
+
periods.unshift(addNewTab);
|
25032
|
+
}
|
25033
|
+
setPeriodItems(periods);
|
25034
|
+
setSelectedPeriod(addNewTab);
|
25035
|
+
return [2 /*return*/];
|
25036
|
+
}
|
25037
|
+
});
|
25038
|
+
}); };
|
25039
|
+
var fetchNdcDetailActions = function () { return __awaiter(void 0, void 0, void 0, function () {
|
25040
|
+
var response;
|
25041
|
+
return __generator(this, function (_a) {
|
25042
|
+
switch (_a.label) {
|
25043
|
+
case 0: return [4 /*yield*/, get("national/programme/queryNdcDetailsAction")];
|
25044
|
+
case 1:
|
25045
|
+
response = _a.sent();
|
25046
|
+
if (response && response.data) {
|
25047
|
+
setNdcDetailsData(response.data);
|
25048
|
+
}
|
25049
|
+
return [2 /*return*/];
|
25050
|
+
}
|
25051
|
+
});
|
25052
|
+
}); };
|
25023
25053
|
React.useEffect(function () {
|
25024
|
-
|
25025
|
-
|
25026
|
-
key: 1,
|
25027
|
-
type: NdcActionType.main,
|
25028
|
-
startDate: new Date("2019-03-25"),
|
25029
|
-
endDate: new Date("2020-03-25"),
|
25030
|
-
nationalPlanObj: "Enhance value addition in key growth opportunities",
|
25031
|
-
kpi: 25,
|
25032
|
-
ministry: "Ministry of Environment",
|
25033
|
-
subNdcDetails: [
|
25034
|
-
{
|
25035
|
-
key: 6,
|
25036
|
-
ndcActionId: 1,
|
25037
|
-
type: NdcActionType.sub,
|
25038
|
-
startDate: new Date("2019-03-25"),
|
25039
|
-
endDate: new Date("2020-03-25"),
|
25040
|
-
nationalPlanObj: "Enhance value addition in key growth opportunities sub details",
|
25041
|
-
kpi: 25,
|
25042
|
-
ministry: "Ministry of Agriculture, Water and Forestry (MAWF)",
|
25043
|
-
},
|
25044
|
-
{
|
25045
|
-
key: 7,
|
25046
|
-
ndcActionId: 1,
|
25047
|
-
type: NdcActionType.sub,
|
25048
|
-
startDate: new Date("2019-03-25"),
|
25049
|
-
endDate: new Date("2020-03-25"),
|
25050
|
-
nationalPlanObj: "",
|
25051
|
-
kpi: "",
|
25052
|
-
ministry: "",
|
25053
|
-
},
|
25054
|
-
],
|
25055
|
-
},
|
25056
|
-
{
|
25057
|
-
key: 2,
|
25058
|
-
type: NdcActionType.main,
|
25059
|
-
startDate: new Date("2019-03-25"),
|
25060
|
-
endDate: new Date("2019-08-25"),
|
25061
|
-
nationalPlanObj: "Strengthen the private sector to create 10,000 jobs",
|
25062
|
-
kpi: 10500,
|
25063
|
-
ministry: "Ministry of Environment",
|
25064
|
-
subNdcDetails: [
|
25065
|
-
{
|
25066
|
-
key: 8,
|
25067
|
-
ndcActionId: 2,
|
25068
|
-
type: NdcActionType.sub,
|
25069
|
-
startDate: new Date("2019-03-25"),
|
25070
|
-
endDate: new Date("2020-03-25"),
|
25071
|
-
nationalPlanObj: "",
|
25072
|
-
kpi: "",
|
25073
|
-
ministry: "",
|
25074
|
-
},
|
25075
|
-
],
|
25076
|
-
},
|
25077
|
-
{
|
25078
|
-
key: 12,
|
25079
|
-
type: NdcActionType.main,
|
25080
|
-
startDate: new Date("2019-03-25"),
|
25081
|
-
endDate: new Date("2019-08-25"),
|
25082
|
-
nationalPlanObj: "Other",
|
25083
|
-
kpi: 10500,
|
25084
|
-
ministry: "Ministry of Environment",
|
25085
|
-
subNdcDetails: [
|
25086
|
-
{
|
25087
|
-
key: 8,
|
25088
|
-
ndcActionId: 12,
|
25089
|
-
type: NdcActionType.sub,
|
25090
|
-
startDate: new Date("2019-03-25"),
|
25091
|
-
endDate: new Date("2020-03-25"),
|
25092
|
-
nationalPlanObj: "",
|
25093
|
-
kpi: "",
|
25094
|
-
ministry: "",
|
25095
|
-
},
|
25096
|
-
],
|
25097
|
-
},
|
25098
|
-
{
|
25099
|
-
key: 3,
|
25100
|
-
type: NdcActionType.main,
|
25101
|
-
startDate: new Date("2021-03-25"),
|
25102
|
-
endDate: new Date("2022-03-25"),
|
25103
|
-
nationalPlanObj: "Consolidate and increase the stock and quality of productive infrastructure by 50%",
|
25104
|
-
kpi: 48,
|
25105
|
-
ministry: "Ministry of Environment",
|
25106
|
-
subNdcDetails: [
|
25107
|
-
{
|
25108
|
-
key: 9,
|
25109
|
-
ndcActionId: 3,
|
25110
|
-
type: NdcActionType.sub,
|
25111
|
-
startDate: new Date("2019-03-25"),
|
25112
|
-
endDate: new Date("2020-03-25"),
|
25113
|
-
nationalPlanObj: "",
|
25114
|
-
kpi: "",
|
25115
|
-
ministry: "",
|
25116
|
-
},
|
25117
|
-
],
|
25118
|
-
},
|
25119
|
-
{
|
25120
|
-
key: 4,
|
25121
|
-
type: NdcActionType.main,
|
25122
|
-
startDate: new Date("2022-03-25"),
|
25123
|
-
endDate: new Date("2022-05-25"),
|
25124
|
-
nationalPlanObj: "Enhance the productivity and social wellbeing of the population",
|
25125
|
-
kpi: 20,
|
25126
|
-
ministry: "Ministry of Environment",
|
25127
|
-
subNdcDetails: [
|
25128
|
-
{
|
25129
|
-
key: 10,
|
25130
|
-
ndcActionId: 4,
|
25131
|
-
type: NdcActionType.sub,
|
25132
|
-
startDate: new Date("2019-03-25"),
|
25133
|
-
endDate: new Date("2020-03-25"),
|
25134
|
-
nationalPlanObj: "",
|
25135
|
-
kpi: "",
|
25136
|
-
ministry: "",
|
25137
|
-
},
|
25138
|
-
],
|
25139
|
-
},
|
25140
|
-
{
|
25141
|
-
key: 5,
|
25142
|
-
type: NdcActionType.main,
|
25143
|
-
startDate: new Date("2022-03-25"),
|
25144
|
-
endDate: new Date("2023-03-25"),
|
25145
|
-
nationalPlanObj: "Strengthen the role of the state in guiding and facilitating development",
|
25146
|
-
kpi: 10,
|
25147
|
-
ministry: "Ministry of Environment",
|
25148
|
-
subNdcDetails: [
|
25149
|
-
{
|
25150
|
-
key: 11,
|
25151
|
-
ndcActionId: 5,
|
25152
|
-
type: NdcActionType.sub,
|
25153
|
-
startDate: new Date("2019-03-25"),
|
25154
|
-
endDate: new Date("2020-03-25"),
|
25155
|
-
nationalPlanObj: "",
|
25156
|
-
kpi: "",
|
25157
|
-
ministry: "",
|
25158
|
-
},
|
25159
|
-
],
|
25160
|
-
},
|
25161
|
-
{
|
25162
|
-
key: 13,
|
25163
|
-
type: NdcActionType.main,
|
25164
|
-
startDate: new Date("2022-03-25"),
|
25165
|
-
endDate: new Date("2023-03-25"),
|
25166
|
-
nationalPlanObj: "Convert to solar energy",
|
25167
|
-
kpi: 50000,
|
25168
|
-
ministry: "Ministry of Environment",
|
25169
|
-
subNdcDetails: [
|
25170
|
-
{
|
25171
|
-
key: 11,
|
25172
|
-
ndcActionId: 13,
|
25173
|
-
type: NdcActionType.sub,
|
25174
|
-
startDate: new Date("2019-03-25"),
|
25175
|
-
endDate: new Date("2020-03-25"),
|
25176
|
-
nationalPlanObj: "Convert to solar energy",
|
25177
|
-
kpi: "3000",
|
25178
|
-
ministry: "Ministry of Agriculture, Water and Forestry (MAWF)",
|
25179
|
-
},
|
25180
|
-
{
|
25181
|
-
key: 14,
|
25182
|
-
ndcActionId: 13,
|
25183
|
-
type: NdcActionType.sub,
|
25184
|
-
startDate: new Date("2019-03-25"),
|
25185
|
-
endDate: new Date("2020-03-25"),
|
25186
|
-
nationalPlanObj: "",
|
25187
|
-
kpi: "",
|
25188
|
-
ministry: "",
|
25189
|
-
},
|
25190
|
-
],
|
25191
|
-
},
|
25192
|
-
{
|
25193
|
-
key: 15,
|
25194
|
-
type: NdcActionType.main,
|
25195
|
-
startDate: new Date("2022-03-25"),
|
25196
|
-
endDate: new Date("2023-03-25"),
|
25197
|
-
nationalPlanObj: "Strengthen the private sector to create jobs",
|
25198
|
-
kpi: 10000,
|
25199
|
-
ministry: "Ministry of Environment",
|
25200
|
-
subNdcDetails: [
|
25201
|
-
{
|
25202
|
-
key: 16,
|
25203
|
-
ndcActionId: 15,
|
25204
|
-
type: NdcActionType.sub,
|
25205
|
-
startDate: new Date("2019-03-25"),
|
25206
|
-
endDate: new Date("2020-03-25"),
|
25207
|
-
nationalPlanObj: "Strengthen the private sector to create jobs",
|
25208
|
-
kpi: "7200",
|
25209
|
-
ministry: "Ministry of Tourism (MoT)",
|
25210
|
-
},
|
25211
|
-
{
|
25212
|
-
key: 17,
|
25213
|
-
ndcActionId: 15,
|
25214
|
-
type: NdcActionType.sub,
|
25215
|
-
startDate: new Date("2019-03-25"),
|
25216
|
-
endDate: new Date("2020-03-25"),
|
25217
|
-
nationalPlanObj: "",
|
25218
|
-
kpi: "",
|
25219
|
-
ministry: "",
|
25220
|
-
},
|
25221
|
-
],
|
25222
|
-
},
|
25223
|
-
{
|
25224
|
-
key: 18,
|
25225
|
-
type: NdcActionType.main,
|
25226
|
-
startDate: new Date("2022-03-25"),
|
25227
|
-
endDate: new Date("2023-03-25"),
|
25228
|
-
nationalPlanObj: "Other",
|
25229
|
-
kpi: '',
|
25230
|
-
ministry: "Ministry of Environment",
|
25231
|
-
subNdcDetails: [
|
25232
|
-
{
|
25233
|
-
key: 19,
|
25234
|
-
ndcActionId: 18,
|
25235
|
-
type: NdcActionType.sub,
|
25236
|
-
startDate: new Date("2019-03-25"),
|
25237
|
-
endDate: new Date("2020-03-25"),
|
25238
|
-
nationalPlanObj: "Strengthen the private sector to create jobs",
|
25239
|
-
kpi: "",
|
25240
|
-
ministry: "Ministry of Agriculture, Water and Forestry (MAWF)",
|
25241
|
-
},
|
25242
|
-
{
|
25243
|
-
key: 20,
|
25244
|
-
ndcActionId: 18,
|
25245
|
-
type: NdcActionType.sub,
|
25246
|
-
startDate: new Date("2019-03-25"),
|
25247
|
-
endDate: new Date("2020-03-25"),
|
25248
|
-
nationalPlanObj: "",
|
25249
|
-
kpi: "",
|
25250
|
-
ministry: "",
|
25251
|
-
},
|
25252
|
-
],
|
25253
|
-
},
|
25254
|
-
];
|
25255
|
-
var initialPeriods = [
|
25256
|
-
{
|
25257
|
-
key: "2019-2020",
|
25258
|
-
label: "2019-2020",
|
25259
|
-
start: 2019,
|
25260
|
-
end: 2020,
|
25261
|
-
children: ndcDetailsTableContent(),
|
25262
|
-
},
|
25263
|
-
{
|
25264
|
-
key: "2021-2023",
|
25265
|
-
label: "2021-2023",
|
25266
|
-
start: 2021,
|
25267
|
-
end: 2021,
|
25268
|
-
children: ndcDetailsTableContent(),
|
25269
|
-
},
|
25270
|
-
];
|
25271
|
-
if (isAddRangeVisible()) {
|
25272
|
-
initialPeriods.unshift({
|
25273
|
-
key: "add_new",
|
25274
|
-
label: "Add New",
|
25275
|
-
start: 0,
|
25276
|
-
end: 0,
|
25277
|
-
children: addNewPeriodContent(),
|
25278
|
-
});
|
25279
|
-
}
|
25280
|
-
addedNdcDetailId.current = 20;
|
25281
|
-
setPeriodItems(initialPeriods);
|
25282
|
-
periodItemsRef.current = initialPeriods;
|
25283
|
-
setNdcDetailsData(defaultNdcDetails);
|
25054
|
+
fetchNdcDetailPeriods();
|
25055
|
+
fetchNdcDetailActions();
|
25284
25056
|
}, []);
|
25285
25057
|
return (React.createElement("div", { className: "ndc-management content-container" },
|
25286
25058
|
React.createElement("div", { className: "title-bar" },
|
@@ -25289,20 +25061,10 @@ var NdcDetailsComponent = function (props) {
|
|
25289
25061
|
React.createElement("div", { className: "body-title" }, t("ndc:ndcTitle")),
|
25290
25062
|
React.createElement("div", { className: "body-sub-title" }, t("ndc:ndcSubTitle"))))),
|
25291
25063
|
React.createElement("div", null,
|
25292
|
-
React.createElement(antd.Tabs, { centered: false, defaultActiveKey: "1", items: periodItems, activeKey:
|
25293
|
-
|
25294
|
-
|
25295
|
-
|
25296
|
-
expandedRowRender: function (record) { return getSubNdcActionContent(record); },
|
25297
|
-
indentSize: 0,
|
25298
|
-
defaultExpandedRowKeys: [selectedNdcDetail.current.key],
|
25299
|
-
}, footer: function () {
|
25300
|
-
return isAddNdcActionVisible() && (React.createElement(antd.Row, { justify: "center" },
|
25301
|
-
React.createElement(antd.Button, { onClick: onAddNewNdcDetail, type: "default", style: {
|
25302
|
-
marginBottom: 16,
|
25303
|
-
width: "100%",
|
25304
|
-
} }, t("ndc:addNdcAction"))));
|
25305
|
-
} }))))));
|
25064
|
+
React.createElement(antd.Tabs, { centered: false, defaultActiveKey: "1", items: periodItems, activeKey: selectedPeriod.key, onChange: onTabChange })),
|
25065
|
+
React.createElement("div", null, selectedPeriod.key === "add_new"
|
25066
|
+
? addNewPeriodContent()
|
25067
|
+
: ndcDetailsTableContent())));
|
25306
25068
|
};
|
25307
25069
|
|
25308
25070
|
var ImgWithFallback = function (_a) {
|