From 4d9e59437db1f48b930102ed08fb7ff3216c7deb Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Fri, 14 Sep 2018 11:03:30 -0400 Subject: [PATCH] LP#1684202: Protect against missing features; Make feature more general I've wrapped the BroadcastChannel code in a test derived from the auth version of the same concept. Also broadcasting the full set of record IDs and the pre-update call number IDs for other interfaces that might be interested. The channel name is also made more generic and made to follow the precedent from the auth channel name. Signed-off-by: Mike Rylander --- Open-ILS/web/js/ui/default/staff/cat/catalog/app.js | 20 +++++++++++++------- Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js | 14 ++++++++++---- 2 files changed, 23 insertions(+), 11 deletions(-) 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 34df7bf334..58f6e88fe6 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 @@ -1078,19 +1078,25 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e }); } - var holdings_bChannel = undefined; + var holdings_bChannel = null; // 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); + if (typeof BroadcastChannel != 'undefined') { + // we're in holdings tab, connect 2 bChannel + holdings_bChannel = new BroadcastChannel('eg.holdings.update'); + holdings_bChannel.onmessage = function(e){ + if (e.data + && e.data.records + && e.data.records.length + && e.data.records.includes($scope.record_id) + ){ // it's for us, refresh grid! + console.log("Got broadcast from channel eg.holdings.update for records " + e.data.records); + $scope.holdings_record_id_changed($scope.record_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 6925943b46..6069fe7b81 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 @@ -1990,10 +1990,16 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , }); } else { $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); + if (typeof BroadcastChannel != 'undefined') { + var bChannel = new BroadcastChannel("eg.holdings.update"); + var bre_ids = cnList && cnList.length > 0 ? cnList.map(function(cn){ return cn.record() }) : []; + var cn_ids = cnList && cnList.length > 0 ? cnList.map(function(cn){ return cn.id() }) : []; + bChannel.postMessage({ + copies : copy_ids, + volumes: cn_ids, + records: bre_ids + }); + } $window.close(); }); -- 2.11.0