[open-ils-commits] r15603 - in trunk/Open-ILS/web/js: dojo/openils/acq/nls ui/default/acq/common (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Feb 19 18:58:32 EST 2010


Author: senator
Date: 2010-02-19 18:58:31 -0500 (Fri, 19 Feb 2010)
New Revision: 15603

Modified:
   trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js
   trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
Log:
Acq: when receiving items, require user to acknowledge any related alerts

Alerts are, in this context, lineitem notes (acqlin) that have a non-null
alert_text value pointing to a lineitem alert text (acqliat).

Users will be prompted to acknowledge all related alerts whether attempting
the receive operation against the whole purchase order, lineitems, or
individual copies.  Users will not be prompted to acknowledge the same alert
more than once per "use" of the purchase order viewing interface.



Modified: trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js	2010-02-19 20:56:38 UTC (rev 15602)
+++ trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js	2010-02-19 23:58:31 UTC (rev 15603)
@@ -21,4 +21,5 @@
     'UNRECEIVE_LI': "Are you sure you want to mark this lineitem as UN-received?",
 
     'UNRECEIVE_LID': "Are you sure you want to mark this copy as UN-received?",
+    'CONFIRM_LI_ALERT': "An alert has been placed on the lineitem titled,\n\"${0}\":\n\n${1}\n\n${2}\n\nChoose OK if you wish to acknowledge this alert."
 }

Modified: trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js	2010-02-19 20:56:38 UTC (rev 15602)
+++ trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js	2010-02-19 23:58:31 UTC (rev 15603)
@@ -40,6 +40,7 @@
     this.toggleState = false;
     this.tbody = dojo.byId('acq-lit-tbody');
     this.selectors = [];
+    this.noteAcks = {};
     this.authtoken = openils.User.authtoken;
     this.rowTemplate = this.tbody.removeChild(dojo.byId('acq-lit-row'));
     this.copyTbody = dojo.byId('acq-lit-li-details-tbody');
@@ -89,6 +90,7 @@
         while(self.tbody.childNodes[0])
             self.tbody.removeChild(self.tbody.childNodes[0]);
         self.selectors = [];
+        self.noteAcks = {};
     };
     
     this.setNext = function(handler) {
@@ -281,7 +283,10 @@
                     openils.Util.hide(real_copies_link);
                     openils.Util.hide(unrecv_link);
                     openils.Util.show(recv_link, "inline");
-                    recv_link.onclick = function() { self.issueReceive(li); };
+                    recv_link.onclick = function() {
+                        if (self.checkLiAlerts(li.id()))
+                            self.issueReceive(li);
+                    };
                     return;
                 case "received":
                     openils.Util.hide(recv_link);
@@ -929,7 +934,10 @@
                 } else {
                     openils.Util.hide(unrecv_link);
                     openils.Util.show(recv_link);
-                    recv_link.onclick = function() { self.issueReceive(copy); };
+                    recv_link.onclick = function() {
+                        if (self.checkLiAlerts(copy.lineitem()))
+                            self.issueReceive(copy);
+                    };
                 }
             } else {
                 openils.Util.hide(unrecv_link);
@@ -944,6 +952,39 @@
         }
     }
 
+    this._confirmAlert = function(li, lin) {
+        return confirm(
+            dojo.string.substitute(
+                localeStrings.CONFIRM_LI_ALERT, [
+                    (new openils.acq.Lineitem({"lineitem": li})).findAttr(
+                        "title", "lineitem_marc_attr_definition"
+                    ),
+                    lin.alert_text().description(), lin.value()
+                ]
+            )
+        );
+    };
+
+    this.checkLiAlerts = function(li_id) {
+        var li = this.liCache[li_id];
+
+        var alert_notes = li.lineitem_notes().filter(
+            function(o) { return Boolean(o.alert_text()); }
+        );
+
+        /* this is _intentionally_ not done in a call to forEach() ... */
+        for (var i = 0; i < alert_notes.length; i++) {
+            if (this.noteAcks[alert_notes[i].id()])
+                continue;
+            else if (!this._confirmAlert(li, alert_notes[i]))
+                return false;
+            else
+                this.noteAcks[alert_notes[i].id()] = true;
+        }
+
+        return true;
+    };
+
     this.deleteCopy = function(row) {
         var copy = this.copyCache[row.getAttribute('copy_id')];
         copy.isdeleted(true);
@@ -1184,7 +1225,15 @@
 
 
     this.receivePO = function() {
-        if(!this.isPO) return;
+        if (!this.isPO) return;
+
+        for (var id in this.liCache) {
+            /* assumption: liCache reflects exactly the
+             * set of LIs that belong to our PO */
+            if (this.liCache[id].state() != "received" &&
+                !this.checkLiAlerts(id)) return;
+        }
+
         this.show('acq-lit-progress-numbers');
         var self = this;
         fieldmapper.standardRequest(



More information about the open-ils-commits mailing list