Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upSearch Bar Display Logic #730
Conversation
end | ||
|
||
show_search_bar | ||
end |
This comment has been minimized.
This comment has been minimized.
BenMorganIO
Jan 13, 2017
•
Collaborator
Refactor suggestion:
# Checks if any of the dashboard's collection attributes are searchable. If none
# of them are, then we know that there isn't any need to load the search bar. In
# which case, we hide it.
#
# @return [Boolean]
def show_search_bar?
dashboard.attribute_types_for(
dashboard.collection_attributes
).any? do |_name, attribute|
attribute.searchable?
end
end
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I really like this PR. Left some comments. Great work @akestner |
This comment has been minimized.
This comment has been minimized.
Thanks @BenMorganIO! I initially wrote it for a client and thought it seemed like a good change to submit back upstream. I've updated the |
b28f125
into
thoughtbot:master
1 check passed
1 check passed
hound
No violations found. Woof!
fwolfst
added a commit
to fwolfst/administrate
that referenced
this pull request
Mar 8, 2017
* hides search bar when no attributes are searchable * adds tests for search bar display logic * extracts capture_view_locals method to ControllerHelpers * no need for page argument to show_search_bar? method * streamlines show_search_bar? method
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
akestner commentedJan 13, 2017
Currently the search bar is shown regardless of whether or not a resource contains searchable attributes. This PR adds a method to the
Administrate::ApplicationController
that checks whether any attributes are searchable and passes a new local variable (show_search_bar
) to the view which is then used to determine whether or not to render the search partial.