ACQ return-to-[search/invoice] buttons repair
[transitory.git] / Open-ILS / web / js / dojo / openils / acq / Lineitem.js
index 877ba54..ee69ef7 100644 (file)
@@ -119,10 +119,10 @@ openils.acq.Lineitem.fetchAndRender = function(liId, args, callback) {
     });
 
     fieldmapper.standardRequest(
-        ['open-ils.acq', 'open-ils.acq.lineitem.retrieve'],
+        ['open-ils.acq', 'open-ils.acq.lineitem.retrieve.authoritative'],
         {
             params : [ openils.User.authtoken, liId, args ],
-
+            async : true,
             oncomplete : function(r) {
                 var lineitem = openils.Util.readResponse(r);
                 if(!lineitem) return;
@@ -144,11 +144,16 @@ openils.acq.Lineitem.fetchAndRender = function(liId, args, callback) {
                 var orderDate = '';
                 var liLink = '';
 
+                if(pl && pl.name() == '') // special pl
+                    pl = null;
+
                 if(po) {
                     liLink = oilsBasePath + '/acq/po/view/' + po.id() + '/' + lineitem.id();
-                    var date = dojo.date.stamp.fromISOString(po.order_date());
-                    if(date) {
-                        orderDate = dojo.date.locale.format(date, {selector:'date'});
+                    if(po.order_date()) {
+                        var date = dojo.date.stamp.fromISOString(po.order_date());
+                        if(date) {
+                            orderDate = dojo.date.locale.format(date, {selector:'date'});
+                        }
                     }
                 }
 
@@ -173,8 +178,18 @@ openils.acq.Lineitem.fetchAndRender = function(liId, args, callback) {
                         lineitem.order_summary().encumbrance_amount() || '0.00',
                         lineitem.order_summary().paid_amount() || '0.00',
                         orderDate,
-                        liLink
-                    ]
+                        liLink,
+                        (po) ? 'foo' : '', // forces class='hiddenfoo' i.e. not hidden
+                        (pl) ? 'foo' : '', // ditto
+                        encodeURIComponent(location.pathname + location.search)
+                    ],
+                    function(str) {
+                        // prevent long titles from filling up the page
+                        var truncSize = 100;
+                        if(str.length > truncSize)
+                            str = str.substring(0, truncSize) + '...';
+                        return str;
+                    }
                 );
 
                 callback(lineitem, displayString);