From 30474adbf58fa0e5931676adbbda5bfdbb1ea9d4 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Wed, 11 Mar 2015 22:26:08 -0400 Subject: [PATCH] webstaff: Toward dirty data flag and better prev/next/start/end buttons Signed-off-by: Mike Rylander Signed-off-by: Galen Charlton Signed-off-by: Jason Stephenson --- .../src/templates/staff/cat/catalog/t_catalog.tt2 | 4 ++-- .../web/js/ui/default/staff/cat/catalog/app.js | 20 ++++++++++++++++++-- .../js/ui/default/staff/cat/services/marcedit.js | 22 +++++++++++++--------- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/Open-ILS/src/templates/staff/cat/catalog/t_catalog.tt2 b/Open-ILS/src/templates/staff/cat/catalog/t_catalog.tt2 index 89fe91a396..8a585d74cd 100644 --- a/Open-ILS/src/templates/staff/cat/catalog/t_catalog.tt2 +++ b/Open-ILS/src/templates/staff/cat/catalog/t_catalog.tt2 @@ -24,7 +24,7 @@ - @@ -64,7 +64,7 @@
- +
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 c6487e28a4..64d4efda09 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 @@ -130,10 +130,26 @@ function($scope , $routeParams , $location , $q , egCore , egHolds, // 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); diff --git a/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js b/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js index 641bdd9a5f..65c36a1f69 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js +++ b/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js @@ -274,7 +274,12 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) 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) {; @@ -663,14 +668,13 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) $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) -- 2.11.0