@undp/carbon-library 1.0.163 → 1.0.164

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.
package/dist/cjs/index.js CHANGED
@@ -24615,36 +24615,61 @@ var NdcDetailsComponent = function (props) {
24615
24615
  var inRange = function (num, min, max) {
24616
24616
  return num >= min && num <= max;
24617
24617
  };
24618
- var handleSave = function (row) {
24619
- if (row.type === NdcActionType.main) {
24620
- var newData = __spreadArray([], ndcDetailsData, true);
24621
- var index = newData.findIndex(function (item) { return row.key === item.key; });
24622
- var item = newData[index];
24623
- newData.splice(index, 1, __assign(__assign({}, item), row));
24624
- setNdcDetailsData(newData);
24618
+ function onAddNewSubNdcDetail() {
24619
+ var range = selectedTab.split('-');
24620
+ var ndcDetail = ndcDetailsData.find(function (item) { return item.key === selectedNdcDetail.current.key; });
24621
+ var ndcDetailItemIndex = ndcDetailsData.findIndex(function (item) { return item.key === selectedNdcDetail.current.key; });
24622
+ if (ndcDetail) {
24623
+ addedNdcDetailId.current = addedNdcDetailId.current + 1;
24624
+ var newData = {
24625
+ key: addedNdcDetailId.current,
24626
+ startDate: new Date("".concat(Number(range[0]), "-01-24 23:12:00")),
24627
+ endDate: new Date("".concat(Number(range[0]), "-12-24 23:12:00")),
24628
+ ndcActionId: ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.key,
24629
+ nationalPlanObj: '',
24630
+ kpi: '',
24631
+ ministry: '',
24632
+ };
24633
+ if (!ndcDetail.subNdcDetails) {
24634
+ ndcDetail.subNdcDetails = [];
24635
+ }
24636
+ ndcDetail.subNdcDetails.push(newData);
24625
24637
  }
24626
- else {
24627
- var newData = __spreadArray([], ndcDetailsData, true);
24628
- var parentIndex = newData.findIndex(function (item) { return row.ndcActionId === item.key; });
24629
- var parentItem = newData[parentIndex];
24630
- if (parentItem) {
24631
- if (parentItem.subNdcDetails) {
24632
- var itemIndex = parentItem.subNdcDetails.findIndex(function (item) { return row.key === item.key; });
24633
- if (itemIndex === -1) {
24634
- parentItem.subNdcDetails.push(row);
24638
+ ndcDetailsData[ndcDetailItemIndex] = ndcDetail;
24639
+ setNdcDetailsData(ndcDetailsData);
24640
+ setTableKey(function (key) { return key + 1; });
24641
+ }
24642
+ var handleSave = function (row) {
24643
+ setNdcDetailsData(function (prevData) {
24644
+ var newData = JSON.parse(JSON.stringify(prevData));
24645
+ if (row.type === NdcActionType.main) {
24646
+ var index = newData.findIndex(function (item) { return row.key === item.key; });
24647
+ if (index !== -1) {
24648
+ newData[index] = __assign(__assign({}, newData[index]), row);
24649
+ }
24650
+ }
24651
+ else {
24652
+ var parentIndex = newData.findIndex(function (item) { return row.ndcActionId === item.key; });
24653
+ var parentItem = newData[parentIndex];
24654
+ if (parentItem) {
24655
+ if (parentItem.subNdcDetails) {
24656
+ var itemIndex = parentItem.subNdcDetails.findIndex(function (item) { return row.key === item.key; });
24657
+ if (itemIndex === -1) {
24658
+ parentItem.subNdcDetails.push(row);
24659
+ }
24660
+ else {
24661
+ parentItem.subNdcDetails[itemIndex] = __assign({}, row);
24662
+ }
24635
24663
  }
24636
24664
  else {
24637
- parentItem.subNdcDetails.splice(itemIndex, 1, __assign({}, row));
24665
+ parentItem.subNdcDetails = [row];
24638
24666
  }
24639
24667
  }
24640
- else {
24641
- parentItem.subNdcDetails = [row];
24642
- }
24668
+ newData[parentIndex] = __assign({}, parentItem);
24669
+ setTableKey(function (key) { return key + 1; });
24643
24670
  }
24644
- newData.splice(parentIndex, 1, __assign({}, parentItem));
24645
- setNdcDetailsData(newData);
24646
- setTableKey(function (key) { return key + 1; });
24647
- }
24671
+ return newData;
24672
+ });
24648
24673
  };
24649
24674
  var getNdcDetailsForPeriod = function () {
24650
24675
  var range = selectedTab.split("-");
@@ -24659,8 +24684,18 @@ var NdcDetailsComponent = function (props) {
24659
24684
  }
24660
24685
  };
24661
24686
  var getSubNdcDetails = function (key) {
24687
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
24662
24688
  var ndcDetail = ndcDetailsData.find(function (item) { return item.key === key; });
24663
24689
  if (ndcDetail) {
24690
+ 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()) !== '' &&
24691
+ ((_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) &&
24692
+ ((_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()) !==
24693
+ '' &&
24694
+ ((_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) &&
24695
+ 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() !== '' &&
24696
+ 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)) {
24697
+ onAddNewSubNdcDetail();
24698
+ }
24664
24699
  return ndcDetail.subNdcDetails;
24665
24700
  }
24666
24701
  else {
@@ -24676,7 +24711,7 @@ var NdcDetailsComponent = function (props) {
24676
24711
  editable: true,
24677
24712
  width: "50%",
24678
24713
  render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(antd.Space, { size: "middle" },
24679
- React.createElement("span", null, record.nationalPlanObj))) : (React.createElement("input", { placeholder: "Please add the National Plan Objective", className: "ant-input", disabled: true, type: "text" })))); },
24714
+ React.createElement("span", null, record.nationalPlanObj))) : (React.createElement("input", { placeholder: "Please add the National Plan Objective", className: "ant-input", type: "text" })))); },
24680
24715
  },
24681
24716
  {
24682
24717
  title: t("ndc:ndcColumnsKpi"),
@@ -24686,7 +24721,7 @@ var NdcDetailsComponent = function (props) {
24686
24721
  editable: true,
24687
24722
  width: "10%",
24688
24723
  render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(antd.Space, { size: "middle" },
24689
- React.createElement("span", null, record.kpi))) : (React.createElement("input", { placeholder: "Enter Kpi", className: "ant-input", disabled: true, type: "text" })))); },
24724
+ React.createElement("span", null, record.kpi))) : (React.createElement("input", { placeholder: "Enter Kpi", className: "ant-input", type: "text" })))); },
24690
24725
  },
24691
24726
  {
24692
24727
  title: "Ministry",
@@ -24696,7 +24731,7 @@ var NdcDetailsComponent = function (props) {
24696
24731
  editable: true,
24697
24732
  width: "40%",
24698
24733
  render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(antd.Space, { size: "middle" },
24699
- React.createElement("span", null, record.ministry))) : (React.createElement("input", { placeholder: "Please add the Ministry name", className: "ant-input", disabled: true, type: "text" })))); },
24734
+ React.createElement("span", null, record.ministry))) : (React.createElement("input", { placeholder: "Please add the Ministry name", className: "ant-input", type: "text" })))); },
24700
24735
  },
24701
24736
  ];
24702
24737
  var columns = defaultColumns.map(function (col) {