Crude OPAC support for expanding serial issuances when showing fully compressed
authorsenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 16 Sep 2010 15:38:48 +0000 (15:38 +0000)
committersenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 16 Sep 2010 15:38:48 +0000 (15:38 +0000)
holdings

git-svn-id: svn://svn.open-ils.org/ILS/trunk@17735 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/skin/default/js/rdetail.js
Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_summary.xml

index fe18c0d..34981fc 100644 (file)
@@ -1168,3 +1168,37 @@ function rdetailGBPViewerLoadCallback() {
 
 }
 
+function rdetailDrawExpandedHoldings(anchor, bibid, type) {
+    anchor.innerHTML = "Hide holdings"; /* XXX i18n */
+    anchor.oldonclick = anchor.onclick;
+    anchor.onclick = function() { anchor.onclick = anchor.oldonclick; anchor.innerHTML = "Show holdings"; dojo.empty(target); };
+
+    var offsets = {"basic": 0, "index": 0, "supplement": 0};
+    var limit = 10; /* XXX give user control over this? */
+    var target = dojo.query("[expanded_holdings='" + type + "']")[0];
+
+    function _load() {
+        dojo.empty(target);
+        fieldmapper.standardRequest(
+            ["open-ils.serial", "open-ils.serial.received_siss.retrieve.by_bib.atomic"], {
+                "params": [bibid, {"offset": offsets[type], "limit": limit}],
+                "async": true,
+                "oncomplete": function(r) {
+                    if (r = openils.Util.readResponse(r)) {
+                        offsets[type] += r.length;
+                        dojo.forEach(
+                            r, function(sum) {
+                                dojo.create("span", {"innerHTML": sum.label()}, target);
+                                dojo.create("br", null, target);
+                            }
+                        );
+                        /* XXX i18n */
+                        if (r.length == limit)
+                            dojo.create("a", {"style": "margin-top: 6px;", "innerHTML": "[More]", "onclick": _load}, target);
+                    }
+                }
+            }
+        );
+    }
+    _load();
+}
index 69a876c..42377f7 100644 (file)
                                                if (fetchOrgSettingDefault(
                                                        getLocation(), "opac.fully_compressed_serial_holdings"
                                                )) {
+                                                       var bibid = BT.textContent(item_list[0]);
                                                        var blob = fieldmapper.standardRequest(
                                                                ['open-ils.serial','open-ils.serial.bib.summary_statements'],
-                                                               [BT.textContent(item_list[0]), { orgid : getLocation(), depth : getDepth() }]
+                                                               [bibid, { orgid : getLocation(), depth : getDepth() }]
                                                        );
 
-                                                       var ret = dojo.create('div');
+                                                       var ret = dojo.create("div");
+                                                       var innerret = dojo.create(
+                                                               "div", {"style":"clear;both;"}, ret
+                                                       );
                                                        for (var i in blob) {
-                                                               var br = dojo.create('br', null, ret);
-                                                               var span = dojo.create('span',{class : 'holding_type_'+ i, innerHTML :  blob[i].join(', ') }, ret);
+                                                               if (!blob[i].length) continue;
+                                                               dojo.create(
+                                                                       "div", {
+                                                                               "innerHTML": blob[i].join(", "),
+                                                                               "className": "holding_type_" + i,
+                                                                               "style": "float:left;width:33%;"
+                                                                       }, innerret
+                                                               );
+                                                               var div = dojo.create("div", {
+                                                                       "style": "float:left;width:33%;"
+                                                               });
+                                                               var a = dojo.create(
+                                                                       "a", {
+                                                                               "innerHTML": "Show holdings",
+                                                                               "href": "#",
+                                                                               "onclick": "rdetailDrawExpandedHoldings(this,"+bibid+",'"+i+"');return false"
+                                                                       }, div
+                                                               );
+                                                               dojo.place(div, innerret);
+                                                               dojo.create("div", {"style":"float:right;width:33%;", "expanded_holdings": i}, innerret);
                                                        }
 
                                                        dojo.removeClass(slot,'hide_me');