[open-ils-commits] r16117 - in trunk/Open-ILS/web: js/ui/default/acq/lineitem opac/common/js opac/locale/en-US opac/skin/default/js opac/skin/default/xml templates/default/acq/lineitem (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Sat Apr 3 16:46:58 EDT 2010


Author: erickson
Date: 2010-04-03 16:46:53 -0400 (Sat, 03 Apr 2010)
New Revision: 16117

Modified:
   trunk/Open-ILS/web/js/ui/default/acq/lineitem/related.js
   trunk/Open-ILS/web/opac/common/js/config.js
   trunk/Open-ILS/web/opac/locale/en-US/opac.dtd
   trunk/Open-ILS/web/opac/skin/default/js/rdetail.js
   trunk/Open-ILS/web/opac/skin/default/js/rresult.js
   trunk/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml
   trunk/Open-ILS/web/templates/default/acq/lineitem/related.tt2
Log:
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.

Modified: trunk/Open-ILS/web/js/ui/default/acq/lineitem/related.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/lineitem/related.js	2010-04-03 14:13:51 UTC (rev 16116)
+++ trunk/Open-ILS/web/js/ui/default/acq/lineitem/related.js	2010-04-03 20:46:53 UTC (rev 16117)
@@ -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;
+var identTarget;
+var bibRecord;
+var paramPL;
+var paramPO;
 
-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();
-            }
-        }
-    );
-}
-
 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';
 
-function fetchRelated() {
     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,11 +54,99 @@
         }
     );
 }
+
+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();
     liTable._isRelatedViewer = true;

Modified: trunk/Open-ILS/web/opac/common/js/config.js
===================================================================
--- trunk/Open-ILS/web/opac/common/js/config.js	2010-04-03 14:13:51 UTC (rev 16116)
+++ trunk/Open-ILS/web/opac/common/js/config.js	2010-04-03 20:46:53 UTC (rev 16117)
@@ -5,6 +5,8 @@
 //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 */

Modified: trunk/Open-ILS/web/opac/locale/en-US/opac.dtd
===================================================================
--- trunk/Open-ILS/web/opac/locale/en-US/opac.dtd	2010-04-03 14:13:51 UTC (rev 16116)
+++ trunk/Open-ILS/web/opac/locale/en-US/opac.dtd	2010-04-03 20:46:53 UTC (rev 16117)
@@ -483,6 +483,7 @@
 <!--	================================================================= 
 	Rdetail
 	================================================================= -->
+<!ENTITY rdetail.actions.orders "Show / Create Orders">
 <!ENTITY rdetail.print "print these details">
 <!ENTITY rdetail.cn.barcode "Barcode">
 <!ENTITY rdetail.cn.location "Location">

Modified: trunk/Open-ILS/web/opac/skin/default/js/rdetail.js
===================================================================
--- trunk/Open-ILS/web/opac/skin/default/js/rdetail.js	2010-04-03 14:13:51 UTC (rev 16116)
+++ trunk/Open-ILS/web/opac/skin/default/js/rdetail.js	2010-04-03 20:46:53 UTC (rev 16117)
@@ -149,6 +149,9 @@
 	G.evt.result.recordReceived = [];
 	G.evt.result.copyCountsReceived = [];
 	G.evt.result.allRecordsReceived = [];
+
+    if(isXUL()) 
+        unHideMe($('rdetail_show_orders'));
 }
 
 function rdetailGetPageIds() {
@@ -1058,3 +1061,8 @@
 	GBPViewer.load('ISBN:' + cleanISBN(record.isbn()) );
 
 }
+
+function rdetailViewOrders() {
+    location.href = STAFF_WEB_BASE_PATH + '/acq/lineitem/related/' + record.doc_id() + '?target=bib';
+}
+

Modified: trunk/Open-ILS/web/opac/skin/default/js/rresult.js
===================================================================
--- trunk/Open-ILS/web/opac/skin/default/js/rresult.js	2010-04-03 14:13:51 UTC (rev 16116)
+++ trunk/Open-ILS/web/opac/skin/default/js/rresult.js	2010-04-03 20:46:53 UTC (rev 16117)
@@ -32,7 +32,7 @@
 	var ids;
 
     var rtype = getRtype();
-    if (rtype.indexOf('|') > -1)
+    if (rtype && rtype.indexOf('|') > -1)
         rtype = rtype.substring(0,rtype.indexOf('|'));
 
 	switch(rtype) {

Modified: trunk/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml
===================================================================
--- trunk/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml	2010-04-03 14:13:51 UTC (rev 16116)
+++ trunk/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml	2010-04-03 20:46:53 UTC (rev 16117)
@@ -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>
 

Modified: trunk/Open-ILS/web/templates/default/acq/lineitem/related.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/lineitem/related.tt2	2010-04-03 14:13:51 UTC (rev 16116)
+++ trunk/Open-ILS/web/templates/default/acq/lineitem/related.tt2	2010-04-03 20:46:53 UTC (rev 16117)
@@ -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" %]



More information about the open-ils-commits mailing list