From da6af978e37f6bd7be55de4d2128797f09c1098b Mon Sep 17 00:00:00 2001 From: phasefx Date: Tue, 7 Dec 2010 16:58:24 +0000 Subject: [PATCH] Wire up the Item Attribute Editor with oils_lock_page. Some tweaks needed to global_util.js for util.widgets.dispatch('close',window) to work. git-svn-id: svn://svn.open-ils.org/ILS/trunk@18929 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../chrome/content/OpenILS/global_util.js | 20 +++++++++++++++++++- Open-ILS/xul/staff_client/server/cat/copy_editor.js | 14 ++++++++++++-- Open-ILS/xul/staff_client/server/cat/copy_editor.xul | 2 +- 3 files changed, 32 insertions(+), 4 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 54d8665b5..c207eb9a9 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,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) { @@ -45,7 +48,22 @@ } } + // 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 ); diff --git a/Open-ILS/xul/staff_client/server/cat/copy_editor.js b/Open-ILS/xul/staff_client/server/cat/copy_editor.js index 5fd09ae71..5332fb7f1 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_editor.js +++ b/Open-ILS/xul/staff_client/server/cat/copy_editor.js @@ -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); } } diff --git a/Open-ILS/xul/staff_client/server/cat/copy_editor.xul b/Open-ILS/xul/staff_client/server/cat/copy_editor.xul index 3fa2ba268..a456da43b 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_editor.xul +++ b/Open-ILS/xul/staff_client/server/cat/copy_editor.xul @@ -89,7 +89,7 @@