[open-ils-commits] [GIT] Evergreen ILS branch master updated. 2fa555d30fac179f8ac1255b6021652b6902ca97

Evergreen Git git at git.evergreen-ils.org
Tue Oct 16 21:47:56 EDT 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  2fa555d30fac179f8ac1255b6021652b6902ca97 (commit)
      from  cfe2507fa9a5e67608b189a7b37aa9435550ad8c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 2fa555d30fac179f8ac1255b6021652b6902ca97
Author: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
Date:   Mon Oct 1 13:53:27 2012 -0400

    Acq: When creating invoices, let the user know if they're repeating an ID
    
    Invoices have a field for Vendor Invoice ID, which is required to be
    unique for invoices associated with a given provider (vendor).  In
    practice users may mistakenly try to create an invoice more than once, so
    this gives them an indication that a given Vnedor Invoice ID has already
    been used before they fill out the whole invoice.
    
    Users do have to have the fields labeled "Vendor Invoice ID",
    "Provider", and "Receiver" filled out before validation can occur (the
    last field is needed because of how permissions are checked when
    searching for invoices).
    
    It is still possible to see a database error at save time if another
    invoice is created between the time you started yours and the time
    somebody else saved theirs.
    
    Also, while we're at it, this commit gets rid of acq/invoice/common.js
    and moves its last function into acq/invoice/view.js, since both are
    actually used only by the one interface.
    
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/templates/acq/invoice/view.tt2 b/Open-ILS/src/templates/acq/invoice/view.tt2
index a4a60fb..a54621a 100644
--- a/Open-ILS/src/templates/acq/invoice/view.tt2
+++ b/Open-ILS/src/templates/acq/invoice/view.tt2
@@ -34,6 +34,7 @@
     <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
         <div id='acq-invoice-summary'>
             <button id='acq-invoice-summary-toggle-off'>[% l('Hide Details') %]</button>
+            <span class="hidden" id="ident-validation-spinner"><img src="[% ctx.media_prefix %]/opac/images/progressbar_green.gif" style="height: 16px; width: 16px" /></span>
             <div id='acq-view-invoice-div'></div>
         </div>
         <div id='acq-invoice-summary-small'>
@@ -326,6 +327,5 @@
 </script>
 <script type="text/javascript" src="[% ctx.media_prefix %]/js/ui/default/acq/common/base64.js"></script>
 <script type="text/javascript" src="[% ctx.media_prefix %]/js/ui/default/acq/search/unified.js"></script>
-<script type="text/javascript" src='[% ctx.media_prefix %]/js/ui/default/acq/invoice/common.js'> </script>
 <script type="text/javascript" src='[% ctx.media_prefix %]/js/ui/default/acq/invoice/view.js'> </script>
 [% END %]
diff --git a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js
index f323a0e..fd7949f 100644
--- a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js
+++ b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js
@@ -86,5 +86,6 @@
     "INVOICE_NUMBER": "Invoice #${0}",
     "COPIES_TO_RECEIVE": "Number of copies to receive: ",
     "CREATE_PO_INVALID": "A purchase order must have an ordering agency and a provider.",
-    "INVOICE_COPY_COUNT_INFO": "Copies received on this invoice: ${0} out of ${1}."
+    "INVOICE_COPY_COUNT_INFO": "Copies received on this invoice: ${0} out of ${1}.",
+    "INVOICE_IDENT_COLLIDE": "There is already an invoice in the system with the given combination of 'Vendor Invoice ID' and 'Provider,' which is not allowed."
 }
diff --git a/Open-ILS/web/js/dojo/openils/widget/EditPane.js b/Open-ILS/web/js/dojo/openils/widget/EditPane.js
index 6876dd3..5bde239 100644
--- a/Open-ILS/web/js/dojo/openils/widget/EditPane.js
+++ b/Open-ILS/web/js/dojo/openils/widget/EditPane.js
@@ -237,6 +237,12 @@ if(!dojo._hasResource['openils.widget.EditPane']) {
                 }
             },
 
