Skip to content

Commit

Permalink
changed logic to reset and set inputs changed for all types of inputs…
Browse files Browse the repository at this point in the history
… and resert when user runs the flowsheet
  • Loading branch information
Sufi Kaur committed Aug 7, 2024
1 parent 61768ca commit a2010ee
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
26 changes: 20 additions & 6 deletions electron/ui/src/views/FlowsheetConfig/ConfigInput/ConfigInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ export default function ConfigInput(props) {
})
}, [flowsheetData.inputData]);

// this is bad
useEffect(() => {
setInputsChanged(true)
}, [displayData])


useEffect(() => {
// console.log(`setting number of subprocesses current: ${numberOfSubprocesses.current}, max: ${numberOfSubprocesses.max}`)
setCurrentNumberOfSubprocesses(numberOfSubprocesses.current)
Expand Down Expand Up @@ -152,30 +146,50 @@ export default function ConfigInput(props) {
const handleUpdateDisplayValue = (id, value) => {
let tempFlowsheetData = { ...flowsheetData };
const inputs = getInputs(tempFlowsheetData)

console.debug('updating ' + id + ' with value ' + value + '. previous value was ' + inputs[id].value)
inputs[id].value = value

// if (outputs!= null || value != Number(outputs.exports[id].value).toFixed(outputs.exports[id].rounding)) {
setInputsChanged(true)
// }
// else {
// setInputsChanged(false)

// // setAlteredInputs(alteredInputs().filter((_,i) => i !== id))
// // setAlteredInputs(altertedInputs)
// }

}

// solved, solved and changed, only changed
// solved ->
// solved and changed,
// only changed

const handleUpdateFixed = (id, value, type) => {
let tempFlowsheetData = {...flowsheetData}
const inputs = getInputs(tempFlowsheetData);
inputs[id].fixed = value;
inputs[id].is_sweep = (type === "sweep");
updateFlowsheetData(tempFlowsheetData, null)
setInputsChanged(true)
runButtonRef.current?.checkDisableRun()
// checkDisableRun()
}

const handleUpdateBounds = (id, value, bound) => {
let tempFlowsheetData = {...flowsheetData}
const inputs = getInputs(tempFlowsheetData)
setInputsChanged(true)
inputs[id][bound] = value
}

const handleUpdateSamples = (id, value) => {
let tempFlowsheetData = {...flowsheetData}
const inputs = getInputs(tempFlowsheetData)
inputs[id].num_samples = value
setInputsChanged(true)
console.debug('updating samples ' + id + ' with value ' + value + ' ' + inputs[id].num_samples)
}
/**
Expand Down
10 changes: 10 additions & 0 deletions electron/ui/src/views/FlowsheetConfig/FlowsheetConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ export default function FlowsheetConfig(props) {


const [inputsChanged, setInputsChanged] = useState(false);
// const [alteredInputs, setAlteredInputs] = useState([])

// const [dialogVisible, setDialogVisible] = useState(false);
// const [pendingPath, setPendingPath] = useState(null);

Expand Down Expand Up @@ -219,6 +221,7 @@ export default function FlowsheetConfig(props) {
setFlowsheetData(tempFlowsheetData);
setTabValue(1);
setSolveDialogOpen(false);
setInputsChanged(false)
}

const handleError = (msg) => {
Expand Down Expand Up @@ -308,6 +311,13 @@ export default function FlowsheetConfig(props) {
}
}

// useEffect(()=>{
// if(alteredInputs.length >= 1) {
// setInputsChanged(true)
// }

// }, [alteredInputs])

console.log("Returning container for FlowsheetConfig. build_options=", flowsheetData.inputData.build_options, "isBuilt=", isBuilt,
"loadingFlowsheetData=", loadingFlowsheetData);
return (
Expand Down

0 comments on commit a2010ee

Please sign in to comment.