From: erickson Date: Sat, 3 Apr 2010 20:46:53 +0000 (+0000) Subject: Added a "View / Place Orders" option to the exta actions drop-down for a X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3cf6313fdc7dd17322583af3d29333a67d8a2538;p=evergreen%2Fmasslnc.git Added a "View / Place Orders" option to the exta actions drop-down for a bib record in the OPAC. Lineitem related LI's page can now take a bib ID as the param (instead of lineitem). For consistency, show title, author, etc. from the catalog record (via BibTemplate) instead of the selected lineitem. git-svn-id: svn://svn.open-ils.org/ILS/trunk@16117 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/js/ui/default/acq/lineitem/related.js b/Open-ILS/web/js/ui/default/acq/lineitem/related.js index c6538feeb4..428627d91e 100644 --- a/Open-ILS/web/js/ui/default/acq/lineitem/related.js +++ b/Open-ILS/web/js/ui/default/acq/lineitem/related.js @@ -1,72 +1,45 @@ dojo.require("openils.acq.Lineitem"); dojo.require("openils.Util"); dojo.require("openils.XUL"); +dojo.require("openils.CGI"); +dojo.require("openils.PermaCrud"); +dojo.require('openils.BibTemplate'); +dojo.require('fieldmapper.OrgUtils'); var liTable; - -function attrDefByName(attr) { - return openils.acq.Lineitem.attrDefs[ - attr.attr_type().replace(/lineitem_(.*)_attr_definition/, "$1") - ].filter( - function(o) { return (o.code() == attr.attr_name()); } - ).pop(); -} - -function drawLiInfo(li) { - var infoTbody = dojo.byId("acq-related-info-tbody"); - var infoRow = infoTbody.removeChild(dojo.byId("acq-related-info-row")); - - li.attributes().forEach( - function(attr) { - var row = dojo.clone(infoRow); - - nodeByName("label", row).innerHTML = - attrDefByName(attr).description(); - nodeByName("value", row).innerHTML = attr.attr_value(); - - infoTbody.appendChild(row); - - if (["title", "author"].indexOf(attr.attr_name()) != -1) { - nodeByName( - attr.attr_name(), dojo.byId("acq-related-mini-display") - ).innerHTML = attr.attr_value(); - } - } - ); -} +var identTarget; +var bibRecord; +var paramPL; +var paramPO; function fetchLi() { fieldmapper.standardRequest( ["open-ils.acq", "open-ils.acq.lineitem.retrieve"], { "async": true, - "params": [openils.User.authtoken, liId, { + "params": [openils.User.authtoken, targetId, { "flesh_attrs": true, "flesh_li_details": true, "flesh_fund_debit": true, "flesh_cancel_reason": true }], "oncomplete": function(r) { + fetchBib(); drawLiInfo(openils.Util.readResponse(r)); } } ); } -function hideDetails() { - openils.Util.show("acq-related-mini"); - openils.Util.hide("acq-related-info-div"); -} - -function showDetails() { - openils.Util.show("acq-related-info-div"); - openils.Util.hide("acq-related-mini"); -} function fetchRelated() { + var method = 'open-ils.acq.lineitems_for_bib.by_lineitem_id'; + if(identTarget == 'bib') + var method = 'open-ils.acq.lineitems_for_bib.by_bib_id'; + fieldmapper.standardRequest( - ["open-ils.acq", "open-ils.acq.lineitems_for_bib.by_lineitem_id"], { + ["open-ils.acq", method], { "async": true, - "params": [openils.User.authtoken, liId, { + "params": [openils.User.authtoken, targetId, { "flesh_attrs": true, "flesh_notes": true, "flesh_cancel_reason": true @@ -81,10 +54,98 @@ function fetchRelated() { } ); } + +function fetchBib() { + new openils.BibTemplate({ + record : targetId, + org_unit : fieldmapper.aou.findOrgUnit(openils.User.user.ws_ou()).shortname() + }).render(); + + new openils.PermaCrud().retrieve('bre', targetId, { + oncomplete : function(r) { + bibRecord = openils.Util.readResponse(r); + // render bib details + // perhaps we just pull these from the beating heart of bibtemplate + } + }) +} + +function addLi(fields) { + + var li = new fieldmapper.jub(); + li.marc(bibRecord.marc()); + li.eg_bib_id(bibRecord.id()); + if(fields.picklist) li.picklist(fields.picklist); + if(fields.po) li.po(fields.po); + li.selector(openils.User.user.id()); + li.creator(openils.User.user.id()); + li.editor(openils.User.user.id()); + + fieldmapper.standardRequest( + ['open-ils.acq', 'open-ils.acq.lineitem.create'], + { async : true, + params : [openils.User.authtoken, li], + oncomplete : function(r) { + var id = openils.Util.readResponse(r); + if(!id) return; + if(fields.picklist) + location.href = oilsBasePath + '/acq/picklist/view/' + fields.picklist; + else + location.href = oilsBasePath + '/acq/po/view/' + fields.po; + } + } + ); +} + +function loadPl() { + + if(paramPL) { + + fieldmapper.standardRequest( + ['open-ils.acq', 'open-ils.acq.picklist.retrieve'], + { async: true, + params: [openils.User.authtoken, paramPL], + oncomplete : function(r) { + var pl = openils.Util.readResponse(r); + plSelector.store = + new dojo.data.ItemFileReadStore({data:fieldmapper.acqpl.toStoreData([pl])}); + plSelector.attr('value', pl.name()); + plSelector.attr('disabled', true); + } + } + ); + + } else { + + fieldmapper.standardRequest( + ['open-ils.acq', 'open-ils.acq.picklist.user.retrieve.atomic'], + { async: true, + params: [openils.User.authtoken], + oncomplete : function(r) { + var list = openils.Util.readResponse(r); + plSelector.store = + new dojo.data.ItemFileReadStore({data:fieldmapper.acqpl.toStoreData(list)}); + } + } + ); + } +} + + function load() { - openils.acq.Lineitem.fetchAttrDefs(fetchLi); - dojo.byId("acq-related-info-back-button").onclick = hideDetails; - dojo.byId("acq-related-info-show-button").onclick = showDetails; + var cgi = new openils.CGI(); + + identTarget = cgi.param('target'); + paramPL = cgi.param('pl'); + paramPO = cgi.param('po'); + + loadPl(); + + if(identTarget == 'bib') { + fetchBib(); + } else { + fetchLi(); + } liTable = new AcqLiTable(); liTable.reset(); diff --git a/Open-ILS/web/opac/common/js/config.js b/Open-ILS/web/opac/common/js/config.js index 1e79f9d23a..50aee75128 100644 --- a/Open-ILS/web/opac/common/js/config.js +++ b/Open-ILS/web/opac/common/js/config.js @@ -5,6 +5,8 @@ var SHOW_MR_DEFAULT = false; /* true if we show metarecords by default */ //var DO_AUTHORITY_LOOKUPS = false; var DO_AUTHORITY_LOOKUPS = true; +var STAFF_WEB_BASE_PATH = '/eg'; // root of the web-based staff interfaces + /* URL param names */ var PARAM_TERM = "t"; /* search term */ var PARAM_STYPE = "tp"; /* search type */ diff --git a/Open-ILS/web/opac/locale/en-US/opac.dtd b/Open-ILS/web/opac/locale/en-US/opac.dtd index 52d2aa352b..a1a0d46475 100644 --- a/Open-ILS/web/opac/locale/en-US/opac.dtd +++ b/Open-ILS/web/opac/locale/en-US/opac.dtd @@ -483,6 +483,7 @@ Please see a librarian to renew your account."> + diff --git a/Open-ILS/web/opac/skin/default/js/rdetail.js b/Open-ILS/web/opac/skin/default/js/rdetail.js index 1bfd241236..d9d05b8821 100644 --- a/Open-ILS/web/opac/skin/default/js/rdetail.js +++ b/Open-ILS/web/opac/skin/default/js/rdetail.js @@ -149,6 +149,9 @@ function rdetailDraw() { G.evt.result.recordReceived = []; G.evt.result.copyCountsReceived = []; G.evt.result.allRecordsReceived = []; + + if(isXUL()) + unHideMe($('rdetail_show_orders')); } function rdetailGetPageIds() { @@ -1058,3 +1061,8 @@ function rdetailGBPViewerLoadCallback() { GBPViewer.load('ISBN:' + cleanISBN(record.isbn()) ); } + +function rdetailViewOrders() { + location.href = STAFF_WEB_BASE_PATH + '/acq/lineitem/related/' + record.doc_id() + '?target=bib'; +} + diff --git a/Open-ILS/web/opac/skin/default/js/rresult.js b/Open-ILS/web/opac/skin/default/js/rresult.js index 985088fdba..145f06bc5d 100644 --- a/Open-ILS/web/opac/skin/default/js/rresult.js +++ b/Open-ILS/web/opac/skin/default/js/rresult.js @@ -32,7 +32,7 @@ function rresultCollectIds() { var ids; var rtype = getRtype(); - if (rtype.indexOf('|') > -1) + if (rtype && rtype.indexOf('|') > -1) rtype = rtype.substring(0,rtype.indexOf('|')); switch(rtype) { diff --git a/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml b/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml index 321cb8aa12..dfd1561f48 100644 --- a/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml +++ b/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml @@ -63,6 +63,9 @@ + + + diff --git a/Open-ILS/web/templates/default/acq/lineitem/related.tt2 b/Open-ILS/web/templates/default/acq/lineitem/related.tt2 index 8f589a7ae4..9a8f18ac8b 100644 --- a/Open-ILS/web/templates/default/acq/lineitem/related.tt2 +++ b/Open-ILS/web/templates/default/acq/lineitem/related.tt2 @@ -1,16 +1,62 @@ [% WRAPPER "default/base.tt2" %] [% ctx.page_title = "Related Lineitems" %] - +

Related Lineitems