make sure forced closures of locked tabs and windows are correctly changing data...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 9 Dec 2010 11:09:08 +0000 (11:09 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 9 Dec 2010 11:09:08 +0000 (11:09 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@18943 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js
Open-ILS/xul/staff_client/chrome/content/main/menu.js

index ec0f548..9b8363d 100644 (file)
@@ -8,11 +8,12 @@
         data.stash('unsaved_data');
     }
 
-    function oils_unsaved_data_P() {
+    function oils_unsaved_data_P(count) {
+        if (!count) { count = 1; }
         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
         data.stash_retrieve();
         if (typeof data.unsaved_data == 'undefined') { data.unsaved_data = 0; }
-        data.unsaved_data--;
+        data.unsaved_data -= count;
         if (data.unsaved_data < 0) { data.unsaved_data = 0; }
         data.stash('unsaved_data');
     }
                     }
                 }
 
-                window.oils_lock = 0;
                 if (typeof xulG != 'undefined') {
                     if (typeof xulG.unlock_tab == 'function') {
                         xulG.unlock_tab();
+                    } else {
+                        oils_unsaved_data_P( window.oils_lock );
                     }
+                } else {
+                    oils_unsaved_data_P( window.oils_lock );
                 }
+                window.oils_lock = 0;
 
                 // Dispatching the window close event doesn't always close the window, even though the event does happen
                 setTimeout(
index 98d1ea9..c6f9e95 100644 (file)
@@ -140,7 +140,7 @@ main.menu.prototype = {
 
                 for (var id in obj.tab_semaphores) {
                     if (obj.tab_semaphores[id] > 0) {
-                        oils_unsaved_data_P();
+                        oils_unsaved_data_P( obj.tab_semaphores[id] );
                     }
                 }
 
@@ -1386,7 +1386,7 @@ main.menu.prototype = {
             if (this.tab_semaphores[id] > 0) {
                 var confirmation = window.confirm(offlineStrings.getString('menu.close_tab.unsaved_data_warning'));
                 if (!confirmation) { return; }
-                oils_unsaved_data_P();
+                oils_unsaved_data_P( this.tab_semaphores[id] );
             }
             delete this.tab_semaphores[id];
         }
@@ -1662,7 +1662,7 @@ main.menu.prototype = {
                 if (obj.tab_semaphores[id] > 0) {
                     var confirmation = window.confirm(offlineStrings.getString('menu.replace_tab.unsaved_data_warning'));
                     if (!confirmation) { return; }
-                    oils_unsaved_data_P();
+                    oils_unsaved_data_P( obj.tab_semaphores[id] );
                 }
                 delete obj.tab_semaphores[id];
             }