@undp/carbon-library 1.0.151-NAM-4.0 → 1.0.152-CARBON-343.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/cjs/index.js CHANGED
@@ -24492,7 +24492,7 @@ var EditableCell = function (_a) {
24492
24492
  return [3 /*break*/, 3];
24493
24493
  case 2:
24494
24494
  errInfo_1 = _a.sent();
24495
- console.log('Save failed:', errInfo_1);
24495
+ console.log("Save failed:", errInfo_1);
24496
24496
  return [3 /*break*/, 3];
24497
24497
  case 3: return [2 /*return*/];
24498
24498
  }
@@ -24506,7 +24506,7 @@ var EditableCell = function (_a) {
24506
24506
  message: "".concat(title, " is required."),
24507
24507
  },
24508
24508
  ] },
24509
- React.createElement(antd.Input, { ref: inputRef, onPressEnter: save, onBlur: save }))) : (React.createElement("div", { className: "editable-cell-value-wrap", style: { paddingRight: 24 }, onClick: toggleEdit }, children));
24509
+ 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));
24510
24510
  }
24511
24511
  return React.createElement("td", __assign({}, restProps), childNode);
24512
24512
  };
@@ -24514,6 +24514,11 @@ var EditableCell = function (_a) {
24514
24514
  var css_248z$4 = ".ndc-steps-actions {\n display: flex;\n flex-direction: row-reverse;\n margin-right: 1rem;\n justify-content: center; }\n .ndc-steps-actions .action-btn {\n border: 1px solid #16b1ff;\n color: #16b1ff;\n margin-right: 1rem; }\n .ndc-steps-actions .back-btn {\n border: 1px solid rgba(140, 140, 140, 0.7);\n color: rgba(140, 140, 140, 0.7);\n margin-right: 1rem; }\n .ndc-steps-actions .mg-left-1 {\n margin-left: 1rem; }\n";
24515
24515
  styleInject(css_248z$4);
24516
24516
 
24517
+ var NdcActionType;
24518
+ (function (NdcActionType) {
24519
+ NdcActionType[NdcActionType["main"] = 0] = "main";
24520
+ NdcActionType[NdcActionType["sub"] = 1] = "sub";
24521
+ })(NdcActionType || (NdcActionType = {}));
24517
24522
  var NdcDetailsComponent = function (props) {
24518
24523
  var t = props.t; props.useConnection; var useUserContext = props.useUserContext;
24519
24524
  var RangePicker = antd.DatePicker.RangePicker;
@@ -24536,19 +24541,39 @@ var NdcDetailsComponent = function (props) {
24536
24541
  return ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT &&
24537
24542
  (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly);
24538
24543
  };
24539
- var isAddSubNdcActionVisible = function () {
24540
- return ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY &&
24541
- (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly);
24542
- };
24543
24544
  var inRange = function (num, min, max) {
24544
24545
  return num >= min && num <= max;
24545
24546
  };
24546
24547
  var handleSave = function (row) {
24547
- var newData = __spreadArray([], ndcDetailsData, true);
24548
- var index = newData.findIndex(function (item) { return row.key === item.key; });
24549
- var item = newData[index];
24550
- newData.splice(index, 1, __assign(__assign({}, item), row));
24551
- setNdcDetailsData(newData);
24548
+ if (row.type === NdcActionType.main) {
24549
+ var newData = __spreadArray([], ndcDetailsData, true);
24550
+ var index = newData.findIndex(function (item) { return row.key === item.key; });
24551
+ var item = newData[index];
24552
+ newData.splice(index, 1, __assign(__assign({}, item), row));
24553
+ setNdcDetailsData(newData);
24554
+ }
24555
+ else {
24556
+ var newData = __spreadArray([], ndcDetailsData, true);
24557
+ var parentIndex = newData.findIndex(function (item) { return row.ndcActionId === item.key; });
24558
+ var parentItem = newData[parentIndex];
24559
+ if (parentItem) {
24560
+ if (parentItem.subNdcDetails) {
24561
+ var itemIndex = parentItem.subNdcDetails.findIndex(function (item) { return row.key === item.key; });
24562
+ if (itemIndex === -1) {
24563
+ parentItem.subNdcDetails.push(row);
24564
+ }
24565
+ else {
24566
+ parentItem.subNdcDetails.splice(itemIndex, 1, __assign({}, row));
24567
+ }
24568
+ }
24569
+ else {
24570
+ parentItem.subNdcDetails = [row];
24571
+ }
24572
+ }
24573
+ newData.splice(parentIndex, 1, __assign({}, parentItem));
24574
+ setNdcDetailsData(newData);
24575
+ setTableKey(function (key) { return key + 1; });
24576
+ }
24552
24577
  };
24553
24578
  var getNdcDetailsForPeriod = function () {
24554
24579
  var range = selectedTab.split("-");
@@ -24578,6 +24603,7 @@ var NdcDetailsComponent = function (props) {
24578
24603
  key: "nationalPlanObj",
24579
24604
  align: "left",
24580
24605
  editable: true,
24606
+ width: 800,
24581
24607
  },
24582
24608
  {
24583
24609
  title: t("ndc:ndcColumnsKpi"),
@@ -24585,6 +24611,7 @@ var NdcDetailsComponent = function (props) {
24585
24611
  key: "kpi",
24586
24612
  align: "left",
24587
24613
  editable: true,
24614
+ width: 100,
24588
24615
  },
24589
24616
  {
24590
24617
  title: "Ministry",
@@ -24608,40 +24635,30 @@ var NdcDetailsComponent = function (props) {
24608
24635
  });
24609
24636
  function onAddNewNdcDetail() {
24610
24637
  var range = selectedTab.split("-");
24611
- addedNdcDetailId.current = addedNdcDetailId.current + 1;
24638
+ var ndcActionId = ++addedNdcDetailId.current;
24612
24639
  var newData = {
24613
- key: addedNdcDetailId.current,
24640
+ key: ndcActionId,
24641
+ type: NdcActionType.main,
24614
24642
  startDate: new Date("".concat(Number(range[0]), "-01-24 23:12:00")),
24615
24643
  endDate: new Date("".concat(Number(range[0]), "-12-24 23:12:00")),
24616
24644
  nationalPlanObj: t("ndc:enterNewPlanTxt"),
24617
24645
  kpi: 0,
24618
24646
  ministry: "Please add the Ministry name",
24647
+ subNdcDetails: [
24648
+ {
24649
+ key: ++addedNdcDetailId.current,
24650
+ ndcActionId: ndcActionId,
24651
+ type: NdcActionType.sub,
24652
+ startDate: new Date("2019-03-25"),
24653
+ endDate: new Date("2020-03-25"),
24654
+ nationalPlanObj: "",
24655
+ kpi: "",
24656
+ ministry: "",
24657
+ },
24658
+ ],
24619
24659
  };
24620
24660
  setNdcDetailsData(__spreadArray(__spreadArray([], ndcDetailsData, true), [newData], false));
24621
24661
  }
24622
- function onAddNewSubNdcDetail() {
24623
- var range = selectedTab.split("-");
24624
- var ndcDetail = ndcDetailsData.find(function (item) { return item.key === selectedNdcDetail.current.key; });
24625
- var ndcDetailItemIndex = ndcDetailsData.findIndex(function (item) { return item.key === selectedNdcDetail.current.key; });
24626
- if (ndcDetail) {
24627
- addedNdcDetailId.current = addedNdcDetailId.current + 1;
24628
- var newData = {
24629
- key: addedNdcDetailId.current,
24630
- startDate: new Date("".concat(Number(range[0]), "-01-24 23:12:00")),
24631
- endDate: new Date("".concat(Number(range[0]), "-12-24 23:12:00")),
24632
- nationalPlanObj: t("ndc:enterNewPlanTxt"),
24633
- kpi: 0,
24634
- ministry: "Please add the Ministry name",
24635
- };
24636
- if (!ndcDetail.subNdcDetails) {
24637
- ndcDetail.subNdcDetails = [];
24638
- }
24639
- ndcDetail.subNdcDetails.push(newData);
24640
- }
24641
- ndcDetailsData[ndcDetailItemIndex] = ndcDetail;
24642
- setNdcDetailsData(ndcDetailsData);
24643
- setTableKey(function (key) { return key + 1; });
24644
- }
24645
24662
  var components = {
24646
24663
  body: {
24647
24664
  row: EditableRow,
@@ -24722,13 +24739,7 @@ var NdcDetailsComponent = function (props) {
24722
24739
  }
24723
24740
  function getSubNdcActionContent(record) {
24724
24741
  selectedNdcDetail.current = record;
24725
- return (React.createElement(antd.Table, { components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getSubNdcDetails(record.key), columns: columns, showHeader: false, pagination: false, footer: function () {
24726
- return isAddSubNdcActionVisible() && (React.createElement(antd.Row, { justify: "center" },
24727
- React.createElement(antd.Button, { onClick: onAddNewSubNdcDetail, type: "default", style: {
24728
- marginBottom: 16,
24729
- width: "100%",
24730
- } }, t("ndc:addSubNdcAction"))));
24731
- } }));
24742
+ return (React.createElement(antd.Table, { components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getSubNdcDetails(record.key), columns: columns, showHeader: false, pagination: false }));
24732
24743
  }
24733
24744
  var onTabChange = function (key) {
24734
24745
  setSelectedTab(key);
@@ -24737,53 +24748,160 @@ var NdcDetailsComponent = function (props) {
24737
24748
  var defaultNdcDetails = [
24738
24749
  {
24739
24750
  key: 1,
24751
+ type: NdcActionType.main,
24740
24752
  startDate: new Date("2019-03-25"),
24741
24753
  endDate: new Date("2020-03-25"),
24742
24754
  nationalPlanObj: "Enhance value addition in key growth opportunities",
24743
24755
  kpi: 25,
24744
- ministry: "Ministry of Agriculture, Water and Forestry (MAWF)",
24756
+ ministry: "Ministry of Environment",
24745
24757
  subNdcDetails: [
24746
24758
  {
24747
24759
  key: 6,
24760
+ ndcActionId: 1,
24761
+ type: NdcActionType.sub,
24748
24762
  startDate: new Date("2019-03-25"),
24749
24763
  endDate: new Date("2020-03-25"),
24750
24764
  nationalPlanObj: "Enhance value addition in key growth opportunities sub details",
24751
24765
  kpi: 25,
24752
24766
  ministry: "Ministry of Agriculture, Water and Forestry (MAWF)",
24753
24767
  },
24768
+ {
24769
+ key: 7,
24770
+ ndcActionId: 1,
24771
+ type: NdcActionType.sub,
24772
+ startDate: new Date("2019-03-25"),
24773
+ endDate: new Date("2020-03-25"),
24774
+ nationalPlanObj: "",
24775
+ kpi: "",
24776
+ ministry: "",
24777
+ },
24754
24778
  ],
24755
24779
  },
24756
24780
  {
24757
24781
  key: 2,
24782
+ type: NdcActionType.main,
24758
24783
  startDate: new Date("2019-03-25"),
24759
24784
  endDate: new Date("2019-08-25"),
24760
24785
  nationalPlanObj: "Strengthen the private sector to create 10,000 jobs",
24761
24786
  kpi: 10500,
24762
- ministry: "Ministry of Tourism (MoT)",
24787
+ ministry: "Ministry of Environment",
24788
+ subNdcDetails: [
24789
+ {
24790
+ key: 8,
24791
+ ndcActionId: 2,
24792
+ type: NdcActionType.sub,
24793
+ startDate: new Date("2019-03-25"),
24794
+ endDate: new Date("2020-03-25"),
24795
+ nationalPlanObj: "",
24796
+ kpi: "",
24797
+ ministry: "",
24798
+ },
24799
+ ],
24800
+ },
24801
+ {
24802
+ key: 12,
24803
+ type: NdcActionType.main,
24804
+ startDate: new Date("2019-03-25"),
24805
+ endDate: new Date("2019-08-25"),
24806
+ nationalPlanObj: "Other",
24807
+ kpi: 10500,
24808
+ ministry: "Ministry of Environment",
24809
+ subNdcDetails: [
24810
+ {
24811
+ key: 8,
24812
+ ndcActionId: 12,
24813
+ type: NdcActionType.sub,
24814
+ startDate: new Date("2019-03-25"),
24815
+ endDate: new Date("2020-03-25"),
24816
+ nationalPlanObj: "",
24817
+ kpi: "",
24818
+ ministry: "",
24819
+ },
24820
+ ],
24763
24821
  },
24764
24822
  {
24765
24823
  key: 3,
24824
+ type: NdcActionType.main,
24766
24825
  startDate: new Date("2021-03-25"),
24767
24826
  endDate: new Date("2022-03-25"),
24768
24827
  nationalPlanObj: "Consolidate and increase the stock and quality of productive infrastructure by 50%",
24769
24828
  kpi: 48,
24770
- ministry: "Ministry of Education, Arts and Culture (MoE)",
24829
+ ministry: "Ministry of Environment",
24830
+ subNdcDetails: [
24831
+ {
24832
+ key: 9,
24833
+ ndcActionId: 3,
24834
+ type: NdcActionType.sub,
24835
+ startDate: new Date("2019-03-25"),
24836
+ endDate: new Date("2020-03-25"),
24837
+ nationalPlanObj: "",
24838
+ kpi: "",
24839
+ ministry: "",
24840
+ },
24841
+ ],
24771
24842
  },
24772
24843
  {
24773
24844
  key: 4,
24845
+ type: NdcActionType.main,
24774
24846
  startDate: new Date("2022-03-25"),
24775
24847
  endDate: new Date("2022-05-25"),
24776
24848
  nationalPlanObj: "Enhance the productivity and social wellbeing of the population",
24777
24849
  kpi: 20,
24778
- ministry: "Ministry of Environment, Forestry and Tourism (MEFT)",
24850
+ ministry: "Ministry of Environment",
24851
+ subNdcDetails: [
24852
+ {
24853
+ key: 10,
24854
+ ndcActionId: 4,
24855
+ type: NdcActionType.sub,
24856
+ startDate: new Date("2019-03-25"),
24857
+ endDate: new Date("2020-03-25"),
24858
+ nationalPlanObj: "",
24859
+ kpi: "",
24860
+ ministry: "",
24861
+ },
24862
+ ],
24779
24863
  },
24780
24864
  {
24781
24865
  key: 5,
24866
+ type: NdcActionType.main,
24782
24867
  startDate: new Date("2022-03-25"),
24783
24868
  endDate: new Date("2023-03-25"),
24784
24869
  nationalPlanObj: "Strengthen the role of the state in guiding and facilitating development",
24785
24870
  kpi: 10,
24786
- ministry: "Ministry of Tourism (MoT)",
24871
+ ministry: "Ministry of Environment",
24872
+ subNdcDetails: [
24873
+ {
24874
+ key: 11,
24875
+ ndcActionId: 5,
24876
+ type: NdcActionType.sub,
24877
+ startDate: new Date("2019-03-25"),
24878
+ endDate: new Date("2020-03-25"),
24879
+ nationalPlanObj: "",
24880
+ kpi: "",
24881
+ ministry: "",
24882
+ },
24883
+ ],
24884
+ },
24885
+ {
24886
+ key: 13,
24887
+ type: NdcActionType.main,
24888
+ startDate: new Date("2022-03-25"),
24889
+ endDate: new Date("2023-03-25"),
24890
+ nationalPlanObj: "Other",
24891
+ kpi: 10,
24892
+ ministry: "Ministry of Environment",
24893
+ subNdcDetails: [
24894
+ {
24895
+ key: 11,
24896
+ ndcActionId: 13,
24897
+ type: NdcActionType.sub,
24898
+ startDate: new Date("2019-03-25"),
24899
+ endDate: new Date("2020-03-25"),
24900
+ nationalPlanObj: "",
24901
+ kpi: "",
24902
+ ministry: "",
24903
+ },
24904
+ ],
24787
24905
  },
24788
24906
  ];
24789
24907
  var initialPeriods = [