selfcheck checkin
authorBill Erickson <berick@esilibrary.com>
Fri, 1 Feb 2013 21:12:49 +0000 (16:12 -0500)
committerBill Erickson <berick@esilibrary.com>
Fri, 1 Feb 2013 21:12:49 +0000 (16:12 -0500)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js

index 5feb557..54c4aec 100644 (file)
@@ -548,46 +548,16 @@ SelfCheckManager.prototype.drawCheckinPage = function() {
 
 SelfCheckManager.prototype.checkin = function(barcode) {
     var self = this;
-
-    var checkinHandler = function(evt) {
-        if(!evt.length) evt = [evt];
-
-        for(var i = 0; i < evt.length; i++) {
-            var tc = evt.textcode;
-            console.log('checkin returned ' + tc);
-
-            switch (tc) {
-                case 'SUCCESS':
-                case 'NO_CHANGE':
-                    continue;
-                    break;
-                default:
-                    self.handleAlert(
-                        // TODO: i18n
-                        'Unhandled checkin event for "' + 
-                            barcode + '"\n' + evt.toString(),
-                        true, 'checkin-failure'
-                    );
-            }
-        }
-
-
-        // TODO checkin would be faster if these were
-        // not updated in real time w/ each checkin
-
-        // fines summary
-        self.updateFinesSummary();
-
-        // holds summary
-        self.updateHoldsSummary();
-
-        // items out summary
-        self.updateCircSummary();
-    };
-
     this.checkinCopy({
         barcode : barcode, 
-        onload : checkinHandler
+        onload : function(evts) {
+            if (!evts.length) evts = [evts];
+            dojo.forEach(evts, 
+                function(evt) {
+                    self.handleCheckinResult(barcode, evt);
+                }
+            );
+        }
     });
 };
 
@@ -1083,6 +1053,48 @@ SelfCheckManager.prototype.failPartMessage = function(result) {
     }
 }
 
+SelfCheckManager.prototype.displayCheckin = function(result) {
+    console.log('display checkin results ' + result);
+    this.updateCircSummary();
+}
+
+SelfCheckManager.prototype.handleCheckinResult = function(item, result) {
+    var displayText = '';
+    var popup = false;  
+    var sound = ''; // sound file reference
+    var payload = result.payload || {};
+    var tc = result.textcode;
+
+    if (tc == 'NO_SESSION') {
+
+        return this.logoutStaff();
+
+    } else if (tc == 'SUCCESS') {
+
+        //displayText = dojo.string.substitute(localeStrings.CHECKOUT_SUCCESS, [item]);
+        displayText = 'Checkin Succeeded ' + item; // TODO i18n
+        this.displayCheckin(result);
+
+    } else if (tc == 'NO_CHANGE') {
+
+        displayText = 'No change ' + item; // TODO i18n
+        this.displayCheckin(result);
+
+    } else if (tc == 'ASSET_COPY_NOT_FOUND') {
+
+        displayText = dojo.string.substitute(
+            localeStrings.ITEM_NOT_CATALOGED, [item]);
+
+    } else {
+
+        displayText = dojo.string.substitute(
+            localeStrings.UNKNOWN_ERROR, [tc]);
+    }
+
+    this.handleAlert(displayText, popup, sound);
+    return {};
+}
+
 SelfCheckManager.prototype.handleXactResult = function(action, item, result) {
 
     var displayText = '';