Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pages Editor: implement Branching Controls #6991

Merged
merged 13 commits into from
Feb 13, 2024
Merged

Conversation

shaunanoordin
Copy link
Member

@shaunanoordin shaunanoordin commented Dec 12, 2023

PR Overview

Part of: Pages Editor MVP project and FEM Lab super-project
Follows #6981
Staging branch URL: https://pr-6991.pfe-preview.zooniverse.org/lab/1982/workflows/editor/3711?env=staging

This PR adds the ability to choose the next Page, for Steps with branching Tasks.

  • i.e. any Step with a Single Question Task will enable branching controls.
    • When branching controls are enabled, a choice of Next Step/Page is given for every answer/choice in the task
    • The Next Step/Page is identified by the Tasks keys within that Step/Page.
  • The visual UI doesn't fully match Sean's design (notably, the yellow arrows aren't going beyond the Step body's container) but that's
    • (2024.02.13 EDIT: I forgot to finish this sentence earlier. It should have said "The visual UI doesn't fully match Sean's design, but that's something I'll take care of in a future PR.")
image

Other changes:

  • Add "Preview Workflow" button (⚠️ hardcoded to WF 3711! I need to update DataManager to pull project data to get this fully working)
  • When dragging Steps to rearrange, the Steps now have a yellow outline

Status

Ready for review!

Do not merge until 6981 is merged. Currently targets pages-editor-pt12 for reviewing purposes; this will be re-targeted to master when ready.

@shaunanoordin shaunanoordin requested a review from a team December 12, 2023 01:24
@coveralls
Copy link

coveralls commented Dec 12, 2023

Coverage Status

coverage: 56.976% (+0.01%) from 56.965%
when pulling 5803cf4 on pages-editor-pt13
into 0e611cf on master.

@kieftrav kieftrav requested review from kieftrav and removed request for a team December 12, 2023 13:23
Copy link
Contributor

@kieftrav kieftrav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM. Small suggestions that are inline with other PR's.

<StepItem
key={`stepItem-${step[0]}`}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase vs kebab-case

const task = allTasks[taskKey];
return (
<EditTaskForm
key={`editTaskForm-${taskKey}`}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase vs kebab

const answers = task.answers || []

function onChange(e) {
const next = e.target?.value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be e?. or e. between this line and the below line.

);
}

function NextStepArrow({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be pulled out as an Icon / it's own file so it's usable in other parts of the codebase (if needed)

@kieftrav
Copy link
Contributor

PR looks good to me and doesn't create any weird error states. The video below shows the behavior of having empty values for answer/choices and then editing those answer/choices after you've set some branching conditions. Not sure if this is the desired behavior to delete/destroy the branching conditions upon changing answer/choices.

Also, your PR Overview has an unfinished sentence: "The visual UI doesn't fully match Sean's design (notably, the yellow arrows aren't going beyond the Step body's container) but that's" (and ends with that... What were you trying to say?

pr-review-6991.mov

@shaunanoordin
Copy link
Member Author

shaunanoordin commented Feb 13, 2024

Thanks Travis!

Also, your PR Overview has an unfinished sentence: "The visual UI doesn't fully match Sean's design (notably, the yellow arrows aren't going beyond the Step body's container) but that's" (and ends with that... What were you trying to say?

Holy crap, did I leave that sentence hanging?? I meant to say "visual UI doesn't fully match Sean's design, but that's something I'll take care of in a future PR. " Sorry, I should have re-read my PR overview before I posted.

Now on to the TODO List:

  • ❗ 🆕 Double check behaviour where Question Task has 1. empty Answer, or 2. duplicate Answers. (Does PFE allow empty answers, or are they auto-deleted?)
    • OK, so in PFE empty answers are valid. In the code that I built, apparently I made it so that empty answers are preserved while you're editing the task (so the input fields don't suddenly disappear if you delete all the text) but are silently removed when the workflow is saved. (Which must have made sense to Previous Shaun.) Duplicate answers are valid.
  • Fix missing noreferrer/noopener in Preview Workflow link.
  • (from 6981) fix accessibility issues
    • Also fixed an issue where pressing the Enter key on the Instruction or Required fields of a Single Question Task would cause the first Answer to be deleted. Yes, seriously.
  • (from 6981) review code style
  • (from 6981) 🐛 ❗ Examine can't rearrange certain Pages via key issue
    • ❓ Can't reliably replicate issue. Possible network latency/race condition?
  • (from 6973) implement DEFAULT_HANDLER

I'll append a few of those updates to this PR, then start on pt14 to address the rest of the feedback.

@shaunanoordin
Copy link
Member Author

OK I'm finally ready to merge this. I've incorporated a lot of the feedback taken from 6981 and 6973. (Thanks Jim, Mark, and Travis!)

PR Update

  • Security: "Preview Workflow" link now has rel="noopener noreferrer"
  • Code improvement/Efficiency: anonymous () => {} functions in multiple files now use a const DEFAULT_HANDLER = () => {}
  • Accessibility: tuned up HTML for Single Question Task and Text Task.
  • Fix: previously, on a Single Question Task, pressing the Enter key in the Instructions text field OR the Required checkbox would cause the FIRST ANSWER to be deleted. This has been fixed by adding type=button to the Delete <button>s
    • Funny thing about this! Apparently I forgot to add type=button to the Delete Answer <button>s.
    • Which mean that these buttons were implicitly type=submit.
    • Which meant that pressing Enter on any non-button input on the same form (e.g. the Instructions text field) would trigger the "submit" action. Which does two things: 1. tell the <form> to submit (which is why our form has an onSubmit handler to cancel any default submit action), and 2. _it presses the FIRST <button type="submit"> that it sees.
    • At least on macOS + Chrome 121! That second thing is completely new to me and deserves its own sub-investigation.

Investigated, but no action taken (other than making a note that this behaviour should be documented):

  • re: "What if Single Question Task has blank Answers?".
    • In PFE empty/blank answers are valid. (i.e. task.answers = [ { label="" } ])
    • In the code that I built, apparently I made it so that empty answers are preserved while you're editing the task (so the input fields don't suddenly disappear if you delete all the text) but are silently removed when the workflow is saved. (Which must have made sense to Previous Shaun.)

Status

Merging, go!

Next for Pages Editor: either Deleting Tasks (easy?) or linking Subject Sets & Tutorials to Workflows.

@shaunanoordin shaunanoordin merged commit 38d95c3 into master Feb 13, 2024
5 checks passed
@shaunanoordin shaunanoordin deleted the pages-editor-pt13 branch February 13, 2024 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants