From: erickson Date: Thu, 22 Jul 2010 21:39:33 +0000 (+0000) Subject: Added option to link a (freerange) lineitem to a catalog X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6148e76e9f84a9be4ca7fdc659b74c7af07b1bf6;p=evergreen%2Ftadl.git Added option to link a (freerange) lineitem to a catalog record via simple pop-up search page. git-svn-id: svn://svn.open-ils.org/ILS/trunk@17016 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/js/ui/default/acq/common/li_table.js b/Open-ILS/web/js/ui/default/acq/common/li_table.js index fe276c804b..43b06f6698 100644 --- a/Open-ILS/web/js/ui/default/acq/common/li_table.js +++ b/Open-ILS/web/js/ui/default/acq/common/li_table.js @@ -269,7 +269,7 @@ function AcqLiTable() { // XXX media prefix for added content if (identifier) { - nodeByName("jacket").setAttribute( + nodeByName("jacket", row).setAttribute( "src", "/opac/extras/ac/jacket/small/" + identifier ); } @@ -280,6 +280,7 @@ function AcqLiTable() { } else { // TODO: Add discovery mechanism for bib linking openils.Util.show(nodeByName('link_to_catalog', row), 'inline'); + nodeByName("link_to_catalog_link", row).onclick = function() { self.drawBibFinder(li) }; } nodeByName("worksheet_link", row).href = @@ -2471,5 +2472,51 @@ function AcqLiTable() { ); } ); + }, + + this.drawBibFinder = function(li) { + + var query = ''; + var liWrapper = new openils.acq.Lineitem({lineitem:li}); + + dojo.forEach( + ['isbn', 'upc', 'issn', 'title', 'author'], + function(field) { + var val = liWrapper.findAttr(field, 'lineitem_marc_attr_definition'); + if(val) { + if(field == 'title' || field == 'author') { + query += field +':' + val + ' '; + } else { + query += 'identifier|' + field + ':' + val + ' '; + } + } + } + ); + + win = window.open( + oilsBasePath + '/acq/lineitem/findbib?query=' + escape(query), + '', 'resizable,scrollbars=1'); + + win.window.recordFound = function(bibId) { + win.close(); + + var attrs = li.attributes(); + li.attributes(null); + li.eg_bib_id(bibId); + + fieldmapper.standardRequest( + ["open-ils.acq", "open-ils.acq.lineitem.update"], + { + "params": [openils.User.authtoken, li], + "async": true, + "oncomplete": function(r) { + if(openils.Util.readResponse(r)) { + location.href = location.href; + } + } + } + ); + } } } + diff --git a/Open-ILS/web/js/ui/default/acq/lineitem/findbib.js b/Open-ILS/web/js/ui/default/acq/lineitem/findbib.js new file mode 100644 index 0000000000..7fb39eae4d --- /dev/null +++ b/Open-ILS/web/js/ui/default/acq/lineitem/findbib.js @@ -0,0 +1,82 @@ +dojo.require('openils.Util'); +dojo.require('openils.BibTemplate'); +dojo.require('fieldmapper.OrgUtils'); +dojo.require('openils.CGI'); +dojo.require('openils.widget.ProgressDialog'); + +var limit = 15; +var offset = 0; +var template; +var container; + +function drawSearch() { + container = dojo.byId('acq-findbib-container'); + template = container.removeChild(dojo.byId('acq-findbib-template')); + var cgi = new openils.CGI(); + searchQuery.attr('value', cgi.param('query') || ''); + searchQuery.domNode.select(); + openils.Util.registerEnterHandler(searchQuery.domNode, doSearch); +} + +function doSearch() { + while(container.childNodes[0]) + container.removeChild(container.childNodes[0]) + progressDialog.show(true); + var query = searchQuery.attr('value'); + fieldmapper.standardRequest( + ['open-ils.search', 'open-ils.search.biblio.multiclass.query'], + { + async : true, + params : [{limit : limit}, query, 1], + oncomplete : drawResult + } + ); +} + +function drawResult(r) { + progressDialog.hide(); + var result = openils.Util.readResponse(r); + dojo.forEach( + result.ids, + function(id) { + id = id[0]; + var div = template.cloneNode(true); + container.appendChild(div); + + var viewMarc = dojo.query('[name=view-marc]', div)[0]; + viewMarc.onclick = function() { showMARC(id); }; + var selectRec = dojo.query('[name=select-rec]', div)[0]; + selectRec.onclick = function() { selectRecord(id); }; + + new openils.BibTemplate({ + record : id, + org_unit : fieldmapper.aou.findOrgUnit(openils.User.user.ws_ou()).shortname(), + root : div + }).render(); + } + ); +} + +function showMARC(bibId) { + openils.Util.show(dojo.byId('marc-div')); + fieldmapper.standardRequest( + ['open-ils.search', 'open-ils.search.biblio.record.html'], + { + async: true, + params: [bibId, true], + oncomplete: function(r) { + dojo.byId('marc-html-div').innerHTML = openils.Util.readResponse(r); + } + } + ); +} + +function selectRecord(bibId) { + if(window.recordFound) { + window.recordFound(bibId); + } +} + + +openils.Util.addOnLoad(drawSearch); + diff --git a/Open-ILS/web/templates/default/acq/lineitem/findbib.tt2 b/Open-ILS/web/templates/default/acq/lineitem/findbib.tt2 new file mode 100644 index 0000000000..3429ee535c --- /dev/null +++ b/Open-ILS/web/templates/default/acq/lineitem/findbib.tt2 @@ -0,0 +1,73 @@ +[% WRAPPER "default/base.tt2" %] +[% ctx.page_title = "Locate Bib Record" %] + + + + + +
+
+
+
+ +
+
+
+
+
+ +
+
+
+ View MARC + Select + + + + + + + + + + +
+
+
+
+ + + +