Skip to content

Commit

Permalink
Mp hypothesis (#1505)
Browse files Browse the repository at this point in the history
* changes in assumptionsForm and Hypothesis

* changes in css

* changes

* minor changes

* css update

* update in css version

* fixed the issue regarding validations and vertical stepper

* added mdms source

* resolved comments

* validation issue fixed

* changes in assumptionsForm and fixed validation issue for assumptions

* resolved comments
  • Loading branch information
Bhargav-egov authored Oct 11, 2024
1 parent c32e6f7 commit 8f2ad09
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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].77-campaign/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].78-campaign/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
@@ -1,6 +1,6 @@
{
"name": "@egovernments/digit-ui-css",
"version": "1.0.77-campaign",
"version": "1.0.78-campaign",
"license": "MIT",
"main": "dist/index.css",
"author": "Jagankumar <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2537,6 +2537,12 @@ $border-color: rgba(214, 213, 212, 1);
align-items: center;
width: 30rem !important;
}
.assumption-label{
display: flex;
flex-wrap: wrap;
align-items: center;
width: 30rem;
}


.kpi-container {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const AssumptionsForm = ({ onSelect, ...props }) => {
if (executionCount < 5) {
if(resourceDistributionStrategyCode === "MIXED"){
onSelect(props.props.name, {selectedRegistrationProcess,selectedDistributionProcess})
setExecutionCount((prevCount) => prevCount + 1);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const FormulaConfigWrapper = ({onSelect, props:customProps})=>{

const [selectedCategory, setSelectedCategory] = useState("GENERAL_ESTIMATION");
const { state, dispatch } = useMyContext();
console.log(state)



customProps.ruleConfigurations = state.AutoFilledRuleConfigurations?.[0]?.ruleConfigurationCategories?.[0]?.ruleConfigurations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@ const Hypothesis = ({ category, assumptions:initialAssumptions })=>{
deletedAssumptionCategories.current[category].push(deletedAssumption);

setDeletedAssumptions(prev => [...prev, deletedAssumption]);
setAssumptions(updatedAssumptions);
setAssumptionValues((prevValues) =>
prevValues.filter((value) => value.key !== deletedAssumption)
);


setAssumptions(updatedAssumptions);

setAssumptionToDelete(null);
}

Expand All @@ -85,7 +88,7 @@ const addNewAssumption = () => {
if (!assumptionValues.some(assumption => assumption.key === assumptionToAdd)) {
setAssumptionValues(prevValues => [
...prevValues,
{ key: assumptionToAdd, value: null } // or an initial value
{ source:"MDMS",key: assumptionToAdd, value: null, } // or an initial value
]);
}

Expand All @@ -96,7 +99,6 @@ const addNewAssumption = () => {
};




return (
<>
Expand All @@ -113,7 +115,7 @@ const addNewAssumption = () => {

return (
<LabelFieldPair className="mp-hypothesis-label-field" key={index}>
<div className="name-container" style={{width:"20rem"}}>
<div className="assumption-label">
<span>{`${t(item)}`}
<span className="mandatory-span">*</span>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@ const HypothesisWrapper = ({ onSelect, props: customProps }) => {
const handleNext = () => {
const currentAssumptions = assumptionCategories[internalKey - 1]?.assumptions || [];
const existingAssumptionKeys = assumptionValues?.map(assumption => assumption.key);
// Filter current assumptions to only those that exist in assumptionValues and are not deleted

//Filter current assumptions to only those that exist in assumptionValues and are not deleted
const visibleAssumptions = currentAssumptions.filter(item =>
existingAssumptionKeys?.includes(item) && !deletedAssumptions?.includes(item)
);

// Validate: Check if any value is empty for visible assumptions
//Validate: Check if any value is empty for visible assumptions
const hasEmptyFields = visibleAssumptions.some(item => {
const value = assumptionValues.find(assumption => assumption.key === item)?.value;
return !value; // Check if any value is empty
Expand Down Expand Up @@ -138,19 +139,17 @@ const HypothesisWrapper = ({ onSelect, props: customProps }) => {





const handleBack = () => {
if (internalKey >1) {
setInternalKey((prevKey) => prevKey - 1); // Update key in URL
}else{
window.dispatchEvent(new Event("moveToPrevious"))
}
};
// const [stepFilledStatus, setStepFilledStatus] = useState(Array(assumptionCategories.length).fill(false));

const handleStepClick = (step)=>{

// Step is zero-based, so we adjust by adding 1
// Step is zero-based, so we adjust by adding 1
const currentStepIndex = internalKey - 1; // Current step index (zero-based)

// // Check if the clicked step is the next step
Expand All @@ -168,14 +167,14 @@ const HypothesisWrapper = ({ onSelect, props: customProps }) => {
return !value; // Check if any value is empty
});

// If there are empty fields, show an error and do not allow moving to the next step

if (hasEmptyFields) {
setShowToast({
key: "error",
label: t("ERR_MANDATORY_FIELD"),
transitionTime: 3000,
});
return; // Prevent moving to the next step
return;
}

// Move to the next step if validation passes
Expand Down Expand Up @@ -220,8 +219,6 @@ const HypothesisWrapper = ({ onSelect, props: customProps }) => {
}, [assumptionValues, internalKey]);
useEffect(() => {
if (executionCount < 5) {


onSelect(customProps.name, {assumptionValues})
setExecutionCount((prevCount) => prevCount + 1);
}
Expand All @@ -233,11 +230,9 @@ const HypothesisWrapper = ({ onSelect, props: customProps }) => {
updateUrlParams({ internalKey,});
}, [internalKey]);


useEffect(() => {
// Initialize assumptionValues with all assumptions set to null
const initialAssumptions = filteredAssumptions.map(item => ({
source:"MDMS",
source: "MDMS",
category: null,
key: item,
value: null
Expand All @@ -246,16 +241,17 @@ const HypothesisWrapper = ({ onSelect, props: customProps }) => {
// Create a set of existing keys for quick lookup
const existingKeys = new Set(assumptionValues.map(assumption => assumption.key));

// Filter out initialAssumptions to avoid duplicates
const newAssumptions = initialAssumptions.filter(assumption => !existingKeys.has(assumption.key));
// Filter out initialAssumptions to avoid duplicates and deleted assumptions
const newAssumptions = initialAssumptions.filter(assumption =>
!existingKeys.has(assumption.key) &&
!deletedAssumptions.includes(assumption.key)
);

// Update state only with non-duplicate assumptions
setAssumptionValues(prev => [...prev, ...newAssumptions]);
}, [filteredAssumptions]);






useEffect(() => {
if (internalKey === assumptionCategories.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ const createUpdatePlanProject = async (req) => {
}else {
setShowToast({ key: "error", label: "ERR_ASSUMPTIONS_FORM_UPDATE" });
}

case "SUB_HYPOTHESIS":
//first fetch current plan object
const fetchedPlanForSubHypothesis = await searchPlanConfig({
Expand Down
2 changes: 1 addition & 1 deletion health/micro-ui/web/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />
<!-- added below css for hcm-workbench module inclusion-->

<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].77-campaign/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].78-campaign/dist/index.css" />

<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
Expand Down

0 comments on commit 8f2ad09

Please sign in to comment.