// ------------------------------------------------------------------
// Holdings
+
$scope.holdingsGridControls = {
activateItem : function (item) {
$scope.selectedHoldingsVolCopyEdit();
});
}
+ 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;
}
});
} 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();
+ });
}
}
});