diff --git a/webapp/components/general/NetPyNECoordsRange.js b/webapp/components/general/NetPyNECoordsRange.js index 51ba51e3..bd0bad21 100644 --- a/webapp/components/general/NetPyNECoordsRange.js +++ b/webapp/components/general/NetPyNECoordsRange.js @@ -96,11 +96,32 @@ export default class NetPyNECoordsRange extends Component { handleCoordParamChange(index, newValue) { const { model, + conds, name, } = this.props; + + function getOppositeObject(list, givenValue) { + const index = list.findIndex(obj => obj.value === givenValue); + + if (index === -1 || list.length !== 2) { + return null; + } + return list[1 - index]; + } + + const opossiteRangeType = getOppositeObject(this.props.items, this.state.rangeType) ; + + if (opossiteRangeType) + { + const pythonMessageDelOpposite = `netpyne_geppetto.${model}['${name}']['${conds}'].pop('${opossiteRangeType.value}', None)`; + Utils.execPythonMessage( + pythonMessageDelOpposite + ); + } + const rangeValue = this.state.rangeValue ; rangeValue[index] = newValue ; - const pythonMessage = `netpyne_geppetto.${model}['${name}']['${this.state.rangeType}'] = [${rangeValue}]` ; + const pythonMessage = `netpyne_geppetto.${model}['${name}']['${conds}']['${this.state.rangeType}'] = [${rangeValue}]` ; Utils.execPythonMessage( pythonMessage );