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

I251 subject search box #238

Merged
merged 5 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ DB_TEST_NAME=hyku_test
DB_USER=postgres
DB_HOST=db
DB_PORT=5432
ENGINE_MOUNT=authorities
FCREPO_HOST=fcrepo
FCREPO_PORT=8080
FCREPO_URL=http://fcrepo:8080/rest
Expand Down
13 changes: 13 additions & 0 deletions app/views/records/edit_fields/_subject.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%= f.input :subject,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will eventually need to be dynamic (to work for any flex defined controlled value).

# TODO(shanalmoore) as: :controlled_vocabulary is not working for some reason,
as: :multi_value,
placeholder: 'Search for a subject',
input_html: {
class: 'form-control',
data: { 'autocomplete-url' => "/authorities/search/loc/subjects",
'autocomplete' => key }
},
### Required for the ControlledVocabulary javascript:
wrapper_html: { data: { 'autocomplete-url' => "/authorities/search/loc/subjects",
'field-name' => key }},
required: f.object.required?(key) %>
31 changes: 31 additions & 0 deletions config/initializers/qa.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Qa.config do |config|
# When enabled, CORS headers will be added to the responses for search and show. `OPTIONS` method will also be supported.
# Uncomment one of the lines below to enable or disable CORS headers. This configuration defaults to disabled when not set.
# More information on CORS headers at: https://fetch.spec.whatwg.org/#cors-protocol
# config.enable_cors_headers
# config.disable_cors_headers

# Provide a token that allows reloading of linked data authorities through the controller
# action '/reload/linked_data/authorities?auth_token=YOUR_AUTH_TOKEN_DEFINED_HERE' without
# requiring a restart of rails. By default, reloading through the browser is not allowed
# when the token is nil or blank. Change to any string to control who has access to reload.
config.authorized_reload_token = 'YOUR_AUTH_TOKEN_DEFINED_HERE'

# For linked data access, specify default language for sorting and selection. The default is only used if a language is not
# specified in the authority's configuration file and not passed in as a parameter. (e.g. :en, [:en], or [:en, :fr])
# config.default_language = :en

# When true, prevents ldpath requests from making additional network calls. All values will come from the context graph
# passed to the ldpath request.
# config.limit_ldpath_to_context = true

# Define default behavior for property_map.optional? when it is not defined in the configuration for a property.
# When false, properties that do not override default optional behavior will be shown whether or not the property has a value in the graph.
# When true, properties that do not override default optional behavior will not be shown whn the property does not have a value in the graph.
# config.property_map_default_for_optional = false

# IP data including IP address, city, state, and country will be logged with each request.
# When false, IP data is logged
# When true, IP data will not be logged (default for backward compatibility)
# config.suppress_ip_data_from_log = true
end
24 changes: 24 additions & 0 deletions config/oclcts-authorities.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
url-pattern:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file was produced by the generator. I am not sure how it gets used yet, but would prefer to keep it around for now to not forget about it later.

prefix-query: http://tspilot.oclc.org/{authority-id}/?query=oclcts.rootHeading+exact+%22{query}*%22&version=1.1&operation=searchRetrieve&recordSchema=http%3A%2F%2Fzthes.z3950.org%2Fxml%2F1.0%2F&maximumRecords=10&startRecord=1&resultSetTTL=300&recordPacking=xml&recordXPath=&sortKeys=
id-lookup: http://tspilot.oclc.org/{authority-id}/?query=dc.identifier+exact+%22{id}%22&version=1.1&operation=searchRetrieve&recordSchema=http%3A%2F%2Fzthes.z3950.org%2Fxml%2F1.0%2F&maximumRecords=10&startRecord=1&resultSetTTL=300&recordPacking=xml&recordXPath=&sortKeys=
authorities:
lcgft:
name: Library of Congress Genre/Form Terms for Library and Archival Materials (LCGFT)
bisacsh:
name: Book Industry Study Group Subject Headings (BISAC®). Used with permission.
fast:
name: Faceted Application of Subject Terminology (FAST subject headings)
gsafd:
name: Form and genre headings for fiction and drama
lcshac:
name: Library of Congress AC Subject Headings
lcsh:
name: Library of Congress Subject Headings
mesh:
name: Medical Subject Headings (MeSH®)
lctgm:
name: "Thesaurus for graphic materials: TGM I, Subject terms"
gmgpc:
name: "Thesaurus for graphic materials: TGM II, Genre terms"
meta:
name: Controlled Vocabulary Metadata
24 changes: 24 additions & 0 deletions spec/views/records/edit_fields/_subject.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

RSpec.describe 'records/edit_fields/_subject.html.erb', type: :view do
let(:work) { GenericWork.new }
let(:form) { Hyrax::GenericWorkForm.new(work, nil, controller) }
let(:form_template) do
%(
<%= simple_form_for [main_app, @form] do |f| %>
<%= render "records/edit_fields/subject", f: f, key: 'subject' %>
<% end %>
)
end

before do
assign(:form, form)
render inline: form_template
end

it 'has url for autocomplete service' do
expect(rendered).to have_selector(
'input[data-autocomplete-url="/authorities/search/loc/subjects"][data-autocomplete="subject"]'
)
end
end