diff --git a/health/micro-ui/web/micro-ui-internals/example/public/index.html b/health/micro-ui/web/micro-ui-internals/example/public/index.html index 0f3e6772d1a..201c5c67559 100644 --- a/health/micro-ui/web/micro-ui-internals/example/public/index.html +++ b/health/micro-ui/web/micro-ui-internals/example/public/index.html @@ -18,7 +18,7 @@ - + diff --git a/health/micro-ui/web/micro-ui-internals/packages/css/package.json b/health/micro-ui/web/micro-ui-internals/packages/css/package.json index 987ed02018e..29196d58052 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/css/package.json +++ b/health/micro-ui/web/micro-ui-internals/packages/css/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-css", - "version": "1.0.82-campaign", + "version": "1.0.83-campaign", "license": "MIT", "main": "dist/index.css", "author": "Jagankumar ", diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/BoundaryKpi.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/BoundaryKpi.js index ea9677c7571..10103dca364 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/BoundaryKpi.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/BoundaryKpi.js @@ -1,16 +1,20 @@ import React from 'react'; import { Card } from '@egovernments/digit-ui-components'; import { useMyContext } from '../utils/context'; +import { useTranslation } from 'react-i18next'; const BoundaryKpi = ({ data }) => { - const {state:{boundaryHierarchy}} = useMyContext() + const { state: { boundaryHierarchy } } = useMyContext() + const { t } = useTranslation(); return ( - {Object.keys(data).map((key) => ( -
-

{String(data[key]).padStart(2, '0')}

-

{key}

