Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates to inbox, UICust #1552

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />

<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].36/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].38/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import _ from "lodash";
import { useLocation, useHistory,Link,useParams } from "react-router-dom";
import React from "react";
import { Dropdown } from "@egovernments/digit-ui-components";
import { DeleteIconv2, DownloadIcon, FileIcon, Button, Card, CardSubHeader,EditIcon,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
Expand Down Expand Up @@ -778,21 +779,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 (
<Dropdown
option={[
{ code: "1", name: "Edit Setup" },
{ code: "2", name: "Duplicate Setup" },
{ code: "3", name: "View Summary" },
{ code: "2", name: "View Summary" },
]}
select={(e) => { 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}&microplanId=${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}&microplanId=${row.id}&campaignId=${row.CampaignDetails.id}`;
}
}}
optionKey={"name"}
selected={{ code: "1", name: "Actions" }}
></Dropdown>
/>
// <p>$${value}</p>

);
Expand Down Expand Up @@ -825,31 +842,124 @@ 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" ? (<Button
label={t("WBH_EDIT")}
variation="secondary"
icon={<EditIcon styles={{ height: "1.25rem", width: "2.5rem" }} />}
type="button"
className="dm-workbench-download-template-btn dm-hover"
onButtonClick={(e) => {

}}
/>) : (row.status === "EXECUTION_TO_BE_DONE") ? (
<Button
label={t("START")}
variation="secondary"
icon={<ArrowForward styles={{ height: "1.25rem", width: "2.5rem" }} />}
type="button"
className="dm-workbench-download-template-btn dm-hover"
onButtonClick={(e) => {

}}
/>
) : (row.status === "RESOURCE_ESTIMATIONS_APPROVED") ? (
<Button
label={t("WBH_DOWNLOAD")}
variation="secondary"
icon={<DownloadIcon styles={{ height: "1.25rem", width: "2.5rem" }} />}
type="button"
className="dm-workbench-download-template-btn dm-hover"
onButtonClick={(e) => {

}}
/>
) : null


);
}

if (key === "Name of the Microplan") {
if (value && value !== "NA") {

return (
<div
style={{
maxWidth: '15rem', // Set the desired maximum width
wordWrap: 'break-word', // Allows breaking within words
whiteSpace: 'normal', // Ensures text wraps normally
overflowWrap: 'break-word' // Break long words at the edge
}}
>
<p>{value}</p>
</div>
)
} else {
return (
<div>
<p>NA</p>
</div>
)
}

}

},
},

UserManagementConfig: {

customValidationCheck: (data) => {
const { phone } = data;
const mobileRegex = /^[0-9]{10}$/;

// Allow empty mobile number
if (!phone || phone.trim() === "") {
return false;
return false;
}

// Check if phone matches the regex
if (!mobileRegex.test(phone)) {
return { error: true, label: "INVALID_MOBILE_NUMBER" }; // Return an error message if invalid
}

return false;
},
preProcess: (data, additionalDetails) => {


preProcess: (data, additionalDetails) => {
const { phone, name } = data?.state?.searchForm || {}
const { sortOrder } = data?.state?.filterForm || {}
let { roleschosen } = data?.state?.filterForm || []

if (!roleschosen) {
roleschosen = {}
}
Expand All @@ -865,34 +975,31 @@ export const UICustomizations = {
if (roleschosen) {
rolesString = Object.keys(roleschosen).filter(role => roleschosen[role] === true).join(',');
}




data.params.names = name;

data.params.phone = phone;

data.params.roles = rolesString;
data.params.tenantId = Digit.ULBService.getCurrentTenantId();
cleanObject(data.params);
delete data.params.roleschosen;
delete data.params.name;


return data
},

rolesForFilter: (props) => {
const userInfo = Digit.UserService.getUser();
const tenantId = Digit.ULBService.getCurrentTenantId();

return {
params: {},
url: '/mdms-v2/v2/_search', //mdms fetch from

body: {
MdmsCriteria: {
tenantId: Digit.ULBService.getCurrentTenantId(),
tenantId: Digit.ULBService.getCurrentTenantId(),
filters: {},
schemaCode: "hcm-microplanning.rolesForMicroplan",
limit: 10,
Expand All @@ -908,46 +1015,41 @@ export const UICustomizations = {
{
roleCode: item.data.roleCode,
i18nKey: Digit.Utils.locale.getTransformedLocale(`MP_ROLE_${item.data.roleCode}`)
// orderNumber: item.data.orderNumber

// roleCode:{labelKey:item.data.roleCode}

}
)
})

return roles
},
},
// changeQueryName:"setPlantUsersInboxDropdown"
}
},




additionalCustomizations: (row, key, column, value, t, searchResult) => {


if (key === "Role") {

if (value && value !== "NA") {
return (
<div>
{value.map((item, index) => (
<span key={index} className="dm-code">
{t(`MP_ROLE_${item.code}`)}
{index < value.length - 1 && ", "}
</span>
))}
</div>
);

return (
<div>
{value.map((item, index) => (
<span key={index} className="dm-code">
{Digit.Utils.locale.getTransformedLocale(`MP_ROLE_${item.code}`)}
{index < value.length - 1 && ", "}
</span>
))}
</div>
);
}

}else{
return(
<div>NA</div>
)
}





},

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
@import "./pages/employee/index.scss";
@import "./pages/employee/campaign.scss";
@import "./pages/employee/formulaConfig.scss";

@import "./pages/employee/microplanInbox.scss";

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.pop-inbox-wrapper {
display: flex;
flex-direction: column;
gap: 2rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"dependencies": {
"@egovernments/digit-ui-react-components": "1.8.2-beta.11",
"@egovernments/digit-ui-components": "0.0.2-beta.41",
"@egovernments/digit-ui-components": "0.0.2-beta.47",
"react": "17.0.2",
"react-date-range": "^1.4.0",
"react-dom": "17.0.2",
Expand Down
Loading