scientist-softserv / west-virginia-university

West Virginia University
0 stars 0 forks source link

🎁 Add Advanced Search #110

Closed jeremyf closed 1 year ago

jeremyf commented 1 year ago

⚙️ Add blacklight_advanced_search gem

b4bf572d9ece40ba7aeb9cbd61132456458ef6f1

Once I added the blacklight_advanced_search gem, I ran the following:

docker compose exec web bundle

This added blacklight_advanced_search to the gem dependency graph by updating the Gemfile.lock

Related to:

🎁 Install blacklight_advanced_search

749ab835c54f8f91437e9410e2b85f0033e0bb9e

These files were generated via:

docker compose exec web rails generate blacklight_advanced_search:install

Note: The documentation said to run rails generate blacklight_advanced_search, however during the installation it mentioned that was deprecated in favor of the above. So I reset and ran the command based on the guidance of the generator (figuring that guidance was likely more correct).

During the installation, the generator asked:

Install local search form with advanced link? (y/N)

I answered y.

Related to:

💄 Move "More options" button beside Search

17c776a7d1bd0fdd0a65130216a80e1f2dab4cd1

Prior to this commit, the "More Options" floated beneath the form; looking very much out of place.

With this change, it's inline and appropriate.

Before Screenshot 2023-10-19 at 11 33 21 AM
After Screenshot 2023-10-19 at 10 14 15 AM

♻️ Add SearchBuilder#initialize parameter handler

97c6980dd35732f901f91087749bed3fc97c1e88

Prior to this commit I was getting the following exception:

ArgumentError in AdvancedController#index
wrong number of arguments (given 2, expected 1; required keyword:
ability)

It turns out that during the AdvancedController#index request cycle we instantiate Blacklight::AccessControls::SearchBuilder multiple times; and with different parameter signatures.

Below are the logged calls of Blacklight::AccessControls::SearchBuilder; note we have only minimal application changes so this appears to be a conflict between versions.

Blacklight::AccessControls::SearchBuilder#initialize with controller as first parameter; caller: /usr/local/bundle/gems/blacklight-access_controls-6.0.1/lib/blacklight/access_controls/catalog.rb:21:in `new'
Blacklight::AccessControls::SearchBuilder#initialize with processor_chain as first parameter; caller: /usr/local/bundle/gems/blacklight-6.25.0/lib/blacklight/search_builder.rb:81:in `new'
Blacklight::AccessControls::SearchBuilder#initialize with processor_chain as first parameter; caller: /usr/local/bundle/gems/blacklight-6.25.0/lib/blacklight/search_builder.rb:61:in `new'

With this commit, I'm introducing a crease in the code to re-arrange the method signature. In doing so the exception mentioned above goes away, and I see the advanced search page.

Before Screenshot 2023-10-19 at 10 16 11 AM
After Screenshot 2023-10-19 at 11 34 43 AM

Related to: