Added a "View / Place Orders" option to the exta actions drop-down for a
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 3 Apr 2010 20:46:53 +0000 (20:46 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 3 Apr 2010 20:46:53 +0000 (20:46 +0000)
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

Open-ILS/web/js/ui/default/acq/lineitem/related.js
Open-ILS/web/opac/common/js/config.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/js/rresult.js
Open-ILS/web/opac/skin/default/xml/page_rdetail.xml
Open-ILS/web/templates/default/acq/lineitem/related.tt2

index c6538fe..428627d 100644 (file)
@@ -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();
index 1e79f9d..50aee75 100644 (file)
@@ -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 */
index 52d2aa3..a1a0d46 100644 (file)
@@ -483,6 +483,7 @@ Please see a librarian to renew your account.">
 <!--   ================================================================= 
        Rdetail
        ================================================================= -->
+<!ENTITY rdetail.actions.orders "Show / Create Orders">
 <!ENTITY rdetail.print "print these details">
 <!ENTITY rdetail.cn.barcode "Barcode">
 <!ENTITY rdetail.cn.location "Location">
index 1bfd241..d9d05b8 100644 (file)
@@ -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';
+}
+
index 985088f..145f06b 100644 (file)
@@ -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) {
index 321cb8a..dfd1561 100644 (file)
@@ -63,6 +63,9 @@
                                                        <option disabled='disabled'>&rdetail.bookbag.add;</option>
                                                        <option disabled='disabled'>--------------</option>
                                                        <option value='new_bookbag' onclick='rdetailNewBookbag();'>&rdetail.bookbag.create;</option>
+                                                       <option disabled='disabled'>--------------</option>
+                            <!-- TODO: i18n, hide when non-xul -->
+                                                       <option id='rdetail_show_orders' class='hide_me' value='view_orders' onclick='rdetailViewOrders();'>&rdetail.actions.orders;</option>
                                                </select>
                                        </span>
 
index 8f589a7..9a8f18a 100644 (file)
@@ -1,16 +1,62 @@
 [% WRAPPER "default/base.tt2" %]
 [% ctx.page_title = "Related Lineitems" %]
 <script src="[% ctx.media_prefix %]/js/ui/default/acq/lineitem/related.js"></script>
-<script type="text/javascript">var liId = "[% ctx.page_args.0 %]";</script>
+<script type="text/javascript">var targetId = "[% ctx.page_args.0 %]";</script>
 <h1>Related Lineitems</h1>
 <div id="acq-related-mini">
+    <script>
+        function iterateSubfields(item) {
+            var out = '';
+            var list = dojo.query('subfield', item);
+            for (var i = 0; i < list.length; i++) {
+                out += dojox.data.dom.textContent(list[i]) + ' ';
+            }
+            return out;
+        }
+    </script>
     <ul id="acq-related-mini-display">
-        <li name="title"></li>
-        <li name="author"></li>
+        <li>
+            <div type='opac/slot-data' query='datafield[tag=245]'>
+                <script type='opac/slot-format'>return iterateSubfields(item)</script>
+            </div>
+        </li>
+        <li>
+            <div type='opac/slot-data' query='datafield[tag=100] subfield[code=a]'/>
+        </li>
+        <li>
+            <div type='opac/slot-data' query='datafield[tag=020]'>
+                <script type='opac/slot-format'>return iterateSubfields(item)</script>
+            </div> 
+            <div type='opac/slot-data' query='datafield[tag=024]'>
+                <script type='opac/slot-format'>return iterateSubfields(item)</script>
+            </div> 
+            <div type='opac/slot-data' query='datafield[tag=022]'>
+                <script type='opac/slot-format'>return iterateSubfields(item)</script>
+            </div>
+        </li>
+        <li>
+            <div type='opac/slot-data' query='datafield[tag=260] subfield[code=c]'/>
+        </li>
     </ul>
-    <div dojoType="dijit.form.Button" id="acq-related-info-show-button">
-        Show details
+    <div dojoType="dijit.form.DropDownButton">
+        <span>Create New Lineitem For This Record</span>
+        <div dojoType="dijit.TooltipDialog"  execute="addLi(arguments[0]);">
+            <table>
+                <tbody>
+                    <tr>
+                        <td>Add To Selection List</td>
+                        <td style='padding-left:10px;'><div name='picklist' jsId='plSelector' dojoType='dijit.form.FilteringSelect'/></td>
+                    </tr>
+                    <tr>
+                        <td colspan='2' style='align:center'>
+                            <button dojoType="dijit.form.Button" type="submit">Create</button>
+                        </td>
+                    </tr>
+                </tbody>
+            </table>
+        </div>
     </div>
+
 </div>
 [% INCLUDE "default/acq/common/info.tt2" which = "Related" %]
 [% INCLUDE "default/acq/common/li_table.tt2" %]