From 3a476c3c1d8b6dca3d34da1111bc3cec96d28f11 Mon Sep 17 00:00:00 2001 From: Swathi-eGov Date: Sat, 19 Oct 2024 11:47:04 +0530 Subject: [PATCH] updated hrnms --- .../micro-ui-internals/example/package.json | 6 +- .../packages/Mukta/package.json | 2 +- .../packages/Mukta/src/Module.js | 2 + .../Mukta/src/components/jurisdiction.js | 338 ++++++++++++++++++ .../libraries/src/services/elements/MDMS.js | 3 +- .../modules/RateAnalysis/package.json | 2 +- .../src/pages/employee/SearchSOR.js | 6 +- .../src/atoms/MultiSelectDropdown.js | 2 +- frontend/micro-ui/web/package.json | 6 +- frontend/micro-ui/web/works/package.json | 2 +- 10 files changed, 355 insertions(+), 14 deletions(-) create mode 100644 frontend/micro-ui/web/micro-ui-internals/packages/Mukta/src/components/jurisdiction.js diff --git a/frontend/micro-ui/web/micro-ui-internals/example/package.json b/frontend/micro-ui/web/micro-ui-internals/example/package.json index 42e213ce3b..c7ad666d91 100644 --- a/frontend/micro-ui/web/micro-ui-internals/example/package.json +++ b/frontend/micro-ui/web/micro-ui-internals/example/package.json @@ -12,7 +12,7 @@ "@egovernments/digit-ui-react-components": "1.5.12", "@egovernments/digit-ui-components": "0.0.2-beta.47", "@egovernments/digit-ui-libraries": "1.5.0", - "@egovernments/digit-ui-module-core": "1.8.2-beta.22", + "@egovernments/digit-ui-module-core": "1.8.2-beta.24", "@egovernments/digit-ui-module-hrms": "1.5.26", "@egovernments/digit-ui-module-dss": "1.5.52", "@egovernments/digit-ui-module-attendencemgmt": "0.4.12", @@ -22,8 +22,8 @@ "@egovernments/digit-ui-module-masters": "0.4.17", "@egovernments/digit-ui-module-project": "0.4.13", "@egovernments/digit-ui-module-expenditure": "0.4.14", - "@egovernments/digit-ui-customisation-mukta": "0.2.9", - "@egovernments/digit-ui-module-rate-analysis": "0.4.11", + "@egovernments/digit-ui-customisation-mukta": "0.2.10", + "@egovernments/digit-ui-module-rate-analysis": "0.4.12", "http-proxy-middleware": "^1.0.5", "react": "17.0.2", "react-dom": "17.0.2", diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/Mukta/package.json b/frontend/micro-ui/web/micro-ui-internals/packages/Mukta/package.json index 8c4e5b11ca..877527f0a9 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/Mukta/package.json +++ b/frontend/micro-ui/web/micro-ui-internals/packages/Mukta/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-customisation-mukta", - "version": "0.2.9", + "version": "0.2.10", "description": "MUKTA Customisation of Works UI", "main": "dist/index.js", "module": "dist/index.modern.js", diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/Mukta/src/Module.js b/frontend/micro-ui/web/micro-ui-internals/packages/Mukta/src/Module.js index 72866d71ba..ad806ac88f 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/Mukta/src/Module.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/Mukta/src/Module.js @@ -8,6 +8,7 @@ import { UICustomizations } from "./configs/UICustomizations"; import HRMSCard from "./components/HRMSCard"; import Captcha from "./components/Captcha"; import DSSCard from "./components/DSSCard"; +import Jurisdictions from "./components/jurisdiction"; const MuktaModule = ({ stateCode, userType, tenants }) => { const moduleCode = ["Mukta"]; @@ -34,6 +35,7 @@ const componentsToRegister = { AttendenceMgmtCard:null , // TO HIDE THE Attendance Mgmt CARD IN HOME SCREEN as per MUKTA HRMSCard, // Overridden the HRMS card as per MUKTA MeasurementCard:null, + Jurisdictions, DSSCard }; diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/Mukta/src/components/jurisdiction.js b/frontend/micro-ui/web/micro-ui-internals/packages/Mukta/src/components/jurisdiction.js new file mode 100644 index 0000000000..2c7ce87060 --- /dev/null +++ b/frontend/micro-ui/web/micro-ui-internals/packages/Mukta/src/components/jurisdiction.js @@ -0,0 +1,338 @@ +import { CardLabel, Dropdown, LabelFieldPair, Loader, RemoveableTag ,MultiSelectDropdown} from "@egovernments/digit-ui-react-components"; +import React, { useEffect, useState } from "react"; +// import MultiSelectDropdown from "./Multiselect"; + + +const cleanup = (payload) => { + if (payload) { + return Object.keys(payload).reduce((acc, key) => { + if (payload[key] === undefined) { + return acc; + } + + // todo: find a better way to check object + acc[key] = typeof payload[key] === "object" ? cleanup(payload[key]) : payload[key]; + return acc; + }, {}); + } + }; + +const makeDefaultValues = (sessionFormData) => { + return sessionFormData?.Jurisdictions?.map((ele,index)=>{ + return { + key: index, + hierarchy: { + code: ele?.hierarchy, + name: ele?.hierarchy, + }, + boundaryType: { label: ele?.boundaryType, i18text:ele.boundaryType ?`EGOV_LOCATION_BOUNDARYTYPE_${ele.boundaryType?.toUpperCase()}`:null }, + boundary: { code: ele?.boundary }, + roles: ele?.roles, + } + }) +} + +const Jurisdictions = ({ t, config, onSelect, userType, formData }) => { + console.log("Jurisdictions") + const tenantId = Digit.ULBService.getCurrentTenantId(); + const [inactiveJurisdictions, setInactiveJurisdictions] = useState([]); + const { data: data = {}, isLoading } = Digit.Hooks.hrms.useHrmsMDMS(tenantId, "egov-hrms", "HRMSRolesandDesignation") || {}; + + const employeeCreateSession = Digit.Hooks.useSessionStorage("NEW_EMPLOYEE_CREATE", {}); + const [sessionFormData,setSessionFormData, clearSessionFormData] = employeeCreateSession; + const isEdit = window.location.href.includes("hrms/edit") + const [jurisdictions, setjurisdictions] = useState( + !isEdit && sessionFormData?.Jurisdictions?.length>0 ? makeDefaultValues(sessionFormData) : ( formData?.Jurisdictions || [ + { + id: undefined, + key: 1, + hierarchy: null, + boundaryType: null, + boundary: null, + roles: [], + }, + ]) + ); + + useEffect(() => { + const jurisdictionsData = jurisdictions?.map((jurisdiction) => { + let res = { + id: jurisdiction?.id, + hierarchy: jurisdiction?.hierarchy?.code, + boundaryType: jurisdiction?.boundaryType?.label, + boundary: jurisdiction?.boundary?.code, + tenantId: jurisdiction?.boundary?.code, + auditDetails: jurisdiction?.auditDetails, + }; + res = cleanup(res); + if (jurisdiction?.roles) { + res["roles"] = jurisdiction?.roles.map((ele) => { + delete ele.description; + return ele; + }); + } + return res; + }); + + onSelect( + config.key, + [...jurisdictionsData, ...inactiveJurisdictions].filter((value) => Object.keys(value).length !== 0) + ); + }, [jurisdictions]); + + const reviseIndexKeys = () => { + setjurisdictions((prev) => prev.map((unit, index) => ({ ...unit, key: index }))); + }; + + const handleAddUnit = () => { + setjurisdictions((prev) => [ + ...prev, + { + key: prev.length + 1, + hierarchy: null, + boundaryType: null, + boundary: null, + roles: [], + }, + ]); + }; + const handleRemoveUnit = (unit) => { + if (unit.id) { + let res = { + id: unit?.id, + hierarchy: unit?.hierarchy?.code, + boundaryType: unit?.boundaryType?.label, + boundary: unit?.boundary?.code, + tenantId: unit?.boundary?.code, + auditDetails: unit?.auditDetails, + isdeleted: true, + isActive: false, + }; + res = cleanup(res); + if (unit?.roles) { + res["roles"] = unit?.roles.map((ele) => { + delete ele.description; + return ele; + }); + } + setInactiveJurisdictions([...inactiveJurisdictions, res]); + } + setjurisdictions((prev) => prev.filter((el) => el.key !== unit.key)); + if (FormData.errors?.Jurisdictions?.type == unit.key) { + clearErrors("Jurisdictions"); + } + reviseIndexKeys(); + }; + let hierarchylist = []; + let boundaryTypeoption = []; + const [focusIndex, setFocusIndex] = useState(-1); + + function gethierarchylistdata() { + return data?.MdmsRes?.["common-masters"]["hierarchyType"]; + } + + function getboundarydata() { + return []; + } + + function getroledata() { + return data?.MdmsRes?.["ACCESSCONTROL-ROLES"].roles.map(role => { return { code: role.code, name: role?.name ? role?.name : " " , labelKey: 'ACCESSCONTROL_ROLES_ROLES_' + role.code } }); + } + + if (isLoading) { + return ; + } + return ( +
+ {jurisdictions?.map((jurisdiction, index) => ( + + ))} + +
+ ); +}; +function Jurisdiction({ + t, + data, + jurisdiction, + jurisdictions, + setjurisdictions, + gethierarchylistdata, + handleRemoveUnit, + hierarchylist, + getroledata, + roleoption, + index, +}) { + const [BoundaryType, selectBoundaryType] = useState([]); + const [Boundary, selectboundary] = useState([]); + useEffect(() => { + selectBoundaryType( + data?.MdmsRes?.["common-masters"]["hierarchyType"] + .filter((ele) => { + return ele?.code === jurisdiction?.hierarchy?.code; + }) + ?.map((item) => { + const boundaryType = item.boundaryType; + return { + label: boundaryType, + i18text: Digit.Utils.locale.convertToLocale(boundaryType, 'EGOV_LOCATION_BOUNDARYTYPE') + }; + }) + ); + }, [jurisdiction?.hierarchy, data?.MdmsRes]); + const tenant = Digit.ULBService.getCurrentTenantId(); + useEffect(() => { + selectboundary(data?.MdmsRes?.tenant?.tenants.filter(city => city.code != Digit.ULBService.getStateId()).map(city => { return { ...city, i18text: Digit.Utils.locale.getCityLocale(city.code) } })); + }, [jurisdiction?.boundaryType, data?.MdmsRes]); + + useEffect(() => { + if (Boundary?.length > 0) { + selectedboundary(Boundary?.filter((ele) => ele.code == jurisdiction?.boundary?.code)[0]); + } + }, [Boundary]); + + const selectHierarchy = (value) => { + setjurisdictions((pre) => pre.map((item) => (item.key === jurisdiction.key ? { ...item, hierarchy: value } : item))); + }; + + const selectboundaryType = (value) => { + setjurisdictions((pre) => pre.map((item) => (item.key === jurisdiction.key ? { ...item, boundaryType: value } : item))); + }; + + const selectedboundary = (value) => { + setjurisdictions((pre) => pre.map((item) => (item.key === jurisdiction.key ? { ...item, boundary: value } : item))); + }; + + const selectrole = (e, data) => { + // const index = jurisdiction?.roles.filter((ele) => ele.code == data.code); + // let res = null; + // if (index.length) { + // jurisdiction?.roles.splice(jurisdiction?.roles.indexOf(index[0]), 1); + // res = jurisdiction.roles; + // } else { + // res = [{ ...data }, ...jurisdiction?.roles]; + // } + let res = []; + e && e?.map((ob) => { + res.push(ob?.[1]); + }); + + res?.forEach(resData => {resData.labelKey = 'ACCESSCONTROL_ROLES_ROLES_' + resData.code}) + + setjurisdictions((pre) => pre.map((item) => (item.key === jurisdiction.key ? { ...item, roles: res } : item))); + }; + + + const onRemove = (index, key) => { + let afterRemove = jurisdiction?.roles.filter((value, i) => { + return i !== index; + }); + setjurisdictions((pre) => pre.map((item) => (item.key === jurisdiction.key ? { ...item, roles: afterRemove } : item))); + + }; + return ( +
+
+ +
+

+ {t("HR_JURISDICTION")} {index + 1} +

+
+ {jurisdictions.length > 1 ? ( +
handleRemoveUnit(jurisdiction)} + style={{ marginBottom: "16px", padding: "5px", cursor: "pointer", textAlign: "right" }} + > + X +
+ ) : null} +
+ + {`${t("HR_HIERARCHY_LABEL")} * `} + + + + {`${t("HR_BOUNDARY_TYPE_LABEL")} * `} + + + + {`${t("HR_BOUNDARY_LABEL")} * `} + + + + + {t("HR_COMMON_TABLE_COL_ROLE")} * +
+ +
+ {jurisdiction?.roles.length > 0 && + jurisdiction?.roles.map((value, index) => { + return onRemove(index, value)} />; + })} +
+
+
+
+
+ ); +} + +export default Jurisdictions; diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/MDMS.js b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/MDMS.js index d7f2262086..c4241a666c 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/MDMS.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/MDMS.js @@ -728,6 +728,7 @@ const getHrmsEmployeeRolesandDesignations = () => ({ masterDetails: [ { name: "Department", filter: "[?(@.active == true)]" }, { name: "Designation", filter: "[?(@.active == true)]" }, + { name : "hierarchyType"} ], }, { @@ -738,7 +739,7 @@ const getHrmsEmployeeRolesandDesignations = () => ({ moduleName: "ACCESSCONTROL-ROLES", masterDetails: [{ name: "roles", filter: "$.[?(@.code!='CITIZEN')]" }], }, - { moduleName: "egov-location", masterDetails: [{ name: "TenantBoundary" }] }, + // { moduleName: "egov-location", masterDetails: [{ name: "TenantBoundary" }] }, ], }); const getFSTPPlantCriteria = (tenantId, moduleCode, type) => ({ diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/RateAnalysis/package.json b/frontend/micro-ui/web/micro-ui-internals/packages/modules/RateAnalysis/package.json index 4d9ea5cb7e..f908e0a728 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/RateAnalysis/package.json +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/RateAnalysis/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-module-rate-analysis", - "version": "0.4.11", + "version": "0.4.12", "description": "Rate Analysis Module UI", "main": "dist/index.js", "module": "dist/index.modern.js", diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/RateAnalysis/src/pages/employee/SearchSOR.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/RateAnalysis/src/pages/employee/SearchSOR.js index ea117e303d..b4bd3d06d2 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/RateAnalysis/src/pages/employee/SearchSOR.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/RateAnalysis/src/pages/employee/SearchSOR.js @@ -1,10 +1,10 @@ import React, { useState, useEffect, useMemo, createContext, Fragment } from "react"; import { useTranslation } from "react-i18next"; -import { Header, Loader, Button, ActionBar, SubmitBar, TextInput, Modal, CardText } from "@egovernments/digit-ui-react-components"; +import { Header, Loader, ActionBar, SubmitBar, TextInput, Modal, CardText } from "@egovernments/digit-ui-react-components"; import { InboxSearchComposer } from "@egovernments/digit-ui-react-components"; import { useHistory } from "react-router-dom"; import searchSORConfig from "../../configs/searchSORConfig"; -import {Toast} from "@egovernments/digit-ui-components"; +import {Toast,Button} from "@egovernments/digit-ui-components"; const Heading = (props) => { return

{props.t(props.heading)}

; @@ -174,7 +174,7 @@ const SearchSOR = () => {