Skip to content

Commit

Permalink
Pushing search-options progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
erinesullivan committed Feb 21, 2025
1 parent 2c7a576 commit f96955e
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/search/presenters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def self.for_datastore(slug)
icons: Icons.new,
styles: ["styles.css", "datastores/styles.css"],
scripts: ["scripts.js", "partials/scripts.js"]
# search_options: SearchOptions.for(slug)
)
end

Expand Down
57 changes: 57 additions & 0 deletions lib/search/presenters/search-options.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
module Search
module Presenters
class SearchOptions
SEARCH_OPTIONS = YAML.load_file(File.join(S.config_path, "search_options.yaml"))

def initialize(datastore)
# selects options
end

def datastore_options
# filtered options
end

def show_optgroups?
# check if more than one group
end

def default_option
# get first option
end

def selected_option
# select option on load
end

def search_only
# grab only `search` group options (used in advanced search)
end
end

class SearchOption
def initialize
#
end

def value
#
end

def tip
#
end

def tip_label
#
end

def text
#
end

def optgroup
#
end
end
end
end
61 changes: 61 additions & 0 deletions spec/presenters/search-options_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# RSpec.describe Search::Presenters::SearchOptions do
# context "#search_options" do
# it "lists search options in the config file" do
# expect(described_class.new.search_options).to include("...")
# end
# end

# context "#datastore_search_options" do
# it "lists search options specific to the datastore" do
# expect(described_class.new.datastore_search_options).to include("...")
# end
# it "defaults to the first datastore if datastore is nil" do
# expect(described_class.new.datastore_search_options).to include("...")
# end
# end

# context "#datastore_search_tips" do
# it "lists search tips specific to the datastore search options" do
# expect(described_class.new.datastore_search_options).to include("...")
# end
# end

# context "#show_optgroups?" do
# it "checks if there is more than one group of search options" do
# expect(described_class.new.datastore_search_options).to include("...")
# end
# end

# context "#default_option" do
# it "gives the first search option specific to the datastore" do
# expect(described_class.new.datastore_search_options).to include("...")
# end
# end

# context "#queried_option" do
# it "lists search options specific to the datastore" do
# expect(described_class.new.datastore_search_options).to include("...")
# end
# it "defaults to the first option if queried option does not exist" do
# expect(described_class.new.datastore_search_options).to include("...")
# end
# it "defaults to the first option if the query contains operators" do
# expect(described_class.new.datastore_search_options).to include("...")
# end
# end
# end

RSpec.describe Search::Presenters::SearchOption do
context "#value" do
it "has a value" do
search_option = {
"id" => "keyword_contains",
"value" => "keyword",
"text" => "Keyword (contains)",
"tip" => "Enter one or more keywords to search broadly (e.g., Black Women Scientists). Use quotes to search for a specific phrase (e.g., \"systems of oppression\"). See tips about <a href=\"https://guides.lib.umich.edu/c.php?g=914690&p=6590011?utm_source=library-search\" class=\"open-in-new\" target=\"_blank\" rel=\"noopener noreferrer\" aria-label=\"Basic Keyword Searching - opens in new window\">Basic Keyword Searching</a>.",
"group" => "search"
}
expect(described_class.new(search_option).value).to eq(search_option["value"])
end
end
end
3 changes: 2 additions & 1 deletion views/partials/header/_search.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
query = query_param.split(":(").first
end
%>
<form class="search-form" role="search" method="post" action="/search">

<form class="search-form" role="search" method="get" action="">
<div class="search-form__inputs viewport-container">
<select aria-label="Select an option" class="search-form__inputs--select" autocomplete="off">
<% if optgroups.length > 1 %>
Expand Down

0 comments on commit f96955e

Please sign in to comment.