From 71f8c27088a6d530eba402a67d0b71630674c3c9 Mon Sep 17 00:00:00 2001 From: Cesar Velez Date: Fri, 17 Aug 2018 07:15:57 -0400 Subject: [PATCH] WIP use BroadcastChannel API to refresh holdings after VolcopyEditor update in child tab --- .../web/js/ui/default/staff/cat/catalog/app.js | 23 ++++++++++++++++++++++ .../web/js/ui/default/staff/cat/volcopy/app.js | 9 ++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) 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(); + }); } } }); -- 2.11.0