Make ACQ Lineitem actions more readily accessible
authorBill Erickson <berick@esilibrary.com>
Thu, 25 Aug 2011 20:03:12 +0000 (16:03 -0400)
committerMike Rylander <mrylander@gmail.com>
Sun, 1 Apr 2012 02:42:38 +0000 (22:42 -0400)
No longer limit PO-related lineitem actions to the PO view UI.  Instead,
limit lineitem actions on the state of the lineitem.  This allows staff
to perform PO-related (e.g. create invoice) directly from the LI search
interface.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/templates/acq/common/li_table.tt2
Open-ILS/web/js/ui/default/acq/common/li_table.js

index 3628b88..1ec4d17 100644 (file)
                             <option name='action_none'>-- Actions --</option>
                             <option name='action_mark_recv' disabled='disabled'>Mark Received</option>
                             <option name='action_mark_unrecv' disabled='disabled'>Un-Receive</option>
-                            <option name='action_update_barcodes' disabled='disabled'>Update Barcodes</option>
-                            <option name='action_holdings_maint' disabled='disabled'>Holdings Maint.</option>
+                            <option name='action_update_barcodes'>Update Barcodes</option>
+                            <option name='action_holdings_maint'>Holdings Maint.</option>
                             <option name='action_new_invoice' disabled='disabled'>New Invoice</option>
                             <option name='action_link_invoice' disabled='disabled'>Link to Invoice</option>
                             <option name='action_view_invoice' disabled='disabled'>View Invoice(s)</option>
                             <option name='action_view_claim_policy'>Apply Claim Policy</option>
-                            <option name='action_manage_claims' disabled='disabled'>Claims</option>
+                            <option name='action_manage_claims'>Claims</option>
                             <option name='action_view_history'>View History</option>
                         </select>
                     </td>
