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

#756 User is able to select filters quickly #799

Merged
merged 2 commits into from
Jan 8, 2021

Conversation

Shaglock
Copy link
Contributor

@Shaglock Shaglock commented Oct 25, 2020

Why

Resolves #756.

Pre-Merge Checklist

  • All new features have been described in the pull request
  • Security & accessibility have been considered
  • All outstanding questions and concerns have been resolved
  • Any next steps that seem like good ideas have been created as issues for future discussion & implementation
  • High quality tests have been added, or an explanation has been given why the features cannot be tested
  • New features have been documented, and the code is understandable and well commented
  • Entry added to CHANGELOG.md if appropriate

What

  • Check/uncheck all filters
  • Check/uncheck specific columns

I added the ability to check all/uncheck all filters by column as well as the entire filters section. If any of the filters in the column is checked, the checkbox for select all shows an indeterminate state.
image
Screen-Recording-2020-10-25-at-1

How

I guess the code is pretty self-explanatory, I tried to keep it simple. I added toggle functions and some helpers to detect the state of the checkboxes.

Testing

I changed the behavior of the old test a little bit because there are more checkboxes now. I am not a frontend developer, this is my first time writing tests for Vue, I tried to follow the example of an existing test. I guess the next step is to add more tests for the functionality I created, for example, test indeterminate state of checkboxes, test for toggle functions. I think the tests I added are not good enough and I am not sure I can do better 😄 But I manually tested everything and it works well.

Next Steps

Outstanding Questions, Concerns and Other Notes

Accessibility

Security

Meta

@Shaglock Shaglock marked this pull request as ready for review October 25, 2020 16:44
Copy link
Collaborator

@solebared solebared left a comment

Choose a reason for hiding this comment

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

Looks great @Shaglock . Apologies for the long delay in reviewing this!
Some thoughts below.

On testing

TBH, i'm not convinced about the testing strategy that was in place here. IIUC, these tests are checking what gets passed into an event handler when a filter is clicked. IMO this only tests a slice of the functionality, ie that we wired the click handler correctly in vue. Also feels like testing implementation details instead of outcomes.

It could be better to mount the component with some known data, click and then check whether the expected contributions are shown. But maybe i'm misreading how these work?

In any case, i realize you are following the precedent set in the example above, and what i'm suggesting is considerably more work to set up!

Tagging @h-m-m in case he has opinions on this.

FilterType component?

Looking over the code, i'm noticing that filters gets passed into three of the new methods and currentFiltersForFilterType gets used a lot. I wonder if this might be hinting at the possibility of extracting a FilterType or similar sub-component?

Each instance of this sub-component would handle only the filters for a single filter type, eliminating the need to pluck out relevant filters in several places.

Just a thought; i'm not sure without trying whether this would be an overall simplification. For one thing, Filters would need to change somewhat to aggregate the current filters from each of the FilterType instances.

Merge?

All that said, i'm happy to merge as is since this is a huge improvement. We could add a separate issue to revisit the specs and any refactorings you/we could consider. LMK if you want to modify anything before i merge.

Thank you! 🙌🏾 🚀

@@ -59,6 +67,16 @@ export default {
prop: 'currentFilters',
event: 'change',
},
computed: {
allFiltersSelected: function () {
return JSON.stringify(this.allFilters.sort()) == JSON.stringify(this.currentFilters.sort())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor (mostly curious): would this.allFilters.size === this.currentFilters.size also work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it works. I don't remember why I did it in such a strange way :D thank you for reviewing

@Shaglock
Copy link
Contributor Author

Hello @exbinary, thank you very much for your review! I suggest to merge this PR and add separate issue(s) to revisit the specs.

Copy link
Collaborator

@maebeale maebeale left a comment

Choose a reason for hiding this comment

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

TYYY!

@svileshina svileshina merged commit 93f769f into rubyforgood:main Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User is able to select filters quickly
4 participants