Serials: When the fully compressed serial holdings are active in the OPAC,
authorsenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 7 Dec 2010 22:42:03 +0000 (22:42 +0000)
committersenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 7 Dec 2010 22:42:03 +0000 (22:42 +0000)
you get this "issues held" display with an expand/compress toggle that will
either show you individual holdings (and allow you to place holds on them)
or compressed holdings statements.

The functionality existed in trunk before this commit, but this cleans it up
and makes it better. It's more consistent with the the result detail table,
it doesn't offer you the change to place holds on issues that don't have
units (copy-equivalent objects), etc etc.

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

Open-ILS/src/perlmods/OpenILS/Application/Serial.pm
Open-ILS/web/js/dojo/openils/opac/nls/opac.js
Open-ILS/web/opac/locale/en-US/opac.dtd
Open-ILS/web/opac/skin/default/js/rdetail.js
Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_summary.xml

index c76004c..9505fea 100644 (file)
@@ -367,7 +367,16 @@ sub received_siss_by_bib {
                 $global ? { transform => "min", column => "id", aggregate => 1 } : "id",
                 "label",
                 "date_published"
-        ]},
+            ],
+            "sitem" => [
+                # We're not really interested in the minimum here.  This is
+                # just a way to distinguish issuances whose items have units
+                # from issuances whose items have no units, without altogether
+                # excluding the latter type of issuances.
+                {"transform" => "min", "alias" => "has_units",
+                    "column" => "unit", "aggregate" => 1}
+            ]
+        },
         from => {
             ssub => {
                 siss => {
@@ -414,7 +423,11 @@ sub received_siss_by_bib {
         distinct => 1
     });
 
-    $client->respond($e->retrieve_serial_issuance($_->{id})) for @$issuances;
+    $client->respond({
+        "issuance" => $e->retrieve_serial_issuance($_->{"id"}),
+        "has_units" => $_->{"has_units"} ? 1 : 0
+    }) for @$issuances;
+
     return undef;
 }
 __PACKAGE__->register_method(
@@ -460,7 +473,8 @@ sub scoped_bib_holdings_summary {
 
     # split into issuance type sets
     my %type_blob = (basic => [], supplement => [], index => []);
-    push @{ $type_blob{ $_->holding_type } }, $_ for (@$issuances);
+    push @{ $type_blob{ $_->{"issuance"}->holding_type } }, $_->{"issuance"}
+        for (@$issuances);
 
     # generate a statement list for each type
     my %statement_blob;
index 8478498..7b9a353 100644 (file)
@@ -32,5 +32,7 @@
        "ONLINE_VOLUMES": "Online volumes",
        "SAVE_MFHD_LABEL": "Save MFHD",
        "SUPPLEMENT_HOLDINGS": "Supplements",
-       "SUPPLEMENT_HOLDINGS_ADD": "Additional Supplement Information"
+       "SUPPLEMENT_HOLDINGS_ADD": "Additional Supplement Information",
+    "PLACE_HOLD": "Place hold",
+    "MORE": "More"
 }
index b215f73..aef4bbb 100644 (file)
@@ -557,6 +557,7 @@ We recommend that you remove this title from any bookbags it may have been added
 <!ENTITY rdetail.noneAvailable " * There are no copies in this location">
 <!ENTITY rdetail.summary.online "Online Resources">
 <!ENTITY rdetail.summary.subjects "Subjects">
+<!ENTITY rdetail.summary.issues_held "Issues Held">
 
 <!ENTITY result.sort_by "Sort Results by Relevance">
 <!ENTITY result.sort_by.title "Sort Results by Title">
index 4369b53..f5c4935 100644 (file)
@@ -1206,18 +1206,24 @@ 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];
+    var target_id = "holding_type_" + type;
+    var target = dojo.byId(target_id);
+
+    anchor.innerHTML = "[-]";
+    anchor.oldonclick = anchor.onclick;
+    anchor.onclick = function() {
+        anchor.onclick = anchor.oldonclick;
+        anchor.innerHTML = "[+]";
+        dojo.empty(target);
+    };
 
     function _load() {
         dojo.empty(target);
         fieldmapper.standardRequest(
-            ["open-ils.serial", "open-ils.serial.received_siss.retrieve.by_bib.atomic"], {
+            ["open-ils.serial",
+                "open-ils.serial.received_siss.retrieve.by_bib.atomic"], {
                 "params": [bibid, {"offset": offsets[type], "limit": limit}],
                 "async": true,
                 "oncomplete": function(r) {
@@ -1225,28 +1231,43 @@ function rdetailDrawExpandedHoldings(anchor, bibid, type) {
                         if (msg = r.recv().content()) { /* sic, assignment */
                             offsets[type] += msg.length;
                             dojo.forEach(
-                                msg, function(iss) {
+                                msg, function(o) {
+                                    dojo.create("br", null, target);
                                     dojo.create(
                                         "span", {
-                                            "innerHTML": iss.label(),
-                                            "style": "padding-right: 1em;"
+                                            "innerHTML": o.issuance.label(),
+                                            "style": {"padding": "0 2em"}
                                         }, target
                                     );
+
+                                    if (!o.has_units) return;
+                                    /* can't place holds if no units */
                                     dojo.create(
                                         "a", {
-                                            "href":"#","onclick":function() {
+                                            "href":"javascript:void(0);",
+                                            "onclick": function() {
                                                 holdsDrawEditor({
-                                                    "type":"I","issuance":iss.id()
+                                                    "type": "I",
+                                                    "issuance": o.issuance.id()
                                                 });
-                                            }, "innerHTML":"Place hold"/*XXX i18n*/
+                                            },
+                                            "innerHTML": "[" +
+                                                opac_strings.PLACE_HOLD + "]"
                                         }, target
                                     );
-                                    dojo.create("br", null, target);
                                 }
                             );
-                            /* XXX i18n */
-                            if (r.length == limit)
-                                dojo.create("a", {"style": "margin-top: 6px;", "innerHTML": "[More]", "onclick": _load}, target);
+                            if (msg.length == limit) {
+                                dojo.create("br", null, target);
+                                dojo.create(
+                                    "a", {
+                                        "href": "javascript:void(0);",
+                                        "innerHTML":
+                                            "[" + opac_strings.MORE + "]",
+                                        "onclick": _load
+                                    }, target
+                                );
+                            }
                         }
                     } catch (E) {
                         void(0);
index ba243cf..bd5f8c6 100644 (file)
                                        ]]></script>
                                </td>
                        </tr>
-                       <tr templated="true"
-                               name="serial_holdings_label"
-                               class="result_table_title_cell hide_me"
-                               type="opac/slot-data"
-                               query="datafield[tag='901'] subfield[code='c']">
-                               <td colspan="2">Issues Held: ${holdingsStatement}
+                       <tr name="serial_holdings_label"
+                               class="result_table_title_cell hide_me">
+                <td class="rdetail_desc">&rdetail.summary.issues_held;</td>
+                <td templated="true" type="opac/slot-data"
+                    query="datafield[tag='901'] subfield[code='c']"
+                    class="rdetail_item">
+                    ${holdingsStatement}
                                        <span class="hide_me" name="holdingsStatement" type="opac/template-value"><![CDATA[
-                                               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'],
-                                                               [bibid, { orgid : getLocation(), depth : getDepth() }]
-                                                       );
-
-                                                       var ret = dojo.create("div");
-                                                       var innerret = dojo.create(
-                                                               "div", {"style":"clear;both;"}, ret
-                                                       );
-
-                                                       var something = false;
-                                                       for (var i in blob) {
-                                                               if (!blob[i].length) continue;
-                                                               something = true;
-                                                               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);
-                                                       }
-
-                                                       if (something) dojo.removeClass(slot,'hide_me');
-                                                       return ret.innerHTML;
-                                               } else {
-                                                       return "";
-                                               }
+                        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"],
+                                [bibid, {
+                                    "orgid": getLocation(), "depth": getDepth()
+                                }]
+                            );
+
+                            var fake = dojo.create("td");
+                            var something = false;
+
+                            for (var i in blob) {
+                                if (!blob[i].length) continue;
+                                if (something) dojo.create("br", null, fake);
+                                something = true;
+
+                                var a = dojo.create(
+                                    "a", {
+                                        "innerHTML": "[+]",
+                                        "href": "javascript:void(0);",
+                                        "onclick":
+                                            "rdetailDrawExpandedHoldings(this,"+
+                                            bibid + ",'" + i + "');",
+                                        "style": {"marginRight": "1.5em"}
+                                    }, fake
+                                );
+                                dojo.create(
+                                    "span", {
+                                        "innerHTML": blob[i].join(", ")
+                                    }, fake
+                                );
+                                dojo.create(
+                                    "span", {"id": "holding_type_" + i}, fake
+                                );
+                            }
+
+                            if (something)
+                                unHideMe(slot.parentNode);
+
+                            return fake.innerHTML;
+                        } else {
+                            return "";
+                        }
                                        ]]></span>
                                </td>
                        </tr>