From 4b72de67dee5cc3144a5f6fa2223e08ddd00c869 Mon Sep 17 00:00:00 2001 From: Jeff Davis Date: Thu, 18 May 2017 15:43:53 -0700 Subject: [PATCH] LP#1690468: fix Exclude Electronic Resources checkbox with advanced search limiters When advanced search limiters are applied, you cannot successfully uncheck the Exclude Electronic Resources checkbox. When you uncheck it, your current search is reloaded, but e-resources are still excluded (and the box remains checked). When you use the checkbox to exclude e-resources, the search form on the results page contains a hidden input element: This commit uses Javascript to remove that element from the search form when the box is unchecked, before submitting the search. Test plan: [1] Enable the "Exclude Electronic Resources" checkbox in config.tt2. [2] Do an advanced search, applying at least one search filter (e.g. Language = "English"). [3] On the search results page, check the Exclude Electronic Resources checkbox. This repeats your search, excluding e-resources. [4] Uncheck the Exclude Electronic Resources box. Your search is repeated, but e-resources are still excluded and the box remains checked on your new results page. [5] Apply this fix. [6] Refresh the page or clear your browser cache, and try to uncheck the Exclude Electronic Resources box again. This time, it should work: e-resources will no longer be excluded, and the box is unchecked when your new results page loads. Signed-off-by: Jeff Davis Signed-off-by: Kathy Lussier --- Open-ILS/web/js/ui/default/opac/simple.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Open-ILS/web/js/ui/default/opac/simple.js b/Open-ILS/web/js/ui/default/opac/simple.js index 2f57bf6066..c1138147bc 100644 --- a/Open-ILS/web/js/ui/default/opac/simple.js +++ b/Open-ILS/web/js/ui/default/opac/simple.js @@ -107,6 +107,14 @@ function exclude_onchange(checkbox) { // Other functions' form submits may create duplicates of this, so /g var reg = /-search_format\(electronic\)/g; search_box.value = search_box.value.replace(reg, ""); + // Remove from the search form itself + var search_format_inputs = document.getElementsByName("fi:-search_format"); + for (var j = 0; j < search_format_inputs.length; j++) { + if (search_format_inputs[j].value == 'electronic') { + search_format_inputs[j].parentNode.removeChild(search_format_inputs[j]); + } + } + } checkbox.form.submit(); -- 2.11.0