From d13e2e16963de592bdf71a9795e26acc1b4af2b6 Mon Sep 17 00:00:00 2001 From: Kyle Huckins Date: Wed, 17 Apr 2019 22:55:49 +0000 Subject: [PATCH] lp1538678 Apply Warning Prompt when leaving dirty MARC editor - Check for unsaved user input when leaving the Create New MARC Record UI, and warn if it exists. Signed-off-by: Kyle Huckins Changes to be committed: modified: services/marcedit.js Signed-off-by: Bill Erickson --- .../js/ui/default/staff/cat/services/marcedit.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 4d2f9c97a5..81ff40d8b9 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 @@ -704,6 +704,19 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) if (typeof $scope.onSaveCallback !== 'undefined' && !angular.isArray($scope.onSaveCallback)) $scope.onSaveCallback = [ $scope.onSaveCallback ]; + $scope.$watch('dirtyFlag', + function(newVal, oldVal) { + if (newVal && newVal != oldVal && !$scope.opac_iframe) { + $($window).on('beforeunload', function(){ + return 'There is unsaved data in this record.' + }); + } else { + if (!$scope.opac_iframe) + $($window).off('beforeunload'); + } + } + ); + MARC21.Record.delimiter = '$'; $scope.enable_fast_add = false; @@ -1426,6 +1439,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) return egCore.pcrud.create( $scope.Record() ).then(function(bre) { + $scope.dirtyFlag = false; $scope.recordId = bre.id(); $scope.caretRecId = $scope.recordId; if ($scope.enable_fast_add) { -- 2.43.2