From 9c0f2991bdc70a356c8272fe93cc7223f766f474 Mon Sep 17 00:00:00 2001 From: Cesar Velez Date: Fri, 7 Dec 2018 18:50:43 -0500 Subject: [PATCH] LP1765179 - fix issue with pending/staged user reg 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 --- Open-ILS/web/js/ui/default/staff/circ/patron/pending.js | 12 ++++++++++++ Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js | 17 +++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/pending.js b/Open-ILS/web/js/ui/default/staff/circ/patron/pending.js index 844aa18e16..65e29ad1d9 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/pending.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/pending.js @@ -71,6 +71,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; diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js b/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js index 583db58477..0f8c451ba2 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js @@ -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 }; @@ -2129,6 +2129,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; -- 2.11.0