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

Sort by semester #537

Merged
merged 54 commits into from
Oct 23, 2021
Merged

Sort by semester #537

merged 54 commits into from
Oct 23, 2021

Conversation

zachary-kent
Copy link
Collaborator

Summary

This pull request implements a dropdown menu that allows the user to select whether their semesters are shown in order of newest to oldest or oldest to newest, persisting their choices in the backend. The dropdown menu also allows users to select whether semesters are displayed in compact or default layout, although this choice is not persistent. Implementing these changes required adding an orderByNewest field both to the user-semesters collection in Firebase and to the Vuex store. To minimize reads and writes to the Firebase, changing the ordering preference on the frontend only modifies the orderByNewest field in the Firebase. As a result, the semesters are no longer sorted in the backend; to ensure this does not introduce any breaking changes, when the orderByNewest field is changes, the semesters are resorted in the Vuex store--but not in the Firebase. Nevertheless, their still exists non-negligible latency when changing the ordering preference on the frontend, something to be explored in the future.

Remaining TODOs:

  • Reduce order preference latency
  • Fix down arrow asset to be more centered

Test Plan

Screen Shot 2021-10-05 at 10 57 39 PM

Screen Shot 2021-10-05 at 10 58 27 PM

Screen Shot 2021-10-05 at 10 58 48 PM

@zachary-kent zachary-kent requested a review from a team as a code owner October 6, 2021 02:59
@SamChou19815
Copy link
Contributor

@zachary0kent You need to fix the merge conflict with the latest master to make all CI jobs run.

Copy link
Member

@willespencer willespencer left a comment

Choose a reason for hiding this comment

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

This looks really good! The menu works great, and semester toggle buttons and re-ordering both seem to work great! Also tested editing semesters to ensure order is properly sorted when sorted by newest and oldest.

Left a bunch of comments, just about some code cleanup things and some bugs! I also have two misc comments...

  1. Is the view button supposed to open the menu on hover, or on click? Not sure what the designs intended, but the hover seems a little strange to me.
  2. Do you think compact/non-compact should persistent like semester order does to be consistent?

src/components/Semester/OrderDropdown.vue Outdated Show resolved Hide resolved
src/assets/scss/_variables.scss Outdated Show resolved Hide resolved
src/assets/scss/_variables.scss Show resolved Hide resolved
src/assets/images/schedule-view/view-settings/settings.svg Outdated Show resolved Hide resolved
src/components/Semester/OrderDropdown.vue Outdated Show resolved Hide resolved
src/components/Semester/OrderDropdown.vue Outdated Show resolved Hide resolved
src/components/Semester/OrderDropdown.vue Outdated Show resolved Hide resolved
src/components/Semester/OrderDropdownOption.vue Outdated Show resolved Hide resolved
src/components/Semester/SemesterView.vue Show resolved Hide resolved
toggleCompact(toggled: boolean) {
if (toggled !== this.compact) {
this.$emit('compact-updated', toggled);
GTagEvent(this.$gtag, toggled ? 'to-compact' : 'to-not-compact');
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for preserving this!

@hahnbeelee
Copy link
Contributor

hahnbeelee commented Oct 7, 2021

There's some weird activity on mobile where the dropdown doesn't always open when you click on it. I agree with @willespencer that the dropdown should show up when you click on it instead of hovering since you can't hover on mobile.

Screen.Recording.2021-10-07.at.6.56.14.PM.mov

@hahnbeelee
Copy link
Contributor

You can look at the RequirementsDropdown.vue code to see how to implement the dropdown appearing from clicks

@github-actions
Copy link
Contributor

github-actions bot commented Oct 19, 2021

Visit the preview URL for this PR (updated for commit 9d9c91e):

https://cornelldti-courseplan-dev--pr537-sort-by-semester-hclt3wcn.web.app

(expires Fri, 29 Oct 2021 20:47:38 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Copy link
Collaborator

@benjamin-shen benjamin-shen left a comment

Choose a reason for hiding this comment

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

The merge resolutions look good! Thanks for putting so much work into this PR. It's really impressive how you picked up what was going on with Vuex.

I left some more comments on the code

src/components/Semester/Semester.vue Outdated Show resolved Hide resolved
src/global-firestore-data/semesters.ts Show resolved Hide resolved
setSemesters(state: VuexStoreState, semesters: readonly FirestoreSemester[]) {
state.semesters = semesters;
state.semesters = sorted(semesters, state.orderByNewest);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Won't this cause a lot of unnecessary sorting? It seems that setOrderByNewest already does this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I was considering the case when the the semesters collection was edited but the orderByNewest Field was unchanged; I wanted to ensure that adding/deleting a semester didn't break the sorting order. Do you think I should remove that?

src/store.ts Outdated Show resolved Hide resolved
src/store.ts Show resolved Hide resolved
src/store.ts Outdated Show resolved Hide resolved
src/SeasonOrdinal.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@hahnbeelee hahnbeelee left a comment

Choose a reason for hiding this comment

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

oo with Toby's changes the semester title overflows in the compact view.
image

Copy link
Contributor

@hahnbeelee hahnbeelee left a comment

Choose a reason for hiding this comment

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

Zak this is really great! Can you make it so that the dropdown closes if you click anywhere on the screen? You can maybe refer to RequirementsDropdown or any of the modal code. If you find yourself spending way too much time on it though don't worry about it. Although I think clickOutside utility function might work here.

@@ -0,0 +1,154 @@
<template>
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe rename this file ViewDropdown

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep I agree!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Screen Shot 2021-10-20 at 4 51 56 PM

I think the wrapping issue also occurs on master

@@ -0,0 +1,55 @@
<template>
Copy link
Contributor

Choose a reason for hiding this comment

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

and this ViewDropdownOption

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the feedback! I think I fixed all of your suggestions.

@hahnbeelee
Copy link
Contributor

@zachary0kent if you want you can address the bigger things I pointed out in a separate PR as long as it gets merged before the deploy day Nov. 4

Copy link
Member

@willespencer willespencer left a comment

Choose a reason for hiding this comment

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

This is looking really good! All my comments were addressed, and modals now look good on top of the view text!

Still having a bit of trouble with new users though? Onboarding does not seem to be able to be finished for those users, and when clicking the "Finish" button, I get this error. Could you please look into this?
image

@zachary-kent
Copy link
Collaborator Author

zachary-kent commented Oct 20, 2021

This is looking really good! All my comments were addressed, and modals now look good on top of the view text!

Still having a bit of trouble with new users though? Onboarding does not seem to be able to be finished for those users, and when clicking the "Finish" button, I get this error. Could you please look into this? image

This is looking really good! All my comments were addressed, and modals now look good on top of the view text!

Still having a bit of trouble with new users though? Onboarding does not seem to be able to be finished for those users, and when clicking the "Finish" button, I get this error. Could you please look into this? image

Hmmm. compareFirestoreSemesters is a comparator function I removed when I reimplemented sorting. No references to it are found when I search for it in vscode, so I'm not sure where the undefined reference could be coming from. Do you have any thoughts? Also, I can replicate the issue on the staging site but not locally, which is why I didn't encounter it before; do you think that would provide some insight into the problem? I could just stub the comparator in where it was previously to solve the issue, but idk if that's ideal.

Edit: stubbing in the comparator allows you to successfully complete the tutorial on staging site.

Copy link
Member

@willespencer willespencer left a comment

Choose a reason for hiding this comment

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

Works for me now so going to approve!!

But yeah I have no idea why the staging site would still expect that function to be needed.., I also don't see any references to it in the code. @hahnbeelee do you have any ideas?

@benjamin-shen
Copy link
Collaborator

benjamin-shen commented Oct 21, 2021

@zachary0kent @willespencer

PR #529 uses compareFirestoreSemesters in a new function getActiveSemesters(). It was recently merged to master, that might be part of the issue?

I also can't reproduce locally. I would pull from master again, tweak @vaishnavi17's changes, and see if there's still an error.

Copy link
Collaborator

@benjamin-shen benjamin-shen left a comment

Choose a reason for hiding this comment

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

Thanks for addressing all my suggestions and comments!! 💯

Like we discussed, there may be a way to make this a purely frontend implementation but we can come back to this if we run into issues with this PR later (which hopefully we won't 🤞)

Copy link
Contributor

@hahnbeelee hahnbeelee left a comment

Choose a reason for hiding this comment

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

littt!!!!! awesome stuff zak!

@zachary-kent zachary-kent merged commit 10764a2 into master Oct 23, 2021
@zachary-kent zachary-kent deleted the sort-by-semester branch October 23, 2021 18:54
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.

6 participants