LP1765179 - fix issue with pending/staged user reg
authorCesar Velez <cesar.velez@equinoxinitiative.org>
Fri, 7 Dec 2018 23:50:43 +0000 (18:50 -0500)
committerJason Etheridge <jason@EquinoxInitiative.org>
Wed, 2 Jan 2019 13:08:58 +0000 (08:08 -0500)
After completing a staged user registration, the controller
in regctl.js was refreshing to the same route, and
trying to fetch the same staged user, but never finding it
as it was no longer staged/pending. This addresses that bug
and adds a bChannel refresh to the pending grid, so once
the user is registered in the child tab, it closes the tab and
the pending user grid is updated.

Signed-off by: Cesar Velez <cesar.velez@equinoxinitiative.org>

Signed-off-by: Jason Etheridge <jason@EquinoxInitiative.org>
Open-ILS/web/js/ui/default/staff/circ/patron/pending.js
Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js

index 0690b3c..0912eb8 100644 (file)
@@ -50,6 +50,18 @@ function($scope , $q , $routeParams , $window , $location , egCore , egGridDataP
         provider.refresh();
     }
 
+    if (typeof BroadcastChannel != 'undefined') {
+        // connect 2 bChannel
+        holdings_bChannel = new BroadcastChannel('eg.pending_usr.update');
+        holdings_bChannel.onmessage = function(e){
+            if (e.data && e.data.usr.home_ou == $scope.context_org.id()){
+                // pending usr was registered, refresh grid!
+                console.log("Got broadcast from channel eg.pending_usr.update for usr id: " + e.data.usr.id);
+                refresh_page();
+            }
+        }
+    };
+
     provider.get = function(offset, count) {
         var deferred = $q.defer();
         var recv_index = 0;
index cd8843a..4e2e9a2 100644 (file)
@@ -1226,10 +1226,10 @@ angular.module('egCoreMod')
 .controller('PatronRegCtrl',
        ['$scope','$routeParams','$q','$uibModal','$window','egCore',
         'patronSvc','patronRegSvc','egUnloadPrompt','egAlertDialog',
-        'egWorkLog',
+        'egWorkLog', '$timeout',
 function($scope , $routeParams , $q , $uibModal , $window , egCore ,
          patronSvc , patronRegSvc , egUnloadPrompt, egAlertDialog ,
-         egWorkLog) {
+         egWorkLog, $timeout) {
 
     $scope.page_data_loaded = false;
     $scope.hold_notify_type = { phone : null, email : null, sms : null };
@@ -2127,6 +2127,19 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore ,
                     + updated_user.id();
                 $window.open(url, '_blank').focus();
 
+            } else if ($window.location.href.indexOf('stage') > -1 ){
+                // we're here after deleting a self-reg staged user.
+                // Just close tab, since refresh won't find staged user
+                $timeout(function(){
+                    if (typeof BroadcastChannel != 'undefined') {
+                        var bChannel = new BroadcastChannel("eg.pending_usr.update");
+                        bChannel.postMessage({
+                            usr: egCore.idl.toHash(updated_user)
+                        });
+                    }
+
+                    $window.close();
+                });
             } else {
                 // reload the current page
                 $window.location.href = location.href;