From a4a165787fd88b6c3f1db8221c4d591c13b8d815 Mon Sep 17 00:00:00 2001 From: Liam Whalen Date: Sat, 28 Jun 2014 13:52:45 -0700 Subject: [PATCH] LP1282277 & LP1282286 Fixed error with Copy Editor With the previous fix applied, it is impossible to edit values within the copy editor. A javascript error occurs. This commit fixes that problem. Signed-off-by: Liam Whalen Signed-off-by: Jennifer Pringle Signed-off-by: Ben Shum --- .../chrome/content/OpenILS/global_util.js | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 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 655008f415..5df577168a 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 @@ -6,16 +6,27 @@ function oils_unsaved_data_V() { 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]; + } + JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve(); data.stash_retrieve(); if (typeof data.unsaved_data == 'undefined') { data.unsaved_data = 0; } - //We allow unsaved data to be incremented only a single time from marc edit - if (tab.marc_edit_allow_multiple_locks || tab.in_marc_edit == false) { + //If there are tabs, we allow unsaved data to be incremented only a single time from marc edit. + //If there are not tabs, then we are in a new window like the Copy Editor (so retain original locking). + if (tab) { + if (tab.marc_edit_allow_multiple_locks || tab.in_marc_edit == false) { + data.unsaved_data++; + window.oils_lock++; + } + } else { data.unsaved_data++; window.oils_lock++; } + data.stash('unsaved_data'); dump('\n=-=-=-=-=\n'); dump('oils_unsaved_data_V for ' + location.href + '\n'); @@ -26,9 +37,6 @@ } function oils_unsaved_data_P(count) { - var tabs = window.parent.parent.document.getElementById('main_tabs'); - var idx = tabs.selectedIndex; - var tab = tabs.childNodes[idx]; dump('\n=-=-=-=-=\n'); dump('oils_unsaved_data_P for ' + location.href + '\n'); if (!count) { count = 1; } @@ -56,8 +64,12 @@ } } 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]; + } + if (typeof xulG != 'undefined') { if (typeof xulG.unlock_tab == 'function') { dump('\twith xulG.lock_tab\n'); @@ -65,6 +77,8 @@ //make sure we are not in the marc edit window var marceditRe = /\/marcedit.xul$/; 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; } @@ -83,10 +97,7 @@ function oils_unlock_page(params) { dump('\n=-=-=-=-=\n'); dump('oils_unlock_page for ' + location.href + '\n'); - var marceditRe = /\/marcedit.xul$/; - var tabs = window.parent.parent.document.getElementById('main_tabs'); - var idx = tabs.selectedIndex; - var tab = tabs.childNodes[idx]; + if (typeof xulG != 'undefined') { if (typeof xulG.unlock_tab == 'function') { dump('\twith xulG.unlock_tab\n'); -- 2.43.2