LP#1440114 invoice item type prorate/blanket warning
authorBill Erickson <berickxx@gmail.com>
Tue, 18 Aug 2015 16:42:14 +0000 (12:42 -0400)
committerBill Erickson <berickxx@gmail.com>
Wed, 19 Aug 2015 16:33:28 +0000 (12:33 -0400)
Warn the user that only one of 'prorate' or 'blanket' may be selected
when creating/editing an invoice item type.  When this happens, the save
operation is aborted and the user is returned to the edit dialog.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/templates/conify/global/acq/invoice_item_type.tt2

index 58fd203..91aba6e 100644 (file)
 <script type="text/javascript">
     dojo.require("openils.widget.AutoGrid");
     dojo.require("dijit.form.FilteringSelect");
+    dojo.require('openils.PermaCrud');
     openils.Util.addOnLoad(
-        function() { aiitGrid.loadAll({"order_by": {"aiit": "name"}}); }
+        function() { 
+          aiitGrid.loadAll({"order_by": {"aiit": "name"}}); 
+
+          // If either "prorate" or "blanket" are selected, 
+          // the other must be deselected.  
+          // "For neither can live while the other survives...."
+          aiitGrid.onEditPane = function(pane) {
+
+            pane.onSubmit = function(inv_type, ops) {
+
+              if (inv_type.blanket() == 't') {
+                if (inv_type.prorate() == 't') {
+                  alert('[% l('Only one of "prorate" and "blanket" may be selected') %]');
+                  return;
+                }
+              }
+
+              (new openils.PermaCrud())[pane.mode](inv_type, ops);
+            }
+          }
+        }
     );
 </script>
 [% END %]