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

5847 surface common filters with helper #5879

Conversation

mononoken
Copy link
Contributor

@mononoken mononoken commented Jul 4, 2024

Note: This is an alternative approach to #5871
Instead of persisting client state with sessionStorage, I scrapped the idea of using client state for the collapse logic. Instead, I am using the original method of having the menu shown or hidden based on the existence of the filter params. However, I have removed the "surfaced" params from this check, so that when you filter only by an option such as "Hide draft", it will not open the filter options menu.


What github issue is this PR for, if any?

Resolves #5847

What changed, and why?

  • Moved the Sorted by and Hide drafts filter options outside of the collapsable area of the form element, so that they display regardless of filter menu collapse status.
  • Fixed the positioning of the form select pseudo icons by refactoring the HTML syntax around the select elements
  • Changed the filter-card-body collapse class logic to, fix a bug where the "Expand / show" button did not respond to the first click after filtering. This change accounts for how Bootstrap implements its version of collapse.
  • Added helper expand_filters? to prevent filter menu from expanding when filtering only by "surfaced" filter options.

How is this tested? (please write tests!) πŸ’–πŸ’ͺ

I added tests for the new expanded_filters? helper method.

Screenshots please :)

SCR-20240629-swmf SCR-20240629-swrz

Feelings gif (optional)

Instead of a gif, I asked ChatGPT to write a haiku about Bootstrap.
γƒ–γƒΌγƒˆγ‚Ήγƒˆγƒ©γƒƒγƒ—
εˆΆη΄„γ‚’ζ„Ÿγ˜γ¦
θ‡ͺ由を求め

@github-actions github-actions bot added ruby Pull requests that update Ruby code Tests! πŸŽ‰πŸ’–πŸ‘ erb labels Jul 4, 2024
@mononoken mononoken marked this pull request as ready for review July 4, 2024 05:29
@mononoken mononoken force-pushed the 5847_surface_common_filters_with_helper branch from d7547e6 to ed6bce2 Compare July 4, 2024 05:33
@mononoken mononoken force-pushed the 5847_surface_common_filters_with_helper branch from ed6bce2 to 9a14fec Compare July 5, 2024 22:23
Copy link
Collaborator

@elasticspoon elasticspoon left a comment

Choose a reason for hiding this comment

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

I'm pretty happy with this. I'll manually test it a bit and let Sam provide his input.

@mononoken Do you think you could add something to the system test that uses the exposed filters? ex:

Have drafts > check present
hide drafts > filter > check absent
expand > select another filter > filter
select all filters work > check still expanded by selecting some other expanded filter option

@elasticspoon elasticspoon requested a review from schoork July 5, 2024 23:12
@mononoken
Copy link
Contributor Author

I'm pretty happy with this. I'll manually test it a bit and let Sam provide his input.

@mononoken Do you think you could add something to the system test that uses the exposed filters? ex:

Have drafts > check present hide drafts > filter > check absent expand > select another filter > filter select all filters work > check still expanded by selecting some other expanded filter option

@elasticspoon , it looks like the first case was already tested at :93, but I have added some system tests to test the hide draft filter and the filter menu collapse functionality. If I missed any cases or the tests could be improved, please let me know!

Copy link
Collaborator

@schoork schoork 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 @mononoken! I like this, too, because I think it will be easier to hook into Hotwire when we add it to the project.

Comment on lines +57 to +58
<% collapse_class = expand_filters? ? "collapse show" : "collapse" %>
<div class="card-content mb-10 ml-20 <%= collapse_class %>" id="filter-card-body">
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you wanted to be fancy you could do:

<div class="<%= token_list("card-content mb-10 ml-20 collapse", {show: expand_filters?}) %>" id="filter-card-body">

https://apidock.com/rails/ActionView/Helpers/TagHelper/token_list

Copy link
Collaborator

@elasticspoon elasticspoon 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 great! Thanks so much.

If you are still interested in turbo I can write up an issue for that πŸ™‚

@elasticspoon elasticspoon merged commit 8a1e07a into rubyforgood:main Jul 7, 2024
18 checks passed
@mononoken
Copy link
Contributor Author

Thank you both for the feedback on the issue! I'd be happy to work on implementing Turbo on the next issue, @elasticspoon .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
erb ruby Pull requests that update Ruby code Tests! πŸŽ‰πŸ’–πŸ‘
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Surface common available filters for case contacts
3 participants