ACQ : lineitem recovers focus from various interfaces
authorBill Erickson <berick@esilibrary.com>
Fri, 13 Jul 2012 16:07:56 +0000 (12:07 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Tue, 24 Jul 2012 16:46:01 +0000 (12:46 -0400)
1. When viewing an invoice then clicking on the title link for a lineitem,
the user is taken away to the copy grid within the PO page for the
lineitem.This adds a "Return to Invoice" button in the copy grid which
takes the user back to the invoice, focused on the lineitem in question.

2. Adds a "Return to Search" button for PL/PO pages to return to the
lineitem in question when the PL or PO links are selected for a lineitem
in a set of search results.

3. Adds a "Return to Invoice" button to PO/Picklist pages with lineitem
focus when the page was accessed from the invoice UI.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/templates/acq/common/li_table.tt2
Open-ILS/src/templates/acq/picklist/view.tt2
Open-ILS/src/templates/acq/po/view.tt2
Open-ILS/web/js/dojo/openils/acq/nls/acq.js
Open-ILS/web/js/ui/default/acq/common/li_table.js
Open-ILS/web/js/ui/default/acq/picklist/view.js
Open-ILS/web/js/ui/default/acq/po/view_po.js

index 8c6b065..9eb8d35 100644 (file)
             <table style='width:100%'>
                 <tr>
                     <td class="acq-lit-li-menu-left">
+                        <span class='hidden' id='acq-lit-copies-back-to-invoice-button-wrapper'>
+                            <button dojoType='dijit.form.Button' id='acq-lit-copies-back-to-invoice-button' 
+                                scrollOnFocus='false'>[% l('&#x2196; Return To Invoice') %]</button>
+                        </span>
                         <div dojoType='dijit.form.Button' id='acq-lit-copies-back-button' scrollOnFocus='false'>&#x2196; Return</div>
                         <span style='margin-left:10px;padding-left:10px;border-left:2px solid #aaa;'>
                             Item Count: 
index a209c3e..65af63b 100644 (file)
             </div>
         </div>
     </div>
+    <div class='hidden' id='acq-pl-return-to-search'>
+        <button dojoType='dijit.form.Button' id='acq-pl-return-to-search-button'>[% l('&#x2196; Return to Search') %]</button>
+    </div>
+    <div class='hidden' id='acq-pl-return-to-invoice'>
+        <button dojoType='dijit.form.Button' id='acq-pl-return-to-invoice-button'>[% l('&#x2196; Return to Invoice') %]</button>
+    </div>
+
     <script type="text/javascript">var plId = '[% ctx.page_args.0 %]';</script>
     [% INCLUDE 'acq/common/li_table.tt2' %]
 </div>
index 605ad7a..2084e10 100644 (file)
                     <td></td>
                     <th>[% l('Allow activation with <br/> zero-copy lineitems') %]</th>
                     <td><input type='checkbox' id='acq-po-activate-zero-copies' onclick='checkCouldActivatePo()'/></td>
+                    <td>
+                        <div class='hidden' id='acq-po-return-to-search'>
+                            <button dojoType='dijit.form.Button' id='acq-po-return-to-search-button'>[% l('&#x2196; Return to Search') %]</button>
+                        </div>
+                        <div class='hidden' id='acq-po-return-to-invoice'>
+                            <button dojoType='dijit.form.Button' id='acq-po-return-to-invoice-button'>[% l('&#x2196; Return to Invoice') %]</button>
+                        </div>
+                    </td>
+                    <td/>
+                </tr>
                 <tr>
                     <td colspan='3'>
                         <a class="hidden" id="acq-po-split" href="javascript:void(0);"
index 7d4ce58..26a0452 100644 (file)
@@ -62,7 +62,7 @@
     "INVOICE_ITEM_DETAILS" : "${0} <br/> ${1} <br/> ${2}. <br/> Estimated Price: $${3}. <br/> Lineitem ID: ${4} <br/> PO: ${5} <br/> Order Date: ${6}",
     "INVOICE_CONFIRM_ITEM_DELETE" : "Remove this $${0} '${1}' charge from the invoice?",
     "INVOICE_CONFIRM_ENTRY_DETACH" : "Remove $${0} charge for item '${1}, ${2} [${3}] from the invoice?",
-    "LINEITEM_SUMMARY" : "<div class='acq-lineitem-summary'><a href='${19}'>${0}</a>, by ${1} (${2})</div>\n<div class='acq-lineitem-summary-extra'>\n${3} Ordered, ${4} Received, ${7} Invoiced, ${8} Claimed, ${9} Cancelled</div>\n<div class='acq-lineitem-summary-extra'>Estimated $${6}, Encumbered $${16}, Paid $${17}</div>\n<div class='acq-lineitem-summary-extra'>\n# ${10} <a style='padding-right: 10px;' class='hidden${20}'  href='${11}/acq/po/view/${12}'>&#x2318; ${13} ${18}</a>\n<a style='padding-right: 10px;' class='hidden${21}' href='${11}/acq/picklist/view/${14}'>&#x2756; ${15}</a></div>",
+    "LINEITEM_SUMMARY" : "<div class='acq-lineitem-summary'><a href='${19}?focus_li=${10}'>${0}</a>, by ${1} (${2})</div>\n<div class='acq-lineitem-summary-extra'>\n${3} Ordered, ${4} Received, ${7} Invoiced, ${8} Claimed, ${9} Cancelled</div>\n<div class='acq-lineitem-summary-extra'>Estimated $${6}, Encumbered $${16}, Paid $${17}</div>\n<div class='acq-lineitem-summary-extra'>\n# ${10} <a style='padding-right: 10px;' class='hidden${20}'  href='${11}/acq/po/view/${12}?focus_li=${10}'>&#x2318; ${13} ${18}</a>\n<a style='padding-right: 10px;' class='hidden${21}' href='${11}/acq/picklist/view/${14}?focus_li=${10}'>&#x2756; ${15}</a></div>",
     "INVOICE_CONFIRM_PRORATE" : "Prorate charges?\n\nAny subsequent changes to the invoice that would affect prorated amounts should be resolved manually.",
     "INVOICE_EXTRA_COPIES" : "You are attempting to invoice <b>${0}</b> more copies than originally ordered.  <br/><br/>To add these items to the original order, select a fund and choose 'Add New Items' below.  <br/>After saving the invoice, you may finish editing and importing the new copies from the lineitem details page.",
     "INVOICE_ITEM_PO_DETAILS" : "<b>${0}</b><br/><a href='${1}/acq/po/view/${2}'>PO #${3} ${4}</a><br/>Total Estimated Cost: $${5}",
index 54ce6cc..d0a9d84 100644 (file)
@@ -459,7 +459,7 @@ function AcqLiTable() {
             if(po && !this.isMeta) {
                 openils.Util.show(nodeByName('po', row), 'inline');
                 var link = nodeByName('po_link', row);
-                link.setAttribute('href', oilsBasePath + '/acq/po/view/' + li.purchase_order());
+                link.setAttribute('href', oilsBasePath + '/acq/po/view/' + li.purchase_order() + '?focus_li=' + li.id());
                 link.innerHTML += po.name();
 
                 openils.Util.show(nodeByName('pro', row), 'inline');
@@ -485,7 +485,7 @@ function AcqLiTable() {
 
                     openils.Util.show(nodeByName('pl', row), 'inline');
                     var link = nodeByName('pl_link', row);
-                    link.setAttribute('href', oilsBasePath + '/acq/picklist/view/' + li.picklist());
+                    link.setAttribute('href', oilsBasePath + '/acq/picklist/view/' + li.picklist() + '?focus_li=' + li.id());
                     link.innerHTML += pl.name();
                 }
             }
@@ -1121,6 +1121,15 @@ function AcqLiTable() {
         if (typeof force_fetch == "undefined")
             force_fetch = false;
 
+        if (document.referrer.match(/invoice/)) {
+            // got here from the invoice page, show the 'return-to-invoice' button
+            var cgi = new openils.CGI({url : document.referrer});
+            cgi.param('focus_li', liId);
+            openils.Util.show(dojo.byId('acq-lit-copies-back-to-invoice-button-wrapper'), 'inline');
+            var button = dojo.byId('acq-lit-copies-back-to-invoice-button');
+            button.onclick = function() { location.href = cgi.url() };
+        }
+
         openils.acq.Lineitem.fetchAndRender(liId, {}, 
             function(li, html) {
                 dojo.byId('acq-lit-copies-li-summary').innerHTML = html;
index 7cbc0c5..c125daf 100644 (file)
@@ -2,6 +2,7 @@ dojo.require('dojo.date.stamp');
 dojo.require('dojo.date.locale');
 dojo.require('openils.User');
 dojo.require('openils.Util');
+dojo.require('openils.CGI');
 dojo.require('dijit.layout.ContentPane');
 
 var plist;
@@ -25,6 +26,24 @@ function load() {
         }
     );
 
+    /* if we got here from the search/invoice page with a focused LI,
+     * return to the previous page with the same LI focused */
+    var cgi = new openils.CGI();
+    if (cgi.param('focus_li')) {
+        dojo.forEach(
+            ['search', 'invoice'], // perhaps a wee bit too loose
+            function(source) {
+                if (document.referrer.match(new RegExp(source))) {
+                    openils.Util.show('acq-pl-return-to-' + source);
+                    var newCgi = new openils.CGI({url : document.referrer});
+                    newCgi.param('focus_li', cgi.param('focus_li'));
+                    dojo.byId('acq-pl-return-to-' + source + '-button').onclick = function() {
+                        location.href = newCgi.url();
+                    }
+                }
+            }
+        );
+    }
 }
 
 function drawPl() {
index 53acfa4..19b7527 100644 (file)
@@ -353,6 +353,26 @@ function renderPo() {
     );
     openils.Util.show("acq-po-view-history", "inline");
 
+    
+    /* if we got here from the search/invoice page with a focused LI,
+     * return to the previous page with the same LI focused */
+    var cgi = new openils.CGI();
+    if (cgi.param('focus_li')) {
+        dojo.forEach(
+            ['search', 'invoice'], // perhaps a wee bit too loose
+            function(source) {
+                if (document.referrer.match(new RegExp(source))) {
+                    openils.Util.show('acq-po-return-to-' + source);
+                    var newCgi = new openils.CGI({url : document.referrer});
+                    newCgi.param('focus_li', cgi.param('focus_li'));
+                    dojo.byId('acq-po-return-to-' + source + '-button').onclick = function() {
+                        location.href = newCgi.url();
+                    }
+                }
+            }
+        );
+    }
+
     prepareInvoiceFeatures();
 }