Skip to content

Commit

Permalink
feat(protocol-designer): rename change tip options (#2003)
Browse files Browse the repository at this point in the history
- fix bug with forms defaulting to blank change tip option

Closes #1933
  • Loading branch information
IanLondon authored Aug 3, 2018
1 parent fa47f85 commit e80fd25
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 27 deletions.
2 changes: 1 addition & 1 deletion protocol-designer/src/components/StepEditForm/MixForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const MixForm = (props: MixFormProps): React.Element<React.Fragment> => {
</FormGroup>
</div>
<div className={styles.right_settings_column}>
<ChangeTipField name="aspirate_changeTip" />
<ChangeTipField stepType="mix" name="aspirate_changeTip" />
<FlowRateField />
<TipPositionField />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const TransferLikeForm = (props: TransferLikeFormProps) => {
</FormGroup>
</div>
<div className={styles.right_settings_column}>
<ChangeTipField name="aspirate_changeTip" />
<ChangeTipField stepType={stepType} name="aspirate_changeTip" />
<FlowRateField />
<TipPositionField />
</div>
Expand Down
46 changes: 30 additions & 16 deletions protocol-designer/src/components/StepEditForm/formFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,22 +181,36 @@ export const FlowRateField = () => <FormGroup label='FLOW RATE'>Default</FormGro
// this is a placeholder
export const TipPositionField = () => <FormGroup label='TIP POSITION'>Bottom, center</FormGroup>

const CHANGE_TIP_OPTIONS = [
{name: 'Always', value: 'always'},
{name: 'Once', value: 'once'},
const getChangeTipOptions = () => [
{name: 'For each aspirate', value: 'always'},
{name: 'Only the first aspirate', value: 'once'},
{name: 'Never', value: 'never'}
]

// NOTE: ChangeTipField not validated as of 6/27/18 so no focusHandlers needed
type ChangeTipFieldProps = {name: StepFieldName}
export const ChangeTipField = (props: ChangeTipFieldProps) => (
<StepField
name={props.name}
render={({value, updateValue}) => (
<FormGroup label='CHANGE TIP'>
<DropdownField
options={CHANGE_TIP_OPTIONS}
value={value ? String(value) : null}
onChange={(e: SyntheticEvent<HTMLSelectElement>) => { updateValue(e.currentTarget.value) } } />
</FormGroup>
)} />
)
type ChangeTipFieldProps = {name: StepFieldName, stepType: StepType}
export const ChangeTipField = (props: ChangeTipFieldProps) => {
const {name, stepType} = props
let options = getChangeTipOptions()
// Override change tip option names for certain step types
switch (stepType) {
case 'consolidate':
options[0].name = 'For each dispense'
break
case 'mix':
options[0].name = 'For each well'
break
}
return (
<StepField
name={name}
render={({value, updateValue}) => (
<FormGroup label='Get new tip'>
<DropdownField
options={options}
value={value ? String(value) : null}
onChange={(e: SyntheticEvent<HTMLSelectElement>) => { updateValue(e.currentTarget.value) } } />
</FormGroup>
)} />
)
}
2 changes: 2 additions & 0 deletions protocol-designer/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ export const FIXED_TRASH_ID: 'trashId' = 'trashId'

export const START_TERMINAL_TITLE = 'STARTING DECK STATE'
export const END_TERMINAL_TITLE = 'FINAL DECK STATE'

export const DEFAULT_CHANGE_TIP_OPTION: 'always' = 'always'
5 changes: 0 additions & 5 deletions protocol-designer/src/steplist/fieldLevel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ export type {
StepFieldName
}

const DEFAULT_CHANGE_TIP_OPTION: 'always' = 'always'

const hydrateLabware = (state, id) => (labwareIngredSelectors.getLabware(state)[id])

type StepFieldHelpers = {
Expand All @@ -35,9 +33,6 @@ const stepFieldHelperMap: {[StepFieldName]: StepFieldHelpers} = {
getErrors: composeErrors(requiredField),
hydrate: hydrateLabware
},
'changeTip': {
processValue: defaultTo(DEFAULT_CHANGE_TIP_OPTION)
},
'dispense_delayMinutes': {
processValue: composeProcessors(castToNumber, defaultTo(0))
},
Expand Down
10 changes: 6 additions & 4 deletions protocol-designer/src/steplist/formProcessing.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import type {
CommandCreatorData
} from '../step-generation'

import {FIXED_TRASH_ID} from '../constants'

const DEFAULT_CHANGE_TIP_OPTION: 'always' = 'always'
import {
DEFAULT_CHANGE_TIP_OPTION,
FIXED_TRASH_ID
} from '../constants'

// TODO LATER Ian 2018-03-01 remove or consolidate these 2 similar types?
export type ValidFormAndErrors = {
Expand Down Expand Up @@ -55,13 +56,14 @@ export const generateNewForm = (stepId: StepIdType, stepType: StepType): BlankFo
if (stepType === 'transfer' || stepType === 'consolidate' || stepType === 'mix') {
return {
...baseForm,
'aspirate_changeTip': 'once'
'aspirate_changeTip': DEFAULT_CHANGE_TIP_OPTION
}
}

if (stepType === 'distribute') {
return {
...baseForm,
'aspirate_changeTip': DEFAULT_CHANGE_TIP_OPTION,
'aspirate_disposalVol_checkbox': true,
'dispense_blowout_checkbox': true,
'dispense_blowout_labware': FIXED_TRASH_ID
Expand Down

0 comments on commit e80fd25

Please sign in to comment.