From: erickson Date: Thu, 14 Jul 2005 17:11:32 +0000 (+0000) Subject: format handling in the opac, added format to searches X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=40f2cd64e2a6857ea1558832a0c4bbd9d63b0aa3;p=Evergreen.git format handling in the opac, added format to searches icons, etc. git-svn-id: svn://svn.open-ils.org/ILS/trunk@1187 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js b/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js index 39c5575695..54ddd071c0 100644 --- a/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js +++ b/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js @@ -213,8 +213,16 @@ AbstractRecordResultPage.prototype.displayRecord = c.className = "record_misc_cell"; var resources = record.types_of_resource(); - for( var i in resources ) - this.buildResourcePic( c, resources[i]); + for( var i in resources ) { + var prefix = "http://" + globalRootURL + ":" + globalPort + globalRootPath; + var res = modsFormatToMARC(resources[i]); + var a = elem("a", + {href: prefix + "?target=record_result&mrid=" + + record.doc_id() + "&format=" + res + + "&page=0&location=" + this.location + + "&depth=" + this.depth} ); + this.buildResourcePic( c, resources[i], a); + } author_row.id = "record_result_author_row_" + id; title_row.id = "record_result_title_row_" + id; @@ -641,18 +649,18 @@ AbstractRecordResultPage.prototype.buildNextLinks = function() { } -AbstractRecordResultPage.prototype.buildResourcePic = function(c, resource) { - return buildResourcePic(c, resource); +AbstractRecordResultPage.prototype.buildResourcePic = function(c, resource, parent) { + return buildResourcePic(c, resource, parent); } -function buildResourcePic(c, resource) { +function buildResourcePic(c, resource, parent) { var pic = createAppElement("img"); - if(resource.indexOf("sound recording") != -1) resource = "sound recording"; pic.setAttribute("src", "/images/" + resource + ".jpg"); + pic.setAttribute("border", "0"); pic.className = "record_resource_pic"; pic.setAttribute("width", "20"); pic.setAttribute("height", "20"); @@ -704,7 +712,13 @@ function buildResourcePic(c, resource) { } c.childNodes[index].innerHTML = ""; - c.childNodes[index].appendChild(pic); + + if(parent) { + parent.appendChild(pic); + c.childNodes[index].appendChild(parent); + } else { + c.childNodes[index].appendChild(pic); + } } AbstractRecordResultPage.prototype.buildRecordImage = function(pic_cell, record, page_id, title) { diff --git a/Open-ILS/src/javascript/opac/MRResultPage.js b/Open-ILS/src/javascript/opac/MRResultPage.js index 84d41379e2..e6260af95b 100644 --- a/Open-ILS/src/javascript/opac/MRResultPage.js +++ b/Open-ILS/src/javascript/opac/MRResultPage.js @@ -73,6 +73,7 @@ MRResultPage.prototype.next = function() { "mr_search_query", this.string, "mr_search_location", location, "mr_search_depth", this.searchDepth, + "format", this.format, "page", this.page + 1 ] ); } @@ -98,6 +99,7 @@ MRResultPage.prototype.prev = function() { "mr_search_query", this.string, "mr_search_location", location, "mr_search_depth", this.searchDepth, + "format", this.format, "page", this.page - 1 ] ); } @@ -118,6 +120,7 @@ MRResultPage.prototype.URLRefresh = function() { "mr_search_query", this.string, "mr_search_location", this.searchLocation, "mr_search_depth", this.searchDepth, + "format", this.format, "page", 0 ]; } @@ -141,6 +144,7 @@ MRResultPage.prototype.mkLink = function(id, type, value, title) { "&hits_per_page=" + this.hitsPerPage + "&location=" + this.searchLocation + "&depth=" + this.searchDepth ); + href.appendChild(createAppTextNode(value)); href.title = "View titles for " + t + ""; break; @@ -153,6 +157,7 @@ MRResultPage.prototype.mkLink = function(id, type, value, title) { "&hits_per_page=" + this.hitsPerPage + "&location=" + this.searchLocation + "&depth=" + this.searchDepth ); + href.title = "View titles for " + t + ""; break; @@ -187,6 +192,7 @@ MRResultPage.prototype.doSearch = function() { var location = paramObj.__mr_search_location; var depth = paramObj.__mr_search_depth; var hitsper = paramObj.__hits_per_page; + var format = paramObj.__format; lastSearchString = string; lastSearchType = stype; @@ -195,7 +201,7 @@ MRResultPage.prototype.doSearch = function() { this.hitsPerPage = parseInt(hitsper); debug("mr search params string " + string + " stype " + stype + - " location " + location + " depth " + depth ); + " location " + location + " depth " + depth + " format " + format); if(depth == null || depth == "undefined") depth = globalSearchDepth; @@ -220,6 +226,7 @@ MRResultPage.prototype.doSearch = function() { string != this.string || stype != this.stype || this.searchLocation != location || + this.format != format || this.searchDepth != depth ) { debug("Resetting MRSearch for search " + string); this.resetSearch(); @@ -233,6 +240,8 @@ MRResultPage.prototype.doSearch = function() { this.stype = stype; this.string = string; this.page = parseInt(paramObj.__page); + this.format = format; + if(this.page == null) this.page = 0; this.searchOffset = this.page * this.hitsPerPage; @@ -279,9 +288,11 @@ MRResultPage.prototype.doSearch = function() { if(isNaN(this.searchDepth)) this.searchDepth = 0; if(isNaN(this.searchLocation)) this.searchLocation = 1; + var form = this.format; + if(this.format == "all") form = null; var creq = new RemoteRequest( "open-ils.search", method, - this.stype, this.string, this.searchLocation, this.searchDepth ); + this.stype, this.string, this.searchLocation, this.searchDepth, form ); /* this request grabs the search count. When the counts come back the metarecord ids are collected */ @@ -398,11 +409,12 @@ MRResultPage.prototype.doMRSearch = function() { debug("Search method is " + method); + var form = this.format; + if(this.format == "all") form = null; + var request = new RemoteRequest( - "open-ils.search", method, - obj.stype, obj.string, - obj.searchLocation, - obj.searchDepth, "50", obj.searchOffset ); + "open-ils.search", method, obj.stype, obj.string, obj.searchLocation, + obj.searchDepth, "50", obj.searchOffset, form ); request.setCompleteCallback( function(req) { diff --git a/Open-ILS/src/javascript/opac/MyOPACSPage.js b/Open-ILS/src/javascript/opac/MyOPACSPage.js index 38b1a4f23c..9e2badda3e 100644 --- a/Open-ILS/src/javascript/opac/MyOPACSPage.js +++ b/Open-ILS/src/javascript/opac/MyOPACSPage.js @@ -177,7 +177,8 @@ function _drawCheckedOut(obj, data) { */ var title_href = createAppElement("a"); - title_href.setAttribute("href","?sub_frame=1&target=record_detail&record=" + record.doc_id() ); + var prefix = "http://" + globalRootURL + ":" + globalPort + globalRootPath; + title_href.setAttribute("href", prefix + "?sub_frame=1&target=record_detail&record=" + record.doc_id() ); title_href.setAttribute("target","_top"); /* escape to the outermost frame */ title_href.appendChild(mktext(record.title())); @@ -1284,7 +1285,8 @@ MyOPACSPage.prototype._addCircs = function(data) { due = due.replace(/[0-9][0-9]:[0-9][0-9]:[0-9][0-9]/,""); var title_href = createAppElement("a"); - title_href.setAttribute("href","?sub_frame=1&target=record_detail&record=" + record.doc_id() ); + var prefix = "http://" + globalRootURL + ":" + globalPort + globalRootPath; + title_href.setAttribute("href",prefix + "?sub_frame=1&target=record_detail&record=" + record.doc_id() ); title_href.setAttribute("target","_top"); /* escape to the outermost frame */ title_href.appendChild(mktext(record.title())); diff --git a/Open-ILS/src/javascript/opac/RecordResultPage.js b/Open-ILS/src/javascript/opac/RecordResultPage.js index b4dd96a95e..eccd0b569e 100644 --- a/Open-ILS/src/javascript/opac/RecordResultPage.js +++ b/Open-ILS/src/javascript/opac/RecordResultPage.js @@ -218,6 +218,7 @@ RecordResultPage.prototype.doSearch = function() { this.page = parseInt(paramObj.__page); var hitsper = paramObj.__hits_per_page; + this.format = paramObj.__format; if(hitsper) this.hitsPerPage = parseInt(hitsper); @@ -332,8 +333,11 @@ RecordResultPage.prototype.globalSearch = function(type, term) { RecordResultPage.prototype.mrSearch = function(mrid) { + var form = this.format; + if(form == "all") form = null; var request = new RemoteRequest("open-ils.search", - "open-ils.search.biblio.metarecord_to_records", mrid ); + "open-ils.search.biblio.metarecord_to_records", mrid, form ); + debug("Gathering doc ids for metarecord " + mrid ); var obj = this; diff --git a/Open-ILS/src/javascript/opac/SearchBarFormChunk.js b/Open-ILS/src/javascript/opac/SearchBarFormChunk.js index f625f28e4b..82f9b27d76 100644 --- a/Open-ILS/src/javascript/opac/SearchBarFormChunk.js +++ b/Open-ILS/src/javascript/opac/SearchBarFormChunk.js @@ -9,11 +9,27 @@ function SearchBarFormChunk() { SearchBarFormChunk.prototype.init = function() { + debug("Initing searchBarFormchunk"); this.search_query = getById("mr_search_query"); this.search_type = getById("mr_search_type"); this.search_button = getById("mr_search_button"); this.searchRange = getById("search_range_select"); + this.setFormat(); +} + + +SearchBarFormChunk.prototype.setFormat = function() { + var fsel = getById("mr_search_format"); + var format = paramObj.__format; + for( var idx = 0; idx != fsel.options.length; idx++ ) { + var obj = fsel.options[idx]; + if(obj && obj.value == format) { + fsel.selectedIndex = idx; + obj.selected = true; + } + } + } SearchBarFormChunk.prototype.resetPage = function() { @@ -21,10 +37,10 @@ SearchBarFormChunk.prototype.resetPage = function() { this.init(); this.search_button.onclick = mrSearchSubmitForm; + this.search_query.onkeydown = mrSearchSubmitOnEnter; this.search_type.onkeydown = mrSearchSubmitOnEnter; - var s = paramObj.__mr_search_query; if(!s) s = lastSearchString; var t = paramObj.__mr_search_type; @@ -41,8 +57,15 @@ SearchBarFormChunk.prototype.resetPage = function() { function mrSearchSubmitForm() { + var search_query = getById("mr_search_query").value; var search_type = getById("mr_search_type").value; + var form = getById("mr_search_format").value + + /* + var fsel = getById("mr_search_format"); + var form = fsel.options[fsel.selectedIndex].value + */ var depth = globalSearchDepth; @@ -58,6 +81,7 @@ function mrSearchSubmitForm() { "mr_search_query", search_query, "mr_search_location", location, "mr_search_depth", depth, + "format", form, "page", 0 ] ); } @@ -65,11 +89,13 @@ function mrSearchSubmitForm() { /* forces the submission of the search */ function mrSearchSubmitOnEnter(evt) { - evt = (evt) ? evt : ((window.event) ? event : null); /* for mozilla and IE */ + var win = getWindow(); + evt = (evt) ? evt : ((win.event) ? globalAppFrame.event : null); /* for mozilla and IE */ var obj = globalSearchBarFormChunk; var code = grabCharCode(evt); - if(code==13||code==3) { + if(code==13 || code==3) { mrSearchSubmitForm(); + return false; } } diff --git a/Open-ILS/src/javascript/util/ils_utils.js b/Open-ILS/src/javascript/util/ils_utils.js index ac7d045453..e26cf5d841 100644 --- a/Open-ILS/src/javascript/util/ils_utils.js +++ b/Open-ILS/src/javascript/util/ils_utils.js @@ -155,6 +155,10 @@ function modsFormatToMARC(format) { return "g"; case "sound recording": return "ij"; + case "sound recording-nonmusical": + return "ij"; + case "sound recording-musical": + return "ij"; case "software, multimedia": return "m"; case "still images": diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm index 3bae11d371..35eafd7297 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm @@ -527,75 +527,6 @@ sub cat_biblio_search_class { -=head comment -__PACKAGE__->register_method( - method => "cat_biblio_search_class_id", - api_name => "open-ils.search.cat.biblio.class.id", - argc => 3, - note => "Searches biblio information by search class and returns the IDs", -); - -sub cat_biblio_search_class_id { - - my( $self, $client, $org_id, $class, $string, $limit, $offset ) = @_; - - $offset ||= 0; - $limit ||= 100; - $limit -= 1; - - - my $bool = ($class eq "subject" || $class eq "keyword"); - $string = OpenILS::Application::Search->filter_search($string, $bool); - - if(!$string) { - return OpenILS::EX->new("SEARCH_TOO_LARGE")->ex(); - } - - warn "Searching cat.biblio.class.id string: $string offset: $offset limit: $limit\n"; - - throw OpenSRF::EX::InvalidArg - ("Not enough args to open-ils.search.cat.biblio.class") - unless( defined($org_id) and $class and $string ); - - - my $search_hash; - - my $cache_key = md5_hex( $org_id . $class . $string ); - my $id_array = OpenILS::Application::SearchCache->get_cache($cache_key); - - if(ref($id_array)) { - warn "Returning class search from cache\n"; - my $size = @$id_array; - my @ids = @$id_array[ $offset..($offset+$limit) ]; - return { count => $size, ids => \@ids }; - } - - my $method = $self->method_lookup("open-ils.search.biblio.marc"); - if(!$method) { - throw OpenSRF::EX::PANIC - ("Can't lookup method 'open-ils.search.biblio.marc'"); - } - - my ($records) = $method->run( $cat_search_hash->{$class}, $string ); - - my @cache_ids; - - for my $i (@$records) { - if(defined($i->[0])) { - push @cache_ids, $i->[0]; - } - } - - my @ids = @cache_ids[ $offset..($offset+$limit) ]; - my $size = @$records; - - OpenILS::Application::SearchCache->put_cache( - $cache_key, \@cache_ids, $size ); - - return { count =>$size, ids => \@ids }; - -} -=cut __PACKAGE__->register_method( method => "biblio_search_class_count", @@ -609,7 +540,7 @@ __PACKAGE__->register_method( sub biblio_search_class_count { - my( $self, $client, $class, $string, $org_id, $org_type ) = @_; + my( $self, $client, $class, $string, $org_id, $org_type, $format ) = @_; warn "org: $org_id : depth: $org_type\n"; @@ -619,7 +550,8 @@ sub biblio_search_class_count { warn "Searching biblio.class.id\n" . "string: $string " . "org_id: $org_id\n" . - "depth: $org_type\n" ; + "depth: $org_type\n" . + "format: $format\n"; # my $bool = ($class eq "subject" || $class eq "keyword"); # $string = OpenILS::Application::Search->filter_search($string, $bool); @@ -660,7 +592,8 @@ sub biblio_search_class_count { term => $string, org_unit => $org_id, cache_page_size => 1, - depth =>$org_type ); + depth =>$org_type, + format => $format ); my $count = $request->gather(1); warn "Received count $count\n"; @@ -692,7 +625,7 @@ __PACKAGE__->register_method( sub biblio_search_class { my( $self, $client, $class, $string, - $org_id, $org_type, $limit, $offset ) = @_; + $org_id, $org_type, $limit, $offset, $format ) = @_; warn "org: $org_id : depth: $org_type : limit: $limit : offset: $offset\n"; @@ -706,7 +639,8 @@ sub biblio_search_class { "\noffset: $offset\n" . "limit: $limit\n" . "org_id: $org_id\n" . - "depth: $org_type\n" ; + "depth: $org_type\n" . + "format: $format\n"; warn "Search filtering string " . time() . "\n"; $string = OpenILS::Application::Search->filter_search($string); @@ -753,6 +687,7 @@ sub biblio_search_class { depth => $org_type, limit => $limit, offset => $offset, + format => $format, cache_page_size => 200, ); @@ -914,7 +849,7 @@ __PACKAGE__->register_method( ); sub biblio_mrid_to_record_ids { - my( $self, $client, $mrid ) = @_; + my( $self, $client, $mrid, $format ) = @_; throw OpenSRF::EX::InvalidArg ("search.biblio.metarecord_to_record_ids requires mr id") @@ -926,7 +861,7 @@ sub biblio_mrid_to_record_ids { "open-ils.storage", #"open-ils.storage.direct.metabib.metarecord_source_map.search.metarecord", $mrid ); "open-ils.storage.ordered.metabib.metarecord.records.atomic", - $mrid ); + $mrid, $format ); #my @ids; diff --git a/Open-ILS/src/templates/opac/pages/chunks/search_bar_form.ttk b/Open-ILS/src/templates/opac/pages/chunks/search_bar_form.ttk index 2ae80ed951..a2683cd990 100644 --- a/Open-ILS/src/templates/opac/pages/chunks/search_bar_form.ttk +++ b/Open-ILS/src/templates/opac/pages/chunks/search_bar_form.ttk @@ -23,8 +23,12 @@ WRAPPER html/select name='format' id='mr_search_format'; option(value='all', selected='selected', content="All Formats"); - option(value='audiobooks', content="Audiobooks"); - option(value='', content="..."); + option(value='at', content="Books"); + option(value='at-d', content="Large Print Books"); + option(value='ij', content="Audiobooks"); + option(value='g', content="Video Recording"); + option(value='cd', content="Music"); + option(value='m', content="Electronic Resources"); END; diff --git a/Open-ILS/src/templates/opac/pages/opac_start.ttk b/Open-ILS/src/templates/opac/pages/opac_start.ttk index a9c7d5a482..1beeabc5e4 100644 --- a/Open-ILS/src/templates/opac/pages/opac_start.ttk +++ b/Open-ILS/src/templates/opac/pages/opac_start.ttk @@ -37,7 +37,8 @@ input( type='hidden', name='page', value='0'); input(id='mr_search_query', name='mr_search_query', - type='textarea', size='54'); + type='textarea', size='54' ); +#onkeydown='logicNode.mrSearchSubmitOnEnter(event); event.preventDefault = true; event.cancelBubble=true;'); # overwite this onkeydown if !IE XXX #space(1); lines(2); @@ -80,8 +81,12 @@ space(2); WRAPPER html/select name='format' id='mr_search_format'; option(value='all', selected='selected', content="All Formats"); - option(value='audiobooks', content="Audiobooks"); - option(value='', content="..."); + option(value='at', content="Books"); + option(value='at-d', content="Large Print Books"); + option(value='ij', content="Audiobooks"); + option(value='g', content="Video Recording"); + option(value='cd', content="Music"); + option(value='m', content="Electronic Resources"); END; END;