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

TD-1337 restore local filter #436

Merged
merged 4 commits into from
Oct 9, 2024
Merged

Conversation

zinc-glaze
Copy link
Contributor

@zinc-glaze zinc-glaze commented Sep 27, 2024

  • Deprecates 'search_sidebar' partial (replaced w/ componenent in BL8)
  • Overrides 'search/sidebar_component' to render 'local_filter' instead
  • Modifies 'local_filter' partial to include markup previously rendered by 'search_sidebar' partial
  • fixes rubocop errors

@zinc-glaze zinc-glaze changed the base branch from main to Blacklight-8 September 27, 2024 14:28
@@ -1,3 +1,4 @@
<% # this partial is deprecated with BL8. catalog/index now renders the sidebar component %>
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should just delete this partial entirely as part of this PR rather than keep it around unused in the codebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -0,0 +1,26 @@
<% # TRLN override of BL8 catalog/index view %>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This does indeed work, but overriding the entire BL core index template comes at a cost. It's probably better in this case to just override/extend BL's view for the sidebar component specifically (https://github.com/projectblacklight/blacklight/blob/release-8.x/app/components/blacklight/search/sidebar_component.html.erb). E.g., if you make a local copy of only that file, then put this at the top, it'd work:

<%= render 'catalog/local_filter',
           local_button_id: 'toggle-local-btn-top',
           trln_button_id: 'toggle-trln-btn-top' %>

It's a bit subjective, so I think worth team weigh-in on how we want to approach this kind of refactor for BL8.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, sounds good. I tried to create a new "local_filter" component to replace that partial, but found that the methods and variables that were available to the view partial were undefined when used in the component. You're saying to remove the "local_filter" partial and move that markup/logic into an override of the new sidebar component? I think it might be a little more complicated than that as the new sidebar component is not a 1-to-1 replacement for the old sidebar partial.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would keep the _local_filter.html.erb partial how you have it. Copy the https://github.com/projectblacklight/blacklight/blob/release-8.x/app/components/blacklight/search/sidebar_component.html.erb file into this engine at the same path. Prepend that snippet to the top, annotated with comments like you've done elsewhere.

You probably don't need to pass search_state to the partial. If you do, the component can still call that method but with helpers.search_state, i.e.:

<%= render 'catalog/local_filter',
           search_state: helpers.search_state,
           local_button_id: 'toggle-local-btn-top',
           trln_button_id: 'toggle-trln-btn-top' %>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found that i had to also include the 'sidebar_component.rb' to get the override to work, as well as updating the configuration to use the override.

…ecate 'search_sidebar' partial per BL8; modify 'local_filter' partial to duplicate deprecated 'search_sidebar'
@zinc-glaze zinc-glaze force-pushed the TD-1337-restore-local-filter branch from de4938b to b73642b Compare October 9, 2024 14:17
module TrlnArgon
module Search
class SidebarComponent < Blacklight::Search::SidebarComponent
def initialize(blacklight_config:, response:, view_config:)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would remove lines 6-15 here, which will spare us from having to reconcile this code frequently against upstream Blacklight to make sure it matches.

@seanaery seanaery merged commit 456f712 into Blacklight-8 Oct 9, 2024
0 of 8 checks passed
@seanaery seanaery deleted the TD-1337-restore-local-filter branch October 9, 2024 18:01
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.

2 participants