Skip to content

Commit

Permalink
TasksPage: setting Starting Page will now just rearrange Steps
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunanoordin committed May 17, 2024
1 parent 3d6477a commit 4dec5eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function ExperimentalPanel({

function experimentalQuickSetup() {
update({
first_task: 'P0',
first_task: '',
tasks: {
'T0': {
answers: [
Expand Down
11 changes: 7 additions & 4 deletions app/pages/lab-pages-editor/components/TasksPage/TasksPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default function TasksPage() {
const newTaskDialog = useRef(null);
const [ activeStepIndex, setActiveStepIndex ] = useState(-1); // Tracks which Step is being edited.
const [ activeDragItem, setActiveDragItem ] = useState(-1); // Keeps track of active item being dragged (StepItem). This is because "dragOver" CAN'T read the data from dragEnter.dataTransfer.getData().
const firstStepKey = workflow?.steps?.[0]?.[0] || '';
const isActive = true; // TODO

/*
Expand Down Expand Up @@ -155,8 +156,10 @@ export default function TasksPage() {
}

function handleChangeStartingPage(e) {
const first_task = e?.target?.value || '';
update({ first_task });
const targetStepKey = e?.target?.value || '';
const targetStepIndex = workflow?.steps?.findIndex(([stepKey]) => stepKey === targetStepKey) || -1;
if (targetStepIndex < 0) return;
moveStep(targetStepIndex, 0);
}

// Changes the optional "next page" of a step/page
Expand Down Expand Up @@ -228,15 +231,15 @@ export default function TasksPage() {
aria-label="Choose starting Page"
className="flex-item"
onChange={handleChangeStartingPage}
defaultValue={workflow?.first_task || ''}
value={firstStepKey}
>
<option value="">Choose starting page</option>
{workflow.steps?.map(([stepKey, stepBody]) => (
<option
key={`choose-starting-page-${stepKey}`}
value={stepKey}
>
{workflow.first_task === stepKey && 'Starting page: '}
{firstStepKey === stepKey && 'Starting page: '}
{stepBody?.taskKeys?.join(', ') || `(${stepKey})` /* Note: if you see the stepKey instead of the taskKeys, something's wrong. */}
</option>
))}
Expand Down

0 comments on commit 4dec5eb

Please sign in to comment.