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

DACCESS 2025 Sprint 1 - Merge dev to main #2221

Merged
merged 102 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
aaaa055
feature: Added query parms to advanced search path.
JeremyDuncan Nov 27, 2024
5fec34b
feature: Added search_form.js
JeremyDuncan Dec 2, 2024
4c31df8
feature: Added search_form.js script load to view
JeremyDuncan Dec 2, 2024
689e225
feature: updated to work with js code
JeremyDuncan Dec 2, 2024
05dd35c
feature: added js code to precompile
JeremyDuncan Dec 2, 2024
cfe275a
refactor: removed console log
JeremyDuncan Dec 2, 2024
5a24369
Merge branch 'dev' of github.com:cul-it/blacklight-cornell into DACCE…
JeremyDuncan Dec 4, 2024
eac5024
Merge branch 'dev' of github.com:cul-it/blacklight-cornell into DACCE…
JeremyDuncan Dec 5, 2024
af8010f
tests: updated to use rspec system tests and added tests for new feat…
JeremyDuncan Dec 5, 2024
b7d6be2
tests: commented out testing code
JeremyDuncan Dec 5, 2024
d6178cc
Merge branch 'dev' of github.com:cul-it/blacklight-cornell into DACCE…
JeremyDuncan Dec 6, 2024
09cc1a8
refactor: added begins with logic
JeremyDuncan Dec 9, 2024
c5b76a6
refactor: added :op param form value
JeremyDuncan Dec 9, 2024
9c17ad6
Merge branch 'dev' of github.com:cul-it/blacklight-cornell into DACCE…
JeremyDuncan Dec 9, 2024
b57c136
Show special request buttons for Kheel items
sarah-cul Dec 11, 2024
75b45a2
LP-1237 - switch CORS to accept connections from the us-east-1 versio…
jgreidy Dec 18, 2024
0a0ab34
Merge pull request #2203 from cul-it/LP-1245---
jgreidy Dec 18, 2024
acc32b5
Merge branch 'dev' of github.com:cul-it/blacklight-cornell into DACCE…
JeremyDuncan Jan 6, 2025
31e6b2d
fix: updated tests to account for new id
JeremyDuncan Jan 6, 2025
3ccfcc4
Bump nokogiri to 1.16.8
chrisrlc Jan 6, 2025
98d6cfc
Merge pull request #2204 from cul-it/nokogiri-bump
chrisrlc Jan 6, 2025
968f32b
Merge branch 'dev' of github.com:cul-it/blacklight-cornell into DACCE…
JeremyDuncan Jan 6, 2025
4ea1dc9
fix: updated jenkins scripts to work with rspec system tests
JeremyDuncan Jan 6, 2025
618b778
fix: updated script wrapper
JeremyDuncan Jan 6, 2025
879b319
DACCESS-291:test-Added test
JeremyDuncan Jan 6, 2025
b205506
Merge branch 'dev' into DACCESS-407
sarah-cul Jan 6, 2025
af8cc30
updated to test parallel processing
JeremyDuncan Jan 8, 2025
b5b0180
updated to test 4 parallel processes
JeremyDuncan Jan 8, 2025
b4fa108
updated to test all parallel processes
JeremyDuncan Jan 8, 2025
354d593
do not allow special requests for Kheel items in this branch, keep th…
sarah-cul Jan 8, 2025
04ca3f3
do not allow special requests for Kheel items in this branch, keep th…
sarah-cul Jan 8, 2025
464c506
DACCESS-291-updated link render logic
JeremyDuncan Jan 8, 2025
5e051af
DACCESS-291-updated link render logic
JeremyDuncan Jan 8, 2025
9b938b0
DACCESS-291-updated id
JeremyDuncan Jan 8, 2025
3937beb
DACCESS-291-updated default form values
JeremyDuncan Jan 8, 2025
8f96526
Merge pull request #2201 from cul-it/DACCESS-407
sarah-cul Jan 8, 2025
9e55909
DACCESS-291-updated default form values
JeremyDuncan Jan 8, 2025
8131232
DACCESS-291-removed debug tag
JeremyDuncan Jan 8, 2025
a1bec93
DACCESS-291-updated cucumber tests to to multiple processors
JeremyDuncan Jan 8, 2025
d1e178b
DACCESS-291-removed options
JeremyDuncan Jan 8, 2025
1259e75
DACCESS-363: fix empty <h2> heading on New TOU view
mhk33 Jan 8, 2025
921faa1
Merge branch 'dev' of github.com:cul-it/blacklight-cornell into DACCE…
JeremyDuncan Jan 8, 2025
75cf348
DACCESS-291-added chrome options
JeremyDuncan Jan 8, 2025
8752aca
Prevent patrons from exceeding the char limit in the special requests…
sarah-cul Jan 8, 2025
4244132
added style class for this character warning, shows red font awesome …
sarah-cul Jan 8, 2025
53235a0
DACCESS-291-added id to link
JeremyDuncan Jan 9, 2025
fee679d
Merge pull request #2207 from cul-it/DACCESS-363
mhk33 Jan 9, 2025
e4b9de9
Merge branch 'dev' into DACCESS-476
sarah-cul Jan 9, 2025
ed0ea6d
DACCESS-291-set to 1 processor
JeremyDuncan Jan 9, 2025
328d210
Merge pull request #2208 from cul-it/DACCESS-476
sarah-cul Jan 9, 2025
fd3f3e6
DACCESS-366 - Don't display bookcover in search results if no_google_…
chrisrlc Jan 8, 2025
0c6b0ef
Merge pull request #2206 from cul-it/DACCESS-366
chrisrlc Jan 9, 2025
afeabab
DACCESS-291-ensure values treated as array
JeremyDuncan Jan 9, 2025
c93f254
DACCESS-291-added javascript tag
JeremyDuncan Jan 9, 2025
2d413ec
DACCESS-291-updated to account for _row params and pass to /edit path
JeremyDuncan Jan 9, 2025
08b600c
DACCESS-291-cleaned up js code
JeremyDuncan Jan 9, 2025
b666ba8
DACCESS-291-updated README
JeremyDuncan Jan 9, 2025
b8824ea
DACCESS-291-updated to work with edit path
JeremyDuncan Jan 9, 2025
3a08383
Merge branch 'dev' of github.com:cul-it/blacklight-cornell into DACCE…
JeremyDuncan Jan 9, 2025
2ab8803
DACCESS-291-removed unneeded readme lines
JeremyDuncan Jan 9, 2025
4d99f8a
DACCESS-360 - dry up simple search SearchBuilder logic
chrisrlc Dec 4, 2024
a4ec769
Set DISPLAY_SOLR_QUERY env in Jenkinsfile
chrisrlc Dec 9, 2024
6509ba8
DACCESS-471 - Display flash error when trying to exceed search limit
chrisrlc Jan 6, 2025
63b7e75
Remove search param handling from CornellCatalog#index
chrisrlc Jan 7, 2025
c93977e
DACCESS-474 - Don't exclude worldcat url generation for lc_callnum se…
chrisrlc Jan 7, 2025
af158d0
Merge pull request #2192 from cul-it/DACCESS-360-simple
chrisrlc Jan 9, 2025
292ba97
DACCESS-291-refactored to follow other param conventions
JeremyDuncan Jan 10, 2025
2964290
DACCESS-291-refactored to follow other param conventions
JeremyDuncan Jan 10, 2025
d1a0f0a
DACCESS-291-refactored to combine precompiles
JeremyDuncan Jan 10, 2025
aa8bcc8
DACCESS-291-merged dev into branch
JeremyDuncan Jan 10, 2025
1ab7d34
Merge pull request #2196 from cul-it/DACCESS-291-Advanced-Search-Carr…
JeremyDuncan Jan 10, 2025
f73f903
DACCESS-484-updated NUM_PROCESSES
JeremyDuncan Jan 10, 2025
1340c8e
DACCESS-484-updated jenkins file
JeremyDuncan Jan 10, 2025
8e9216b
DACCESS-484-updated jenkins file
JeremyDuncan Jan 10, 2025
ce9fc6d
DACCESS-484-updated jenkins file
JeremyDuncan Jan 10, 2025
07471fe
DACCESS-484-updated jenkins file
JeremyDuncan Jan 10, 2025
817924f
Merge pull request #2209 from cul-it/DACCESS-484-test_variable_update
JeremyDuncan Jan 10, 2025
58045d2
DACCESS-485 update the photoduplication form so its similar to the A…
sarah-cul Jan 13, 2025
dd4648c
remove bootstrap muted class
sarah-cul Jan 13, 2025
67144e1
DACCESS-41 - Display Total Works when exists in heading counts_json, …
chrisrlc Jan 14, 2025
63daa71
Merge pull request #2213 from cul-it/DACCESS-41
chrisrlc Jan 15, 2025
74c1ef3
DACCESS-411 - Add sort by date acquired option
chrisrlc Jan 15, 2025
1a662b5
DACCESS-487: add click event for Articles & Full Text, update event f…
mhk33 Jan 15, 2025
49d9db3
DACCESS-487: update to use blacklight_format or title for Matomo clic…
mhk33 Jan 16, 2025
a86262a
Merge branch 'dev' into DACCESS-485
sarah-cul Jan 16, 2025
89916d7
Merge pull request #2214 from cul-it/DACCESS-411
chrisrlc Jan 16, 2025
0ec2b55
Merge branch 'dev' into DACCESS-487
mhk33 Jan 16, 2025
10392b9
Merge branch 'dev' into DACCESS-485
sarah-cul Jan 16, 2025
82d5348
Merge pull request #2210 from cul-it/DACCESS-485
sarah-cul Jan 16, 2025
8436299
Merge branch 'dev' into DACCESS-487
mhk33 Jan 16, 2025
0e12690
DACCESS-472 - for bookmarks, use the catalog path to show the details…
sarah-cul Jan 16, 2025
1393f94
Merge pull request #2215 from cul-it/DACCESS-487
mhk33 Jan 16, 2025
2822f04
DACCESS-489: fix click events on non-catalog links in bento
mhk33 Jan 17, 2025
3511fc2
DACCESS-489: clean up syntax and re-word matomo label
mhk33 Jan 17, 2025
281619e
Merge pull request #2219 from cul-it/DACCESS-489
mhk33 Jan 17, 2025
17c5a4e
remove searchable concerns for bookmarks, and add cucumber scenario t…
sarah-cul Jan 17, 2025
1fd7527
reverse changes to display_helper
sarah-cul Jan 17, 2025
1137933
Merge branch 'dev' into DACCESS-472
sarah-cul Jan 17, 2025
6d91ecf
Update My Account and Edge library
Baroquem Jan 17, 2025
7a40707
Merge pull request #2216 from cul-it/DACCESS-472
sarah-cul Jan 18, 2025
6be02d5
Merge branch 'dev' into update-my-account
Baroquem Jan 21, 2025
4733dc3
Merge pull request #2220 from cul-it/update-my-account
Baroquem Jan 21, 2025
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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,10 @@ You can run RSPEC tests by supplying -s flag.
./run_test.sh -r YOUR_RAILS_ENV_FILE -f features/catalog_search/item_view.feature
./run_test.sh -sr YOUR_RAILS_ENV_FILE
./run_test.sh -sr YOUR_RAILS_ENV_FILE -f spec/helpers/advanced_helper_spec.rb

