From df33553f72b3a5a274cc066bd9386aba18cc0bc8 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Mon, 1 Aug 2011 01:40:22 -0400 Subject: [PATCH] robustify (and klunkify) unified volume copy creator Disable/style the Item Editor while changes in the volume/item pane are being considered, and require an explicit press of a Ready Item Editor button to enable the interface. This reduces the chance of editing widgets in the item editor from being ripped out from under you (for example, if you try to go straight from editing a call number to editing an item attribute). Signed-off-by: Jason Etheridge Signed-off-by: Mike Rylander --- Open-ILS/web/opac/locale/en-US/lang.dtd | 2 + .../staff_client/chrome/content/util/widgets.js | 14 ++++++- .../xul/staff_client/server/cat/copy_editor.js | 24 +++++++++++- .../staff_client/server/cat/volume_copy_creator.js | 43 ++++++++++++++++++---- .../server/cat/volume_copy_creator.xul | 5 +++ Open-ILS/xul/staff_client/server/skin/global.css | 3 +- 6 files changed, 79 insertions(+), 12 deletions(-) diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index c76f3a91ec..1c889f8295 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -2877,6 +2877,8 @@ + + diff --git a/Open-ILS/xul/staff_client/chrome/content/util/widgets.js b/Open-ILS/xul/staff_client/chrome/content/util/widgets.js index 2bad0b009f..4867256e9e 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/widgets.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/widgets.js @@ -232,7 +232,19 @@ util.widgets.apply_vertical_tab_on_enter_handler = function(node,onfailure,no_en } } else { if (typeof no_enter_func == 'function') { - no_enter_func(ev); + if ([ + 35 /* end */, + 36 /* home */, + 37 /* left */, + 38 /* up */, + 39 /* right */, + 40 /* down */, + 9 /* tab */ + ].indexOf(ev.keyCode) == -1 + ) { + // really the no_enter, no_arrow_key, no_tab, etc. func :) + no_enter_func(ev); + } } } }, 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 d5018f2d4d..1848feefca 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_editor.js +++ b/Open-ILS/xul/staff_client/server/cat/copy_editor.js @@ -1,5 +1,5 @@ // vim:et:sw=4:ts=4 -var g = {}; +var g = { 'disabled' : false }; g.map_acn = {}; function $(id) { return document.getElementById(id); } @@ -164,8 +164,20 @@ function my_init() { g.check_for_unmet_required_fields(); if (xulG.unified_interface) { + xulG.disable_copy_editor = function(c) { + addCSSClass(document.documentElement,'red_bg'); + g.disabled = true; + } + xulG.enable_copy_editor = function(c) { + removeCSSClass(document.documentElement,'red_bg'); + g.disabled = false; + xulG.refresh_copy_editor(); + } xulG.refresh_copy_editor = function() { + dump('refresh_copy_editor\n'); + addCSSClass(document.documentElement,'blue_bg'); try { + xulG.clear_update_copy_editor_timeout(); g.copies = xulG.copies; g.edit = g.copies.length > 0; if (g.edit) { @@ -179,6 +191,11 @@ function my_init() { g.summarize( g.copies ); g.render(); g.check_for_unmet_required_fields(); + setTimeout( + function() { + removeCSSClass(document.documentElement,'blue_bg'); + }, 1000 + ); } catch(E) { alert('Error in copy_editor.js, xulG.refresh_copy_editor(): ' + E); } @@ -1281,7 +1298,10 @@ g.render_input = function(node,blob) { function on_click(ev){ try { - if (block) return; block = true; + if (block || g.disabled || !g.edit) { + return; + } + block = true; oils_lock_page(); diff --git a/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js b/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js index 5246e9c612..aae4edce1b 100644 --- a/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js +++ b/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js @@ -62,8 +62,29 @@ function my_init() { g.save_button_locked = false; document.getElementById("Create").disabled = false; } + xulG.clear_update_copy_editor_timeout = function() { + if (g.update_copy_editor_timeoutID) { + clearTimeout(g.update_copy_editor_timeoutID); + g.gather_copies(); + } + } + $('Sync').addEventListener( + 'command', + function() { + // give gather_copies_soon fired off directly/indirectly by + // onchange a chance to go first + setTimeout( + function() { + xulG.enable_copy_editor(); + }, + 0 + ); + }, + false + ); } else { $('Create').hidden = true; + $('Sync').hidden = true; } /***********************************************************************************************************/ @@ -283,8 +304,8 @@ g.render_volume_count_entry = function(row,ou_id) { } util.widgets.apply_vertical_tab_on_enter_handler( tb, - function() { render_copy_count_entry({'target':tb}); setTimeout(function(){util.widgets.vertical_tab(tb);},0); }, - g.delay_gather_copies_soon + function() { render_copy_count_entry({'target':tb}); setTimeout(function(){util.widgets.vertical_tab(tb);},0); } + ,function() { $('Sync').disabled = true; } ); tb.addEventListener( 'change', render_copy_count_entry, false); tb.addEventListener( 'change', g.gather_copies_soon, false); @@ -475,11 +496,11 @@ g.render_callnumber_copy_count_entry = function(row,ou_id,count) { util.widgets.vertical_tab(call_number_column_textbox); },0 ); - }, - g.delay_gather_copies_soon + } + ,function() { $('Sync').disabled = true; } ); call_number_column_textbox.addEventListener( 'change', handle_change_to_callnumber_data, false); - call_number_column_textbox.addEventListener( 'change', g.gather_copies_soon, false); + //call_number_column_textbox.addEventListener( 'change', g.gather_copies_soon, false); call_number_column_textbox.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false ); /**** CLASSIFICATION COLUMN revisited ****/ @@ -543,8 +564,8 @@ g.render_callnumber_copy_count_entry = function(row,ou_id,count) { util.widgets.vertical_tab(number_of_copies_column_textbox); },0 ); - }, - g.delay_gather_copies_soon + } + ,function() { $('Sync').disabled = true; } ); number_of_copies_column_textbox.addEventListener( 'change', handle_change_number_of_copies_column_textbox, false); number_of_copies_column_textbox.addEventListener( 'change', g.gather_copies_soon, false); @@ -767,7 +788,7 @@ g.render_barcode_entry = function(node,callnumber_composite_key,count,ou_id) { setTimeout( function() { ev.target.select(); ev.target.focus(); }, 0); } }, false); - tb.addEventListener('change', g.gather_copies_soon, false); + //tb.addEventListener('change', g.gather_copies_soon, false); tb.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false ); } } @@ -830,6 +851,10 @@ g.gather_copies_soon = function(ev) { try { if (!xulG.unified_interface) { return; } dump('g.gather_copies_soon()\n'); + if (typeof xulG.disable_copy_editor == 'function') { + xulG.disable_copy_editor(); + } + $('Sync').disabled = true; if (g.update_copy_editor_timeoutID) { clearTimeout(g.update_copy_editor_timeoutID); } @@ -839,6 +864,8 @@ g.gather_copies_soon = function(ev) { function() { try { g.gather_copies(); + //xulG.enable_copy_editor(); + $('Sync').disabled = false; xulG.refresh_copy_editor(); } catch(E) { dump('Error in volume_copy_editor.js with g.gather_copies_soon setTimeout func(): ' + E + '\n'); diff --git a/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.xul b/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.xul index 5cfc111c9b..00a846f576 100644 --- a/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.xul +++ b/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.xul @@ -121,6 +121,11 @@