@@ -32,11 +32,34 @@ export default class NetPyNESubCellsConnectivityRule extends React.Component {
3232 sectionId : 'General' ,
3333 errorMessage : undefined ,
3434 errorDetails : undefined ,
35- type : 'uniform' ,
36- coord : '' ,
35+ type : undefined ,
36+ density : undefined ,
37+ coord : undefined ,
3738 } ;
3839 }
3940
41+ refreshComponent ( ) {
42+ //get initial values
43+ Utils . evalPythonMessage ( `netpyne_geppetto.netParams.subConnParams["${
44+ this . props . name
45+ } "]`)
46+ . then ( ( response ) => {
47+ if ( ( typeof response == 'object' ) && ( response . density ) )
48+ {
49+ this . setState ( { type : response . density . type , density : response . density } ) //splitting so it fires update
50+ }
51+ } )
52+ }
53+
54+ componentDidUpdate ( prevProps , prevState ) {
55+ if ( JSON . stringify ( prevProps . model ) != JSON . stringify ( this . props . model ) )
56+ this . refreshComponent ( ) ;
57+ }
58+
59+ componentDidMount ( ) {
60+ this . refreshComponent ( ) ;
61+ }
62+
4063 handleRenameChange = ( event ) => {
4164 const storedValue = this . props . name ;
4265 const newValue = Utils . nameValidation ( event . target . value ) ;
@@ -105,20 +128,14 @@ export default class NetPyNESubCellsConnectivityRule extends React.Component {
105128 }
106129
107130 UNSAFE_componentWillReceiveProps ( nextProps ) {
108- this . setState ( { currentName : nextProps . name } ) ;
131+ this . setState ( { currentName : nextProps . name , type : nextProps . model . density } ) ;
109132 }
110133
111134 handleDensity ( value ) {
112135 this . setState ( { type : value } )
113- if ( value === 'uniform' ) {
114- Utils . execPythonMessage (
115- `netpyne_geppetto.netParams.subConnParams['${ this . props . name } ']['density'] = 'uniform'` ,
116- )
117- } else {
118- Utils . execPythonMessage (
119- `netpyne_geppetto.netParams.subConnParams['${ this . props . name } ']['density'] = {}` ,
120- )
121- }
136+ Utils . execPythonMessage (
137+ `netpyne_geppetto.netParams.subConnParams['${ this . props . name } ']['density'] = { 'type': '${ value } ' }` ,
138+ )
122139 }
123140
124141 handleCoord ( value ) {
0 commit comments