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

Fix classroom form state #75

Merged
merged 11 commits into from
Oct 26, 2017
Merged

Fix classroom form state #75

merged 11 commits into from
Oct 26, 2017

Conversation

srallen
Copy link
Contributor

@srallen srallen commented Oct 24, 2017

This does two things:

  • Fixes a possible regression I introduced that I noticed while debugging Darien classrooms table #74
    • The classroom create/edit form wasn't clearing out the form fields on unmount, so when you created a classroom and then clicked to create another (or edit), the form field had the previous content.
  • This also adds a consistent sort order for the I2A assignments

@srallen srallen requested a review from shaunanoordin October 24, 2017 19:31
@srallen
Copy link
Contributor Author

srallen commented Oct 24, 2017

Note: I'm not really sure why all those commits are showing up... It looks like something odd happened while rebasing. I can squash those if you want me too... or we can squash on merge.

@@ -141,7 +141,7 @@ Effect('getClassroomsAndAssignments', (selectedProgram) => {
// loop through the number of pages to request all of the data
// and concatenate the response data together for the app state
// Neither Pagination nor infinite scroll would be good UX for current table design.
Actions.getAssignments(classroom.id);
Actions.getAssignments({ classroomId: classroom.id, selectedProgram });
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, is there any reason the function getAssignments() is structured like getAssignments(data) where data = {classroomId, selectedProgram} instead of getAssignments(classroomId, selectedProgram)?

It's functionally the same, but from a readability standpoint, it's not very clear what arguments/values getAssignments() is expecting.

The only advantages that I can see for using a single 'compound variable' instead of spelling out the different variables are if:

  • the compound variable (data) supports different kinds of key-values (e.g. an advanced search query, data = {color:'red', species:'dragon', optionalAge: null } ), or
  • the data is structured in a specific way that doesn't matter to the function(), but matters to the API (e.g. createAssignnments())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Jumpstate's Effect either wasn't designed to work or had a bug when I tried to pass it two separate arguments! 😢

Copy link
Member

Choose a reason for hiding this comment

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

Oh gods, that's right! I totally forgot about Jumpstate's "one Effect, one argument" rule. 🤦‍♂️

@shaunanoordin
Copy link
Member

At the moment, I'm encountering an error loading I2A Assignments:
screen shot 2017-10-24 at 20 52 21

master looks OK, so it seems to be some issue with this bit here...

props.assignments[classroom.id].map((assignment) => {
  const projectUrl = (assignmentsMetadata && assignmentsMetadata[assignment.workflowId]) ?
    `${config.zooniverse}/projects/${assignmentsMetadata[assignment.workflowId].slug}/classify?group=${classroom.attributes.zooniverse_group_id}` :
    null;

...where, for some reason, there are cases where assignment is null/undefined. (Specifically, props.assignments['316'] = [undefined, undefined, undefined] - whuuuh?)

@srallen
Copy link
Contributor Author

srallen commented Oct 25, 2017

@shaunanoordin thanks for catching that. There is an edge case of I2A classrooms that do not have assignments. These may have been created while there was that issue with the API with linking assignments correctly. zootester1 has one of these classrooms. I moved the code to sort the assignments out into its own function and do a existential check on the assignments first before returning the sorted assignments.

Copy link
Member

@shaunanoordin shaunanoordin left a comment

Choose a reason for hiding this comment

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

PR Review

  • This PR fixes an issue with the Create Classroom form, which would sometimes remember values from the previous Create Classroom attempt.
  • Another issue related to I2A Classrooms without Assignments was also addressed within the PR itself.
  • Also, note: a polyfill service was added as a part of this PR. (I didn't realise we were missing this; I should run some tests on IE11 soon.)

Status

LGTM, approving and merging 👍

@shaunanoordin shaunanoordin merged commit db48770 into master Oct 26, 2017
@shaunanoordin shaunanoordin deleted the fix-classroom-form-state branch November 8, 2017 14:35
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.

2 participants