+            getFieldWidget : function(field) {
+                for (var i in this.fieldList)
+                    if (field == this.fieldList[i].name)
+                        return this.fieldList[i].widget;
+            },
+
             setFieldValue : function(field, val) {
                 for(var i in this.fieldList) {
                     if(field == this.fieldList[i].name) {
diff --git a/Open-ILS/web/js/ui/default/acq/invoice/common.js b/Open-ILS/web/js/ui/default/acq/invoice/common.js
deleted file mode 100644
index 0980fca..0000000
--- a/Open-ILS/web/js/ui/default/acq/invoice/common.js
+++ /dev/null
@@ -1,75 +0,0 @@
-dojo.require('dojo.date.stamp');
-dojo.require('openils.User');
-dojo.require('openils.widget.EditPane');
-
-function drawInvoicePane(parentNode, inv, args) {
-    args = args || {};
-    var pane;
-
-    var override = {};
-    if(!inv) {
-        override = {
-            recv_date : {widgetValue : dojo.date.stamp.toISOString(new Date())},
-            //receiver : {widgetValue : openils.User.user.ws_ou()},
-            recv_method : {widgetValue : 'PPR'}
-        };
-    }
-
-    dojo.mixin(override, {
-        provider : { 
-            dijitArgs : { 
-                store_options : { base_filter : { active :"t" } },
-                onChange : function(val) {
-                    pane.setFieldValue('shipper', val);
-                }
-            } 
-        },
-        shipper  : { dijitArgs : { store_options : { base_filter : { active :"t" } } } }
-    });
-
-    for(var field in args) {
-        override[field] = {widgetValue : args[field]};
-    }
-
-    // push the name of the invoice into the name display field after update
-    override.inv_ident = dojo.mixin(
-        override.inv_ident,
-        {dijitArgs : {onChange :
-            function(newVal) {
-                if (dojo.byId('acq-invoice-summary-name'))
-                    dojo.byId('acq-invoice-summary-name').innerHTML = newVal;
-            }
-        }}
-    );
-
-
-    pane = new openils.widget.EditPane({
-        fmObject : inv,
-        paneStackCount : 2,
-        fmClass : 'acqinv',
-        mode : (inv) ? 'edit' : 'create',
-        hideActionButtons : true,
-        overrideWidgetArgs : override,
-        readOnly : (inv) && openils.Util.isTrue(inv.complete()),
-        requiredFields : [
-            'inv_ident', 
-            'recv_date', 
-            'provider', 
-            'shipper'
-        ],
-        fieldOrder : [
-            'inv_ident', 
-            'recv_date', 
-            'recv_method', 
-            'inv_type', 
-            'provider', 
-            'shipper'
-        ],
-        suppressFields : ['id', 'complete']
-    });
-
-    pane.startup();
-    parentNode.appendChild(pane.domNode);
-    return pane;
-}
-
diff --git a/Open-ILS/web/js/ui/default/acq/invoice/view.js b/Open-ILS/web/js/ui/default/acq/invoice/view.js
index 2036f6f..6c306db 100644
--- a/Open-ILS/web/js/ui/default/acq/invoice/view.js
+++ b/Open-ILS/web/js/ui/default/acq/invoice/view.js
@@ -1022,6 +1022,134 @@ function storeExtraCopies(entry, numExtra) {
     extraItemsDialog.show();
 }
 
+function validateInvIdent(inv_ident, provider, receiver) {
+    if (!(inv_ident && provider && receiver)) {
+        console.info("not enough information to pre-validate inv_ident");
+        return;
+    }
+
+    openils.Util.show("ident-validation-spinner", "inline");
+    var pcrud = new openils.PermaCrud();
+    pcrud.search(
+        "acqinv", {"inv_ident": inv_ident, "provider": provider}, {
+            "oncomplete": function(r) {
+                openils.Util.hide("ident-validation-spinner");
+
+                /* This could throw an event about the user not having perms,
+                 * but in such a case the whole interface is already busted
+                 * anyway. */
+                r = openils.Util.readResponse(r);
+
+                var w = invoicePane.getFieldWidget("inv_ident").widget;
+                if (r.length) {
+                    alert(localeStrings.INVOICE_IDENT_COLLIDE);
+                    w.validator = function() { return false; };
+                    w.validate();
+                } else {
+                    w.validator = function() { return true; };
+                    w.validate();
+                }
+                w.focus();
+                pcrud.disconnect();
+            }
+        }
+    );
+}
+
+function drawInvoicePane(parentNode, inv, args) {
+    args = args || {};
+    var pane;
+
+    var override = {};
+    if(!inv) {
+        override = {
+            recv_date : {widgetValue : dojo.date.stamp.toISOString(new Date())},
+            //receiver : {widgetValue : openils.User.user.ws_ou()},
+            receiver : {
+                "dijitArgs": {
+                    "onChange": function(val) {
+                        validateInvIdent(
+                            invoicePane && invoicePane.getFieldValue("inv_ident"),
+                            invoicePane && invoicePane.getFieldValue("provider"),
+                            val
+                        );
+                    }
+                }
+            },
+            recv_method : {widgetValue : 'PPR'}
+        };
+    }
+
+    dojo.mixin(override, {
+        provider : { 
+            dijitArgs : { 
+                store_options : { base_filter : { active :"t" } },
+                onChange : function(val) {
+                    pane.setFieldValue('shipper', val);
+                    validateInvIdent(
+                        invoicePane && invoicePane.getFieldValue("inv_ident"),
+                        val,
+                        invoicePane && invoicePane.getFieldValue("receiver")
+                    );
+                }
+            } 
+        },
+        shipper  : { dijitArgs : { store_options : { base_filter : { active :"t" } } } }
+    });
+
+    for(var field in args) {
+        override[field] = {widgetValue : args[field]};
+    }
+
+    // push the name of the invoice into the name display field after update
+    override.inv_ident = dojo.mixin(
+        override.inv_ident,
+        {dijitArgs : {onChange :
+            function(newVal) {
+                validateInvIdent(
+                    newVal,
+                    invoicePane && invoicePane.getFieldValue("provider"),
+                    invoicePane && invoicePane.getFieldValue("receiver")
+                );
+
+                if (dojo.byId('acq-invoice-summary-name'))
+                    dojo.byId('acq-invoice-summary-name').innerHTML = newVal;
+            }
+        }}
+    );
+
+
+    pane = new openils.widget.EditPane({
+        fmObject : inv,
+        paneStackCount : 2,
+        fmClass : 'acqinv',
+        mode : (inv) ? 'edit' : 'create',
+        hideActionButtons : true,
+        overrideWidgetArgs : override,
+        readOnly : (inv) && openils.Util.isTrue(inv.complete()),
+        requiredFields : [
+            'inv_ident', 
+            'recv_date', 
+            'provider', 
+            'shipper'
+        ],
+        fieldOrder : [
+            'inv_ident', 
+            'recv_date', 
+            'recv_method', 
+            'inv_type', 
+            'provider', 
+            'shipper'
+        ],
+        suppressFields : ['id', 'complete']
+    });
+
+    pane.startup();
+    parentNode.appendChild(pane.domNode);
+    return pane;
+}
+
+
 function createExtraCopies(oncomplete) {
 
     var lids = [];

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/src/templates/acq/invoice/view.tt2      |    2 +-
 Open-ILS/web/js/dojo/openils/acq/nls/acq.js      |    3 +-
 Open-ILS/web/js/dojo/openils/widget/EditPane.js  |    6 +
 Open-ILS/web/js/ui/default/acq/invoice/common.js |   75 -------------
 Open-ILS/web/js/ui/default/acq/invoice/view.js   |  128 ++++++++++++++++++++++
 5 files changed, 137 insertions(+), 77 deletions(-)
 delete mode 100644 Open-ILS/web/js/ui/default/acq/invoice/common.js


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list