## Parallel Testing
Testing has been updated to allow for parallel testing with cucumber tests.
### To run tests in parallel:
* Update constant `NUM_PROCESSES=1` in `jenkins/cucumber-features.sh` to the number of processes you want to run in parallel.
Copy link
Contributor

Choose a reason for hiding this comment

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

I may have missed discussion of this during the standups, but how does one determine the right number of processes to use? What are the disadvantages of just selecting the maximum number all the time? Presumably that might impact others who are trying to run Jenkins jobs on the same server for other projects, but how would one know that without sending out a general query to all the developers on Slack?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Baroquem, As its setup now, It defaults to just using 1 processor, but you can manually set it to use more than one processor (with diminishing gains the more you add).

Currently there are only 4 processors available for Jenkins to use If there are more tests running than processors, then it increases the time it takes to finish those tests.

If you use 2 processors in Jenkins it cuts the time down to about 25 minutes.

Greg said there can be more processors added, but they are working on getting the docker container tests setup first

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. I’m more wondering about the impact on other people. The selfish thing to do is obviously to grab all the available processors for my own testing, to finish it as quickly as possible, but I wouldn’t do that if it negatively affects other people’s work. But then do I pick 2 processors … or 3…? I don’t have a sense of how to find the best compromise there.

And if nobody else happens to be using Jenkins at the time, then I could use all the processors without guilt — but I don’t think we have a good way of determining that.

