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

Move students: Add section dropdown #22099

Merged
merged 11 commits into from
Apr 27, 2018
Merged

Move students: Add section dropdown #22099

merged 11 commits into from
Apr 27, 2018

Conversation

maddiedierker
Copy link
Contributor

@maddiedierker maddiedierker commented Apr 27, 2018

This is the second in a series of PRs to rewrite the 'move students' functionality in React (first PR here).

Before

screen shot 2018-04-27 at 11 13 22 am

After

Righthand panel with a dropdown of the teacher's other sections plus an "other teacher" option:
screen shot 2018-04-27 at 11 11 21 am

screen shot 2018-04-27 at 11 15 01 am

If "other teacher" is chosen, additional fields appear for the teacher to input the other teacher's section code and choose whether to copy/move the students to the other teacher's section:
screen shot 2018-04-27 at 11 11 32 am

Work Remaining

This is obviously not finished, so I wanted to outline what is left to do for this feature:

  • Add functionality to move/copy students when 'move students' button is clicked
  • Disable 'move students' button until at least 1 student and the section are chosen
  • If 'other teacher' option is chosen, validate that section code input is 6 characters
  • Sort students A-Z on dialog open
  • Refactor tests to simulate component usage rather than unit tests on helper methods
  • Style tweaks
  • Add success messages
  • Empty state for section that has no students yet
  • Remove Angular MovingStudentsController code
  • Remove current section from dropdown list and replace with empty placeholder
  • Other feedback!

{id: 0, name: 'sectiona'},
{id: 1, name: 'sectionb'},
{id: 2, name: 'sectionc'}
];
Copy link
Contributor

Choose a reason for hiding this comment

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

This sections array is basically the same as the one used in the Story. If there are other similar constants used, we could consider extracting to their own file.

Copy link
Member

Choose a reason for hiding this comment

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

I'd say you'll get an A+ for extracting a shared constant here, but I'll also add that we're generally much more lenient about allowing duplication in our stories and tests than we are in the rest of our codebase. in most tests and stories there would be no real danger for this data to change in one place but not the other, and I might only consider extracting test data if it becomes quite complex or if the format is changing a lot. For example we do have a generateFakeProjects method which is very useful because it produces fairly complex test data.

Copy link
Member

Choose a reason for hiding this comment

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

Apologies, @Erin007 , as I've sat quiet as these kind of extractions have been suggested in the past 😊

<input
required
name="sectionCode"
style={{...styles.input, width: 225}}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you'll see it all over the place, but in general we try to avoid inline styles

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call! i'll pull that into its own styles key

Copy link
Contributor

@Erin007 Erin007 left a comment

Choose a reason for hiding this comment

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

Great progress! LGTM!

Copy link
Member

@davidsbailey davidsbailey left a comment

Choose a reason for hiding this comment

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

Very nice, Maddie, this is great progress! I'm "approving with comments", meaning the suggestions I'm making are minor and I don't necessarily need to re-review after you address them unless something big ends up changing.

};

onChangeSection = (event) => {
const val = event.target.value;
Copy link
Member

Choose a reason for hiding this comment

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

nit: would be nice to give this a more descriptive name (moveType? moveTarget?), and also use it later in this function in place of event.target.value

{id: 0, name: 'sectiona'},
{id: 1, name: 'sectionb'},
{id: 2, name: 'sectionc'}
];
Copy link
Member

Choose a reason for hiding this comment

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

I'd say you'll get an A+ for extracting a shared constant here, but I'll also add that we're generally much more lenient about allowing duplication in our stories and tests than we are in the rest of our codebase. in most tests and stories there would be no real danger for this data to change in one place but not the other, and I might only consider extracting test data if it becomes quite complex or if the format is changing a lot. For example we do have a generateFakeProjects method which is very useful because it produces fairly complex test data.

export default MoveStudents;
export const UnconnectedMoveStudents = MoveStudents;

export default connect(state => ({
Copy link
Member

Choose a reason for hiding this comment

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

nice job getting connected + unconnected components working!

</div>
}
</div>
</div>
Copy link
Member

Choose a reason for hiding this comment

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

no need to do this right now, but you'll probably want to extract a subcomponent or two as this component grows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, i was thinking about that. this component is definitely at its limit right now... i feel like there's a few places it could be broken up. maybe i'll pull the 'other teacher' functionality into its own component

Copy link
Member

Choose a reason for hiding this comment

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

yeah, the "other teacher" stuff seems like a great candidate for extraction.

{id: 0, name: 'sectiona'},
{id: 1, name: 'sectionb'},
{id: 2, name: 'sectionc'}
];
Copy link
Member

Choose a reason for hiding this comment

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

Apologies, @Erin007 , as I've sat quiet as these kind of extractions have been suggested in the past 😊

Copy link
Contributor

@islemaster islemaster left a comment

Choose a reason for hiding this comment

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

Just wanted to say I trust Dave and Erin and you don't need to wait on my approval. 👍

waiting_crocodile

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.

None yet

4 participants