-
- ))} + {Object.keys(data).map((key) => { + return ( +
+

{String(data[key]).padStart(2, '0')}

+

{t(`MICROPLAN_${key.toUpperCase()}`)}

{/* Correct use of t with template literal */} +
+ ); + })}
); }; diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/MicroplanCard.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/MicroplanCard.js index 1d33ca39010..679c77fe3f8 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/MicroplanCard.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/MicroplanCard.js @@ -2,10 +2,22 @@ import { EmployeeModuleCard, WorksMgmtIcon } from "@egovernments/digit-ui-react- import React from "react"; import { useTranslation } from "react-i18next"; + const ROLES = { MICROPLAN: ["MICROPLAN_ADMIN"], + SUPERVISOR:[ + "PLAN_ESTIMATION_APPROVER", + "ROOT_PLAN_ESTIMATION_APPROVER", + "POPULATION_DATA_APPROVER", + "ROOT_POPULATION_DATA_APPROVER", + "FACILITY_CATCHMENT_MAPPER", + "ROOT_FACILITY_CATCHMENT_MAPPER", + "MICROPLAN_VIEWER" + ] }; + + const MicroplanCard = () => { const { t } = useTranslation(); const tenantId = Digit.ULBService.getCurrentTenantId(); @@ -18,7 +30,20 @@ const MicroplanCard = () => { }; }; - let links = [generateLink("SETUP_MICROPLAN","setup-microplan"),generateLink("SEARCH_MICROPLANS","microplan-search"),generateLink("USER_MANAGEMENT","user-management")]; + const generateOtherLink = (labelKey, pathSuffix) => { + return { + label: t(labelKey), + link: `/${window?.contextPath}/employee/microplan/${pathSuffix}`, + roles: ROLES.SUPERVISOR, + }; + }; + + let links = [ + generateLink("SETUP_MICROPLAN","setup-microplan"), + generateLink("SEARCH_MICROPLANS","microplan-search"), + generateLink("USER_MANAGEMENT","user-management"), + generateOtherLink("MY_MICROPLANS","my-microplans") + ]; links = links.filter((link) => (link?.roles && link?.roles?.length > 0 ? Digit.Utils.didEmployeeHasAtleastOneRole(link?.roles) : true)); @@ -31,4 +56,4 @@ const MicroplanCard = () => { return ; }; -export default MicroplanCard; +export default MicroplanCard; \ No newline at end of file diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/MicroplanSearchConfig.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/MicroplanSearchConfig.js index 176de7bbf5a..da7da31bdd5 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/MicroplanSearchConfig.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/MicroplanSearchConfig.js @@ -2,126 +2,125 @@ // default values of search input component const defaultSearchValues = { - microplanName: "", + microplanName: "", + +}; + - }; + //config for tab search sceeen + export const TabSearchconfig = { + // moduleName: "commonCampaignUiConfig", + showTab: true, // setting true will enable tab screen + TabSearchconfig: [ // all tab config should be added in json array + { + label: "MY_MICROPLANS", + type: "search", + apiDetails: { + serviceName: "/plan-service/config/_search", //! Note + requestParam: {}, + requestBody: {}, + masterName: "commonUiConfig", + moduleName: "MicroplanSearchConfig", + minParametersForSearchForm: 0, + tableFormJsonPath: "requestBody.PlanConfigurationSearchCriteria.pagination", + // filterFormJsonPath: "requestBody.MdmsCriteria.customs", + searchFormJsonPath: "requestBody.PlanConfigurationSearchCriteria", + }, + + sections: { + search: { + uiConfig: { + formClassName: "custom-both-clear-search", + primaryLabel: "ES_COMMON_SEARCH", + secondaryLabel: "ES_COMMON_CLEAR_SEARCH", + minReqFields: 0, + defaultValues: defaultSearchValues, // Set default values for search fields + fields: [ + { + label: "Name of the microplan", + isMandatory: false, + key: "microplanName", + type: "text", + populators: { + name: "microplanName", + error: "Required", + validation: { pattern: /^[A-Za-z]+$/i }, + }, + }, + // { + // label: "Phone number", + // isMandatory: false, + // key: "Phone number", + // type: "number", + // disable: false, + // populators: { name: "mobileNumber", error: "sample error message", validation: { min: 0, max: 999999999 } }, + // }, + // { + // label: "Individual Id ", + // isMandatory: false, + // type: "text", + // disable: false, + // populators: { + // name: "individualId", + // }, + // }, + ], + }, - - //config for tab search sceeen - export const TabSearchconfig = { - // moduleName: "commonCampaignUiConfig", - showTab: true, // setting true will enable tab screen - TabSearchconfig: [ // all tab config should be added in json array - { - label: "ALL", - type: "search", - apiDetails: { - serviceName: "/plan-service/config/_search", //! Note - requestParam: {}, - requestBody: {}, - masterName: "commonUiConfig", - moduleName: "MicroplanSearchConfig", - minParametersForSearchForm: 0, - tableFormJsonPath: "requestBody.PlanConfigurationSearchCriteria.pagination", - // filterFormJsonPath: "requestBody.MdmsCriteria.customs", - searchFormJsonPath: "requestBody.PlanConfigurationSearchCriteria", + show: true, }, + searchResult: { + uiConfig: { + columns: [ + { + label: "Name of the Microplan", + jsonPath: "name", + additionalCustomization:true + }, - sections: { - search: { - uiConfig: { - formClassName: "custom-both-clear-search", - primaryLabel: "ES_COMMON_SEARCH", - secondaryLabel: "ES_COMMON_CLEAR_SEARCH", - minReqFields: 0, - defaultValues: defaultSearchValues, // Set default values for search fields - fields: [ - { - label: "Name of the microplan", - isMandatory: false, - key: "microplanName", - type: "text", - populators: { - name: "microplanName", - error: "Required", - validation: { pattern: /^[A-Za-z]+$/i }, - }, - }, - // { - // label: "Phone number", - // isMandatory: false, - // key: "Phone number", - // type: "number", - // disable: false, - // populators: { name: "mobileNumber", error: "sample error message", validation: { min: 0, max: 999999999 } }, - // }, - // { - // label: "Individual Id ", - // isMandatory: false, - // type: "text", - // disable: false, - // populators: { - // name: "individualId", - // }, - // }, - ], - }, - - show: true, - }, - searchResult: { - uiConfig: { - columns: [ - { - label: "Name of the Microplan", - jsonPath: "name", - additionalCustomization:true - }, - - { - label: "Microplan Status", - jsonPath: "status", - }, - { - label: "Campaign Disease", - jsonPath: "CampaignDetails.campaignName", - }, - { - label:"Camapaign Type", - jsonPath:"CampaignDetails.startDate" - }, - { - label:"Distribution Strategy", - jsonPath:" proposalDate" - }, - { - label:"Actions", - jsonPath:"", - additionalCustomization:true - } - ], - resultsJsonPath: "PlanConfiguration", - - enableColumnSort: true, - // resultsJsonPath: "mdms", - }, - show: true, + { + label: "Microplan Status", + jsonPath: "status", + }, + { + label: "Campaign Disease", + jsonPath: "additionalDetails.disease", + }, + { + label:"Camapaign Type", + jsonPath:"additionalDetails.campaignType" + }, + { + label:"Distribution Strategy", + jsonPath:"additionalDetails.resourceDistributionStrategyCode" + }, + { + label:"Actions", + jsonPath:"", + additionalCustomization:true + } + ], + resultsJsonPath: "PlanConfiguration", + + enableColumnSort: true, + // resultsJsonPath: "mdms", }, - // customHookName: "microplanv1.useSavedMicroplans", //! Note - + show: true, }, - customHookName:"microplanv1.useSavedMicroplans" + // customHookName: "microplanv1.useSavedMicroplans", //! Note + }, + customHookName:"microplanv1.useSavedMicroplans" + }, + + + {label: "DRAFTED_SETUP"}, + {label: "EXECUTION_TO_BE_DONE",}, + {label:"EXECUTION_IN_PROGRESS"}, + {label:"MICROPLAN_EXECUTED"}, + + + ], + }; - - {label: "DRAFTED_SETUP"}, - {label: "EXECUTION_TO_BE_DONE",}, - {label:"EXECUTION_IN_PROGRESS"}, - {label:"MICROPLAN_EXECUTED"}, - - - ], - }; - - - \ No newline at end of file + diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/MyMicroplanSearchConfig.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/MyMicroplanSearchConfig.js new file mode 100644 index 00000000000..f30837bae79 --- /dev/null +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/MyMicroplanSearchConfig.js @@ -0,0 +1,124 @@ + + +// default values of search input component +const defaultSearchValues = { + microplanName: "", + + }; + + + //config for tab search sceeen + export const TabSearchconfig = { + // moduleName: "commonCampaignUiConfig", + showTab: true, // setting true will enable tab screen + TabSearchconfig: [ // all tab config should be added in json array + { + label: "ALL", + type: "search", + apiDetails: { + serviceName: "/plan-service/config/_search", // Note + requestParam: {}, + requestBody: {}, + masterName: "commonUiConfig", + moduleName: "MyMicroplanSearchConfig", //uses same as microplan search + minParametersForSearchForm: 0, + tableFormJsonPath: "requestBody.PlanConfigurationSearchCriteria.pagination", + // filterFormJsonPath: "requestBody.MdmsCriteria.customs", + searchFormJsonPath: "requestBody.PlanConfigurationSearchCriteria", + }, + + sections: { + search: { + uiConfig: { + formClassName: "custom-both-clear-search", + primaryLabel: "ES_COMMON_SEARCH", + secondaryLabel: "ES_COMMON_CLEAR_SEARCH", + minReqFields: 0, + defaultValues: defaultSearchValues, // Set default values for search fields + fields: [ + { + label: "Name of the microplan", + isMandatory: false, + key: "microplanName", + type: "text", + populators: { + name: "microplanName", + error: "Required", + validation: { pattern: /^[A-Za-z]+$/i }, + }, + }, + // { + // label: "Phone number", + // isMandatory: false, + // key: "Phone number", + // type: "number", + // disable: false, + // populators: { name: "mobileNumber", error: "sample error message", validation: { min: 0, max: 999999999 } }, + // }, + // { + // label: "Individual Id ", + // isMandatory: false, + // type: "text", + // disable: false, + // populators: { + // name: "individualId", + // }, + // }, + ], + }, + + show: true, + }, + searchResult: { + uiConfig: { + columns: [ + { + label: "Name of the Microplan", + jsonPath: "name", + additionalCustomization:true + }, + + { + label: "Microplan Status", + jsonPath: "status", + }, + { + label: "Campaign Disease", + jsonPath: "additionalDetails.disease", + }, + { + label:"Camapaign Type", + jsonPath:"additionalDetails.campaignType" + }, + { + label:"Distribution Strategy", + jsonPath:"additionalDetails.resourceDistributionStrategyCode" + }, + { + label:"Actions", + jsonPath:"", + additionalCustomization:true + } + ], + resultsJsonPath: "PlanConfiguration", + + enableColumnSort: true, + // resultsJsonPath: "mdms", + }, + show: true, + }, + // customHookName: "microplanv1.useSavedMicroplans", //! Note + + }, + customHookName:"microplanv1.useSavedMicroplans" + }, + {label: "EXECUTION_TO_BE_DONE",}, + {label:"EXECUTION_IN_PROGRESS"}, + {label:"MICROPLAN_EXECUTED"}, + + + ], + }; + + + \ No newline at end of file diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js index cd27afcada2..6635a616954 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js @@ -2,7 +2,9 @@ import { Link, useLocation, useHistory, useParams } from "react-router-dom"; import _ from "lodash"; import React from "react"; import { Dropdown } from "@egovernments/digit-ui-components"; - +import { DeleteIconv2, DownloadIcon, FileIcon, Button, Card, CardSubHeader } from "@egovernments/digit-ui-react-components"; +import { EditIcon } from "@egovernments/digit-ui-react-components"; +import { ArrowForward } from "@egovernments/digit-ui-react-components"; //create functions here based on module name set in mdms(eg->SearchProjectConfig) //how to call these -> Digit?.Customizations?.[masterName]?.[moduleName] // these functions will act as middlewares @@ -50,21 +52,37 @@ export const UICustomizations = { data.body.PlanConfigurationSearchCriteria.status = status?.status; cleanObject(data.body.PlanConfigurationSearchCriteria); + const dic = { '0': null, '1': ["DRAFT"], '2': ["EXECUTION_TO_BE_DONE"], '3': ["CENSUS_DATA_APPROVAL_IN_PROGRESS", "CENSUS_DATA_APPROVED", "RESOURCE_ESTIMATION_IN_PROGRESS"], "4": ["RESOURCE_ESTIMATIONS_APPROVED"] } + const url = Digit.Hooks.useQueryParams(); + + const tabId = url.tabId ?? '0'; // Default to '0' if tabId is undefined + data.body.PlanConfigurationSearchCriteria.status = dic[String(tabId)]; + cleanObject(data.body.PlanConfigurationSearchCriteria) return data; }, additionalCustomizations: (row, key, column, value, t, searchResult) => { if (key === "Actions") { + // `/${window.contextPath}/employee/microplan/setup-microplan?key=${9}&preview=${true}&action=${false}` return ( { console.log(e, "event") }} + select={(e) => { + console.log(e, "event"); // e contains the selected option + if (e.code === "1") { + // Use window.location.href to navigate + window.location.href = `/${window.contextPath}/employee/microplan/setup-microplan?key=${1}&preview=${true}&action=${false}µplanId=${row.id}&campaignId=${row.CampaignDetails.id}`; + } + if (e.code === "2") { + // Use window.location.href to navigate + window.location.href = `/${window.contextPath}/employee/microplan/setup-microplan?key=${9}&preview=${true}&action=${false}µplanId=${row.id}&campaignId=${row.CampaignDetails.id}`; + } + }} optionKey={"name"} selected={{ code: "1", name: "Actions" }} - > + /> //

