Wire up the Item Attribute Editor with oils_lock_page. Some tweaks needed to global_...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 7 Dec 2010 16:58:24 +0000 (16:58 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 7 Dec 2010 16:58:24 +0000 (16:58 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@18929 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js
Open-ILS/xul/staff_client/server/cat/copy_editor.js
Open-ILS/xul/staff_client/server/cat/copy_editor.xul

index 54d8665..c207eb9 100644 (file)
@@ -1,6 +1,7 @@
     function $(id) { return document.getElementById(id); }
 
     function oils_lock_page(params) {
+        dump('oils_lock_page\n');
         if (!params) { params = {}; }
         if (window.oils_lock) {
             if (!params.allow_multiple_locks) {
@@ -17,6 +18,7 @@
     }
 
     function oils_unlock_page(params) {
+        dump('oils_unlock_page\n');
         window.oils_lock = false;
         if (typeof xulG != 'undefined') {
             if (typeof xulG.unlock_tab == 'function') {
@@ -29,7 +31,8 @@
     window.addEventListener(
         'close',
         function(ev) {
-
+            try {
+                dump('oils_lock_page/oils_unlock_page onclose handler\n');
                 if (window.oils_lock) {
                     var confirmation = window.confirm($('offlineStrings').getString('menu.close_window.unsaved_data_warning'));
                     if (!confirmation) {
                     }
                 }
 
+                // Dispatching the window close event doesn't always close the window, even though the event does happen
+                setTimeout(
+                    function() {
+                        try {
+                            window.close();
+                        } catch(E) {
+                            dump('Error inside global_util.js, onclose handler, setTimeout window.close KLUDGE: ' + E + '\n');
+                        }
+                    }, 0
+                );
+
                 return true;
+            } catch(E) {
+                dump('Error inside global_util.js, onclose handler: ' + E + '\n');
+                return true;
+            }
         },
         false
     );
index 5fd09ae..5332fb7 100644 (file)
@@ -388,6 +388,7 @@ g.reset = function() {
     g.summarize( g.copies );
     g.render();
     g.check_for_unmet_required_fields();
+    oils_unlock_page();
 }
 
 /******************************************************************************************************/
@@ -414,6 +415,8 @@ g.apply = function(field,value) {
             alert(E);
         }
     }
+
+    oils_lock_page();
 }
 
 /******************************************************************************************************/
@@ -447,6 +450,8 @@ g.apply_stat_cat = function(sc_id,entry_id) {
             g.error.standard_unexpected_error_alert('apply_stat_cat',E);
         }
     }
+
+    oils_lock_page();
 }
 
 /******************************************************************************************************/
@@ -480,6 +485,8 @@ g.apply_owning_lib = function(ou_id) {
             g.error.standard_unexpected_error_alert('apply_stat_cat',E);
         }
     }
+
+    oils_lock_page();
 }
 
 /******************************************************************************************************/
@@ -1262,6 +1269,8 @@ g.render_input = function(node,blob) {
 
 g.stash_and_close = function() {
     try {
+        oils_unlock_page();
+
         if (g.handle_update) {
             try {
                 var r = g.network.request(
@@ -1281,9 +1290,10 @@ g.stash_and_close = function() {
         //g.data.stash('temp_copies');
         xulG.copies = g.copies;
         update_modal_xulG(xulG);
-        window.close();
+        JSAN.use('util.widgets');
+        util.widgets.dispatch('close',window);
     } catch(E) {
-        g.error.standard_unexpected_error_alert('stash and close',E);
+        alert('Error in copy_editor.js, g.stash_and_close(): '+E);
     }
 }
 
index 3fa2ba2..a456da4 100644 (file)
@@ -89,7 +89,7 @@
             <spacer flex="1"/>
             <button id="copy_notes" label="&staff.cat.copy_editor.copy_notes.label;" accesskey="&staff.cat.copy_editor.copy_notes.accesskey;" oncommand="g.copy_notes();"/>
             <button id="save" label="&staff.cat.copy_editor.save.label;" hidden="true" accesskey="&staff.cat.copy_editor.save.accesskey;" oncommand="g.stash_and_close();"/>
-            <button id="cancel" label="&staff.cat.copy_editor.cancel.label;" accesskey="&staff.cat.copy_editor.cancel.accesskey;" oncommand="window.close();"/>
+            <button id="cancel" label="&staff.cat.copy_editor.cancel.label;" accesskey="&staff.cat.copy_editor.cancel.accesskey;" oncommand="JSAN.use('util.widgets'); util.widgets.dispatch('close',window);"/>
         </hbox>
 
         <spacer/>