Skip to content

Commit

Permalink
Prevent tasks linking to themselves (#5925)
Browse files Browse the repository at this point in the history
Add a task prop to the NextTaskSelector in the lab and pass down the current task. Filter the current task out of the list of next task options.
  • Loading branch information
eatyourgreens authored Apr 13, 2021
1 parent 4125df6 commit 4dc080d
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/classifier/tasks/combo/editor.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ ComboTaskEditor = createReactClass
<p>
<label>
Next task:{' '}
<NextTaskSelector workflow={@props.workflow} value={@props.task.next} onChange={@setNextTask} />
<NextTaskSelector task={@props.task} workflow={@props.workflow} value={@props.task.next} onChange={@setNextTask} />
</label>
<br />
<span className="form-help">This overrides anything set by a sub-task.</span>
Expand Down
1 change: 1 addition & 0 deletions app/classifier/tasks/dropdown/editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ export default class DropdownEditor extends React.Component {
<span className="form-label">Next task</span>
<br />
<NextTaskSelector
task={this.props.task}
workflow={this.props.workflow}
name={`${this.props.taskPrefix}.next`}
value={this.props.task.next || ''}
Expand Down
4 changes: 2 additions & 2 deletions app/classifier/tasks/generic-editor.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ module.exports = createReactClass
<div className="workflow-choice-setting">
<AutoSave resource={@props.workflow}>
Next task{' '}
<NextTaskSelector workflow={@props.workflow} name="#{@props.taskPrefix}.#{choicesKey}.#{index}.next" value={choice.next ? ''} onChange={handleChange} />
<NextTaskSelector task={@props.task} workflow={@props.workflow} name="#{@props.taskPrefix}.#{choicesKey}.#{index}.next" value={choice.next ? ''} onChange={handleChange} />
</AutoSave>
</div>

Expand Down Expand Up @@ -266,7 +266,7 @@ module.exports = createReactClass
<div>
<AutoSave resource={@props.workflow}>
Next task{' '}
<NextTaskSelector workflow={@props.workflow} name="#{@props.taskPrefix}.next" value={@props.task.next ? ''} onChange={handleChange} />
<NextTaskSelector task={@props.task} workflow={@props.workflow} name="#{@props.taskPrefix}.next" value={@props.task.next ? ''} onChange={handleChange} />
</AutoSave>
</div>}
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/classifier/tasks/next-task-selector.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = createReactClass
<select name={@props.name} value={@props.value} onChange={@props.onChange}>
<option value="">(Submit classification and load next subject)</option>
{for key, definition of @props.workflow.tasks
unless definition.type is 'shortcut'
unless definition.type is 'shortcut' or definition is @props.task
text = tasks[definition.type]?.getTaskText definition
if text and text.length > MAX_TEXT_LENGTH_IN_MENU
text = text[0...MAX_TEXT_LENGTH_IN_MENU] + '...'
Expand Down
1 change: 1 addition & 0 deletions app/classifier/tasks/slider/editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const SliderTaskEditor = (props) => {
<span className="form-label">Next task</span>
<br />
<NextTaskSelector
task={props.task}
workflow={props.workflow}
name={`${props.taskPrefix}.next`}
value={props.task.next ? props.task.next : ''}
Expand Down
2 changes: 1 addition & 1 deletion app/classifier/tasks/survey/editor.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ module.exports = createReactClass
<AutoSave resource={@props.workflow}>
<span className="form-label">Next task</span>
<br />
<NextTaskSelector workflow={@props.workflow} name="#{@props.taskPrefix}.next" value={@props.task.next ? ''} onChange={handleInputChange.bind @props.workflow} />
<NextTaskSelector task={@props.task} workflow={@props.workflow} name="#{@props.taskPrefix}.next" value={@props.task.next ? ''} onChange={handleInputChange.bind @props.workflow} />
</AutoSave>
</p>

Expand Down
2 changes: 1 addition & 1 deletion app/classifier/tasks/text/editor.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,6 @@ module.exports = createReactClass
<AutoSave resource={@props.workflow}>
<span className="form-label">Next task</span>
<br />
<NextTaskSelector workflow={@props.workflow} name="#{@props.taskPrefix}.next" value={@props.task.next ? ''} onChange={handleInputChange.bind @props.workflow} />
<NextTaskSelector task={@props.task} workflow={@props.workflow} name="#{@props.taskPrefix}.next" value={@props.task.next ? ''} onChange={handleInputChange.bind @props.workflow} />
</AutoSave>}
</div>

0 comments on commit 4dc080d

Please sign in to comment.