[open-ils-commits] r18927 - in trunk/Open-ILS/xul/staff_client/chrome: content/auth content/main locale/en-US (phasefx)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Dec 7 11:58:17 EST 2010
Author: phasefx
Date: 2010-12-07 11:58:14 -0500 (Tue, 07 Dec 2010)
New Revision: 18927
Modified:
trunk/Open-ILS/xul/staff_client/chrome/content/auth/controller.js
trunk/Open-ILS/xul/staff_client/chrome/content/main/main.js
trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js
trunk/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties
Log:
have lock_tab cause warning prompts for logoff attempts and application shutdown
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/auth/controller.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/auth/controller.js 2010-12-07 16:58:10 UTC (rev 18926)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/auth/controller.js 2010-12-07 16:58:14 UTC (rev 18927)
@@ -511,6 +511,16 @@
},
'logoff' : function() {
+
+ this.data.stash_retrieve();
+ if (typeof this.data.unsaved_data != 'undefined') {
+ if (this.data.unsaved_data > 0) {
+ var confirmation = window.confirm( document.getElementById('offlineStrings').getString('menu.logoff.unsaved_data_warning') );
+ if (!confirmation) { return; }
+ this.data.unsaved_data = 0;
+ this.data.stash('unsaved_data');
+ }
+ }
this.error.sdump('D_AUTH','logoff' + this.w + '\n');
this.controller.view.progress_bar.value = 0;
@@ -552,7 +562,18 @@
this.error.sdump('D_AUTH','close' + this.w + '\n');
- if (window.confirm(document.getElementById('authStrings').getString('staff.auth.controller.confirm_close'))) {
+ var confirm_string = document.getElementById('authStrings').getString('staff.auth.controller.confirm_close');
+
+ this.data.stash_retrieve();
+ if (typeof this.data.unsaved_data != 'undefined') {
+ if (this.data.unsaved_data > 0) {
+ confirm_string = document.getElementById('offlineStrings').getString('menu.shutdown.unsaved_data_warning');
+ }
+ }
+
+ if (window.confirm(confirm_string)) {
+ this.data.unsaved_data = 0;
+ this.data.stash('unsaved_data');
this.logoff();
this.w.close(); /* Probably won't go any further */
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/main.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/main.js 2010-12-07 16:58:10 UTC (rev 18926)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/main.js 2010-12-07 16:58:14 UTC (rev 18927)
@@ -541,6 +541,30 @@
}
}
+ window.addEventListener(
+ 'close',
+ function(ev) {
+
+ G.data.stash_retrieve();
+ if (typeof G.data.unsaved_data != 'undefined') {
+ if (G.data.unsaved_data > 0) {
+ var confirmation = window.confirm(offlineStrings.getString('menu.shutdown.unsaved_data_warning'));
+ if (!confirmation) {
+ ev.preventDefault();
+ return false;
+ }
+ }
+ }
+ G.data.unsaved_data = 0;
+ G.data.stash('unsaved_data');
+
+ return true;
+
+ },
+ false
+ );
+
+
} catch(E) {
var error = offlineStrings.getFormattedString('common.exception', [E, '']);
try { G.error.sdump('D_ERROR',error); } catch(E) { dump(error); }
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js 2010-12-07 16:58:10 UTC (rev 18926)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js 2010-12-07 16:58:14 UTC (rev 18927)
@@ -138,6 +138,12 @@
}
}
+ for (var id in obj.tab_semaphores) {
+ if (obj.tab_semaphores[id] > 0) {
+ obj.global_unsaved_data_P();
+ }
+ }
+
return true;
},
@@ -1305,7 +1311,16 @@
'cmd_shutdown' : [
['oncommand'],
function() {
- if (window.confirm(offlineStrings.getString('menu.cmd_shutdown.prompt'))) {
+ var confirm_string = offlineStrings.getString('menu.cmd_shutdown.prompt');
+ obj.data.stash_retrieve();
+ if (typeof obj.data.unsaved_data != 'undefined') {
+ if (obj.data.unsaved_data > 0) {
+ confirm_string = offlineStrings.getString('menu.shutdown.unsaved_data_warning');
+ }
+ }
+ if (window.confirm(confirm_string)) {
+ obj.data.unsaved_data = 0; // just in case the program doesn't close somehow
+ obj.data.stash('unsaved_data');
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService();
var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
@@ -1371,8 +1386,9 @@
if (this.tab_semaphores[id] > 0) {
var confirmation = window.confirm(offlineStrings.getString('menu.close_tab.unsaved_data_warning'));
if (!confirmation) { return; }
- delete this.tab_semaphores[id];
+ obj.global_unsaved_data_P();
}
+ delete this.tab_semaphores[id];
}
this.controller.view.tabs.removeItemAt(idx);
@@ -1630,6 +1646,22 @@
'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/';
@@ -1646,8 +1678,9 @@
if (obj.tab_semaphores[id] > 0) {
var confirmation = window.confirm(offlineStrings.getString('menu.replace_tab.unsaved_data_warning'));
if (!confirmation) { return; }
- delete obj.tab_semaphores[id];
+ obj.global_unsaved_data_P();
}
+ delete obj.tab_semaphores[id];
}
}
var unique_id = idx + ':' + new Date();
@@ -1662,6 +1695,7 @@
obj.tab_semaphores[id] = 0;
}
obj.tab_semaphores[id]++;
+ obj.global_unsaved_data_V();
return obj.tab_semaphores[id];
};
content_params.unlock_tab = function() {
@@ -1671,6 +1705,7 @@
}
obj.tab_semaphores[id]--;
if (obj.tab_semaphores[id] < 0) { obj.tab_semaphores[id] = 0; }
+ obj.global_unsaved_data_P();
return obj.tab_semaphores[id];
};
content_params.inspect_tab = function() {
Modified: trunk/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties 2010-12-07 16:58:10 UTC (rev 18926)
+++ trunk/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties 2010-12-07 16:58:14 UTC (rev 18927)
@@ -283,3 +283,5 @@
menu.close_tab.unsaved_data_warning=This tab may have unsaved data. Close it anyway?
menu.replace_tab.unsaved_data_warning=This tab may have unsaved data. Replace it anyway?
menu.close_window.unsaved_data_warning=This window may have unsaved data. Close it anyway?
+menu.logoff.unsaved_data_warning=This session may have unsaved data. Logoff anyway?
+menu.shutdown.unsaved_data_warning=This application may have unsaved data. Exit it anyway?
More information about the open-ils-commits
mailing list