From: Liam Whalen Date: Sun, 13 Jul 2014 17:49:07 +0000 (-0700) Subject: LP1282277_LP1282286_Unitialized_Vars_FIx X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4a9c694863cb43d4ead2093f04265fc3eedabc1b;p=working%2FEvergreen.git LP1282277_LP1282286_Unitialized_Vars_FIx The commit to prompt users if they are going to lose data in MARC edit added some new variables (tabs, and tab) in various files. If the MARC edit window does not appear in a tab, then these variables remain unitialzed and cause problems for MARC edits that appear in their own window. By checking for the existence of the variables before MARC edito loads in its own windown, the problems are resolved. Signed-off-by: Liam Whalen --- 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 5df577168a..10432aea1c 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 @@ -79,8 +79,10 @@ if (marceditRe.exec(window.document.location)) { //We do not have to check for tab here because //the MARC editor is explicitly in a tabbed window - tab.marc_edit_changed = true; - tab.marc_edit_allow_multiple_locks = false; + if (tab) { + tab.marc_edit_changed = true; + tab.marc_edit_allow_multiple_locks = false; + } } window.oils_lock++; // different window scope than the chrome of xulG.lock_tab } else { diff --git a/Open-ILS/xul/staff_client/chrome/content/cat/opac.js b/Open-ILS/xul/staff_client/chrome/content/cat/opac.js index a765a69e13..673eede35d 100644 --- a/Open-ILS/xul/staff_client/chrome/content/cat/opac.js +++ b/Open-ILS/xul/staff_client/chrome/content/cat/opac.js @@ -61,9 +61,11 @@ function default_focus() { function opac_wrapper_set_help_context() { try { var tabs = window.parent.document.getElementById('main_tabs'); - var idx = tabs.selectedIndex; - var tab = tabs.childNodes[idx]; - tab.in_marc_edit = false; + if (tabs) { + var idx = tabs.selectedIndex; + var tab = tabs.childNodes[idx]; + tab.in_marc_edit = false; + } dump('Entering opac.js, opac_wrapper_set_help_context\n'); var cw = bottom_pane.get_contentWindow(); if (cw && typeof cw['location'] != 'undefined') { @@ -84,7 +86,9 @@ function opac_wrapper_set_help_context() { } var marceditRe = /\/marcedit.xul$/; if (marceditRe.exec(cw.location)) { - tab.in_marc_edit = true; + if (tab) { + tab.in_marc_edit = true; + } } } else { dump('opac.js: problem in opac_wrapper_set_help_context(): bottom_pane = ' + bottom_pane + ' cw = ' + cw + '\n'); @@ -1180,12 +1184,14 @@ function record_action(action_function) { var args = Array.prototype.slice.call(arguments, 1); if (action_function.name == 'set_marc_edit') { var tabs = window.parent.document.getElementById('main_tabs'); - var idx = tabs.selectedIndex; - var tab = tabs.childNodes[idx]; + if (tabs) { + var idx = tabs.selectedIndex; + var tab = tabs.childNodes[idx]; - if (tab.marc_edit_changed) { - xulG.lock_tab(); - tab.marc_edit_allow_multiple_locks = false; + if (tab.marc_edit_changed) { + xulG.lock_tab(); + tab.marc_edit_allow_multiple_locks = false; + } } } @@ -1203,32 +1209,35 @@ function safe_to_proceed() { var marc_edit_changed; var tabs = window.parent.document.getElementById('main_tabs'); - var idx = tabs.selectedIndex; - var tab = tabs.childNodes[idx]; - in_marc_edit = tab.in_marc_edit; - marc_edit_changed = tab.marc_edit_changed; + if (tabs) { + var idx = tabs.selectedIndex; + var tab = tabs.childNodes[idx]; - if ((in_marc_edit != true) || (marc_edit_changed != true)) { - if (typeof xulG.is_tab_locked == 'undefined') { return true; } - if (! xulG.is_tab_locked()) { return true; } - } - var r = window.confirm( - document.getElementById('offlineStrings').getString( - 'generic.unsaved_data_warning' - ) - ); + in_marc_edit = tab.in_marc_edit; + marc_edit_changed = tab.marc_edit_changed; - //If we are confirming from within MARC edit then - //drop the tab locks. Otherwise the locks get dropped - //in cmd_search_tcn - if (r) { - if (typeof xulG.unlock_tab === 'function') { - while ( xulG.unlock_tab() > 0 ) {}; + if ((in_marc_edit != true) || (marc_edit_changed != true)) { + if (typeof xulG.is_tab_locked == 'undefined') { return true; } + if (! xulG.is_tab_locked()) { return true; } } + var r = window.confirm( + document.getElementById('offlineStrings').getString( + 'generic.unsaved_data_warning' + ) + ); - return true; - } else { - return false; + //If we are confirming from within MARC edit then + //drop the tab locks. Otherwise the locks get dropped + //in cmd_search_tcn + if (r) { + if (typeof xulG.unlock_tab === 'function') { + while ( xulG.unlock_tab() > 0 ) {}; + } + + return true; + } else { + return false; + } } } diff --git a/Open-ILS/xul/staff_client/server/cat/marcedit.js b/Open-ILS/xul/staff_client/server/cat/marcedit.js index 691eeaacd8..922fe6f65e 100644 --- a/Open-ILS/xul/staff_client/server/cat/marcedit.js +++ b/Open-ILS/xul/staff_client/server/cat/marcedit.js @@ -567,8 +567,11 @@ function setFocusToNextTag (row, direction) { function set_lock_on_keypress(ev) { try { var tabs = window.parent.parent.document.getElementById('main_tabs'); - var idx = tabs.selectedIndex; - var tab = tabs.childNodes[idx]; + + if (tabs) { + var idx = tabs.selectedIndex; + var tab = tabs.childNodes[idx]; + } //dump('keypress: isChar = ' + ev.isChar + ' char = ' + ev.char + ' charCode = ' + ev.charCode + ' key = ' + ev.key + ' keyCode = ' + ev.keyCode + '\n'); if (! /* NOT */( ev.altKey @@ -1217,15 +1220,20 @@ function fastItemAdd_attempt(doc_id) { function save_attempt(xml_string) { try { var tabs = window.parent.parent.document.getElementById('main_tabs'); - var idx = tabs.selectedIndex; - var tab = tabs.childNodes[idx]; + + if (tabs) { + var idx = tabs.selectedIndex; + var tab = tabs.childNodes[idx]; + } var result = window.xulG.save.func( xml_string ); // I'd prefer to pass on_complete on through to fast_item_add, // but with the way these window scopes get destroyed with // tab replacement, maybe not a good idea var replace_on_complete = false; if (result) { - tab.marc_edit_changed = false; + if (tab) { + tab.marc_edit_changed = false; + } oils_unlock_page(); if (result.id) { replace_on_complete = fastItemAdd_attempt(result.id); @@ -1350,10 +1358,13 @@ function marcSubfield (sf) { function loadRecord() { try { var tabs = window.parent.parent.document.getElementById('main_tabs'); - var idx = tabs.selectedIndex; - var tab = tabs.childNodes[idx]; - tab.marc_edit_changed = false; - tab.marc_edit_allow_multiple_locks = true; + + if (tabs) { + var idx = tabs.selectedIndex; + var tab = tabs.childNodes[idx]; + tab.marc_edit_changed = false; + tab.marc_edit_allow_multiple_locks = true; + } var grid_rows = document.getElementById('recGrid').lastChild;