@undp/carbon-library 1.0.162 → 1.0.163-ndc-action-add-table-fixes.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/index.js +62 -27
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +62 -27
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
@@ -24524,36 +24524,61 @@ var NdcDetailsComponent = function (props) {
|
|
24524
24524
|
var inRange = function (num, min, max) {
|
24525
24525
|
return num >= min && num <= max;
|
24526
24526
|
};
|
24527
|
-
|
24528
|
-
|
24529
|
-
|
24530
|
-
|
24531
|
-
|
24532
|
-
|
24533
|
-
|
24527
|
+
function onAddNewSubNdcDetail() {
|
24528
|
+
var range = selectedTab.split('-');
|
24529
|
+
var ndcDetail = ndcDetailsData.find(function (item) { return item.key === selectedNdcDetail.current.key; });
|
24530
|
+
var ndcDetailItemIndex = ndcDetailsData.findIndex(function (item) { return item.key === selectedNdcDetail.current.key; });
|
24531
|
+
if (ndcDetail) {
|
24532
|
+
addedNdcDetailId.current = addedNdcDetailId.current + 1;
|
24533
|
+
var newData = {
|
24534
|
+
key: addedNdcDetailId.current,
|
24535
|
+
startDate: new Date("".concat(Number(range[0]), "-01-24 23:12:00")),
|
24536
|
+
endDate: new Date("".concat(Number(range[0]), "-12-24 23:12:00")),
|
24537
|
+
ndcActionId: ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.key,
|
24538
|
+
nationalPlanObj: '',
|
24539
|
+
kpi: '',
|
24540
|
+
ministry: '',
|
24541
|
+
};
|
24542
|
+
if (!ndcDetail.subNdcDetails) {
|
24543
|
+
ndcDetail.subNdcDetails = [];
|
24544
|
+
}
|
24545
|
+
ndcDetail.subNdcDetails.push(newData);
|
24534
24546
|
}
|
24535
|
-
|
24536
|
-
|
24537
|
-
|
24538
|
-
|
24539
|
-
|
24540
|
-
|
24541
|
-
|
24542
|
-
|
24543
|
-
|
24547
|
+
ndcDetailsData[ndcDetailItemIndex] = ndcDetail;
|
24548
|
+
setNdcDetailsData(ndcDetailsData);
|
24549
|
+
setTableKey(function (key) { return key + 1; });
|
24550
|
+
}
|
24551
|
+
var handleSave = function (row) {
|
24552
|
+
setNdcDetailsData(function (prevData) {
|
24553
|
+
var newData = JSON.parse(JSON.stringify(prevData));
|
24554
|
+
if (row.type === NdcActionType.main) {
|
24555
|
+
var index = newData.findIndex(function (item) { return row.key === item.key; });
|
24556
|
+
if (index !== -1) {
|
24557
|
+
newData[index] = __assign(__assign({}, newData[index]), row);
|
24558
|
+
}
|
24559
|
+
}
|
24560
|
+
else {
|
24561
|
+
var parentIndex = newData.findIndex(function (item) { return row.ndcActionId === item.key; });
|
24562
|
+
var parentItem = newData[parentIndex];
|
24563
|
+
if (parentItem) {
|
24564
|
+
if (parentItem.subNdcDetails) {
|
24565
|
+
var itemIndex = parentItem.subNdcDetails.findIndex(function (item) { return row.key === item.key; });
|
24566
|
+
if (itemIndex === -1) {
|
24567
|
+
parentItem.subNdcDetails.push(row);
|
24568
|
+
}
|
24569
|
+
else {
|
24570
|
+
parentItem.subNdcDetails[itemIndex] = __assign({}, row);
|
24571
|
+
}
|
24544
24572
|
}
|
24545
24573
|
else {
|
24546
|
-
parentItem.subNdcDetails
|
24574
|
+
parentItem.subNdcDetails = [row];
|
24547
24575
|
}
|
24548
24576
|
}
|
24549
|
-
|
24550
|
-
|
24551
|
-
}
|
24577
|
+
newData[parentIndex] = __assign({}, parentItem);
|
24578
|
+
setTableKey(function (key) { return key + 1; });
|
24552
24579
|
}
|
24553
|
-
newData
|
24554
|
-
|
24555
|
-
setTableKey(function (key) { return key + 1; });
|
24556
|
-
}
|
24580
|
+
return newData;
|
24581
|
+
});
|
24557
24582
|
};
|
24558
24583
|
var getNdcDetailsForPeriod = function () {
|
24559
24584
|
var range = selectedTab.split("-");
|
@@ -24568,8 +24593,18 @@ var NdcDetailsComponent = function (props) {
|
|
24568
24593
|
}
|
24569
24594
|
};
|
24570
24595
|
var getSubNdcDetails = function (key) {
|
24596
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
24571
24597
|
var ndcDetail = ndcDetailsData.find(function (item) { return item.key === key; });
|
24572
24598
|
if (ndcDetail) {
|
24599
|
+
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()) !== '' &&
|
24600
|
+
((_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) &&
|
24601
|
+
((_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()) !==
|
24602
|
+
'' &&
|
24603
|
+
((_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) &&
|
24604
|
+
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() !== '' &&
|
24605
|
+
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)) {
|
24606
|
+
onAddNewSubNdcDetail();
|
24607
|
+
}
|
24573
24608
|
return ndcDetail.subNdcDetails;
|
24574
24609
|
}
|
24575
24610
|
else {
|
@@ -24585,7 +24620,7 @@ var NdcDetailsComponent = function (props) {
|
|
24585
24620
|
editable: true,
|
24586
24621
|
width: "50%",
|
24587
24622
|
render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(Space, { size: "middle" },
|
24588
|
-
React.createElement("span", null, record.nationalPlanObj))) : (React.createElement("input", { placeholder: "Please add the National Plan Objective", className: "ant-input",
|
24623
|
+
React.createElement("span", null, record.nationalPlanObj))) : (React.createElement("input", { placeholder: "Please add the National Plan Objective", className: "ant-input", type: "text" })))); },
|
24589
24624
|
},
|
24590
24625
|
{
|
24591
24626
|
title: t("ndc:ndcColumnsKpi"),
|
@@ -24595,7 +24630,7 @@ var NdcDetailsComponent = function (props) {
|
|
24595
24630
|
editable: true,
|
24596
24631
|
width: "10%",
|
24597
24632
|
render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(Space, { size: "middle" },
|
24598
|
-
React.createElement("span", null, record.kpi))) : (React.createElement("input", { placeholder: "Enter Kpi", className: "ant-input",
|
24633
|
+
React.createElement("span", null, record.kpi))) : (React.createElement("input", { placeholder: "Enter Kpi", className: "ant-input", type: "text" })))); },
|
24599
24634
|
},
|
24600
24635
|
{
|
24601
24636
|
title: "Ministry",
|
@@ -24605,7 +24640,7 @@ var NdcDetailsComponent = function (props) {
|
|
24605
24640
|
editable: true,
|
24606
24641
|
width: "40%",
|
24607
24642
|
render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(Space, { size: "middle" },
|
24608
|
-
React.createElement("span", null, record.ministry))) : (React.createElement("input", { placeholder: "Please add the Ministry name", className: "ant-input",
|
24643
|
+
React.createElement("span", null, record.ministry))) : (React.createElement("input", { placeholder: "Please add the Ministry name", className: "ant-input", type: "text" })))); },
|
24609
24644
|
},
|
24610
24645
|
];
|
24611
24646
|
var columns = defaultColumns.map(function (col) {
|