Skip to content

Commit

Permalink
Hcmpre 1290 (#1834)
Browse files Browse the repository at this point in the history
* fixed app delivery condition

* added my microplan screen

* changes in the url

* changes

---------

Co-authored-by: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com>
  • Loading branch information
Bhavya-egov and jagankumar-egov authored Nov 15, 2024
1 parent bc60ede commit d297c75
Show file tree
Hide file tree
Showing 10 changed files with 263 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const CampaignCard = () => {
}

const { t } = useTranslation();
const userId = Digit.UserService.getUser().info.uuid;
const microplanStatus = "RESOURCE_ESTIMATIONS_APPROVED"

let links = [

Expand All @@ -36,9 +38,9 @@ const CampaignCard = () => {
roles: ROLES.CAMPAIGN_MANAGER,
// count: isLoading?"-":data
},
{ //@Bhavya put the new url and remove the comment
{
label: t("ACTION_TEST_SETUP_CAMPAIGN_FROM_MICROPLAN"),
link: `/${window?.contextPath}/employee/campaign/setup-campaign`,
link: `/${window?.contextPath}/employee/campaign/setup-from-microplan&userId=${userId}&status=${microplanStatus}`,
roles: ROLES.CAMPAIGN_MANAGER
},
{
Expand All @@ -58,7 +60,7 @@ const CampaignCard = () => {
link: `/${window?.contextPath}/employee/campaign/boundary/home`,
roles: ROLES.BOUNDARY_MANAGER,
// count: isLoading?"-":data
},
}
];

links = links.filter((link) => (link?.roles && link?.roles?.length > 0 ? Digit.Utils.didEmployeeHasAtleastOneRole(link?.roles) : true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@ import { ErrorMessage, FieldV1 , Stepper , TextBlock ,Card } from "@egovernments

const CampaignName = ({ onSelect, formData, control, formState, ...props }) => {
const { t } = useTranslation();
const [name, setName] = useState(props?.props?.sessionData?.HCM_CAMPAIGN_NAME?.campaignName || "");

const [executionCount, setExecutionCount] = useState(0);
const [startValidation, setStartValidation] = useState(null);
const [error, setError] = useState(null);
const searchParams = new URLSearchParams(location.search);
const microplanName = searchParams.get("microName");
const source = searchParams.get("source");
const [name, setName] = useState(props?.props?.sessionData?.HCM_CAMPAIGN_NAME?.campaignName || "");
useEffect(() => {
setName(props?.props?.sessionData?.HCM_CAMPAIGN_NAME?.campaignName);
if(source === "microplan"){
const sessionName = props?.props?.sessionData?.HCM_CAMPAIGN_NAME?.campaignName.replace(/&/g, "and");
if(sessionName === microplanName){
setName("");
}
}
else setName(props?.props?.sessionData?.HCM_CAMPAIGN_NAME?.campaignName);
}, [props?.props?.sessionData?.HCM_CAMPAIGN_NAME]);
const searchParams = new URLSearchParams(location.search);

const [currentStep , setCurrentStep] = useState(1);
const currentKey = searchParams.get("key");
const [key, setKey] = useState(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => {
const searchParams = new URLSearchParams(location.search);
const [currentStep , setCurrentStep] = useState(1);
const currentKey = searchParams.get("key");
const source = searchParams.get("source");
const [key, setKey] = useState(() => {
const keyParam = searchParams.get("key");
return keyParam ? parseInt(keyParam) : 1;
Expand Down Expand Up @@ -118,7 +119,7 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => {
<div
className="campaign-type-wrapper"
onClick={(e) => {
if (props?.props?.sessionData?.HCM_CAMPAIGN_TYPE?.projectType && !canUpdate) {
if (props?.props?.sessionData?.HCM_CAMPAIGN_TYPE?.projectType && !canUpdate && source!=="microplan") {
setShowPopUp(true);
return;
}
Expand All @@ -143,6 +144,8 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => {
setStartValidation(true);
handleChange(value);
}}
disabled = {source === "microplan"}

/>
{error?.message && <ErrorMessage message={t(error?.message)} showIcon={true} />}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ export const UICustomizations = {
history.push(`/${window.contextPath}/employee/campaign/checklist/create?campaignName=${campaignName}&role=${role_code}&checklistType=${cl_code}&projectType=${projectType}&campaignId=${campaignId}`)
}}
/>
)
}
);
}
default:
return value;
}
Expand Down Expand Up @@ -299,11 +299,63 @@ export const UICustomizations = {
}}
/>
</>
)
);
}

},
},
MicroplanCampaignSearchConfig: {
preProcess: (data, additionalDetails) => {
const url = window.location.pathname;
const queryString = url.includes("?") ? url.split("?")[1] : url.split("&").slice(1).join("&");
const searchParams = new URLSearchParams(queryString);
const userId = searchParams.get("userId");
const status = searchParams.get("status");
data.body.PlanConfigurationSearchCriteria.userUuid = userId;
data.body.PlanConfigurationSearchCriteria.status = [status];
data.body.PlanConfigurationSearchCriteria.name = data?.state?.searchForm?.microplanName;
// data.body.PlanConfigurationSearchCriteria.campaignType = data?.state?.searchForm?.campaignType?.[0]?.code;
return data;
},
additionalCustomizations: (row, key, column, value, t, searchResult) => {
switch (key) {
case "NAME_OF_MICROPLAN":
if (value && value !== "NA") {
return (
<div
style={{
maxWidth: "15rem",
wordWrap: "break-word",
whiteSpace: "normal",
overflowWrap: "break-word",
}}
>
<p>{t(value)}</p>
</div>
);
} else {
return (
<div>
<p>{t("NA")}</p>
</div>
);
}

case "CAMPAIGN_TYPE":
if (value && value != "NA") {
return <p>{t(Digit.Utils.locale.getTransformedLocale("CAMPAIGN_TYPE_" + value))}</p>;
} else {
return (
<div>
<p>{t("NA")}</p>
</div>
);
}
case "LAST_MODIFIED_TIME":
return Digit.DateUtils.ConvertEpochToDate(value);
default:
return null; // Handle any unexpected keys here if needed
}
},
},
MyCampaignConfigOngoing: {
preProcess: (data, additionalDetails) => {
Expand Down Expand Up @@ -397,7 +449,6 @@ export const UICustomizations = {
setTimeline(true);
break;
case "ACTION_LABEL_CONFIGURE_APP":

window.history.pushState(
{
name: row?.campaignName,
Expand Down Expand Up @@ -715,7 +766,6 @@ export const UICustomizations = {
setTimeline(true);
break;


case "ACTION_LABEL_UPDATE_BOUNDARY_DETAILS":
window.history.pushState(
{
Expand All @@ -735,7 +785,7 @@ export const UICustomizations = {
name: row?.campaignName,
data: row,
projectId: row?.projectId,
campaignType: row?.projectType
campaignType: row?.projectType,
},
"",
`/${window.contextPath}/employee/campaign/checklist/search?name=${row?.campaignName}&campaignId=${row?.id}&projectType=${row?.projectType}`
Expand Down Expand Up @@ -886,7 +936,7 @@ export const UICustomizations = {
return value ? t("CM_UPDATE_REQUEST") : t("CM_CREATE_REQUEST");
case "CAMPAIGN_START_DATE":
return Digit.DateUtils.ConvertEpochToDate(value);
case "CAMPAIGN_END_DATE":
case "LAST_MODIFIED_TIME":
return Digit.DateUtils.ConvertEpochToDate(value);
default:
return "case_not_found";
Expand Down Expand Up @@ -977,8 +1027,8 @@ export const UICustomizations = {
setTimeline(true);
break;
case "ACTION_LABEL_RETRY":
retryCampaign(row,searchResult);
break;
retryCampaign(row, searchResult);
break;
default:
console.log(value);
break;
Expand All @@ -993,7 +1043,8 @@ export const UICustomizations = {
</Link>
</span>
);

case "CM_DRAFT_TYPE":
return value ? t("CM_UPDATE_REQUEST") : t("CM_CREATE_REQUEST");
case "CAMPAIGN_START_DATE":
return Digit.DateUtils.ConvertEpochToDate(value);
case "CAMPAIGN_END_DATE":
Expand All @@ -1006,7 +1057,10 @@ export const UICustomizations = {
type="actionButton"
variation="secondary"
label={"Action"}
options={[{ key: 1, code: "ACTION_LABEL_VIEW_TIMELINE", i18nKey: t("ACTION_LABEL_VIEW_TIMELINE") },{ key: 2, code: "ACTION_LABEL_RETRY", i18nKey: t("ACTION_LABEL_RETRY") }].filter(obj=>Digit.Utils.didEmployeeHasAtleastOneRole(["SYSTEM_ADMINISTRATOR"]||obj?.key!=2))} //added retry for system adminstrator for failed campaign
options={[
{ key: 1, code: "ACTION_LABEL_VIEW_TIMELINE", i18nKey: t("ACTION_LABEL_VIEW_TIMELINE") },
{ key: 2, code: "ACTION_LABEL_RETRY", i18nKey: t("ACTION_LABEL_RETRY") },
].filter((obj) => Digit.Utils.didEmployeeHasAtleastOneRole(["SYSTEM_ADMINISTRATOR"] || obj?.key != 2))} //added retry for system adminstrator for failed campaign
optionsKey="i18nKey"
showBottom={true}
isSearchable={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,11 +524,16 @@ export const myCampaignConfig = {
additionalCustomization: true,
// disableSortBy: true,
},
// {
// label: "CAMPAIGN_END_DATE",
// jsonPath: "endDate",
// additionalCustomization: true,
// // disableSortBy: true,
// },
{
label: "CAMPAIGN_END_DATE",
jsonPath: "endDate",
additionalCustomization: true,
// disableSortBy: true,
label:"LAST_MODIFIED_TIME",
jsonPath:"auditDetails.lastModifiedTime",
additionalCustomization:true
},
],
enableGlobalSearch: false,
Expand Down Expand Up @@ -637,6 +642,11 @@ export const myCampaignConfig = {
jsonPath: "campaignName",
// additionalCustomization: true,
},
{
label: "CM_DRAFT_TYPE",
jsonPath: "parentId",
additionalCustomization: true,
},
{
label: "CAMPAIGN_TYPE",
jsonPath: "projectType",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@


const tenantId = Digit.ULBService.getCurrentTenantId();
const mdms_context_path = window?.globalConfigs?.getConfig("MDMS_V2_CONTEXT_PATH") || "mdms-v2";
export const MicroplanCampaignSearchConfig = [
{
label: "MICROPLAN_SEARCH",
type: "search",
apiDetails: {
serviceName: "/plan-service/config/_search",
requestParam: {
},
requestBody: {
"PlanConfigurationSearchCriteria": {
"limit": 10,
"offset": 0,
"tenantId": tenantId,
},
},
masterName: "commonUiConfig",
moduleName: "MicroplanCampaignSearchConfig",
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:{
microplanName: "",
campaignType: "",
},
fields: [
{
label: "NAME_OF_MICROPLAN",
isMandatory: false,
key: "microplanName",
type: "text",
populators: {
name: "microplanName"
},
},
// {
// label: "CAMPAIGN_SEARCH_TYPE",
// type: "apidropdown",
// isMandatory: false,
// disable: false,
// populators: {
// optionsCustomStyle: {
// top: "2.3rem",
// },
// name: "campaignType",
// optionsKey: "code",
// allowMultiSelect: false,
// masterName: "commonUiConfig",
// moduleName: "MyCampaignConfigDrafts",
// customfn: "populateCampaignTypeReqCriteria",
// },
// },
],
},

show: true,
},
searchResult: {
uiConfig: {
columns: [
{
label: "NAME_OF_MICROPLAN",
jsonPath: "name",
additionalCustomization:true
},
{
label:"CAMPAIGN_TYPE",
jsonPath:"additionalDetails.campaignType",
additionalCustomization:true
},
{
label:"LAST_MODIFIED_TIME",
jsonPath:"auditDetails.lastModifiedTime",
additionalCustomization:true
},
],
resultsJsonPath: "PlanConfiguration",

enableColumnSort: true,
},
show: true,
},

},
},
];


Loading

0 comments on commit d297c75

Please sign in to comment.