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

9396 form filter #584

Merged
merged 44 commits into from
Mar 20, 2019
Merged

9396 form filter #584

merged 44 commits into from
Mar 20, 2019

Conversation

cooperka
Copy link
Member

@cooperka cooperka commented Mar 11, 2019

This adds a new Filters component containing a FormFilter button.

⚠️ Currently the search bar is not contained within Filters so they don't "play nice" together. That should be done before release as part of 9402 (Kevin).

⚠️ This will also require the "advanced search" change from 9393 (Tom) in order to remove the now-obsolete form:(foo|bar) text from the advanced searchbox. We should probably prioritize this separately from the rest of that issue.

cooperka added 29 commits March 8, 2019 12:17
Now it also dismisses on click as it should.
Seems like we should somehow be able to use the jquery module
from rails, perhaps using a strategy similar to
rails/webpacker#738,
but it seems like installing via npm is necessary.
Add 'id' for a11y and only pass single default value
Needed for things like class variables.
Some test assertion within Enzyme seems to be misbehaving when given
stub components; react-test-renderer never had a problem with this.

This is a common issue others have, but I couldn't find any good
solutions besides suppressing the warnings.
React lib seems to initialize on its own
@cooperka cooperka requested a review from smoyte March 11, 2019 14:09
Copy link
Member Author

@cooperka cooperka left a comment

Choose a reason for hiding this comment

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

Explanations below.

.eslintrc.yml Show resolved Hide resolved
app/views/searches/_form.html.erb Show resolved Hide resolved
package.json Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
Copy link
Contributor

@smoyte smoyte left a comment

Choose a reason for hiding this comment

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

Magnificent! Overall very clean and great.

Some tweaks to functionality and style:

image

I think the text in the box should read form:"Form B".

image

Can we please get a consistent padding on all sides of the popover.

Button styles are changing a bit as a result of the other issue I'm working on. Right now the search button and your button are a bit different but let's leave for now and plan to do a styling pass at the end.

Regarding if/when we merge this, perhaps we can do a kind of feature flag thing. Can you please make display of filters contingent on the presence (in Ruby) of Settings.filters_beta (so Settings.filters_beta.present?? Then I can set that env var on the staging server and devs (like you) can set it in their config/settings.local.yml. We will want to be able to demo this stuff progressively to client.

Great stuff!

* Converts a list of forms from the backend into something Select2 understands.
*/
const parseFormsForSelect2 = (allForms) => allForms
.map((form) => mapKeys(form, (value, key) => key === "displayName" ? "text" : key));
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this outside of the class? Seems like something that would be a private method. Is this how private methods are accomplished in React?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is effectively a private method (though JavaScript doesn't have that concept), but more importantly, it's static.

I could have instead declared it a static class method but that's messier to factor out. I like putting utils outside of the class for ease of future refactoring. As soon as some other component wants to use this logic, it can move into a shared utils.js or something.

options={{
placeholder: I18n.t("filter.chooseForm"),
dropdownCssClass: "filters-select2-dropdown",
width: "100%",
Copy link
Contributor

Choose a reason for hiding this comment

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

Trailing comma on purpose?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes for better git diff. The linter will soon enforce this too.

render() {
return (
<OverlayTrigger
containerPadding={25}
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems wrong to have style details like this in here. Or am I misunderstanding what this is...

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree 😢 Bootstrap requires this. This adds a pseudo-margin to the overlay itself so it doesn't hit the side of the screen.

app/views/searches/_form.html.erb Outdated Show resolved Hide resolved
config/locales/en/main.yml Show resolved Hide resolved
docs/development-setup.md Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
spec/javascript/setupTests.js Show resolved Hide resolved
@cooperka
Copy link
Member Author

@smoyth all feedback is addressed

@smoyte smoyte merged commit 1ab5abb into develop Mar 20, 2019
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.

3 participants