-
Notifications
You must be signed in to change notification settings - Fork 112
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
Break apart FilterableListControls #4771
Conversation
fc64493
to
9895f06
Compare
9895f06
to
05af0c0
Compare
@anselmbradford 👍 all good. |
@schaferjh I was wondering about the first "No posts state" at the top. Do we want to have a state where the component doesn't render anything at all? What should be the behavior if a filter has no posts to filter and there has been no message set by content editors? |
|
||
{# SHOW A NOTIFICATION IF THERE'S NOTHING TO FILTER. #} | ||
|
||
{% if value.no_posts_message %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blergh, good catch. I pushed up a has_results
variable and check that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to has_unfiltered_results
to better describe it since it had a value when the filters were applied and the warning notification was showing. b322bf0
Should those fields (at least |
{{ activity_list.render(posts) }} | ||
{% elif value.output_5050 %} | ||
{% from 'molecules/info-unit-2.html' import info_unit with context %} | ||
<div class="o-info-unit-group u-mb30" data-qa-hook="image-text-50-50"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: This whole block should go into its own template, but to manage the complexity of this PR best break things apart here and do a separate PR to separate this part out.
@anselmbradford would you post a screenshot? |
@chosak I didn't see any value in making the |
@schbetsy thanks for the explanation, that makes sense. |
In my opinion, it would make more sense for the filter controls to be open when there is a validation error. The user will have to interact with the expandable to fix the error; why make them press the "+" button to open it? |
Argh, yeah this is a mistake. Any behavior that isn't like production is probably a mistake. If I recall, the only difference is hiding the results when there're client-side errors to align with how it's done server-side. |
@anselmbradford I agree with @schbetsy's thinking that no posts is not a common enough situation to be a required field for all filterable lists. In fact it's really only likely on the events page and rarely possible on open notices. So, to your specific question,
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good step forward in making Filterable Lists more manageable 👍
None of my questions and comments are truly blocking, but I'm "requesting changes" until we get the open-when-filters-are-active issue fixed.
# atomic name used on the frontend of FilterableListControls, | ||
# or vice versa. | ||
class FilterControls(BaseExpandable): | ||
class FilterableList(BaseExpandable): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't really need to subclass BaseExpandable
, does it? We're probably never going to create a filterable list that uses different label, border, etc. options than our standard. May need to add expandable.js
to the js
array in this class, though, if we stop subclassing BaseExpandable
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filters should be untangled from expandables in multiple ways. I think that's out of scope here, but duly noted!
|
||
{% set total_pages = posts.paginator.num_pages %} | ||
{% set current_page = posts.number %} | ||
{% if total_pages > 1 and current_page <= total_pages %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition seems superfluous?
{% if total_pages > 1 and current_page <= total_pages %} | |
{% if total_pages > 1 %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmmm okay I've removed it in 9086a5f
This is actually a direct duplicate from https://github.com/cfpb/cfgov-refresh/blob/master/cfgov/jinja2/v1/_includes/molecules/pagination.html#L26 that is necessary to hide the pagination container, which is kinda a bummer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems unnecessary for that to exist there. Seems like it should be up to the thing calling pagination to know if it actually should be calling it or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly, the method signature looks pretty clear there and it's nice it handles the arguments coming into it correctly.
@schbetsy This is fixed in f0a1825, I thought EDIT: cc @Scotchester |
@schaferjh So the other option is to have a default message, but the issue there is what the text would say that would cover the possible cases for the no results. The problem with completely blank from a frontend perspective is that we can't always assume that a filterable list will occupy space on the page, so have to be aware that there's an edge-case in regard to padding in the layout. Currently with it empty an empty div is added to the page markup that occupies space. |
I like it being separate and leaving |
@anselmbradford hmmm, if that's a problem then @ascott1 might be the better person to weigh in. From a UX perspective, it's such an edge case, I do not see a need to solve for it. |
It occurs to me that renaming a block type like this ( Unfortunately this isn't currently documented in wagtail-inventory, so I've opened cfpb/wagtail-inventory#19 there. |
Choosing PDF type is obsolete and no longer supported.
Remove form_type from FilterableList organism
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't reviewed the JS, but this is looking good in the browser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't go through the JS with a fine-toothed comb, either, but everything looks good on a skim, and all the example pages work well 👍
I defer all JS errors this has introduced to @schbetsy and @Scotchester 😆 Have a good long weekend! |
FilterableListControls contains the controls, notifications, results and pagination. It really should instead have a parent module, FilterableList, that includes those elements.
Additions
Removals
block
and the JS.filter_type
option (see changes from Remove form_type from FilterableList organism #4774)Changes
render
macro and callsvalue
values directly, like other templates that render directly from the block.Testing
gulp clean && gulp build
No posts state
Example URL: http://localhost:8000/about-us/events/
No content shown.
Example URL: http://localhost:8000/about-us/events/
Content for "No posts message" in Wagtail added.
† Notification shown is in the default gray state.
Page loaded state, no filter interaction.
Example URL: http://localhost:8000/about-us/newsroom/
Page loaded state, single filter applied.
Example URL: http://localhost:8000/about-us/newsroom/?categories=blog
Page loaded state, filters applied, small result set.
Example URL: http://localhost:8000/about-us/newsroom/?categories=blog&topics=financial-education&authors=holly-petraeus
Page loaded state, filters applied, no result set.
Example URL: http://localhost:8000/about-us/newsroom/?categories=blog&topics=financial-education&authors=holly-petraeus&from_date=2018
Page loaded state, filters applied, erroneous entry (one field).
Example URL: http://localhost:8000/about-us/newsroom/?to_date=asdf
Page loaded state, filters applied, erroneous entry (multiple fields).
Example URL: http://localhost:8000/about-us/newsroom/?to_date=asdf&from_date=asdf
Page loaded state, activity-log.
Example URL: http://localhost:8000/activity-log/
Page loaded state, info-unit.
Example URL: http://localhost:8000/consumer-tools/everyone-has-a-story/
Notes
An additional edge-case only-JS behavior is to expand the filter and enter an erroneous value for one of the date filters. It should display an error message and hide the results. It's identical to "Page loaded state, filters applied, erroneous entry (one field)," but performed via JS instead of server-side. However, it differs in the wording of the error message:
Server-side:
Client-side:
This is due to how the backend and frontend store the label that is added to the error message. This should probably be adjusted to be equal in the future.