From 0ad636712162fd1380962e0c899b1de43b796000 Mon Sep 17 00:00:00 2001 From: phasefx Date: Thu, 9 Dec 2010 11:09:08 +0000 Subject: [PATCH] make sure forced closures of locked tabs and windows are correctly changing data.unsaved_data git-svn-id: svn://svn.open-ils.org/ILS/trunk@18943 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../xul/staff_client/chrome/content/OpenILS/global_util.js | 11 ++++++++--- Open-ILS/xul/staff_client/chrome/content/main/menu.js | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js index ec0f548fcd..9b8363d29a 100644 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js +++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js @@ -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'); } @@ -68,12 +69,16 @@ } } - 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( diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu.js b/Open-ILS/xul/staff_client/chrome/content/main/menu.js index 98d1ea9b60..c6f9e959a9 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -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]; } -- 2.11.0