From: Liam Whalen Date: Thu, 13 Mar 2014 17:37:25 +0000 (-0700) Subject: LP1282277 & LP1282286 MARC edit TCN search lose data prompts X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=8de316bcfe597ef3ce02275c2ab6b47b38825866;p=working%2FEvergreen.git LP1282277 & LP1282286 MARC edit TCN search lose data prompts This commit modifies my previous commits. The code now uses the previous versions code to mark a tab as locked and to record that data is saved or not saved. However, when a user returns to the MARC edit screen, if there are changes still present, then the code now locks the tab again and records that there is unsaved data. This should allow all previous functionality to remain while providing the proper warnings when within the MARC editor. --- 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 79152f72b1..96688d0607 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 @@ -11,7 +11,7 @@ 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 a single time from marc edit + //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) { data.unsaved_data++; window.oils_lock++; @@ -37,17 +37,13 @@ //because we might come back and edit it later, and the window.oils_lock //prevents us from closing the window and losing data. If the marc //data is not changed and we have a window lock, then we can decerment it - if (tab.in_marc_edit == false || tab.marc_edit_changed == false) { - window.oils_lock -= count; - if (window.oils_lock < 0) { window.oils_lock = 0; } - } + window.oils_lock -= count; + if (window.oils_lock < 0) { window.oils_lock = 0; } 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; } dump('decrementing data.unsaved_data by ' + count + '\n'); - if (tab.in_marc_edit == false || tab.marc_edit_changed == false) { - data.unsaved_data -= count; - } + data.unsaved_data -= count; if (data.unsaved_data < 0) { data.unsaved_data = 0; } data.stash('unsaved_data'); dump('\twindow.oils_lock == ' + window.oils_lock + '\n'); 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 70154d5fb0..a765a69e13 100644 --- a/Open-ILS/xul/staff_client/chrome/content/cat/opac.js +++ b/Open-ILS/xul/staff_client/chrome/content/cat/opac.js @@ -1178,6 +1178,17 @@ function gen_statusbar_click_handler(data_key) { function record_action(action_function) { if (safe_to_proceed()) { 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 (tab.marc_edit_changed) { + xulG.lock_tab(); + tab.marc_edit_allow_multiple_locks = false; + } + } + return action_function.apply(null, args); } } diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu.js b/Open-ILS/xul/staff_client/chrome/content/main/menu.js index b8836fc7bb..711fe84355 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -423,6 +423,8 @@ main.menu.prototype = { if (typeof obj.tab_semaphores[id] != 'undefined') { if (obj.tab_semaphores[id] > 0) { + //If confirmation has not been defined yet + //make sure we prompt for possible loss of data if (typeof confirmation == undefined) { confirmation = window.confirm(offlineStrings.getString('menu.replace_tab.unsaved_data_warning')); } @@ -2469,14 +2471,18 @@ commands: obj.tab_semaphores[id] = 0; } - //If we are in marc edit, then unlock is only calld when saving - //the edits. So, drop all locks in this case. - //Otherwise leave the code as is because I am not sure how other parts - if (tab.in_marc_edit) { - obj.tab_semaphores[id] = 0; - } else { - obj.tab_semaphores[id]--; - } + //If we are in marc edit, then unlock is only calld when saving + //the edits. So, drop all locks in this case. + //Otherwise leave the code as is because I am not sure how other parts + //of the staff client interact with the tab locking + if (tab.in_marc_edit) { + obj.tab_semaphores[id] = 0; + //allow multiple locks again, so if we + //return to marc edit we can put a lock on it again + tab.marc_edit_allow_multiple_locks = true; + } else { + obj.tab_semaphores[id]--; + } if (obj.tab_semaphores[id] < 0) { obj.tab_semaphores[id] = 0; } oils_unsaved_data_P(); return obj.tab_semaphores[id];