From 4001a02688bbc8fae12116f5ebf41fcd9f26075a Mon Sep 17 00:00:00 2001 From: nitish-egov <137176807+nitish-egov@users.noreply.github.com> Date: Wed, 24 Jul 2024 13:35:06 +0530 Subject: [PATCH 01/22] some changes related to generate boundary template (#1133) --- utilities/project-factory/src/server/utils/targetUtils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/utilities/project-factory/src/server/utils/targetUtils.ts b/utilities/project-factory/src/server/utils/targetUtils.ts index 4efca24623f..0ebc47aadb1 100644 --- a/utilities/project-factory/src/server/utils/targetUtils.ts +++ b/utilities/project-factory/src/server/utils/targetUtils.ts @@ -16,6 +16,7 @@ async function generateDynamicTargetHeaders(request: any, campaignObject: any, l } else { headerColumnsAfterHierarchy = await getConfigurableColumnHeadersBasedOnCampaignType(request); + headerColumnsAfterHierarchy.shift(); } return headerColumnsAfterHierarchy; } From e01bec696a910d0a65a1ac425f4eb8e9ac4f2791 Mon Sep 17 00:00:00 2001 From: nitish-egov <137176807+nitish-egov@users.noreply.github.com> Date: Wed, 24 Jul 2024 16:24:54 +0530 Subject: [PATCH 02/22] updated logic for target columns acc to delivery conditions only for smc (#1137) * some changes related to generate boundary template * updated logic for making configurable target acc to delivery only for smc * refactored code for including dynamic target columns for specific types according to configs array --- .../project-factory/src/server/config/index.ts | 2 +- .../src/server/utils/campaignUtils.ts | 4 ++-- .../src/server/utils/targetUtils.ts | 14 ++++++++++---- .../src/server/validators/campaignValidators.ts | 4 ++-- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/utilities/project-factory/src/server/config/index.ts b/utilities/project-factory/src/server/config/index.ts index 83540f022a5..417886225b9 100644 --- a/utilities/project-factory/src/server/config/index.ts +++ b/utilities/project-factory/src/server/config/index.ts @@ -16,8 +16,8 @@ const getDBSchemaName = (dbSchema = "") => { } // Configuration object containing various environment variables const config = { + enableDynamicTemplateFor: ["MR-DN"], isCallGenerateWhenDeliveryConditionsDiffer: true, - enableDynamicTargetTemplate: true, prefixForMicroplanCampaigns: "MP", excludeHierarchyTypeFromBoundaryCodes: false, excludeBoundaryNameAtLastFromBoundaryCodes: false, diff --git a/utilities/project-factory/src/server/utils/campaignUtils.ts b/utilities/project-factory/src/server/utils/campaignUtils.ts index ecefcee6c79..370c346c01d 100644 --- a/utilities/project-factory/src/server/utils/campaignUtils.ts +++ b/utilities/project-factory/src/server/utils/campaignUtils.ts @@ -19,7 +19,7 @@ import { validateBoundaryOfResouces } from "../validators/campaignValidators"; import { getExcelWorkbookFromFileURL, getNewExcelWorkbook, lockTargetFields, updateFontNameToRoboto } from "./excelUtils"; import { callGenerateIfBoundariesDiffer } from "./generateUtils"; import { createProcessTracks, persistTrack } from "./processTrackUtils"; -import { generateDynamicTargetHeaders, updateTargetColumnsIfDeliveryConditionsDifferForSMC } from "./targetUtils"; +import { generateDynamicTargetHeaders, isDynamicTargetTemplateForProjectType, updateTargetColumnsIfDeliveryConditionsDifferForSMC } from "./targetUtils"; const _ = require('lodash'); @@ -1445,7 +1445,7 @@ async function createNewSheet(request: any, workbook: any, newSheetData: any, un addDataToSheet(newSheet, newSheetData, 'F3842D', 40); let columnsNotToBeFreezed: any; const boundaryCodeColumnIndex = localizedHeaders.findIndex((header: any) => header === getLocalizedName(config?.boundary?.boundaryCode, localizationMap)); - if (campaignObject.deliveryRules && campaignObject.deliveryRules.length > 0 && config?.enableDynamicTargetTemplate) { + if (isDynamicTargetTemplateForProjectType(campaignObject?.projectType) && campaignObject.deliveryRules && campaignObject.deliveryRules.length > 0) { columnsNotToBeFreezed = localizedHeaders.slice(boundaryCodeColumnIndex + 1); } else { diff --git a/utilities/project-factory/src/server/utils/targetUtils.ts b/utilities/project-factory/src/server/utils/targetUtils.ts index 0ebc47aadb1..244bcd3016b 100644 --- a/utilities/project-factory/src/server/utils/targetUtils.ts +++ b/utilities/project-factory/src/server/utils/targetUtils.ts @@ -8,8 +8,7 @@ import { callGenerate } from './generateUtils'; async function generateDynamicTargetHeaders(request: any, campaignObject: any, localizationMap?: any) { const isSourceMicroplan = checkIfSourceIsMicroplan(campaignObject); let headerColumnsAfterHierarchy: any; - if (campaignObject.deliveryRules && campaignObject.deliveryRules.length > 0 && config?.enableDynamicTargetTemplate && !isSourceMicroplan) { - + if (isDynamicTargetTemplateForProjectType(campaignObject?.projectType) && campaignObject.deliveryRules && campaignObject.deliveryRules.length > 0 && !isSourceMicroplan) { const modifiedUniqueDeliveryConditions = modifyDeliveryConditions(campaignObject.deliveryRules); headerColumnsAfterHierarchy = generateTargetColumnsBasedOnDeliveryConditions(modifiedUniqueDeliveryConditions, localizationMap); @@ -78,7 +77,7 @@ function generateTargetColumnsBasedOnDeliveryConditions(uniqueDeliveryConditions function createTargetString(uniqueDeliveryConditionsObject: any, localizationMap?: any) { let targetString: any; - const prefix = getLocalizedName("HCM_ADMIN_CONSOLE_TARGET", localizationMap); + const prefix = getLocalizedName("HCM_ADMIN_CONSOLE_TARGET_SMC", localizationMap); const attributeCode = getLocalizedName(uniqueDeliveryConditionsObject.attribute.code.toUpperCase(), localizationMap); const operatorMessage = getLocalizedName(uniqueDeliveryConditionsObject.operator.code, localizationMap); const localizedFROM = getLocalizedName("FROM", localizationMap); @@ -94,7 +93,7 @@ function createTargetString(uniqueDeliveryConditionsObject: any, localizationMap async function updateTargetColumnsIfDeliveryConditionsDifferForSMC(request: any) { const existingCampaignDetails = request?.body?.ExistingCampaignDetails; if (existingCampaignDetails) { - if (config?.isCallGenerateWhenDeliveryConditionsDiffer && !_.isEqual(existingCampaignDetails?.deliveryRules, request?.body?.CampaignDetails?.deliveryRules)) { + if (isDynamicTargetTemplateForProjectType(request?.body?.CampaignDetails?.projectType) && config?.isCallGenerateWhenDeliveryConditionsDiffer && !_.isEqual(existingCampaignDetails?.deliveryRules, request?.body?.CampaignDetails?.deliveryRules)) { const newRequestBody = { RequestInfo: request?.body?.RequestInfo, Filters: { @@ -117,6 +116,12 @@ async function updateTargetColumnsIfDeliveryConditionsDifferForSMC(request: any) } } +function isDynamicTargetTemplateForProjectType(projectType: string) { + const projectTypesFromConfig = config?.enableDynamicTemplateFor; + return projectTypesFromConfig?.includes(projectType) ?? false; +} + + @@ -125,4 +130,5 @@ export { generateTargetColumnsBasedOnDeliveryConditions, generateDynamicTargetHeaders, updateTargetColumnsIfDeliveryConditionsDifferForSMC, + isDynamicTargetTemplateForProjectType }; diff --git a/utilities/project-factory/src/server/validators/campaignValidators.ts b/utilities/project-factory/src/server/validators/campaignValidators.ts index 87f1459ed8d..8c50b9bcd46 100644 --- a/utilities/project-factory/src/server/validators/campaignValidators.ts +++ b/utilities/project-factory/src/server/validators/campaignValidators.ts @@ -20,7 +20,7 @@ import { searchProjectTypeCampaignService } from "../service/campaignManageServi import { campaignStatuses, resourceDataStatuses } from "../config/constants"; import { getBoundaryColumnName, getBoundaryTabName } from "../utils/boundaryUtils"; import addAjvErrors from "ajv-errors"; -import { generateTargetColumnsBasedOnDeliveryConditions, modifyDeliveryConditions } from "../utils/targetUtils"; +import { generateTargetColumnsBasedOnDeliveryConditions, isDynamicTargetTemplateForProjectType, modifyDeliveryConditions } from "../utils/targetUtils"; @@ -220,7 +220,7 @@ async function validateTargets(request: any, data: any[], errors: any[], localiz let columnsToValidate: any; const responseFromCampaignSearch = await getCampaignSearchResponse(request); const campaignObject = responseFromCampaignSearch?.CampaignDetails?.[0]; - if (campaignObject.deliveryRules && campaignObject.deliveryRules.length > 0 && config?.enableDynamicTargetTemplate) { + if (isDynamicTargetTemplateForProjectType(campaignObject?.projectType) && campaignObject.deliveryRules && campaignObject.deliveryRules.length > 0) { const modifiedUniqueDeliveryConditions = modifyDeliveryConditions(campaignObject.deliveryRules); columnsToValidate = generateTargetColumnsBasedOnDeliveryConditions(modifiedUniqueDeliveryConditions, localizationMap); From ef95f2598e3bc33669df6b9682b0d931d0bd05af Mon Sep 17 00:00:00 2001 From: Bhavya-egov <137176879+Bhavya-egov@users.noreply.github.com> Date: Wed, 24 Jul 2024 16:35:51 +0530 Subject: [PATCH 03/22] updated version and boundary fix (#1141) --- .../micro-ui-internals/example/package.json | 2 +- .../example/public/index.html | 2 +- micro-ui/web/micro-ui-internals/package.json | 2 +- .../packages/css/package.json | 2 +- .../css/src/pages/employee/campaign.scss | 1 - .../modules/campaign-manager/package.json | 2 +- .../src/components/TimelineComponent.js | 83 +++++++++++++++---- .../src/components/UploadData.js | 47 ++++++----- micro-ui/web/package.json | 2 +- micro-ui/web/public/index.html | 2 +- micro-ui/web/workbench/package.json | 2 +- 11 files changed, 99 insertions(+), 48 deletions(-) diff --git a/micro-ui/web/micro-ui-internals/example/package.json b/micro-ui/web/micro-ui-internals/example/package.json index b465d0e7127..d7477b96f74 100644 --- a/micro-ui/web/micro-ui-internals/example/package.json +++ b/micro-ui/web/micro-ui-internals/example/package.json @@ -11,7 +11,7 @@ "devDependencies": { "@egovernments/digit-ui-libraries": "1.8.2-beta.5", "@egovernments/digit-ui-module-workbench": "1.0.2-beta.3", - "@egovernments/digit-ui-components": "0.0.2-beta.14", + "@egovernments/digit-ui-components": "0.0.2-beta.15", "@egovernments/digit-ui-module-core": "1.8.2-beta.6", "@egovernments/digit-ui-module-utilities": "1.0.1-beta.30", "@egovernments/digit-ui-react-components": "1.8.2-beta.11", diff --git a/micro-ui/web/micro-ui-internals/example/public/index.html b/micro-ui/web/micro-ui-internals/example/public/index.html index 44c5d8df3a7..cb302969a6c 100644 --- a/micro-ui/web/micro-ui-internals/example/public/index.html +++ b/micro-ui/web/micro-ui-internals/example/public/index.html @@ -17,7 +17,7 @@ - + diff --git a/micro-ui/web/micro-ui-internals/package.json b/micro-ui/web/micro-ui-internals/package.json index 3fb54fe4899..62cf5393350 100644 --- a/micro-ui/web/micro-ui-internals/package.json +++ b/micro-ui/web/micro-ui-internals/package.json @@ -46,7 +46,7 @@ "lodash": "4.17.21", "microbundle-crl": "0.13.11", "@egovernments/digit-ui-react-components": "1.8.2-beta.11", - "@egovernments/digit-ui-components": "0.0.2-beta.14", + "@egovernments/digit-ui-components": "0.0.2-beta.15", "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/css/package.json b/micro-ui/web/micro-ui-internals/packages/css/package.json index dfadba4e94f..387687e08d7 100644 --- a/micro-ui/web/micro-ui-internals/packages/css/package.json +++ b/micro-ui/web/micro-ui-internals/packages/css/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-css", - "version": "1.0.61-campaign", + "version": "1.0.62-campaign", "license": "MIT", "main": "dist/index.css", "author": "Jagankumar ", diff --git a/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/campaign.scss b/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/campaign.scss index a849c77372e..4cc371900f3 100644 --- a/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/campaign.scss +++ b/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/campaign.scss @@ -119,6 +119,5 @@ } .timeline-user{ display: flex; - flex-direction: row-reverse; justify-content: space-between; } diff --git a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/package.json b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/package.json index cee5e99dcf2..d04e6665ff9 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/package.json +++ b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "@egovernments/digit-ui-react-components": "1.8.2-beta.11", - "@egovernments/digit-ui-components": "0.0.2-beta.14", + "@egovernments/digit-ui-components": "0.0.2-beta.15", "@rjsf/core": "5.10.0", "@rjsf/utils": "5.10.0", "@rjsf/validator-ajv8": "5.10.0", diff --git a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/TimelineComponent.js b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/TimelineComponent.js index 6bdefbfcb22..f6ca3957669 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/TimelineComponent.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/TimelineComponent.js @@ -37,6 +37,7 @@ const TimelineComponent = ({campaignId, resourceId}) => { const tenantId = Digit.ULBService.getCurrentTenantId(); const searchParams = new URLSearchParams(location.search); const [userCredential , setUserCredential] = useState(null); + const { data: baseTimeOut } = Digit.Hooks.useCustomMDMS(tenantId, "HCM-ADMIN-CONSOLE", [{ name: "baseTimeOut" }]); const formatLabel = (label) => { return `HCM_${label.replace(/-/g, "_").toUpperCase()}`; @@ -80,13 +81,6 @@ const TimelineComponent = ({campaignId, resourceId}) => { }; // use refetch interval in this const { data: progessTrack , refetch} = Digit.Hooks.useCustomAPIHook(reqCriteria); - useEffect(() => { - const intervalId = setInterval(() => { - refetch(); - }, 60000); // 60000ms = 1 minute - - return () => clearInterval(intervalId); - }, [refetch]); const lastCompletedProcess = progessTrack?.processTrack .filter((process) => process.status === "completed") @@ -97,6 +91,23 @@ const TimelineComponent = ({campaignId, resourceId}) => { return latestProcess; }, null); + useEffect(() => { + let intervalId; + + if (lastCompletedProcess?.type !== 'campaign-creation') { + intervalId = setInterval(() => { + refetch(); + }, baseTimeOut?.["HCM-ADMIN-CONSOLE"]?.baseTimeOut?.[0]?.timelineRefetch); + } + + return () => { + if (intervalId) { + clearInterval(intervalId); + } + }; + }, [lastCompletedProcess]); + + const completedProcesses = progessTrack?.processTrack .filter(process => process.status === 'completed') .sort((a, b) => b.lastModifiedTime - a.lastModifiedTime) @@ -123,21 +134,49 @@ const TimelineComponent = ({campaignId, resourceId}) => { ? upcomingProcesses.map(process => `${t(formatLabel(process.type))} , ${epochToDateTime(process.lastModifiedTime)}`) : []; + // useEffect(()=>{ + // const lastCompletedProcess = progessTrack?.processTrack + // .filter((process) => process.status === "completed") + // .reduce((latestProcess, currentProcess) => { + // if (!latestProcess || currentProcess.lastModifiedTime > latestProcess.lastModifiedTime) { + // return currentProcess; + // } + // return latestProcess; + // }, null); + // setLastCompletedProgress(lastCompletedProcess); + + // const completedProcesses = progessTrack?.processTrack + // .filter(process => process.status === 'completed') + // .sort((a, b) => b.lastModifiedTime - a.lastModifiedTime) + // .map(process => ({ type: process.type, lastModifiedTime: process.lastModifiedTime })); + // setCompletedProgress(completedProcesses); + + + // const completedTimelines = completedProcesses?.map(process => ({ + // label: t(formatLabel(process.type)), + // subElements: [epochToDateTime(process.lastModifiedTime)], + // })); + // setCompletedTimeline(completedTimelines); + + // const inprogressProcesses = progessTrack?.processTrack + // .filter(process => process.status === 'inprogress') + // .map(process => ({ type: process.type, lastModifiedTime: process.lastModifiedTime })); + + // setinprogressProcesses(inprogressProcesses); + + // const upcomingProcesses = progessTrack?.processTrack + // .filter(process => process.status === "toBeCompleted") + // .map(process => ({ type: process.type, lastModifiedTime: process.lastModifiedTime })); + + // setupcomingProcesses(upcomingProcesses); + + // }, [progessTrack]) + return (
- {userCredential && ( -
); diff --git a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js index 71401bf6c4b..9d989d0a9a6 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js @@ -475,18 +475,19 @@ const UploadData = ({ formData, onSelect, ...props }) => { expectedHeaders = XLSX.utils.sheet_to_json(sheet, { header: 1 })[0]; } - for (const header of mdmsHeaders) { - if (!expectedHeaders.includes(t(header))) { - const errorMessage = t("HCM_BOUNDARY_INVALID_SHEET"); - setErrorsType((prevErrors) => ({ - ...prevErrors, - [type]: errorMessage, - })); - setIsError(true); - isValid = false; - break; - } - } + + // for (const header of mdmsHeaders) { + // if (!expectedHeaders.includes(t(header))) { + // const errorMessage = t("HCM_BOUNDARY_INVALID_SHEET"); + // setErrorsType((prevErrors) => ({ + // ...prevErrors, + // [type]: errorMessage, + // })); + // setIsError(true); + // isValid = false; + // break; + // } + // } if (!isValid) return isValid; @@ -505,16 +506,16 @@ const UploadData = ({ formData, onSelect, ...props }) => { })[0]; // Check if headers match the expected headers - if (!arraysEqual(headersToValidate, expectedHeaders)) { - const errorMessage = t("HCM_MISSING_HEADERS"); - setErrorsType((prevErrors) => ({ - ...prevErrors, - [type]: errorMessage, - })); - setIsError(true); - isValid = false; - break; - } + // if (!arraysEqual(headersToValidate, expectedHeaders)) { + // const errorMessage = t("HCM_MISSING_HEADERS"); + // setErrorsType((prevErrors) => ({ + // ...prevErrors, + // [type]: errorMessage, + // })); + // setIsError(true); + // isValid = false; + // break; + // } } if (!isValid) return isValid; @@ -536,6 +537,8 @@ const UploadData = ({ formData, onSelect, ...props }) => { })[0]; const jsonData = XLSX.utils.sheet_to_json(sheet, { blankrows: true }); + + if(jsonData.length == 0) continue; const boundaryCodeIndex = headersToValidate.indexOf(t("HCM_ADMIN_CONSOLE_BOUNDARY_CODE")); diff --git a/micro-ui/web/package.json b/micro-ui/web/package.json index e6ab4936637..5dcba66d352 100644 --- a/micro-ui/web/package.json +++ b/micro-ui/web/package.json @@ -19,7 +19,7 @@ "@egovernments/digit-ui-module-core": "1.8.2-beta.6", "@egovernments/digit-ui-module-hrms": "1.8.0-beta.2", "@egovernments/digit-ui-react-components": "1.8.2-beta.11", - "@egovernments/digit-ui-components": "0.0.2-beta.14", + "@egovernments/digit-ui-components": "0.0.2-beta.15", "@egovernments/digit-ui-module-dss": "1.8.0-beta", "@egovernments/digit-ui-module-common": "1.8.0-beta", "@egovernments/digit-ui-module-utilities": "1.0.0-beta", diff --git a/micro-ui/web/public/index.html b/micro-ui/web/public/index.html index 1e83fb5524f..f4499a408a4 100644 --- a/micro-ui/web/public/index.html +++ b/micro-ui/web/public/index.html @@ -11,7 +11,7 @@ - + DIGIT diff --git a/micro-ui/web/workbench/package.json b/micro-ui/web/workbench/package.json index 75ff74cd786..a7e81bbf16c 100644 --- a/micro-ui/web/workbench/package.json +++ b/micro-ui/web/workbench/package.json @@ -14,7 +14,7 @@ "dependencies": { "@egovernments/digit-ui-libraries": "1.8.2-beta.5", "@egovernments/digit-ui-module-workbench": "1.0.2-beta.3", - "@egovernments/digit-ui-components": "0.0.2-beta.14", + "@egovernments/digit-ui-components": "0.0.2-beta.15", "@egovernments/digit-ui-module-core": "1.8.2-beta.6", "@egovernments/digit-ui-module-utilities": "1.0.1-beta.30", "@egovernments/digit-ui-react-components": "1.8.2-beta.11", From 96ff68a9ae96589d16c9b34c9bb1f5f2e4f3abb5 Mon Sep 17 00:00:00 2001 From: nitish-egov <137176807+nitish-egov@users.noreply.github.com> Date: Wed, 24 Jul 2024 17:01:07 +0530 Subject: [PATCH 04/22] updated readmeconfig for sheet (#1142) --- .../project-factory/src/server/utils/excelUtils.ts | 4 ++-- .../src/server/utils/genericUtils.ts | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/utilities/project-factory/src/server/utils/excelUtils.ts b/utilities/project-factory/src/server/utils/excelUtils.ts index e8ee221b781..8f7a0acc614 100644 --- a/utilities/project-factory/src/server/utils/excelUtils.ts +++ b/utilities/project-factory/src/server/utils/excelUtils.ts @@ -71,8 +71,8 @@ function updateFontNameToRoboto(worksheet: ExcelJS.Worksheet) { function formatWorksheet(worksheet: any, datas: any, headerSet: any) { // Add empty rows after the main header - worksheet.addRow([]); - worksheet.addRow([]); + // worksheet.addRow([]); + // worksheet.addRow([]); worksheet.addRow([]); // Add the data rows with text wrapping diff --git a/utilities/project-factory/src/server/utils/genericUtils.ts b/utilities/project-factory/src/server/utils/genericUtils.ts index 6c276c37092..6b8ca7c24e5 100644 --- a/utilities/project-factory/src/server/utils/genericUtils.ts +++ b/utilities/project-factory/src/server/utils/genericUtils.ts @@ -521,13 +521,15 @@ async function createReadMeSheet(request: any, workbook: any, mainHeader: any, l const headerSet = new Set(); - const datas = readMeConfig.texts.flatMap((text: any) => { - const descriptions = text.descriptions.map((description: any) => { - return getLocalizedName(description.text, localizationMap); + const datas = readMeConfig.texts + .filter((text: any) => text?.inSheet) // Filter out texts with inSheet set to false + .flatMap((text: any) => { + const descriptions = text.descriptions.map((description: any) => { + return getLocalizedName(description.text, localizationMap); + }); + headerSet.add(getLocalizedName(text.header, localizationMap)); + return [getLocalizedName(text.header, localizationMap), ...descriptions, ""]; }); - headerSet.add(getLocalizedName(text.header, localizationMap)); - return [getLocalizedName(text.header, localizationMap), ...descriptions, "", "", "", ""]; - }); // Create the worksheet and add the main header const worksheet = workbook.addWorksheet(getLocalizedName("HCM_README_SHEETNAME", localizationMap)); From 33d980ca112071db6517303d826f907ced10836d Mon Sep 17 00:00:00 2001 From: nabeelmd-eGov <94039229+nabeelmd-eGov@users.noreply.github.com> Date: Wed, 24 Jul 2024 17:27:20 +0530 Subject: [PATCH 05/22] HCMPRE-140: Action column fixes, date editable logic change (#1143) * Action column fixes, date editable logic change * added roles for dss --------- Co-authored-by: nabeelmd-eGov --- .../src/components/BoundaryWithDate.js | 2 +- .../src/components/CampaignSummary.js | 60 ++++++--------- .../src/components/DSSCard.js | 22 ++++-- .../src/components/DateWithBoundary.js | 16 +++- .../src/configs/UICustomizations.js | 74 +++++++++++++++++++ .../src/configs/myCampaignConfig.js | 12 +++ .../src/pages/employee/MyCampaign.js | 13 ++-- .../src/pages/employee/SetupCampaign.js | 40 ++++++++-- .../src/pages/employee/index.js | 5 ++ 9 files changed, 183 insertions(+), 61 deletions(-) diff --git a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/BoundaryWithDate.js b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/BoundaryWithDate.js index 4026e38313a..b9683e364b3 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/BoundaryWithDate.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/BoundaryWithDate.js @@ -161,7 +161,7 @@ const BoundaryWithDate = ({ project, props, onSelect, dateReducerDispatch }) => withoutLabel={true} type="date" value={item?.endDate} - nonEditable={today >= item?.endDate ? true : false} + nonEditable={today >= item?.endDate && today >= cycleDates?.[index + 1]?.startDate ? true : false} placeholder={t("HCM_END_DATE")} populators={ today >= item?.endDate diff --git a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignSummary.js b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignSummary.js index 4b4acf3e1bc..c17e2fed55a 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignSummary.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignSummary.js @@ -141,7 +141,6 @@ const CampaignSummary = (props) => { const searchParams = new URLSearchParams(location.search); const id = searchParams.get("id"); const noAction = searchParams.get("action"); - const isChangeDates = searchParams.get("changeDates"); const [showToast, setShowToast] = useState(null); const [userCredential, setUserCredential] = useState(null); const [deliveryErrors, setDeliveryErrors] = useState(null); @@ -223,50 +222,33 @@ const CampaignSummary = (props) => { return { cards: [ isPreview - ? - { - name: "timeline", - sections: [ - { + ? { name: "timeline", - type: "COMPONENT", - component: "TimelineComponent", - props: { - campaignId: data?.[0]?.id, - resourceId: resourceIdArr - }, - cardHeader: { value: t("HCM_TIMELINE"), inlineStyles: { marginTop: 0, fontSize: "1.5rem" } }, - }, - ], - }: {}, + sections: [ + { + name: "timeline", + type: "COMPONENT", + component: "TimelineComponent", + props: { + campaignId: data?.[0]?.id, + resourceId: resourceIdArr, + }, + cardHeader: { value: t("HCM_TIMELINE"), inlineStyles: { marginTop: 0, fontSize: "1.5rem" } }, + }, + ], + } + : {}, { sections: [ { type: "DATA", cardHeader: { value: t("CAMPAIGN_DETAILS"), inlineStyles: { marginTop: 0, fontSize: "1.5rem" } }, - cardSecondaryAction: - isChangeDates === "true" ? ( -
- history.push(`/${window.contextPath}/employee/campaign/update-dates-boundary?id=${id}`, { - name: data?.[0]?.campaignName, - projectId: data?.[0]?.projectId, - data: data?.[0], - }) - } - > - {t(`CAMPAIGN_UPDATE_DATES`)} - -
- ) : ( - noAction !== "false" && ( -
handleRedirect(1)}> - {t(`CAMPAIGN_EDIT`)} - -
- ) - ), + cardSecondaryAction: noAction !== "false" && ( +
handleRedirect(1)}> + {t(`CAMPAIGN_EDIT`)} + +
+ ), values: [ { key: "CAMPAIGN_TYPE", diff --git a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/DSSCard.js b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/DSSCard.js index 5420f16df52..c8970672d33 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/DSSCard.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/DSSCard.js @@ -59,6 +59,11 @@ const NDSSCard = () => { const DSSCard = () => { const STADMIN = Digit.UserService.hasAccess("STADMIN"); + const isNationalSupervisor = Digit.UserService.hasAccess(["NATIONAL_SUPERVISOR"]); + const isProvincialSupervisor = Digit.UserService.hasAccess(["PROVINCIAL_SUPERVISOR"]); + const isDistrictSupervisor = Digit.UserService.hasAccess(["DISTRICT_SUPERVISOR"]); + const isHealthFacilitySupervisor = Digit.UserService.hasAccess(["HEALTH_FACILITY_SUPERVISOR"]); + const isCommunitySupervisor = Digit.UserService.hasAccess(["COMMUNITY_SUPERVISOR"]); const { t } = useTranslation(); const { data: tenantData } = Digit.Hooks.dss.useMDMS(Digit.ULBService.getStateId(), "tenant", ["tenants"], { @@ -69,15 +74,22 @@ const DSSCard = () => { enabled: true, }); + if ( + !STADMIN || + !isNationalSupervisor || + !isProvincialSupervisor || + !isDistrictSupervisor || + !isHealthFacilitySupervisor || + !isCommunitySupervisor + ) { + return null; + } + const shouldInvokeProjectService = tenantData?.integrateProjectService || false; if (shouldInvokeProjectService) { return ; } - if (!STADMIN) { - return null; - } - let links = Object.values(nationalScreenURLs) .filter((ele) => ele["active"] === true) .map((obj) => ({ @@ -206,4 +218,4 @@ const DynamicDSSCard = () => { return ; }; -export { DSSCard, NDSSCard }; \ No newline at end of file +export { DSSCard, NDSSCard }; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/DateWithBoundary.js b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/DateWithBoundary.js index acffd238847..e2b9498cbcc 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/DateWithBoundary.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/DateWithBoundary.js @@ -1,4 +1,4 @@ -import React, { useState, useEffect, Fragment, useReducer } from "react"; +import React, { useState, useEffect, Fragment, useReducer, useMemo } from "react"; import { useTranslation } from "react-i18next"; import { useLocation } from "react-router-dom"; import { LabelFieldPair, Header } from "@egovernments/digit-ui-react-components"; @@ -106,6 +106,10 @@ const DateWithBoundary = ({ onSelect, formData, ...props }) => { return data?.["HCM-ADMIN-CONSOLE"]?.hierarchyConfig?.find((item) => item.isActive)?.hierarchy; }, }); + const { isLoading, data: hierarchyConfig } = Digit.Hooks.useCustomMDMS(tenantId, "HCM-ADMIN-CONSOLE", [{ name: "hierarchyConfig" }]); + const lowestHierarchy = useMemo(() => { + return hierarchyConfig?.["HCM-ADMIN-CONSOLE"]?.hierarchyConfig?.find((item) => item.isActive)?.lowestHierarchy; + }, [hierarchyConfig]); const [hierarchyTypeDataresult, setHierarchyTypeDataresult] = useState([]); const [selectedLevel, setSelectedLevel] = useState(null); const [filteredBoundaries, setFilteredBoundaries] = useState([]); @@ -170,11 +174,17 @@ const DateWithBoundary = ({ onSelect, formData, ...props }) => { return sortedHierarchy; }; - const sortedHierarchy = sortHierarchy(hierarchyDefinition.boundaryHierarchy); + const temp = sortHierarchy(hierarchyDefinition.boundaryHierarchy); + const sortedHierarchy = temp.filter((boundary, index, array) => { + // Find the index of the lowest hierarchy + const lowestIndex = array.findIndex((b) => b.boundaryType === lowestHierarchy); + // Include only those boundaries that are above or equal to the lowest hierarchy + return index <= lowestIndex; + }); const sortedHierarchyWithLocale = sortedHierarchy.map((i) => { return { ...i, - i18nKey: BOUNDARY_HIERARCHY_TYPE + "_" + i?.boundaryType, + i18nKey: (BOUNDARY_HIERARCHY_TYPE + "_" + i?.boundaryType).toUpperCase(), }; }); setHierarchyTypeDataresult(sortedHierarchyWithLocale); diff --git a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js index 8dcbb992ed7..881d767a315 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js @@ -250,6 +250,17 @@ export const UICustomizations = { return ""; }, additionalCustomizations: (row, key, column, value, t, searchResult) => { + const [timeLine, setTimeline] = React.useState(false); + const onActionSelect = (value, row) => { + switch (value?.code) { + case "ACTION_LABEL_VIEW_TIMELINE": + setTimeline(true); + break; + default: + console.log(value); + break; + } + }; switch (key) { case "CAMPAIGN_NAME": return ( @@ -264,6 +275,32 @@ export const UICustomizations = { return Digit.DateUtils.ConvertEpochToDate(value); case "CAMPAIGN_END_DATE": return Digit.DateUtils.ConvertEpochToDate(value); + case "CAMPAIGN_ACTIONS": + return ( + <> +