[open-ils-commits] r18925 - in trunk/Open-ILS/xul/staff_client/chrome: content/cat content/main content/util locale/en-US (phasefx)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Dec 7 11:58:09 EST 2010


Author: phasefx
Date: 2010-12-07 11:58:06 -0500 (Tue, 07 Dec 2010)
New Revision: 18925

Modified:
   trunk/Open-ILS/xul/staff_client/chrome/content/cat/opac.js
   trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js
   trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.js
   trunk/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties
Log:
tab lock infrastructure.  call xulG.lock_tab() and then any attempt to close or replace the tab will give staff a confirmation dialog.  multiple locks may be placed on a given tab, and an identical number of xulG.unlock_tab() invocations will unlock it

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/cat/opac.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/cat/opac.js	2010-12-06 21:16:42 UTC (rev 18924)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/cat/opac.js	2010-12-07 16:58:06 UTC (rev 18925)
@@ -458,6 +458,9 @@
         content_params.new_tab = xulG.new_tab;
         content_params.set_tab = xulG.set_tab;
         content_params.close_tab = xulG.close_tab;
+        content_params.lock_tab = xulG.lock_tab;
+        content_params.unlock_tab = xulG.unlock_tab;
+        content_params.inspect_tab = xulG.inspect_tab;
         content_params.new_patron_tab = xulG.new_patron_tab;
         content_params.set_patron_tab = xulG.set_patron_tab;
         content_params.volume_item_creator = xulG.volume_item_creator;
@@ -582,6 +585,9 @@
         content_params.new_tab = xulG.new_tab;
         content_params.set_tab = xulG.set_tab;
         content_params.close_tab = xulG.close_tab;
+        content_params.lock_tab = xulG.lock_tab;
+        content_params.unlock_tab = xulG.unlock_tab;
+        content_params.inspect_tab = xulG.inspect_tab;
         content_params.new_patron_tab = xulG.new_patron_tab;
         content_params.set_patron_tab = xulG.set_patron_tab;
         content_params.volume_item_creator = xulG.volume_item_creator;

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-06 21:16:42 UTC (rev 18924)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js	2010-12-07 16:58:06 UTC (rev 18925)
@@ -1336,6 +1336,17 @@
     'close_tab' : function (specific_idx) {
         var idx = specific_idx || this.controller.view.tabs.selectedIndex;
         var panel = this.controller.view.panels.childNodes[ idx ];
+
+        var tab = this.controller.view.tabs.getItemAtIndex( idx );
+        var id = tab.getAttribute('id');
+        if (typeof this.tab_semaphores[id] != 'undefined') {
+            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];
+            }
+        }
+
         this.controller.view.tabs.removeItemAt(idx);
         this.controller.view.panels.removeChild(panel);
         if(this.controller.view.tabs.childNodes.length > idx) {
@@ -1588,6 +1599,9 @@
             if (params.src) { help_btn.setAttribute('src', params.src); }
         }
     },
+
+    'tab_semaphores' : {},
+
     'set_tab' : function(url,params,content_params) {
         var obj = this;
         if (!url) url = '/xul/server/';
@@ -1597,10 +1611,44 @@
         var idx = this.controller.view.tabs.selectedIndex;
         if (params && typeof params.index != 'undefined') idx = params.index;
         var tab = this.controller.view.tabs.childNodes[ idx ];
+
+        var id = tab.getAttribute('id');
+        if (id) {
+            if (typeof obj.tab_semaphores[id] != 'undefined') {
+                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];
+                }
+            }
+        }
+        var unique_id = idx + ':' + new Date();
+        tab.setAttribute('id',unique_id);
         if (params.focus) tab.focus();
         var panel = this.controller.view.panels.childNodes[ idx ];
         while ( panel.lastChild ) panel.removeChild( panel.lastChild );
 
+        content_params.lock_tab = function() { 
+            var id = tab.getAttribute('id');
+            if (typeof obj.tab_semaphores[id] == 'undefined') {
+                obj.tab_semaphores[id] = 0;
+            }
+            obj.tab_semaphores[id]++; 
+            return obj.tab_semaphores[id]; 
+        };
+        content_params.unlock_tab = function() { 
+            var id = tab.getAttribute('id');
+            if (typeof obj.tab_semaphores[id] == 'undefined') {
+                obj.tab_semaphores[id] = 0;
+            }
+            obj.tab_semaphores[id]--;
+            if (obj.tab_semaphores[id] < 0) { obj.tab_semaphores[id] = 0; } 
+            return obj.tab_semaphores[id]; 
+        };
+        content_params.inspect_tab = function() {
+            var id = tab.getAttribute('id');
+            return 'id = ' + id + ' semaphore = ' + obj.tab_semaphores[id];
+        }
         content_params.new_tab = function(a,b,c) { return obj.new_tab(a,b,c); };
         content_params.set_tab = function(a,b,c) { return obj.set_tab(a,b,c); };
         content_params.close_tab = function() { return obj.close_tab(); };

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.js	2010-12-06 21:16:42 UTC (rev 18924)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.js	2010-12-07 16:58:06 UTC (rev 18925)
@@ -257,6 +257,10 @@
             cw.xulG = obj.passthru_content_params || {};
             if (!cw.xulG.set_tab) { cw.xulG.set_tab = function(a,b,c) { return window.xulG.set_tab(a,b,c); }; }
             if (!cw.xulG.new_tab) { cw.xulG.new_tab = function(a,b,c) { return window.xulG.new_tab(a,b,c); }; }
+            if (!cw.xulG.close_tab) { cw.xulG.close_tab = function(a) { return window.xulG.close_tab(a); }; }
+            if (!cw.xulG.lock_tab) { cw.xulG.lock_tab = function() { return window.xulG.lock_tab(); }; }
+            if (!cw.xulG.unlock_tab) { cw.xulG.unlock_tab = function() { return window.xulG.unlock_tab(); }; }
+            if (!cw.xulG.inspect_tab) { cw.xulG.inspect_tab = function() { return window.xulG.inspect_tab(); }; }
             if (!cw.xulG.new_patron_tab) { cw.xulG.new_patron_tab = function(a,b) { return window.xulG.new_patron_tab(a,b); }; }
             if (!cw.xulG.set_patron_tab) { cw.xulG.set_patron_tab = function(a,b) { return window.xulG.set_patron_tab(a,b); }; }
             if (!cw.xulG.volume_item_creator) { cw.xulG.volume_item_creator = function(a) { return window.xulG.volume_item_creator(a); }; }

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-06 21:16:42 UTC (rev 18924)
+++ trunk/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties	2010-12-07 16:58:06 UTC (rev 18925)
@@ -280,3 +280,5 @@
 menu.tab8.accesskey=8
 menu.tab9.accesskey=9
 menu.tab10.accesskey=0
+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?



More information about the open-ils-commits mailing list