Skip to content

Commit 394e1c0

Browse files
authored
Merge pull request #725 from MetaCell/feature/netpyne-149
Feature/netpyne 149
2 parents 577df15 + 6ee606f commit 394e1c0

4 files changed

Lines changed: 92 additions & 26 deletions

File tree

webapp/components/general/TutorialBubble.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const TutorialBubble = ({
7272
const nextTourStep = steps[requestedTourStep];
7373
const { target: nextTarget } = nextTourStep || { target: undefined };
7474

75-
const { target, title, content } = tourStep;
75+
const { target, validation, title, content } = tourStep;
7676

7777
const DOMtarget = getDOMTarget(target, tourStep);
7878
const nextDOMtarget = getDOMTarget(nextTarget, nextTourStep);
@@ -117,6 +117,25 @@ const TutorialBubble = ({
117117
stopTutorial(event);
118118
};
119119

120+
const isNextDisabled = (validationExpr, isDisabled, startElement) => {
121+
if (validationExpr) {
122+
if (startElement?.value === validationExpr) {
123+
return !isDisabled
124+
}
125+
try {
126+
const validationDOMTarget = startElement.querySelector(validationExpr) ||
127+
startElement.parentNode.querySelector(validationExpr)
128+
if (validationDOMTarget && validationDOMTarget.checkVisibility()) {
129+
return !isDisabled;
130+
}
131+
} catch (e) {
132+
// In case the validation expr is not selector
133+
}
134+
return true;
135+
}
136+
return !isDisabled;
137+
};
138+
120139
if (currentTourStep === requestedTourStep) {
121140
tutorialTarget.current = null;
122141
}
@@ -195,7 +214,7 @@ const TutorialBubble = ({
195214
variant="contained"
196215
color="primary"
197216
onClick={listen}
198-
disabled={!nextIsVisible}
217+
disabled={isNextDisabled(validation, nextIsVisible, DOMtarget)}
199218
>
200219
Next
201220
</Button>

webapp/redux/reducers/data/tutorial2_steps.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ const tutorial2_steps = [
3333
<div>
3434
<p>Change the cell rule label to "PTcell"</p>
3535
</div>
36-
)
36+
),
37+
validation: 'PTcell'
3738
},
3839
{
3940
target: '#importCellParamsCellName',
@@ -44,7 +45,8 @@ const tutorial2_steps = [
4445
<div>
4546
<p>Change the template/cell name to "PTcell"</p>
4647
</div>
47-
)
48+
),
49+
validation: 'PTcell'
4850
},
4951
{
5052
target: '.fa-folder',
@@ -55,7 +57,7 @@ const tutorial2_steps = [
5557
<div>
5658
<p>Click on the folder icon to select the template:</p>
5759
<p> NetPyNE-UI &gt; workspace</p>
58-
<p> &gt; cells &gt; PTcells.hoc</p>
60+
<p> &gt; cells &gt; PTcell.hoc</p>
5961
</div>
6062
)
6163
},
@@ -179,7 +181,8 @@ const tutorial2_steps = [
179181
<div>
180182
<p>Change the cell rule label to "SRI"</p>
181183
</div>
182-
)
184+
),
185+
validation: 'SRI'
183186
},
184187
{
185188
target: '#importCellParamsCellName',
@@ -190,7 +193,8 @@ const tutorial2_steps = [
190193
<div>
191194
<p>Change the template/cell name to "SRI"</p>
192195
</div>
193-
)
196+
),
197+
validation: 'SRI'
194198
},
195199
{
196200
target: '.fa-folder',
@@ -288,7 +292,8 @@ const tutorial2_steps = [
288292
),
289293
content: (
290294
<p>Change the population name to "E"</p>
291-
)
295+
),
296+
validation: 'input[value="E"]'
292297
},
293298
{
294299
target: 'div[id^="netParamspopParams"][id$="cellType"]',
@@ -306,7 +311,8 @@ const tutorial2_steps = [
306311
),
307312
content: (
308313
<p>Enter 2 as number of cells</p>
309-
)
314+
),
315+
validation: '2'
310316
},
311317
{
312318
target: '#newPopulationButton',
@@ -326,7 +332,8 @@ const tutorial2_steps = [
326332
),
327333
content: (
328334
<p>Change the population name to "I"</p>
329-
)
335+
),
336+
validation: 'input[value="I"]'
330337
},
331338
{
332339
target: 'div[id^="netParamspopParams"][id$="cellType"]',
@@ -355,7 +362,8 @@ const tutorial2_steps = [
355362
),
356363
content: (
357364
<p>Enter 2 as number of cells</p>
358-
)
365+
),
366+
validation: '2'
359367
},
360368
// Network creation
361369
{

webapp/redux/reducers/data/tutorial3_steps.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ const tutorial3_steps = [
148148
<p>Increase the initial concentration to 0.1.</p>
149149
</div>
150150
),
151-
waitFor: 'fieldEdition'
151+
waitFor: 'fieldEdition',
152+
validation: '0.1'
152153
},
153154
// Update the model
154155
{

webapp/redux/reducers/data/tutorial_steps.js

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ const tutorial_steps = [
2222
},
2323
{
2424
target: '#cellRuleName',
25+
validation: 'input[value="pyr"]',
2526
title: 'Cell Customization',
2627
content: (
2728
<p>Rename the cell type: "pyr" for pyramidal.</p>
28-
)
29+
),
30+
validation: 'pyr'
2931
},
3032
{
3133
target: '#newSectionButton',
@@ -82,7 +84,8 @@ const tutorial_steps = [
8284
title: 'Cell Population Creation',
8385
content: (
8486
<p>Change the population name to “E” for excitatory</p>
85-
)
87+
),
88+
validation: 'input[value="E"]',
8689
},
8790
{
8891
target: 'div[id*="netParamspopParams"][id*="cellType"]',
@@ -108,7 +111,8 @@ const tutorial_steps = [
108111
title: 'Cell Population Creation',
109112
content: (
110113
<p>Enter 40 for the number of cells</p>
111-
)
114+
),
115+
validation: '40',
112116
},
113117
{
114118
target: '.MuiGrid-item .MuiButton-root:nth-last-child(2)',
@@ -169,7 +173,8 @@ const tutorial_steps = [
169173
content: (
170174
<p>Name the synapse “exc”</p>
171175
),
172-
collectionIndex: 2
176+
collectionIndex: 2,
177+
validation: 'exc'
173178
},
174179
{
175180
target: 'MuiInputBase-input MuiFilledInput-input',
@@ -185,23 +190,26 @@ const tutorial_steps = [
185190
content: (
186191
<p>Enter 0.1 in Time constant for exponential 1 </p>
187192
),
188-
collectionIndex: 4
193+
collectionIndex: 4,
194+
validation: '0.1'
189195
},
190196
{
191197
target: 'MuiInputBase-input MuiFilledInput-input',
192198
title: 'Synaptic Mechanism Creation',
193199
content: (
194-
<p>Enter 1.0 in Time constant for exponential 2</p>
200+
<p>Enter 1.0 (or 1) in Time constant for exponential 2</p>
195201
),
196-
collectionIndex: 5
202+
collectionIndex: 5,
203+
validation: '1'
197204
},
198205
{
199206
target: 'MuiInputBase-input MuiFilledInput-input',
200207
title: 'Synaptic Mechanism Creation',
201208
content: (
202209
<p>Enter 0 in Reversal potential </p>
203210
),
204-
collectionIndex: 6
211+
collectionIndex: 6,
212+
validation: '0'
205213
},
206214
{
207215
target: 'img[src*="connParams.svg"]',
@@ -223,6 +231,7 @@ const tutorial_steps = [
223231
content: (
224232
<p>Name the rule "E-&gt;E" (without spaces)</p>
225233
),
234+
validation: 'E->E'
226235
},
227236
{
228237
target: 'input[id*="netParamsconnParams"][id*="weight"]',
@@ -232,6 +241,7 @@ const tutorial_steps = [
232241
<p>Enter 0.005 in Weight of synaptic connection</p>
233242
</>
234243
),
244+
validation: '0.005'
235245
},
236246
{
237247
target: 'input[id*="netParamsconnParams"][id*="probability"]',
@@ -241,6 +251,7 @@ const tutorial_steps = [
241251
<p>Enter 0.1 in Probability of connection</p>
242252
</>
243253
),
254+
validation: '0.1'
244255
},
245256
{
246257
target: 'input[id*="netParamsconnParams"][id*="delay"]',
@@ -250,6 +261,7 @@ const tutorial_steps = [
250261
<p>Enter 5 in Connection delay</p>
251262
</>
252263
),
264+
validation: '5'
253265
},
254266
{
255267
target: 'div[id*="netParamsconnParams"][id*="synMech"]',
@@ -268,6 +280,7 @@ const tutorial_steps = [
268280
<p>Add "dend" as new postsynaptic neuron section</p>
269281
</>
270282
),
283+
validation: 'dend'
271284
},
272285
{
273286
target: 'button[id^="netParamsconnParams"][id$="sec-button"]',
@@ -286,6 +299,7 @@ const tutorial_steps = [
286299
<p>Enter 0.5 as new postsynaptic neuron location</p>
287300
</>
288301
),
302+
validation: '0.5'
289303
},
290304
{
291305
target: 'button[id^="netParamsconnParams"][id$="loc-button"]',
@@ -395,13 +409,25 @@ const tutorial_steps = [
395409
<p>Type "IClamp1" in The name of the stimulation source</p>
396410
</>
397411
),
412+
validation: 'IClamp1'
398413
},
399414
{
400415
target: '#stimSourceSelect',
401416
title: 'Stimulation Sources Creation',
402417
content: (
403418
<>
404-
<p>Set "IClamp" as the Point process used as stimulator</p>
419+
<p>Set the Point process used as stimulator</p>
420+
</>
421+
),
422+
waitFor: 'click',
423+
grabGlobalClick: true
424+
},
425+
{
426+
target: 'li[data-value^="IClamp"]',
427+
title: 'Stimulation Sources Creation',
428+
content: (
429+
<>
430+
<p>Select "IClamp" as the Point process</p>
405431
</>
406432
),
407433
},
@@ -413,6 +439,7 @@ const tutorial_steps = [
413439
<p>Set Current clamp delay to 20</p>
414440
</>
415441
),
442+
validation: '20'
416443
},
417444
{
418445
target: 'input[id^="netParamsstimSourceParams"][id$="dur"]',
@@ -422,6 +449,7 @@ const tutorial_steps = [
422449
<p>Set Current clamp duration to 5</p>
423450
</>
424451
),
452+
validation: '5'
425453
},
426454
{
427455
target: 'input[id^="netParamsstimSourceParams"][id$="amp"]',
@@ -431,6 +459,7 @@ const tutorial_steps = [
431459
<p>Set Current clamp amplitude to 0.1 </p>
432460
</>
433461
),
462+
validation: '0.1'
434463
},
435464
//
436465
// Simulation targets
@@ -461,6 +490,7 @@ const tutorial_steps = [
461490
<p>Type “IClamp1-&gt;cell0” in The name of the stimulation target </p>
462491
</>
463492
),
493+
validation: 'IClamp1->cell0'
464494
},
465495
{
466496
target: 'div[id*="netParamsstimTargetParams"][id*="source"]',
@@ -479,6 +509,7 @@ const tutorial_steps = [
479509
<p>Type “dend” in Target section</p>
480510
</>
481511
),
512+
validation: 'dend'
482513
},
483514
{
484515
target: 'input[id*="netParamsstimTargetParams"][id*="loc"]',
@@ -488,6 +519,7 @@ const tutorial_steps = [
488519
<p>Enter 1 in Target location</p>
489520
</>
490521
),
522+
validation: '1'
491523
},
492524
//
493525
// Conditions tab
@@ -508,7 +540,8 @@ const tutorial_steps = [
508540
<>
509541
<p>Enter 0 as new Target cell global indices</p>
510542
</>
511-
)
543+
),
544+
validation: '0'
512545
},
513546
{
514547
target: 'button[id*="netParamsstimTargetParams"][id*="condscellList-button"]',
@@ -539,7 +572,8 @@ const tutorial_steps = [
539572
<>
540573
<p>Change the Duration to 200</p>
541574
</>
542-
)
575+
),
576+
validation: '200'
543577
},
544578
{
545579
target: '#simConfigdt',
@@ -549,6 +583,7 @@ const tutorial_steps = [
549583
<p>Change the Time Step to 0.1</p>
550584
</>
551585
),
586+
validation: '0.1'
552587
},
553588
{
554589
target: '#configRecord',
@@ -566,7 +601,8 @@ const tutorial_steps = [
566601
<>
567602
<p>Enter 0 as new Cells to record traces from</p>
568603
</>
569-
)
604+
),
605+
validation: '0'
570606
},
571607
{
572608
target: '#simConfigrecordCells-button',
@@ -583,8 +619,10 @@ const tutorial_steps = [
583619
content: (
584620
<>
585621
<p>Type "{"V_dend: {sec: dend, loc: 1.0, var: v}"}"</p>
622+
<p>(note: the tutorial input validation is case and space sensitive)</p>
586623
</>
587-
)
624+
),
625+
validation: 'V_dend: {sec: dend, loc: 1.0, var: v}'
588626
},
589627
{
590628
target: '#simConfigrecordTraces-button',
@@ -760,4 +798,4 @@ const tutorial_steps = [
760798
)
761799
}
762800
]
763-
export default tutorial_steps;
801+
export default tutorial_steps;

0 commit comments

Comments
 (0)