<button type="button" ng-disabled="from_route" class="btn btn-default" ng-click="opac_call('rdetailEnd')">
[% l('End') %]
</button>
- <button type="button" ng-disabled="from_route" class="btn btn-default" ng-click="opac_call('rdetailBackToResults')">
+ <button type="button" ng-disabled="from_route" class="btn btn-default" ng-click="opac_call('rdetailBackToResults', true)">
[% l('Back To Results') %]
</button>
</div> <!-- padding -->
</div>
<!-- ng-if the remaining tabs so they can be instantiated on demand -->
<div ng-if="record_tab == 'marc_edit'">
- <eg-marc-edit-record record-id="record_id"></eg-marc-edit-record>
+ <eg-marc-edit-record dirty-flag="stop_unload" record-id="record_id"></eg-marc-edit-record>
</div>
<div ng-if="record_tab == 'marc_html'">
<eg-record-html record-id="record_id"></eg-record-html>
// will hold a ref to the opac iframe
$scope.opac_iframe = null;
- $scope.opac_call = function (thing) {
- if ($scope.opac_iframe) $scope.opac_iframe.contentWindow[thing]()
+ $scope.opac_call = function (opac_frame_function, force_opac_tab) {
+ if ($scope.opac_iframe) {
+ if (force_opac_tab) $scope.record_tab = 'catalog';
+ $scope.opac_iframe.contentWindow[opac_frame_function]();
+ }
}
+ $scope.stop_unload = false;
+ $scope.$watch('stop_unload',
+ function(newVal, oldVal) {
+ if (newVal && newVal != oldVal && $scope.opac_iframe) {
+ $($scope.opac_iframe.contentWindow).on('beforeunload', function(){
+ return 'There is unsaved data in this record.'
+ });
+ } else {
+ $($scope.opac_iframe.contentWindow).off('beforeunload');
+ }
+ }
+ );
+
// Set the "last bib" cookie, if we have that
if ($scope.record_id)
egCore.hatch.setLocalItem("eg.cat.last_record_retrieved", $scope.record_id);
templateUrl : './cat/share/t_marcedit',
restrict: 'E',
replace: true,
- scope: { recordId : '=', recordType : '@', maxUndo : '@' },
+ scope: {
+ dirtyFlag : '=',
+ recordId : '=',
+ recordType : '@',
+ maxUndo : '@'
+ },
link: function (scope, element, attrs) {
element.bind('click', function(e) {;
$scope.force_render = false;
}
- if ($scope.record_undo_stack.length != $scope.save_stack_depth) {
- console.log('should get a listener... does not');
- $('body').on('beforeunload', function(){
- return 'There is unsaved data in this record.'
- });
- } else {
- $('body').off('beforeunload');
- }
+ }
+
+ if ($scope.record_undo_stack.length != $scope.save_stack_depth) {
+ console.log('should get a listener... does not');
+ $scope.dirtyFlag = true;
+ } else {
+ $scope.dirtyFlag = false;
}
if ($scope.record_undo_stack.length > $scope.max_undo)