// XXX media prefix for added content
if (identifier) {
- nodeByName("jacket").setAttribute(
+ nodeByName("jacket", row).setAttribute(
"src", "/opac/extras/ac/jacket/small/" + identifier
);
}
} 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 =
);
}
);
+ },
+
+ 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;
+ }
+ }
+ }
+ );
+ }
}
}
+
--- /dev/null
+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);
+
--- /dev/null
+[% WRAPPER "default/base.tt2" %]
+[% ctx.page_title = "Locate Bib Record" %]
+<script src="[% ctx.media_prefix %]/js/ui/default/acq/lineitem/findbib.js"></script>
+<script type="text/javascript">
+ function iterateSubfields(item) {
+ var out = '';
+ dojo.query('subfield', item).forEach(
+ function(item) { out += item.textContent + ' '; } );
+ return out;
+ }
+</script>
+
+<div id='acq-findbib-search' style='margin:30px; border:1px solid #333; text-align:center;'>
+ <input dojoType='dijit.form.TextBox' jsId='searchQuery' style='width:500px;'></input>
+ <button dojoType='dijit.form.Button' onclick='doSearch'>Search</button>
+</div>
+
+<div style='width:100%; ' id='acq-findbib-container'>
+ <div id='acq-findbib-template' style='border-bottom:1px solid #333; padding:10px;'>
+ <div style='font-weight:bold;'>
+ <div type='opac/slot-data' query='datafield[tag=245]'>
+ <script type='opac/slot-format'>return iterateSubfields(item)</script>
+ </div>
+ </div>
+ <div style='margin-left:20px;'>
+ <div>
+ <div type='opac/slot-data' query='datafield[tag=100]'>
+ <script type='opac/slot-format'>return iterateSubfields(item)</script>
+ </div>
+ </div>
+ <div>
+ <span><a name='view-marc' href='javascript:void(0);'>View MARC</a></span>
+ <span><a name='select-rec' href='javascript:void(0);'>Select</a></span>
+ <span type='opac/slot-data' query='datafield[tag=020]'>
+ <script type='opac/slot-format'>return iterateSubfields(item)</script>
+ </span>
+ <span type='opac/slot-data' query='datafield[tag=024]'>
+ <script type='opac/slot-format'>return iterateSubfields(item)</script>
+ </span>
+ <span type='opac/slot-data' query='datafield[tag=022]'>
+ <script type='opac/slot-format'>return iterateSubfields(item)</script>
+ </span>
+ <span type='opac/slot-data' query='datafield[tag=260] subfield[code=c]'></span>
+ </div>
+ </div>
+ </div>
+</div>
+
+<style>
+ #marc-div {
+ position: fixed;
+ top:100px;
+ right:10px;
+ left:200px;
+ bottom:100px;
+ border: 3px solid #333;
+ -moz-border-radius: 5px;
+ padding: 30px;
+ text-align:center;
+ background: #FFF;
+ overflow: auto;
+ }
+</style>
+
+<div id='marc-div' class='hidden'>
+ <button dojoType='dijit.form.Button' onclick='openils.Util.hide("marc-div");'>Hide</button>
+ <div style='text-align:left;'>
+ <div id='marc-html-div'/>
+ </div>
+</div>
+<div jsId='progressDialog' dojoType='openils.widget.ProgressDialog' message='Searching....'/>
+
+[% END %]