* Currently, Jenkins has a maximum of 4 processes.
* Set to `NUM_PROCESSES=$(nproc --all)` to use all available processors.
7 changes: 4 additions & 3 deletions blacklight-cornell/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ gem "marc"
gem "blacklight-marc", "~> 6.3"
gem "rb-readline", "~> 0.5.x"
gem "net-ldap"
gem "nokogiri", ">= 1.14.3"
gem "nokogiri", "~> 1.16.7"
gem "rufus-scheduler"
gem "addressable", ">= 2.8.0"
gem "redis-session-store"
Expand Down Expand Up @@ -90,6 +90,7 @@ group :test do
gem "capybara-email"
gem "simplecov", :require => false
gem "simplecov-rcov", :require => false
gem 'parallel_tests'
end

gem "jquery-rails"
Expand Down Expand Up @@ -121,8 +122,8 @@ gem "font-awesome-rails"
gem "blacklight_cornell_requests", git: "https://github.com/cul-it/blacklight-cornell-requests", tag: "v5.2"
# gem 'blacklight_cornell_requests', :path => '/Users/matt/code/cul/d&a/blacklight-cornell-requests'
# gem 'my_account', :path => '/Users/matt/code/cul/d&a/cul-my-account'
gem "cul-folio-edge", git: "https://github.com/cul-it/cul-folio-edge", tag: "v3.1"
gem "my_account", git: "https://github.com/cul-it/cul-my-account", tag: "v2.3.3"
gem "cul-folio-edge", git: "https://github.com/cul-it/cul-folio-edge", tag: "v3.2"
gem "my_account", git: "https://github.com/cul-it/cul-my-account", tag: "v2.3.4"
gem "ruby-saml", ">= 1.12.1"
gem "bento_search", "~> 2.0.0.rc1"
gem "celluloid", "0.17.4" # Required for bento_search multisearcher
Expand Down
28 changes: 16 additions & 12 deletions blacklight-cornell/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ GIT

