[open-ils-commits] r514 - conifer/trunk/web/opac/skin/default/js (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Jun 4 16:31:43 EDT 2009
Author: dbs
Date: 2009-06-04 16:31:39 -0400 (Thu, 04 Jun 2009)
New Revision: 514
Modified:
conifer/trunk/web/opac/skin/default/js/rdetail.js
Log:
Get our default, MFHD-friendly rdetail.js into Subversion
Modified: conifer/trunk/web/opac/skin/default/js/rdetail.js
===================================================================
--- conifer/trunk/web/opac/skin/default/js/rdetail.js 2009-06-03 13:51:54 UTC (rev 513)
+++ conifer/trunk/web/opac/skin/default/js/rdetail.js 2009-06-04 20:31:39 UTC (rev 514)
@@ -27,7 +27,14 @@
var rdetailShowCopyLocation = true;
var googleBookPreview = true;
var enableHoldsOnAvailable = false;
+var displaySerialHoldings = true;
+var opac_strings;
+/* serials are currently the only use of Dojo strings in the OPAC */
+if (displaySerialHoldings) {
+ dojo.requireLocalization("openils.opac", "opac");
+ opac_strings = dojo.i18n.getLocalization("openils.opac", "opac");
+}
var nextContainerIndex;
@@ -118,6 +125,12 @@
req.callback(_rdetailDraw);
req.send();
+ if (displaySerialHoldings) {
+ var req = new Request(FETCH_MFHD_SUMMARY, getRid());
+ req.callback(_holdingsDraw);
+ req.send();
+ }
+
detachAllEvt("result", "idsReceived");
G.evt.result.hitCountReceived = [];
G.evt.result.recordReceived = [];
@@ -174,7 +187,103 @@
hideMe(G.ui.rdetail.cp_info_none);
}
+function OpenMarcEditWindow(pcrud, rec) {
+ /*
+ To run in Firefox directly, must set signed.applets.codebase_principal_support
+ to true in about:config
+ */
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ win = window.open('/xul/server/cat/marcedit.xul'); // XXX version?
+ dojo.require('openils.PermaCrud');
+ win.xulG = {
+ "record" : {"marc" : rec.marc()},
+ "save" : {
+ "label": opac_strings.SAVE_MFHD_LABEL,
+ "func": function(xmlString) {
+ rec.marc(xmlString);
+ rec.ischanged(true);
+ pcrud.update(rec);
+ }
+ }
+ };
+}
+
+function loadMarcEditor(recId) {
+ var pcrud = new openils.PermaCrud({"authtoken": G.user.session});
+ var rec = pcrud.retrieve("sre", recId);
+ if (rec) {
+ OpenMarcEditWindow(pcrud, rec);
+ }
+}
+
+/*
+ * This function could be written much more intelligently
+ * Limited brain power means that I'm brute-forcing it for now
+ */
+function _holdingsDraw(h) {
+ holdings = h.getResultObject();
+ if (!holdings) { return null; }
+
+ dojo.forEach(holdings, _holdingsDrawMFHD);
+}
+
+function _holdingsDrawMFHD(holdings, entryNum) {
+ var here = findOrgUnit(getLocation());
+ if (getDepth() > 0 || getDepth === 0 ) {
+ while (getDepth() < findOrgDepth(here))
+ here = findOrgUnit( here.parent_ou() );
+ if (!orgIsMine(findOrgUnit(here), findOrgUnit(holdings.owning_lib()))) {
+ return null;
+ }
+ }
+ var hh = holdings.holdings();
+ var hch = holdings.current_holdings();
+ var hs = holdings.supplements();
+ var hcs = holdings.current_supplements();
+ var hi = holdings.indexes();
+ var hci = holdings.current_indexes();
+ var ho = holdings.online();
+ var hm = holdings.missing();
+ var hinc = holdings.incomplete();
+
+ if ( hh.length == 0 && hch.length == 0 && hs.length == 0 &&
+ hcs.length == 0 && hi.length == 0 && hci.length == 0 &&
+ ho.length == 0 && hm.length == 0 && hinc.length == 0
+ ) {
+ return null;
+ }
+
+ dojo.place("<table style='width: 100%;'><caption id='mfhdHoldingsCaption' class='rdetail_header color_1'>" +
+ dojo.string.substitute(opac_strings.HOLDINGS_TABLE_CAPTION, [holdings.location()]) +
+ "</caption><tbody id='rdetail_holdings_tbody_" + entryNum +
+ "'></tbody></table>", "rdetail_details_table", "after"
+ );
+ if (hh.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.HOLDINGS, hh); }
+ if (hch.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.CURRENT_HOLDINGS, hch); }
+ if (hs.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.SUPPLEMENTS, hs); }
+ if (hcs.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.CURRENT_SUPPLEMENTS, hcs); }
+ if (hi.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.INDEXES, hi); }
+ if (hci.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.CURRENT_INDEXES, hci); }
+ if (ho.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.ONLINE_VOLUMES, ho); }
+ if (hm.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.MISSING_VOLUMES, hm); }
+ if (hinc.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.INCOMPLETE_VOLUMES, hinc); }
+
+ if (isXUL()) {
+ dojo.require('openils.Event');
+ dojo.require('openils.PermaCrud');
+ dojo.place("<span> - </span><a class='classic_link' href='javascript:loadMarcEditor(" +
+ holdings.id() + ")'>" + opac_strings.EDIT_LABEL + "</a>",
+ "mfhdHoldingsCaption", "last"
+ );
+ }
+}
+
+function _holdingsDrawMFHDEntry(entryNum, entryName, entry) {
+ var flatEntry = entry.toString().replace(/,/g, ', ');
+ dojo.place("<tr><td> </td><td nowrap='nowrap' class='rdetail_desc'>" + entryName + "</td><td class='rdetail_item'>" + flatEntry + "</td></tr>", "rdetail_holdings_tbody_" + entryNum, "last");
+}
+
function _rdetailDraw(r) {
record = r.getResultObject();
@@ -244,7 +353,7 @@
}
}
$('rdetail_online').appendChild(elem('a', {href:href,'class':'classic_link'}, displayLabel));
- if (!note && note != displayLabel) {
+ if (note && note != displayLabel) {
$('rdetail_online').appendChild(elem('span', {'class':'url_note'}, ' - ' + note));
}
$('rdetail_online').appendChild(elem('br'));
More information about the open-ils-commits
mailing list