Skip to content

Commit 0d70618

Browse files
author
rodriguez-facundo
committed
#152 Add 'import from template' to create new celltype button
1 parent b84e72f commit 0d70618

6 files changed

Lines changed: 33 additions & 21 deletions

File tree

webapp/components/definition/cellRules/NetPyNECellRule.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,6 @@ class NetPyNECellRule extends React.Component {
114114
>Add new section</Button>
115115
</Box>
116116

117-
<Box m={1}>
118-
<Button
119-
variant="contained"
120-
color="secondary"
121-
onClick={() => this.props.openTopbarDialog(this.state.currentName)}
122-
>Import cell template</Button>
123-
</Box>
124-
125-
126117
</div>
127118
{dialogPop}
128119
</div>

webapp/components/definition/cellRules/NetPyNECellRules.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import {
1010
NetPyNEThumbnail,
1111
GridLayout,
1212
Filter,
13-
NetPyNESection
13+
NetPyNESection,
14+
SelectCellTemplate
1415
} from 'netpyne/components';
1516

16-
import SelectCellTemplate from './SelectCellTemplate'
1717
import NetPyNEMechanism from './sections/mechanisms/NetPyNEMechanism';
1818
import NetPyNENewMechanism from './sections/mechanisms/NetPyNENewMechanism';
1919

webapp/components/definition/cellRules/SelectCellTemplate.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ export default class NetPyNENewPlot extends React.Component {
2828
this.props.callback()
2929
})
3030
}
31+
32+
handleOpenTopbarDialog () {
33+
var cellRuleId = Utils.getAvailableKey(this.props.model, "CellType");
34+
this.props.openTopbarDialog(cellRuleId)
35+
this.props.callback()
36+
}
3137

3238
render () {
3339
const { page, label, tooltip, handleButtonClick, anchorEl, clearAnchorEl } = this.props
@@ -76,6 +82,15 @@ export default class NetPyNENewPlot extends React.Component {
7682
>
7783
Ball and stick HH
7884
</MenuItem>
85+
86+
87+
<MenuItem
88+
key={"fromTemplate"}
89+
value={"fromTemplate"}
90+
onClick={() => this.handleOpenTopbarDialog()}
91+
>
92+
Import cell template
93+
</MenuItem>
7994

8095
</Menu>
8196
</div>

webapp/components/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,12 @@ export const Dialog = connect(
282282
dispatch => ({ handleClose: () => dispatch(closeDialog), })
283283
)(_Dialog)
284284

285+
286+
import _SelectCellTemplate from './definition/cellRules/SelectCellTemplate'
287+
export const SelectCellTemplate = connect(
288+
null,
289+
dispatch => ({ openTopbarDialog: cellTemplateName => dispatch(openTopbarDialog(TOPBAR_CONSTANTS.IMPORT_CELL_TEMPLATE, { cellRuleName: cellTemplateName })), })
290+
)(_SelectCellTemplate)
285291
// ---------------------------------------------------------------------------------------- //
286292

287293
// DEFAULTS

webapp/components/topbar/Topbar.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,46 +89,46 @@ class Topbar extends Component {
8989
switch (this.props.topbarDialogName){
9090
case TOPBAR_CONSTANTS.LOAD:
9191
content = <LoadFileDialog
92-
open={this.props.openDialog}
92+
open={this.props.dialogOpen}
9393
onRequestClose={() => this.handleClose()}
9494
/>
9595
break;
9696
case TOPBAR_CONSTANTS.SAVE:
9797
content = <SaveFileDialog
98-
open={this.props.openDialog}
98+
open={this.props.dialogOpen}
9999
onRequestClose={() => this.handleClose()}
100100
/>
101101
break;
102102
case TOPBAR_CONSTANTS.IMPORT_HLS:
103103
content = <ImportExportHLSDialog
104-
open={this.props.openDialog}
104+
open={this.props.dialogOpen}
105105
onRequestClose={() => this.handleClose()}
106106
mode ={"IMPORT"}/>
107107
break;
108108
case TOPBAR_CONSTANTS.EXPORT_HLS:
109109
content = <ImportExportHLSDialog
110-
open={this.props.openDialog}
110+
open={this.props.dialogOpen}
111111
onRequestClose={() => this.handleClose()}
112112
mode ={"EXPORT"}
113113
/>
114114
break;
115115
case TOPBAR_CONSTANTS.IMPORT_CELL_TEMPLATE:
116116
content = <ImportCellParamsDialog
117-
open={this.props.openDialog}
118-
cellRuleName={this.props.dialogMetadata.cellRuleName}
117+
open={this.props.dialogOpen}
118+
cellRuleName={this.props.topbarDialogMetadata.cellRuleName}
119119
onRequestClose={() => this.handleClose()}
120120
/>
121121
break;
122122
case TOPBAR_CONSTANTS.NEW_MODEL:
123123
content = <NewModelDialog
124-
open={this.props.openDialog}
124+
open={this.props.dialogOpen}
125125
onRequestClose={() => this.handleClose()}
126126
onAction={() => this.resetModel()}
127127
/>
128128
break;
129129
case TOPBAR_CONSTANTS.UPLOAD_FILES:
130130
content = <UploadDownloadFilesDialog
131-
open={this.props.openDialog}
131+
open={this.props.dialogOpen}
132132
onRequestClose={() => this.handleClose()}
133133
openSnackBar={message => {
134134
this.handleOpenSnackBar(message)
@@ -137,7 +137,7 @@ class Topbar extends Component {
137137
break;
138138
case TOPBAR_CONSTANTS.DOWNLOAD_FILES:
139139
content = <UploadDownloadFilesDialog
140-
open={this.props.openDialog}
140+
open={this.props.dialogOpen}
141141
onRequestClose={() => this.handleClose()}
142142
openSnackBar={message => {
143143
this.handleOpenSnackBar(message)

webapp/components/topbar/dialogs/ImportCellParams.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ImportCellParams extends React.Component {
3838
constructor (props) {
3939
super(props);
4040
this.state = {
41-
label: props.dialogMetadata.cellRuleName,
41+
label: props.cellRuleName,
4242
fileName: '',
4343
cellName: '',
4444
modFolder: '',

0 commit comments

Comments
 (0)