GIT
remote: https://github.com/cul-it/cul-folio-edge
revision: c34dab4611ce57dfca2308344e03a72dbc92ff44
tag: v3.1
revision: bfdc3a28749ce826caf7dd1c415dd044a72a8b4f
tag: v3.2
specs:
cul-folio-edge (3.1)
cul-folio-edge (3.2)
rest-client

GIT
remote: https://github.com/cul-it/cul-my-account
revision: c03cd679cb1d730e1f1da24705854941c7e566ad
tag: v2.3.3
revision: 81a6040fff2fe0e2e534cd32deb68a7fa0e926be
tag: v2.3.4
specs:
my_account (2.3.3)
my_account (2.3.4)
blacklight (>= 7.0)
cul-folio-edge (~> 3.1)
cul-folio-edge (~> 3.2)
rails (~> 6.1)
rest-client
xml-simple
Expand Down Expand Up @@ -543,13 +543,13 @@ GEM
net-ssh (5.2.0)
netrc (0.11.0)
nio4r (2.7.1)
nokogiri (1.16.7-aarch64-linux)
nokogiri (1.16.8-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.7-arm64-darwin)
nokogiri (1.16.8-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-darwin)
nokogiri (1.16.8-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-linux)
nokogiri (1.16.8-x86_64-linux)
racc (~> 1.4)
nori (2.7.0)
bigdecimal
Expand Down Expand Up @@ -587,6 +587,9 @@ GEM
scrub_rb (~> 1.0)
orm_adapter (0.5.0)
ostruct (0.6.0)
parallel (1.26.3)
parallel_tests (4.8.0)
parallel
parslet (2.0.0)
piwik_analytics (1.0.2)
actionpack
Expand Down Expand Up @@ -903,13 +906,14 @@ DEPENDENCIES
mysql2 (= 0.5.6)
net-ldap
net-smtp
nokogiri (>= 1.14.3)
nokogiri (~> 1.16.7)
omniauth (~> 2.0)
omniauth-facebook (~> 5.0)
omniauth-google-oauth2 (~> 0.8)
omniauth-oauth2
omniauth-rails_csrf_protection
omniauth-saml (>= 2.1.2)
parallel_tests
parslet
piwik_analytics (~> 1.0.1)
protected_attributes_continued
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ function AuthorBrowse() {
const { citizenship, education, entity, image, pseudonyms } = parsedWikidata;

if (image) {
$('#agent-image').attr('src', image.url);
$('#img-container').show();
$('#bio-image').attr('src', image.url);
$('#img-container').removeClass('d-none');;
$('#wiki-image-acknowledge').html(`<br/>Image: ${wikidataConnector.imageAttributionHtml(image)}`);
} else {
$('#comment-container').removeClass();
Expand Down Expand Up @@ -208,11 +208,11 @@ function AuthorBrowse() {

// when there's no wikidata or an error occurs in one of the ajax calls
function displayCatalogMetadata() {
$('#bio-desc').removeClass('d-none');
$('#bio-without-ld').removeClass('d-none');
};

function displayLinkedData() {
$('#info-details').removeClass('d-none');
$('#bio-with-ld').removeClass('d-none');
$('#ref-info').addClass('mt-4');
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function AuthorTitleBrowse() {
// TODO: Add ability to exclude excludeEntities.yml?

async function renderLinkedData() {
let wikidata = {};
try {
// Query Library of Congress for localName that can be used to fetch Wikidata results
const headingAttr = $('#author-title-heading').data('heading');
Expand All @@ -14,11 +15,13 @@ function AuthorTitleBrowse() {

if (localName) {
// If LOC name found for heading, query Wikidata for additional data to display
const wikidata = await bamwowHelper.getWikidata(localName);
renderWikidata(wikidata);
wikidata = await bamwowHelper.getWikidata(localName);
}
} catch(err) {
console.log(err);
} finally {
// Either display linked data or default catalog metadata
showDetails(wikidata);
}
};

Expand All @@ -27,37 +30,50 @@ function AuthorTitleBrowse() {
return bamwowHelper.reformatHeading(headingAttr);
};

function renderWikidata(data) {
function showDetails(data) {
if (bamwowHelper.canRender(data)) {
const fieldHtml = generateFieldHtml(data);
$('dl#item-details').append(fieldHtml);
renderWikidata(data);
displayLinkedData();
} else {
displayCatalogMetadata();
}
};

const sourceLinkHtml = generateWikidataSourceLinks(data);
$('#wiki-acknowledge').html(sourceLinkHtml);
// when there's no wikidata or an error occurs in one of the ajax calls
function displayCatalogMetadata() {
$('#bio-without-ld').removeClass('d-none');
};

// Show details
$('#info-details').removeClass('d-none');
$('#ref-info').addClass('mt-4');
}
function displayLinkedData() {
$('#bio-with-ld').removeClass('d-none');
$('#ref-info').addClass('mt-4');
};

function renderWikidata(data) {
const fieldHtml = generateFieldHtml(data);
$('dl#item-details').append(fieldHtml);

const sourceLinkHtml = generateWikidataSourceLinks(data);
$('#wiki-acknowledge').html(sourceLinkHtml);
}

// Generate fields
function generateFieldHtml(data) {
let html = '';
if (data.codes?.length) {
const codesArr = data.codes.map(code => `<dt>${code.catalogLabel} : ${code.code} *</dt>`);
const codesArr = data.codes.map(code => `<li class='list-unstyled'>${code.catalogLabel} : ${code.code} *</li>`);
html += (
`<dt class="col-sm-4">Catalog numbers:</dt>
<dd class="col-sm-8">
<dl class="dl-horizontal">${codesArr.join(' ')}</dl>
`<dt>Catalog numbers:</dt>
<dd>
<ul class='list-group'>${codesArr.join(' ')}</ul>
</dd>`
);
}
if ('createdFor' in data) {
const { loc: createdForLoc, label: createdForLabel } = data.createdFor;
html += (
`<dt class="blacklight-wd-created col-sm-4">Created for:</dt>
<dd class="col-sm-8" loc="${createdForLoc}">${createdForLabel} *</dd>`
`<dt class="blacklight-wd-created">Created for:</dt>
<dd loc="${createdForLoc}">${createdForLabel} *</dd>`
);
}

Expand All @@ -68,7 +84,7 @@ function AuthorTitleBrowse() {
let value = data[prop];
if (prop === 'date') value = bamwowHelper.formatDates(value);
if ($.isArray(value)) value = value.join(', ');
html += `<dt class="col-sm-4">${label}:</dt><dd class="col-sm-8">${value} *</dd>`;
html += `<dt>${label}:</dt><dd>${value} *</dd>`;
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ function SubjectDataBrowse() {

function renderWikiImage(image) {
if (image) {
$('#subject-image').attr('src', image.url);
$('#img-container').show();
$('#bio-image').attr('src', image.url);
$('#img-container').removeClass('d-none');;
$('#wiki-image-acknowledge').html(`<br/>Image: ${wikidataConnector.imageAttributionHtml(image)}`);
} else {
$('#comment-container').removeClass();
Expand Down Expand Up @@ -154,11 +154,11 @@ function SubjectDataBrowse() {
};

function displayCatalogMetadata() {
$('#bio-desc').removeClass('d-none');
$('#bio-without-ld').removeClass('d-none');
};

function displayLinkedData() {
$('#info-details').removeClass('d-none');
$('#bio-with-ld').removeClass('d-none');
$('#ref-info').addClass('mt-4');
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ function WikidataConnector() {
});
}

// TODO: Strip html from Wikidata response?
// Example where response doesn't fit in below format: "Shakespeare, William, 1564-1616." (headingType=[subject, author])
function imageAttributionHtml(image) {
const wmcUrl = `https://commons.wikimedia.org/wiki/${encodeURIComponent(image.title)}`;
const titleHtml = `"<a href="${wmcUrl}">${image.name || image.title}</a>"`;
Expand Down
106 changes: 106 additions & 0 deletions blacklight-cornell/app/assets/javascripts/search_form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
document.addEventListener("DOMContentLoaded", function () {
const advancedSearchLink = document.getElementById("advanced-search-link");
// Select all inputs, selects, and textareas if no dynamic fields are found
let formFields = document.querySelectorAll("[data-dynamic='true']");
if (formFields.length === 0) {
formFields = document.querySelectorAll("input, select, textarea");
}

if (advancedSearchLink && formFields) {
const searchField = document.getElementById("q");
// Update the Advanced Search link dynamically
const updateAdvancedSearchLink = () => {
let params = new URLSearchParams();
let hasSearchText = searchField && searchField.value.trim().length > 0;

formFields.forEach((field) => {
if (field.name && field.value && field.name !== "q") {
const fieldMappings = {
authq: "q",
browse_type: "search_field",
search_field: "search_field"
};

const searchValueMappings = {
author: "author",
author_browse: "author",
at_browse: "author",
"catalog:author": "author",
Author: "author",
"Author-Title": "author",
subject: "subject",
subject_browse: "subject",
"catalog:subject": "subject",
Subject: "subject",
publisher: "publisher",
"catalog:publisher": "publisher",
title: "title",
title_starts: "title",
"catalog:title": "title",
journaltitle: "journaltitle",
"catalog:journaltitle": "journaltitle",
"catalog:lc_callnum": "lc_callnum",
"Call-Number": "lc_callnum",
callnumber_browse: "lc_callnum",
lc_callnum: "lc_callnum"
};

if (field.name in fieldMappings) {
if (field.name === "browse_type" || field.name === "search_field" || field.name === "search_field_row") {
if (field.value in searchValueMappings) {
params.append("search_field_row[]", searchValueMappings[field.value]);
if (field.value === "title_starts") {
params.append("op_row[]", "begins_with");
}
}
} else {
params.append(fieldMappings[field.name], field.value);
}
} else if (field.name !== "authenticity_token" && field.name !== "utf8") {
params.append(field.name, field.value);
}
}
});

// Add q_row as a parameter if the search field has text
if (hasSearchText) {
params.append("q_row[]", searchField.value.trim()); // Append q_row
}

// Append other advanced search parameters if present
const opRow = document.querySelectorAll("[name='op_row[]']");
const searchFieldRow = document.querySelectorAll("[name='search_field_row[]']");
const booleanRow = document.querySelectorAll("[name='boolean_row[]']");
const facetFields = document.querySelectorAll("[name^='f[']");

opRow.forEach((field, index) => params.append(`op_row[${index}]`, field.value));
searchFieldRow.forEach((field, index) => params.append(`search_field_row[${index}]`, field.value));
booleanRow.forEach((field, index) => params.append(`boolean_row[${index}]`, field.value));

// Handle facets, including f[format]
const uniqueFacets = new Set();
facetFields.forEach((field) => {
const match = field.name.match(/^f\[(.+)\]$/); // Match f[key] format
if (match && match[1]) {
const key = `f[${match[1]}]`;
const value = field.value;
const facetEntry = `${key}=${value}`;

if (!uniqueFacets.has(facetEntry)) {
uniqueFacets.add(facetEntry);
params.append(key, value);
}
}
});
// Update link href to use the /edit path
advancedSearchLink.href = `/edit?${params.toString()}`;
};

formFields.forEach((field) => {
field.addEventListener("input", updateAdvancedSearchLink);
field.addEventListener("change", updateAdvancedSearchLink);
});
updateAdvancedSearchLink();
advancedSearchLink.addEventListener("click", updateAdvancedSearchLink);
}
});
Loading
Loading