Skip to content

Commit cba8943

Browse files
committed
netpyne-149 Add first full version of validation for tutorial text
fields
1 parent 57037a3 commit cba8943

2 files changed

Lines changed: 65 additions & 20 deletions

File tree

webapp/components/general/TutorialBubble.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,19 @@ const TutorialBubble = ({
117117
stopTutorial(event);
118118
};
119119

120-
const isNextDisabled = (validationTarget, step, isDisabled) => {
121-
if (validationTarget) {
122-
const validationDOMTarget = getDOMTarget(validationTarget, undefined);
123-
if (validationDOMTarget && validationDOMTarget.checkVisibility()) {
124-
return !isDisabled;
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
125133
}
126134
return true;
127135
}
@@ -206,7 +214,7 @@ const TutorialBubble = ({
206214
variant="contained"
207215
color="primary"
208216
onClick={listen}
209-
disabled={isNextDisabled(validation, tourStep, isNextDisabled)}
217+
disabled={isNextDisabled(validation, nextIsVisible, DOMtarget)}
210218
>
211219
Next
212220
</Button>

webapp/redux/reducers/data/tutorial_steps.js

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ const tutorial_steps = [
2626
title: 'Cell Customization',
2727
content: (
2828
<p>Rename the cell type: "pyr" for pyramidal.</p>
29-
)
29+
),
30+
validation: 'pyr'
3031
},
3132
{
3233
target: '#newSectionButton',
@@ -83,7 +84,8 @@ const tutorial_steps = [
8384
title: 'Cell Population Creation',
8485
content: (
8586
<p>Change the population name to “E” for excitatory</p>
86-
)
87+
),
88+
validation: 'input[value="E"]',
8789
},
8890
{
8991
target: 'div[id*="netParamspopParams"][id*="cellType"]',
@@ -109,7 +111,8 @@ const tutorial_steps = [
109111
title: 'Cell Population Creation',
110112
content: (
111113
<p>Enter 40 for the number of cells</p>
112-
)
114+
),
115+
validation: '40',
113116
},
114117
{
115118
target: '.MuiGrid-item .MuiButton-root:nth-last-child(2)',
@@ -170,7 +173,8 @@ const tutorial_steps = [
170173
content: (
171174
<p>Name the synapse “exc”</p>
172175
),
173-
collectionIndex: 2
176+
collectionIndex: 2,
177+
validation: 'exc'
174178
},
175179
{
176180
target: 'MuiInputBase-input MuiFilledInput-input',
@@ -186,23 +190,26 @@ const tutorial_steps = [
186190
content: (
187191
<p>Enter 0.1 in Time constant for exponential 1 </p>
188192
),
189-
collectionIndex: 4
193+
collectionIndex: 4,
194+
validation: '0.1'
190195
},
191196
{
192197
target: 'MuiInputBase-input MuiFilledInput-input',
193198
title: 'Synaptic Mechanism Creation',
194199
content: (
195-
<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>
196201
),
197-
collectionIndex: 5
202+
collectionIndex: 5,
203+
validation: '1'
198204
},
199205
{
200206
target: 'MuiInputBase-input MuiFilledInput-input',
201207
title: 'Synaptic Mechanism Creation',
202208
content: (
203209
<p>Enter 0 in Reversal potential </p>
204210
),
205-
collectionIndex: 6
211+
collectionIndex: 6,
212+
validation: '0'
206213
},
207214
{
208215
target: 'img[src*="connParams.svg"]',
@@ -224,6 +231,7 @@ const tutorial_steps = [
224231
content: (
225232
<p>Name the rule "E-&gt;E" (without spaces)</p>
226233
),
234+
validation: 'E->E'
227235
},
228236
{
229237
target: 'input[id*="netParamsconnParams"][id*="weight"]',
@@ -233,6 +241,7 @@ const tutorial_steps = [
233241
<p>Enter 0.005 in Weight of synaptic connection</p>
234242
</>
235243
),
244+
validation: '0.005'
236245
},
237246
{
238247
target: 'input[id*="netParamsconnParams"][id*="probability"]',
@@ -242,6 +251,7 @@ const tutorial_steps = [
242251
<p>Enter 0.1 in Probability of connection</p>
243252
</>
244253
),
254+
validation: '0.1'
245255
},
246256
{
247257
target: 'input[id*="netParamsconnParams"][id*="delay"]',
@@ -251,6 +261,7 @@ const tutorial_steps = [
251261
<p>Enter 5 in Connection delay</p>
252262
</>
253263
),
264+
validation: '5'
254265
},
255266
{
256267
target: 'div[id*="netParamsconnParams"][id*="synMech"]',
@@ -269,6 +280,7 @@ const tutorial_steps = [
269280
<p>Add "dend" as new postsynaptic neuron section</p>
270281
</>
271282
),
283+
validation: 'dend'
272284
},
273285
{
274286
target: 'button[id^="netParamsconnParams"][id$="sec-button"]',
@@ -287,6 +299,7 @@ const tutorial_steps = [
287299
<p>Enter 0.5 as new postsynaptic neuron location</p>
288300
</>
289301
),
302+
validation: '0.5'
290303
},
291304
{
292305
target: 'button[id^="netParamsconnParams"][id$="loc-button"]',
@@ -396,13 +409,25 @@ const tutorial_steps = [
396409
<p>Type "IClamp1" in The name of the stimulation source</p>
397410
</>
398411
),
412+
validation: 'IClamp1'
399413
},
400414
{
401415
target: '#stimSourceSelect',
402416
title: 'Stimulation Sources Creation',
403417
content: (
404418
<>
405-
<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>
406431
</>
407432
),
408433
},
@@ -414,6 +439,7 @@ const tutorial_steps = [
414439
<p>Set Current clamp delay to 20</p>
415440
</>
416441
),
442+
validation: '20'
417443
},
418444
{
419445
target: 'input[id^="netParamsstimSourceParams"][id$="dur"]',
@@ -423,6 +449,7 @@ const tutorial_steps = [
423449
<p>Set Current clamp duration to 5</p>
424450
</>
425451
),
452+
validation: '5'
426453
},
427454
{
428455
target: 'input[id^="netParamsstimSourceParams"][id$="amp"]',
@@ -432,6 +459,7 @@ const tutorial_steps = [
432459
<p>Set Current clamp amplitude to 0.1 </p>
433460
</>
434461
),
462+
validation: '0.1'
435463
},
436464
//
437465
// Simulation targets
@@ -462,6 +490,7 @@ const tutorial_steps = [
462490
<p>Type “IClamp1-&gt;cell0” in The name of the stimulation target </p>
463491
</>
464492
),
493+
validation: 'IClamp1->cell0'
465494
},
466495
{
467496
target: 'div[id*="netParamsstimTargetParams"][id*="source"]',
@@ -480,6 +509,7 @@ const tutorial_steps = [
480509
<p>Type “dend” in Target section</p>
481510
</>
482511
),
512+
validation: 'dend'
483513
},
484514
{
485515
target: 'input[id*="netParamsstimTargetParams"][id*="loc"]',
@@ -489,6 +519,7 @@ const tutorial_steps = [
489519
<p>Enter 1 in Target location</p>
490520
</>
491521
),
522+
validation: '1'
492523
},
493524
//
494525
// Conditions tab
@@ -509,7 +540,8 @@ const tutorial_steps = [
509540
<>
510541
<p>Enter 0 as new Target cell global indices</p>
511542
</>
512-
)
543+
),
544+
validation: '0'
513545
},
514546
{
515547
target: 'button[id*="netParamsstimTargetParams"][id*="condscellList-button"]',
@@ -540,7 +572,8 @@ const tutorial_steps = [
540572
<>
541573
<p>Change the Duration to 200</p>
542574
</>
543-
)
575+
),
576+
validation: '200'
544577
},
545578
{
546579
target: '#simConfigdt',
@@ -550,6 +583,7 @@ const tutorial_steps = [
550583
<p>Change the Time Step to 0.1</p>
551584
</>
552585
),
586+
validation: '0.1'
553587
},
554588
{
555589
target: '#configRecord',
@@ -567,7 +601,8 @@ const tutorial_steps = [
567601
<>
568602
<p>Enter 0 as new Cells to record traces from</p>
569603
</>
570-
)
604+
),
605+
validation: '0'
571606
},
572607
{
573608
target: '#simConfigrecordCells-button',
@@ -584,8 +619,10 @@ const tutorial_steps = [
584619
content: (
585620
<>
586621
<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>
587623
</>
588-
)
624+
),
625+
validation: 'V_dend: {sec: dend, loc: 1.0, var: v}'
589626
},
590627
{
591628
target: '#simConfigrecordTraces-button',
@@ -761,4 +798,4 @@ const tutorial_steps = [
761798
)
762799
}
763800
]
764-
export default tutorial_steps;
801+
export default tutorial_steps;

0 commit comments

Comments
 (0)