index 860f82a..b44a53f 100644 (file)
@@ -578,51 +578,30 @@ function AcqLiTable() {
         var actUnRecv = nodeByName("action_mark_unrecv", row);
         var actUpdateBarcodes = nodeByName("action_update_barcodes", row);
         var actHoldingsMaint = nodeByName("action_holdings_maint", row);
-
         var actNewInvoice = nodeByName('action_new_invoice', row);
         var actLinkInvoice = nodeByName('action_link_invoice', row);
         var actViewInvoice = nodeByName('action_view_invoice', row);
 
+        // always allow access to LI history
         nodeByName('action_view_history', row).onclick = 
             function() { location.href = oilsBasePath + '/acq/lineitem/history/' + li.id(); };
 
-        var state_cell = nodeByName("li_state", row);
-
-        if (li.state() == "cancelled") {
-            if (typeof li.cancel_reason() == "object") {
-                var holds_state = dojo.create(
-                    "span", {
-                        "style": "border-bottom: 1px dashed #000;",
-                        "innerHTML": li.state()
-                    }, state_cell, "only"
-                );
-                new dijit.Tooltip(
-                    {
-                        "label": "<em>" + li.cancel_reason().label() +
-                            "</em><br />" + li.cancel_reason().description(),
-                        "connectId": [holds_state]
-                    }, dojo.create("span", null, state_cell, "last")
-                );
-            } else {
-                state_cell.innerHTML = li.state(); // TODO i18n state labels
-            }
-        } else {
-            state_cell.innerHTML = li.state(); // TODO i18n state labels
-        }
-
-
         /* handle row coloring for based on LI state */
         openils.Util.removeCSSClass(row, /^oils-acq-li-state-/);
         openils.Util.addCSSClass(row, "oils-acq-li-state-" + li.state());
 
-        /* handle links that appear/disappear based on whether LI is received */
-        if (this.isPO) {
-            var self = this;
+        // Expose invoice actions for any lineitem that is linked to a PO 
+        if( li.purchase_order() ) {
+
+            actNewInvoice.disabled = false;
+            actLinkInvoice.disabled = false;
+            actViewInvoice.disabled = false;
 
             actNewInvoice.onclick = function() {
                 location.href = oilsBasePath + '/acq/invoice/view?create=1&attach_li=' + li.id();
                 nodeByName("action_none", row).selected = true;
             };
+
             actLinkInvoice.onclick = function() {
                 if (!self.invoiceLinkDialogManager) {
                     self.invoiceLinkDialogManager =
@@ -632,6 +611,7 @@ function AcqLiTable() {
                 acqLitLinkInvoiceDialog.show();
                 nodeByName("action_none", row).selected = true;
             };
+
             actViewInvoice.onclick = function() {
                 location.href = oilsBasePath +
                     "/acq/search/unified?so=" +
@@ -639,41 +619,70 @@ function AcqLiTable() {
                     "&rt=invoice";
                 nodeByName("action_none", row).selected = true;
             };
+        }
+                
 
-            actNewInvoice.disabled = false;
-            actLinkInvoice.disabled = false;
-            actViewInvoice.disabled = false;
+        /*
+         * If we haven't fleshed the lineitem_details, default to allowing access to the 
+         * holdings maintenence actions.  The alternative is to flesh LIDs on every lineitem, 
+         * but that will add to page render time.  Let's see if this will suffice...
+         */
+        var lids = li.lineitem_details();
+        if( !lids || 
+                (lids && !lids.filter(function(lid) { return lid.eg_copy_id() })[0] )) {
 
-            switch(li.state()) {
-                case "on-order":
-                    actReceive.disabled = false;
-                    actReceive.onclick = function() {
-                        if (self.checkLiAlerts(li.id()))
-                            self.issueReceive(li);
-                        nodeByName("action_none", row).selected = true;
-                    };
-                    return;
+            actUpdateBarcodes.disabled = false;
+            actUpdateBarcodes.onclick = function() {
+                self.showRealCopyEditUI(li);
+                nodeByName("action_none", row).selected = true;
+            }
+            actHoldingsMaint.disabled = false;
+            actHoldingsMaint.onclick = 
+                self.generateMakeRecTab( li.eg_bib_id(), 'copy_browser', row );
+        }
 
-                case "received":
-                    actUnRecv.disabled = false;
-                    actUnRecv.onclick = function() {
-                        if (confirm(localeStrings.UNRECEIVE_LI))
-                            self.issueReceive(li, /* rollback */ true);
-                        nodeByName("action_none", row).selected = true;
-                    };
-                    // TODO we should allow editing before receipt, in which case the
-                    // test should be "if 1 or more real (acp) copies exist
-                    actUpdateBarcodes.disabled = false;
-                    actUpdateBarcodes.onclick = function() {
-                        self.showRealCopyEditUI(li);
-                        nodeByName("action_none", row).selected = true;
-                    }
-                    actHoldingsMaint.disabled = false;
-                    actHoldingsMaint.onclick = self.generateMakeRecTab( li.eg_bib_id(), 'copy_browser', row );
+        var state_cell = nodeByName("li_state", row);
 
-                    return;
-            }
+        switch(li.state()) {
+
+            case 'cancelled':
+                if(typeof li.cancel_reason() == "object") {
+                    var holds_state = dojo.create(
+                        "span", {
+                            "style": "border-bottom: 1px dashed #000;",
+                            "innerHTML": li.state()
+                        }, state_cell, "only"
+                    );
+                    new dijit.Tooltip(
+                        {
+                            "label": "<em>" + li.cancel_reason().label() +
+                                "</em><br />" + li.cancel_reason().description(),
+                            "connectId": [holds_state]
+                        }, dojo.create("span", null, state_cell, "last")
+                    );
+                }
+                return; // all done
+
+            case "on-order":
+                actReceive.disabled = false;
+                actReceive.onclick = function() {
+                    if (self.checkLiAlerts(li.id()))
+                        self.issueReceive(li);
+                    nodeByName("action_none", row).selected = true;
+                };
+                break;
+
+            case "received":
+                actUnRecv.disabled = false;
+                actUnRecv.onclick = function() {
+                    if (confirm(localeStrings.UNRECEIVE_LI))
+                        self.issueReceive(li, /* rollback */ true);
+                    nodeByName("action_none", row).selected = true;
+                };
+                break;
         }
+
+        state_cell.innerHTML = li.state(); // TODO i18n state labels
     };