From: Cesar Velez Date: Fri, 17 Aug 2018 11:15:57 +0000 (-0400) Subject: WIP use BroadcastChannel API to refresh holdings after VolcopyEditor update in child tab X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=71f8c27088a6d530eba402a67d0b71630674c3c9;p=working%2FEvergreen.git WIP use BroadcastChannel API to refresh holdings after VolcopyEditor update in child tab --- diff --git a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js index 43af4d568d..34df7bf334 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js @@ -729,6 +729,7 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e // ------------------------------------------------------------------ // Holdings + $scope.holdingsGridControls = { activateItem : function (item) { $scope.selectedHoldingsVolCopyEdit(); @@ -1077,6 +1078,28 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e }); } + var holdings_bChannel = undefined; + // subscribe to BroadcastChannel for any child VolCopy tabs + // refresh grid if needed to show new updates + // if ($scope.record_tab === 'holdings'){ + $scope.$watch('record_tab', function(n){ + + if (n === 'holdings'){ + // we're in holdings tab, connect 2 bChannel + holdings_bChannel = new BroadcastChannel('volcopy_update'); + holdings_bChannel.onmessage = function(e){ + console.log("Getting Broadcast from volcopy_update for bib=" + e.data.record); + if ($scope.record_id == e.data.record){ // it's for us, refresh grid! + $scope.holdings_record_id_changed($scope.record_id); + } + }; + + } else if (holdings_bChannel){ // we're leaving holding tab, close bChannel + holdings_bChannel.close(); + } + + }); + // refresh the list of holdings when the record_id is changed. $scope.holdings_record_id_changed = function(id) { if ($scope.record_id != id) $scope.record_id = id; diff --git a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js index a289134ad5..6925943b46 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js @@ -1989,7 +1989,14 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , } }); } else { - $timeout(function(){$window.close()}); + $timeout(function(){ + var bChannel = new BroadcastChannel("volcopy_update"); + var bre_id = cnList && cnList.length > 0 ? cnList[0].record() : -1; + var msg = {copies: copy_ids, record: bre_id}; + bChannel.postMessage(msg); + + $window.close(); + }); } } });