From: phasefx Date: Thu, 9 Dec 2010 11:09:06 +0000 (+0000) Subject: fix copy/paste-o with decrement of unsaved_data semaphore and move functions from... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=98b8a3832fdf514153a63756653712d69a4a4f03;p=contrib%2FConifer.git fix copy/paste-o with decrement of unsaved_data semaphore and move functions from menu.js to global_util.js. tie unsaved_data into offline mode to speedbump closure via the login window git-svn-id: svn://svn.open-ils.org/ILS/trunk@18942 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- 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 aa6b966e80..ec0f548fcd 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 @@ -1,5 +1,22 @@ function $(id) { return document.getElementById(id); } + function oils_unsaved_data_V() { + 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.stash('unsaved_data'); + } + + function oils_unsaved_data_P() { + 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--; + if (data.unsaved_data < 0) { data.unsaved_data = 0; } + data.stash('unsaved_data'); + } + function oils_lock_page(params) { dump('oils_lock_page\n'); if (!params) { params = {}; } @@ -12,7 +29,11 @@ if (typeof xulG != 'undefined') { if (typeof xulG.unlock_tab == 'function') { xulG.lock_tab(); + } else { + oils_unsaved_data_V(); } + } else { + oils_unsaved_data_V(); } return window.oils_lock; } @@ -24,7 +45,11 @@ if (typeof xulG != 'undefined') { if (typeof xulG.unlock_tab == 'function') { xulG.unlock_tab(); + } else { + oils_unsaved_data_P(); } + } else { + oils_unsaved_data_P(); } return window.oils_lock; } 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 2318c22acc..98d1ea9b60 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) { - obj.global_unsaved_data_P(); + oils_unsaved_data_P(); } } @@ -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; } - obj.global_unsaved_data_P(); + oils_unsaved_data_P(); } delete this.tab_semaphores[id]; } @@ -1646,22 +1646,6 @@ main.menu.prototype = { 'tab_semaphores' : {}, - 'global_unsaved_data_V' : function() { - var obj = this; - obj.data.stash_retrieve(); - if (typeof obj.data.unsaved_data == 'undefined') { obj.data.unsaved_data = 0; } - obj.data.unsaved_data++; - obj.data.stash('unsaved_data'); - }, - 'global_unsaved_data_P' : function() { - var obj = this; - obj.data.stash_retrieve(); - if (typeof obj.data.unsaved_data == 'undefined') { obj.data.unsaved_data = 0; } - obj.data.unsaved_data++; - if (obj.data.unsaved_data < 0) { obj.data.unsaved_data = 0; } - obj.data.stash('unsaved_data'); - }, - 'set_tab' : function(url,params,content_params) { var obj = this; if (!url) url = '/xul/server/'; @@ -1678,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; } - obj.global_unsaved_data_P(); + oils_unsaved_data_P(); } delete obj.tab_semaphores[id]; } @@ -1695,7 +1679,7 @@ main.menu.prototype = { obj.tab_semaphores[id] = 0; } obj.tab_semaphores[id]++; - obj.global_unsaved_data_V(); + oils_unsaved_data_V(); return obj.tab_semaphores[id]; }; content_params.unlock_tab = function() { @@ -1705,7 +1689,7 @@ main.menu.prototype = { } obj.tab_semaphores[id]--; if (obj.tab_semaphores[id] < 0) { obj.tab_semaphores[id] = 0; } - obj.global_unsaved_data_P(); + oils_unsaved_data_P(); return obj.tab_semaphores[id]; }; content_params.inspect_tab = function() {