From: Zavier Banks Date: Tue, 26 Nov 2019 22:10:12 +0000 (+0000) Subject: LP#1849212 OPAC Search Course Reserves Facet X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=aeb434f1147a4c52fbc3726e5f5364753b3f7f15;p=working%2FEvergreen.git LP#1849212 OPAC Search Course Reserves Facet Created a facet that will filter the course materials against the current search. Using the checkbox, the user can toggle the filter on and off. Signed-off-by: Zavier Banks --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 43459a1889..73a581e90d 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -3094,7 +3094,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - + diff --git a/Open-ILS/src/templates/opac/parts/advanced/search.tt2 b/Open-ILS/src/templates/opac/parts/advanced/search.tt2 index 7ac166dba9..89de95c454 100644 --- a/Open-ILS/src/templates/opac/parts/advanced/search.tt2 +++ b/Open-ILS/src/templates/opac/parts/advanced/search.tt2 @@ -139,7 +139,6 @@ [% l("Group Formats and Editions") %] [% END %] - [% CASE "copy_location" %] + + + + + diff --git a/Open-ILS/src/templates/opac/parts/result/adv_filter.tt2 b/Open-ILS/src/templates/opac/parts/result/adv_filter.tt2 index 35b2c77723..5b8cf68d0f 100644 --- a/Open-ILS/src/templates/opac/parts/result/adv_filter.tt2 +++ b/Open-ILS/src/templates/opac/parts/result/adv_filter.tt2 @@ -83,3 +83,14 @@ FOR filter IN ctx.query_struct.filters; [%- END; # IF pubdate_filters -%] [%- END; # FOR -%] + +[%IF CGI.param('coursereserves').grep('filtercoursereserves').size >0 %] +
+
+

[% l('Course Reserves') %]

+ × +
+
+[%- END %] diff --git a/Open-ILS/web/js/ui/default/opac/copyloc.js b/Open-ILS/web/js/ui/default/opac/copyloc.js index 08023d69b5..d4161434fb 100644 --- a/Open-ILS/web/js/ui/default/opac/copyloc.js +++ b/Open-ILS/web/js/ui/default/opac/copyloc.js @@ -1,10 +1,68 @@ dojo.require("DojoSRF"); dojo.require("openils.CGI"); +var course_list_query=[]; +course_reserves = dojo.byId("opac.result.coursereserves"); +value = dojo.byId("coursereservesvalue"); +qtype = dojo.byId("coursereservesqtype"); +contains = dojo.byId("coursereservescontains"); + +/** + * Query the database for the course reserves materials. + */ +function get_course_reserves(display_orgs) { + var params = [{ + cache : 1, + fields : ['item'], + query : {course : display_orgs} + }]; + new OpenSRF.ClientSession('open-ils.fielder').request({ + method: 'open-ils.fielder.acmcm.atomic', + params: params, + async: true, + oncomplete: function(r) { + var resp = r.recv(); + if (resp) { + var list = resp.content(); + //List out all the items, and add them to a list. + dojo.forEach(list, function(item, index) { + if(index == 0){ //If this is the first entry, create the string. + course_list_query = "((id:"+item.item+")"; + } else{ course_list_query += "||(id:"+item.item+")";} + }) + course_list_query += ")"; + filter_reserves(); + } + } + }).send(); +} + +/** + * Add the query to the filterwithreserves checkbox + */ +function filter_reserves() { + value.setAttribute('value', course_list_query) +} + +window.add_course_reserves_ids_to_query = add_course_reserves_ids_to_query; +function add_course_reserves_ids_to_query() { + //Resets the Course Reserves Facet, if unchecked. + if(!course_reserves.getAttribute("checked") || course_reserves.getAttribute("checked") == "") { + course_reserves.setAttribute("checked", 'checked') + value.setAttribute("checked", 'checked') + qtype.setAttribute("checked", 'checked') + contains.setAttribute("checked", 'checked') + }else { + dojo.removeAttr(course_reserves, 'checked'); + dojo.removeAttr(value, 'checked'); + dojo.removeAttr(qtype, 'checked'); + dojo.removeAttr(contains, 'checked'); + } +} + // called on initial page load and when the advance search org unit // selector is changed. function apply_adv_copy_locations() { - // patron selected org var sel = dojo.byId('adv_org_selector'); var selected_id = sel.options[sel.selectedIndex].getAttribute('value'); @@ -32,6 +90,7 @@ function apply_adv_copy_locations() { display_orgs.push(org_unit.id); collect_parent_orgs(org_unit.parent_ou); fetch_adv_copy_locations(display_orgs); + get_course_reserves(display_orgs) } function fetch_adv_copy_locations(org_ids) { @@ -58,7 +117,7 @@ function fetch_adv_copy_locations(org_ids) { } else { dojo.addClass('adv_chunk_copy_location', 'hidden'); } - } + } }).send(); } @@ -72,9 +131,8 @@ function render_adv_copy_locations(locations) { if (!dojo.isArray(url_selected)) url_selected = [url_selected]; } - dojo.removeClass('adv_chunk_copy_location', 'hidden'); - + // sort by name locations = locations.sort( function(a, b) {return a.name < b.name ? -1 : 1}