$${value}

); @@ -97,6 +115,98 @@ export const UICustomizations = { }, }, + MyMicroplanSearchConfig: { + preProcess: (data, additionalDetails) => { + const { name, status } = data?.state?.searchForm || {}; + + data.body.PlanConfigurationSearchCriteria = {}; + 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; + // delete data.body.PlanConfigurationSearchCriteria.pagination + data.body.PlanConfigurationSearchCriteria.status = status?.status; + cleanObject(data.body.PlanConfigurationSearchCriteria); + + const dic = { '0': null, '1': ["DRAFT"], '2': ["EXECUTION_TO_BE_DONE"], '3': ["CENSUS_DATA_APPROVAL_IN_PROGRESS", "CENSUS_DATA_APPROVED", "RESOURCE_ESTIMATION_IN_PROGRESS"], "4": ["RESOURCE_ESTIMATIONS_APPROVED"] } + const url = Digit.Hooks.useQueryParams(); + + const tabId = url.tabId ?? '0'; // Default to '0' if tabId is undefined + data.body.PlanConfigurationSearchCriteria.status = dic[String(tabId)]; + cleanObject(data.body.PlanConfigurationSearchCriteria) + return data; + }, + additionalCustomizations: (row, key, column, value, t, searchResult) => { + if (key === "Actions") { + // `/${window.contextPath}/employee/microplan/setup-microplan?key=${9}&preview=${true}&action=${false}` + return ( + + row.status === "DRAFT" ? (