Refresh PO activatable state after all prices entered
authorBill Erickson <berick@esilibrary.com>
Tue, 14 Feb 2012 18:14:40 +0000 (13:14 -0500)
committerMike Rylander <mrylander@gmail.com>
Wed, 7 Mar 2012 16:59:05 +0000 (11:59 -0500)
After all lineitems within a PO have a price, re-test whether the PO can
be activated.  This allows the activation of PO's without having to
refresh the page after the last price is entered.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/web/js/ui/default/acq/common/li_table.js

index eb0b620..6ee88d2 100644 (file)
@@ -831,7 +831,7 @@ function AcqLiTable() {
     }
 
     this.updateLiPrice = function(input, li) {
-
+        var self = this;
         var price = input.value;
         if(Number(price) == Number(li.estimated_unit_price())) return;
 
@@ -843,6 +843,20 @@ function AcqLiTable() {
                 oncomplete : function(r) {
                     openils.Util.readResponse(r);
                     li.estimated_unit_price(price); // update local copy
+
+                    /*
+                     * If this is a PO and every visible lineitem has a price,
+                     * check again to see if this PO can be activated.  Note that 
+                     * every visible lineitem having a price does not guarantee it can
+                     * be activated, which is why we still make the call.  Having a price
+                     * set for every visiable lineitem is just the lowest barrier to entry.
+                     */
+                    if (self.isPO) {
+                        var priceNodes = dojo.query('[name=price]', dojo.byId('acq-lit-tbody'));
+                        var allSet = true;
+                        dojo.forEach(priceNodes, function(node) { if (node.value == '') allSet = false});
+                        if (allSet) checkCouldActivatePo();
+                    }
                 }
             }
         );