forked from zooniverse/Panoptes-Front-End
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pages Editor: rebuild "Next Page" logic. Add placeholder answers. (zo…
…oniverse#7055) * pages-editor-pt17: debug, show step.next * Add SimpleNextControls. Rename BranchingControls. * Refactor: separate NextStepArrow. SimpleNextControls: test functionality * SimpleNextControls: add and populate 'next page' dropdown * TasksPage: add second QuickSetup debug feature * BranchingNextControls: move from Step to Task * TaskItem: add PlaceholderAnswers subcomponent * TasksPage: rename updateAnswerNext() * TasksPage: implement updateNextStepForStep() * Remove automatic linking of steps/pages * cleanupTasksAndSteps: now also removes orphaned references in step.next
- Loading branch information
1 parent
a2a2ad4
commit 04a4bbe
Showing
8 changed files
with
292 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
app/pages/lab-pages-editor/components/TasksPage/components/StepItem/NextStepArrow.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export default function NextStepArrow({ | ||
alt, | ||
className = 'icon', | ||
color = 'currentColor', | ||
height = 48, | ||
pad = 4, | ||
strokeWidth = 2, | ||
width = 16 | ||
}) { | ||
const xA = 0 + pad; | ||
const xB = width * 0.5; | ||
const xC = width - pad; | ||
const yA = 0 + pad; | ||
const yB = height - (width / 2); | ||
const yC = height - pad; | ||
|
||
return ( | ||
<svg aria-label={alt} width={width} height={height} className={className}> | ||
<g stroke={color} strokeWidth={strokeWidth}> | ||
<line x1={xB} y1={yA} x2={xB} y2={yC} /> | ||
<line x1={xA} y1={yB} x2={xB} y2={yC} /> | ||
<line x1={xC} y1={yB} x2={xB} y2={yC} /> | ||
</g> | ||
</svg> | ||
); | ||
} |
52 changes: 52 additions & 0 deletions
52
app/pages/lab-pages-editor/components/TasksPage/components/StepItem/SimpleNextControls.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import PropTypes from 'prop-types'; | ||
import NextStepArrow from './NextStepArrow.jsx'; | ||
|
||
const DEFAULT_HANDLER = () => {}; | ||
|
||
export default function SimpleNextControls({ | ||
allSteps = [], | ||
step, | ||
updateNextStepForStep = DEFAULT_HANDLER | ||
}) { | ||
if (!step) return null; | ||
const [ stepKey, stepBody ] = step; | ||
|
||
function onChange(e) { | ||
const next = e.target?.value; | ||
updateNextStepForStep(stepKey, next); | ||
} | ||
|
||
return ( | ||
<div className="next-controls vertical-layout"> | ||
<NextStepArrow className="next-arrow" /> | ||
<select | ||
className={(!stepBody?.next) ? 'next-is-submit' : ''} | ||
onChange={onChange} | ||
value={stepBody?.next || ''} | ||
> | ||
<option | ||
value={''} | ||
> | ||
Submit | ||
</option> | ||
{allSteps.map(([otherStepKey, otherStepBody]) => { | ||
const taskKeys = otherStepBody?.taskKeys?.toString() || '(none)'; | ||
return ( | ||
<option | ||
key={`simple-next-controls-option-${otherStepKey}`} | ||
value={otherStepKey} | ||
> | ||
{taskKeys} | ||
</option> | ||
); | ||
})} | ||
</select> | ||
</div> | ||
); | ||
} | ||
|
||
SimpleNextControls.propTypes = { | ||
allSteps: PropTypes.arrayOf(PropTypes.array), | ||
step: PropTypes.array, | ||
updateNextStepForStep: PropTypes.func | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.