Skip to content

Commit 7876448

Browse files
committed
Added numeric validation to coords range fields
1 parent fa97c66 commit 7876448

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

webapp/components/general/NetPyNECoordsRange.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,23 +109,25 @@ export default class NetPyNECoordsRange extends Component {
109109
return list[1 - index];
110110
}
111111

112-
const opossiteRangeType = getOppositeObject(this.props.items, this.state.rangeType) ;
112+
if (newValue === '' || (/^\d+$/.test(newValue))) {
113+
const opossiteRangeType = getOppositeObject(this.props.items, this.state.rangeType) ;
113114

114-
if (opossiteRangeType)
115-
{
116-
const pythonMessageDelOpposite = `netpyne_geppetto.${model}['${name}']['${conds}'].pop('${opossiteRangeType.value}', None)`;
115+
if (opossiteRangeType)
116+
{
117+
const pythonMessageDelOpposite = `netpyne_geppetto.${model}['${name}']['${conds}'].pop('${opossiteRangeType.value}', None)`;
118+
Utils.execPythonMessage(
119+
pythonMessageDelOpposite
120+
);
121+
}
122+
123+
const rangeValue = this.state.rangeValue ;
124+
rangeValue[index] = newValue ;
125+
const pythonMessage = `netpyne_geppetto.${model}['${name}']['${conds}']['${this.state.rangeType}'] = [${rangeValue}]` ;
117126
Utils.execPythonMessage(
118-
pythonMessageDelOpposite
127+
pythonMessage
119128
);
129+
this.setState({ rangeValue })
120130
}
121-
122-
const rangeValue = this.state.rangeValue ;
123-
rangeValue[index] = newValue ;
124-
const pythonMessage = `netpyne_geppetto.${model}['${name}']['${conds}']['${this.state.rangeType}'] = [${rangeValue}]` ;
125-
Utils.execPythonMessage(
126-
pythonMessage
127-
);
128-
this.setState({ rangeValue })
129131
}
130132

131133
render () {

0 commit comments

Comments
 (0)