From 354494e23a2344ca85bb31ac836f508f3b301b3a Mon Sep 17 00:00:00 2001 From: siddhant-nawale-egov <162107530+siddhant-nawale-egov@users.noreply.github.com> Date: Sat, 18 May 2024 20:55:50 +0530 Subject: [PATCH] HLM-5156 adding filter layer is mapping section HLM-5880 bug --- .../micro-ui-internals/example/package.json | 2 +- micro-ui/web/micro-ui-internals/package.json | 2 +- .../modules/hcm-microplanning/package.json | 9 +- .../src/components/MicroplanningHeader.js | 7 +- .../src/components/resourceMapping.js | 8 +- .../src/configs/UICustomizations.js | 4 +- .../src/icons/MapLayerIcon.js | 40 ------ .../src/icons/MapLayerIcon.stories.js | 30 ----- .../hcm-microplanning/src/icons/NorthArrow.js | 36 ------ .../src/icons/NorthArrow.stories.js | 30 ----- .../hcm-microplanning/src/icons/Svg.js | 70 +++++----- .../src/pages/employee/CreateMicroplan.js | 59 ++++++++- .../src/pages/employee/Hypothesis.js | 9 +- .../src/pages/employee/Mapping.js | 17 ++- .../src/pages/employee/MicroplanPreview.js | 2 +- .../src/pages/employee/RuleEngine.js | 28 ++-- .../src/pages/employee/SavedMicroplans.js | 2 +- .../src/pages/employee/Upload.js | 2 +- .../src/services/searchSavedPlans.js | 2 + .../hcm-microplanning/src/utils/index.js | 10 +- .../src/utils/updateSessionUtils.js | 120 ++++++++++-------- micro-ui/web/microplan/package.json | 4 +- micro-ui/web/package.json | 2 +- 23 files changed, 226 insertions(+), 269 deletions(-) delete mode 100644 micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/icons/MapLayerIcon.js delete mode 100644 micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/icons/MapLayerIcon.stories.js delete mode 100644 micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/icons/NorthArrow.js delete mode 100644 micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/icons/NorthArrow.stories.js diff --git a/micro-ui/web/micro-ui-internals/example/package.json b/micro-ui/web/micro-ui-internals/example/package.json index e787e32bcb7..35c9efc282c 100644 --- a/micro-ui/web/micro-ui-internals/example/package.json +++ b/micro-ui/web/micro-ui-internals/example/package.json @@ -12,7 +12,7 @@ "@egovernments/digit-ui-libraries": "1.8.1-beta.1", "@egovernments/digit-ui-module-core": "1.8.1-beta.14", "@egovernments/digit-ui-module-utilities": "1.0.1-beta.1", - "@egovernments/digit-ui-react-components": "1.8.1-beta.2", + "@egovernments/digit-ui-react-components": "1.8.1-beta.20", "@egovernments/digit-ui-module-hcmmicroplanning":"0.0.1", "http-proxy-middleware": "^1.0.5", "react": "17.0.2", diff --git a/micro-ui/web/micro-ui-internals/package.json b/micro-ui/web/micro-ui-internals/package.json index a319030953b..041d69e5c76 100644 --- a/micro-ui/web/micro-ui-internals/package.json +++ b/micro-ui/web/micro-ui-internals/package.json @@ -44,7 +44,7 @@ "dependencies": { "lodash": "4.17.21", "microbundle-crl": "0.13.11", - "@egovernments/digit-ui-react-components": "1.8.1-beta.2", + "@egovernments/digit-ui-react-components": "1.8.1-beta.20", "react": "17.0.2", "react-dom": "17.0.2", "react-hook-form": "6.15.8", diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/package.json b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/package.json index 7728bf653a6..45e99637775 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/package.json +++ b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/package.json @@ -19,9 +19,9 @@ }, "dependencies": { "@cyntler/react-doc-viewer": "1.10.3", - "@egovernments/digit-ui-components": "0.0.1-beta.17", - "@egovernments/digit-ui-react-components": "1.8.1-beta.17", - "@egovernments/digit-ui-svg-components": "1.0.7", + "@egovernments/digit-ui-components": "0.0.1-beta.20", + "@egovernments/digit-ui-react-components": "1.8.1-beta.20", + "@egovernments/digit-ui-svg-components": "1.0.8", "@rjsf/core": "5.10.0", "@rjsf/utils": "5.10.0", "@rjsf/validator-ajv8": "5.10.0", @@ -44,7 +44,8 @@ "safe-buffer": "^5.2.1", "shpjs": "^4.0.4", "uuid": "^9.0.1", - "xlsx": "0.17.5" + "xlsx": "0.17.5", + "react-joyride": "2.5.5" }, "license": "MIT", "keywords": [ diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanningHeader.js b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanningHeader.js index e7d5ceba4a3..3c59e47a067 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanningHeader.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanningHeader.js @@ -1,9 +1,8 @@ -import { Tutorial, useTourState } from "@egovernments/digit-ui-react-components"; +import { HelpOutlineIcon, useTourState } from "@egovernments/digit-ui-react-components"; import React, { useEffect, useContext, Fragment } from "react"; import { useTranslation } from "react-i18next"; import { useLocation } from "react-router-dom"; import { useMyContext } from "../utils/context"; -import { HelpOutlineIcon } from "../icons/Svg"; // import { TourSteps } from '../utils/TourSteps'; @@ -20,7 +19,7 @@ const MicroplanningHeader = () => { return ( <> - + {/* */}
{/* */}
@@ -32,4 +31,4 @@ const MicroplanningHeader = () => { ); }; -export default MicroplanningHeader; +export default MicroplanningHeader; \ No newline at end of file diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/resourceMapping.js b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/resourceMapping.js index 3124a7bdcd2..ad25dbfe59f 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/resourceMapping.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/resourceMapping.js @@ -113,16 +113,16 @@ export const SpatialDataPropertyMapping = ({ uploadedData, resourceMapping, setR
diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/configs/UICustomizations.js b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/configs/UICustomizations.js index ea3750799d8..020f6596241 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/configs/UICustomizations.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/configs/UICustomizations.js @@ -287,7 +287,9 @@ export const UICustomizations = { const { name,status } = data?.state?.searchForm || {}; data.body.PlanConfigurationSearchCriteria = {} - data.body.PlanConfigurationSearchCriteria.pagination = data?.state?.tableForm + // data.body.PlanConfigurationSearchCriteria.limit = data?.state?.tableForm?.limit + data.body.PlanConfigurationSearchCriteria.limit = 10 + data.body.PlanConfigurationSearchCriteria.offset = data?.state?.tableForm?.offset data.body.PlanConfigurationSearchCriteria.name = name data.body.PlanConfigurationSearchCriteria.tenantId = Digit.ULBService.getCurrentTenantId(); data.body.PlanConfigurationSearchCriteria.userUuid = Digit.UserService.getUser().info.uuid; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/icons/MapLayerIcon.js b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/icons/MapLayerIcon.js deleted file mode 100644 index 6a1ac77f9cc..00000000000 --- a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/icons/MapLayerIcon.js +++ /dev/null @@ -1,40 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; - -export const MapLayerIcon = ({ className, width = "24", height = "27", style = {}, fill = "white", onClick = null }) => { - return ( - - - - ); -}; - - -MapLayerIcon.propTypes = { - /** custom width of the svg icon */ - width: PropTypes.string, - /** custom height of the svg icon */ - height: PropTypes.string, - /** custom colour of the svg icon */ - fill: PropTypes.string, - /** custom class of the svg icon */ - className: PropTypes.string, - /** custom style of the svg icon */ - style: PropTypes.object, - /** Click Event handler when icon is clicked */ - onClick: PropTypes.func, -}; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/icons/MapLayerIcon.stories.js b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/icons/MapLayerIcon.stories.js deleted file mode 100644 index 94ece58c82c..00000000000 --- a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/icons/MapLayerIcon.stories.js +++ /dev/null @@ -1,30 +0,0 @@ -import React from "react"; -import { MapLayerIcon } from "./MapLayerIcon"; - -export default { - tags: ['autodocs'], - argTypes: { - className: { - options: ['custom-class'], - control: { type: 'check' }, - } - }, - title: "MapLayerIcon", - component: MapLayerIcon, -}; - -export const Default = () => ; -export const Fill = () => ; -export const Size = () => ; -export const CustomStyle = () => ; -export const CustomClassName = () => ; - -export const Clickable = () => console.log("clicked")} />; - -const Template = (args) => ; - -export const Playground = Template.bind({}); -Playground.args = { - className: "custom-class", - style: { border: "3px solid green" } -}; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/icons/NorthArrow.js b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/icons/NorthArrow.js deleted file mode 100644 index b17bfd69f6f..00000000000 --- a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/icons/NorthArrow.js +++ /dev/null @@ -1,36 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; - -export const NorthArrow = ({ className, width = "40", height = "40", style = {}, fill = "white", onClick = null }) => { - return ( - - - - - - ); -}; - -NorthArrow.propTypes = { - /** custom width of the svg icon */ - width: PropTypes.string, - /** custom height of the svg icon */ - height: PropTypes.string, - /** custom colour of the svg icon */ - fill: PropTypes.string, - /** custom class of the svg icon */ - className: PropTypes.string, - /** custom style of the svg icon */ - style: PropTypes.object, - /** Click Event handler when icon is clicked */ - onClick: PropTypes.func, -}; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/icons/NorthArrow.stories.js b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/icons/NorthArrow.stories.js deleted file mode 100644 index 5346aa2a9fa..00000000000 --- a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/icons/NorthArrow.stories.js +++ /dev/null @@ -1,30 +0,0 @@ -import React from "react"; -import { NorthArrow } from "./NorthArrow"; - -export default { - tags: ['autodocs'], - argTypes: { - className: { - options: ['custom-class'], - control: { type: 'check' }, - } - }, - title: "NorthArrow", - component: NorthArrow, -}; - -export const Default = () => ; -export const Fill = () => ; -export const Size = () => ; -export const CustomStyle = () => ; -export const CustomClassName = () => ; - -export const Clickable = () => console.log("clicked")} />; - -const Template = (args) => ; - -export const Playground = Template.bind({}); -Playground.args = { - className: "custom-class", - style: { border: "3px solid green" } -}; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/icons/Svg.js b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/icons/Svg.js index 0f93d6265a8..11efa73a352 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/icons/Svg.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/icons/Svg.js @@ -45,23 +45,15 @@ export const DefaultMapMarkerSvg = (style) => { `; }; -export const Warehouse = ({ className = "", fill = "white", fillBackground = "#42BBFF", style = {}, width = "1.5rem", height = "1.5rem" }) => { - return ( - - - - - - - - - - - - ); -}; -export const WarehouseMarker = ({ className = "", fill = "white", fillBackground = "#42BBFF", style = {} , width="3.125rem",height="3.125rem" }) => { +export const WarehouseMarker = ({ + className = "", + fill = "white", + fillBackground = "#42BBFF", + style = {}, + width = "3.125rem", + height = "3.125rem", +}) => { return ` @@ -77,6 +69,22 @@ export const WarehouseMarker = ({ className = "", fill = "white", fillBackground `; }; +export const Warehouse = ({ className = "", fill = "white", fillBackground = "#42BBFF", style = {}, width = "1.5rem", height = "1.5rem" }) => { + return ( + + + + + + + + + + + + ); +}; + export const Church = ({ className = "", fill = "white", fillBackground = "#064466", style = {}, width = "1.5rem", height = "1.5rem" }) => { return ( @@ -124,20 +132,18 @@ export const School = ({ className = "", fill = "white", fillBackground = "#FF7B ); }; -export const HealthFacility = ({ className = "", fill = "white", fillBackground = "#FF7B42", style = {}, width = "1.5rem", height = "1.5rem" }) => { +export const HealthFacility = ({ className = "", fill = "white", fillBackground = "#0C9219", style = {}, width = "1.5rem", height = "1.5rem" , onClick=null}) => { return ( - - - - + + + + - - - + + + ); @@ -174,7 +180,14 @@ export const SchoolMarker = ({ className = "", fill = "white", fillBackground = `; }; -export const HealthFacilityMarker = ({ className = "", fill = "white", fillBackground = "#0C9219", style = {}, width = "3.125rem", height = "3.125rem" }) => { +export const HealthFacilityMarker = ({ + className = "", + fill = "white", + fillBackground = "#0C9219", + style = {}, + width = "3.125rem", + height = "3.125rem", +}) => { return ` @@ -189,4 +202,3 @@ export const HealthFacilityMarker = ({ className = "", fill = "white", fillBackg `; }; - diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/CreateMicroplan.js b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/CreateMicroplan.js index 76d5a5bae51..0d781b48db7 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/CreateMicroplan.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/CreateMicroplan.js @@ -24,6 +24,7 @@ export const components = { import MicroplanCreatedScreen from "../../components/MicroplanCreatedScreen"; import { LoaderWithGap, Tutorial } from "@egovernments/digit-ui-react-components"; import { useMyContext } from "../../utils/context"; +import { updateSessionUtils } from "../../utils/updateSessionUtils"; // will be changed laters const campaignType = "ITIN"; @@ -45,6 +46,40 @@ const CreateMicroplan = () => { const [loaderActivation, setLoaderActivation] = useState(false); const { state } = useMyContext(); + //fetch campaign data + const { id = "" } = Digit.Hooks.useQueryParams(); + const { isLoading: isCampaignLoading, data: campaignData } = Digit.Hooks.microplan.useSearchCampaign( + { + CampaignDetails: { + tenantId: Digit.ULBService.getCurrentTenantId(), + ids: [id], + }, + }, + { + enabled: !!id, + } + ); + + // request body for boundary hierarchy api + const reqCriteria = { + url: `/boundary-service/boundary-hierarchy-definition/_search`, + params: {}, + body: { + BoundaryTypeHierarchySearchCriteria: { + tenantId: Digit.ULBService.getStateId(), + hierarchyType: campaignData?.hierarchyType, + // hierarchyType: "Microplan", + }, + }, + config: { + enabled: !!campaignData?.hierarchyType, + select: (data) => { + return data?.BoundaryHierarchy?.[0]?.boundaryHierarchy?.map((item) => item?.boundaryType) || {}; + }, + }, + }; + const { isLoading: ishierarchyLoading, data: heirarchyData } = Digit.Hooks.useCustomAPIHook(reqCriteria); + // useEffect to initialise the data from MDMS useEffect(() => { let temp; @@ -122,11 +157,19 @@ const CreateMicroplan = () => { const createPlanConfiguration = async (body, setCheckDataCompletion, setLoaderActivation) => { await CreateMutate(body, { onSuccess: async (data) => { - setMicroplanData((previous) => ({ - ...previous, - planConfigurationId: data?.PlanConfiguration[0]?.id, - auditDetails: data?.PlanConfiguration[0]?.auditDetails, - })); + // setMicroplanData((previous) => ({ + // ...previous, + // planConfigurationId: data?.PlanConfiguration[0]?.id, + // auditDetails: data?.PlanConfiguration[0]?.auditDetails, + // })); + debugger + const additionalPropsForExcel = { + heirarchyData: heirarchyData, + t, + }; + const computedSession = await updateSessionUtils.computeSessionObject(data?.PlanConfiguration[0], state, additionalPropsForExcel); + setMicroplanData(computedSession); + debugger setToastCreateMicroplan({ state: "success", message: t("SUCCESS_DATA_SAVED") }); setTimeout(() => { setToastCreateMicroplan(undefined); @@ -153,6 +196,12 @@ const CreateMicroplan = () => { body.PlanConfiguration["auditDetails"] = microplanData?.auditDetails; await UpdateMutate(body, { onSuccess: async (data) => { + const additionalPropsForExcel = { + heirarchyData: heirarchyData, + t, + }; + const computedSession = await updateSessionUtils.computeSessionObject(data?.PlanConfiguration[0], state, additionalPropsForExcel); + setMicroplanData(computedSession); setToastCreateMicroplan({ state: "success", message: t("SUCCESS_DATA_SAVED") }); setTimeout(() => { setToastCreateMicroplan(undefined); diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/Hypothesis.js b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/Hypothesis.js index afc1d9338b8..9d13506c2f5 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/Hypothesis.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/Hypothesis.js @@ -6,7 +6,7 @@ import { ButtonType1, ButtonType2, CloseButton, ModalHeading } from "../../compo import { Modal, Toast } from "@egovernments/digit-ui-components"; import { useMyContext } from "../../utils/context"; import { tourSteps } from "../../configs/tourSteps"; - +import { v4 as uuidv4 } from 'uuid'; const page = "hypothesis"; const Hypothesis = ({ campaignType = "SMC", microplanData, setMicroplanData, checkDataCompletion, setCheckDataCompletion, currentPage, pages }) => { @@ -214,10 +214,12 @@ const Hypothesis = ({ campaignType = "SMC", microplanData, setMicroplanData, che // Function to add a new assumption const addAssumptionsHandler = (setAssumptions) => { + let uuid = uuidv4(); setAssumptions((previous) => [ ...previous, { - id: previous.length ? previous[previous.length - 1].id + 1 : 0, + id: uuid, + // previous.length ? previous[previous.length - 1].id + 1 : 0, key: "", value: "", }, @@ -461,8 +463,9 @@ const setAutofillHypothesisData = (autofillHypothesis, assumptions, setAssumptio if (assumptions?.length !== 0) return []; let newAssumptions = []; for (let i in autofillHypothesis) { + let uuid = uuidv4(); newAssumptions.push({ - id: Number(i), + id: uuid, key: autofillHypothesis[Number(i)], value: "", }); diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/Mapping.js b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/Mapping.js index 73729bbc868..66fd734fb12 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/Mapping.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/Mapping.js @@ -17,8 +17,6 @@ import React, { memo, useCallback, useEffect, useMemo, useRef, useState, Fragmen import { useTranslation } from "react-i18next"; import ZoomControl from "../../components/ZoomControl"; import CustomScaleControl from "../../components/CustomScaleControl"; -import { MapLayerIcon } from "../../icons/MapLayerIcon"; -import { NorthArrow } from "../../icons/NorthArrow"; import * as DigitSvgs from "@egovernments/digit-ui-svg-components"; import { CardSectionHeader, InfoIconOutline, LoaderWithGap } from "@egovernments/digit-ui-react-components"; import { @@ -378,7 +376,7 @@ const Mapping = ({ >

{t("VIRTUALIZATION")}

- + {DigitSvgs.FilterAlt && }
@@ -386,7 +384,7 @@ const Mapping = ({
- + {DigitSvgs.FilterAlt && }
@@ -429,7 +427,7 @@ const FilterItemBuilder = ({ item, MapFilters, t }) => { // if (typeof DynamicIcon === "function") icon = DynamicIcon({}); return DynamicIcon && typeof DynamicIcon === "function" ? (
- +

{t(item)}

) : ( @@ -456,7 +454,7 @@ const FilterSection = memo(
setShowFilterOptions((previous) => !previous)}>

{t("FILTERS")}

- + {DigitSvgs.FilterAlt && }
{showFilterOptions && ( @@ -481,9 +479,9 @@ const FilterSection = memo(