From 79011fb361a1c3545e8c6cd66fb1d0f352bb2d5f Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Fri, 11 Mar 2011 06:57:15 -0500 Subject: [PATCH] integrate batch drop downs with templating --- .../xul/staff_client/server/cat/copy_editor.js | 11 ++++ .../staff_client/server/cat/volume_copy_creator.js | 74 ++++++++++++++++++++-- .../server/cat/volume_copy_creator.xul | 3 +- 3 files changed, 83 insertions(+), 5 deletions(-) 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 38fb418582..7daa37c3ba 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_editor.js +++ b/Open-ILS/xul/staff_client/server/cat/copy_editor.js @@ -189,6 +189,9 @@ function my_init() { xulG.unlock_copy_editor = function() { oils_unlock_page(); }; + xulG.notify_of_templatable_field_change = function(id,v) { + g.changed[ 'volume_copy_creator.'+id ] = { 'type' : 'volume_copy_creator', 'field' : id, 'value' : v }; + } } } catch(E) { @@ -280,6 +283,11 @@ g._apply_template = function(name) { case 'owning_lib' : g.apply_owning_lib(template[i].value); break; + case 'volume_copy_creator' : + if (xulG.unified_interface) { + xulG.apply_template_to_batch(template[i].field,template[i].value); + } + break; } } } @@ -451,6 +459,9 @@ g.reset = function() { g.render(); g.check_for_unmet_required_fields(); oils_unlock_page(); + if (xulG.unified_interface) { + xulG.reset_batch_menus(); + } } /******************************************************************************************************/ 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 fc2d39ac5a..9ded72c8e6 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 @@ -33,6 +33,26 @@ function my_init() { if (xulG.unified_interface) { $('non_unified_buttons').hidden = true; + xulG.reset_batch_menus = function() { + $('batch_class_menulist').value = false; + util.widgets.dispatch('command',$('batch_class_menulist')); + $('batch_prefix_menulist').value = false; + util.widgets.dispatch('command',$('batch_prefix_menulist')); + $('batch_suffix_menulist').value = false; + util.widgets.dispatch('command',$('batch_suffix_menulist')); + } + xulG.apply_template_to_batch = function(id,value) { + if (!isNaN(Number(value))) { + $(id).value = value; + util.widgets.dispatch('command',$(id)); + } + setTimeout( + function() { + // TODO: Only apply batch to columns that haven't been adjusted manually? + util.widgets.dispatch('command',$('batch_button')); + },0 + ); + } } else { $('Create').hidden = true; } @@ -1290,6 +1310,21 @@ g.list_classes = function() { ) ) ); hbox.appendChild(ml); + ml.setAttribute('id','batch_class_menulist'); + ml.addEventListener( + 'command', + function() { + if (!isNaN(Number(ml.value))) { + addCSSClass(hbox,'copy_editor_field_changed'); + if (xulG.unified_interface) { + xulG.notify_of_templatable_field_change('batch_class_menulist',ml.value); + } + } else { + removeCSSClass(hbox,'copy_editor_field_changed'); + } + }, + false + ); } g.list_prefixes = function() { @@ -1302,6 +1337,21 @@ g.list_prefixes = function() { for (var i = 0; i < g.common_ancestor_ou_ids.length; i++) { g.render_prefix_menu_items(ml.firstChild,g.common_ancestor_ou_ids[i]); } + ml.setAttribute('id','batch_prefix_menulist'); + ml.addEventListener( + 'command', + function() { + if (!isNaN(Number(ml.value))) { + addCSSClass(hbox,'copy_editor_field_changed'); + if (xulG.unified_interface) { + xulG.notify_of_templatable_field_change('batch_prefix_menulist',ml.value); + } + } else { + removeCSSClass(hbox,'copy_editor_field_changed'); + } + }, + false + ); } g.list_suffixes = function() { @@ -1314,11 +1364,27 @@ g.list_suffixes = function() { for (var i = 0; i < g.common_ancestor_ou_ids.length; i++) { g.render_suffix_menu_items(ml.firstChild,g.common_ancestor_ou_ids[i]); } + ml.setAttribute('id','batch_suffix_menulist'); + ml.addEventListener( + 'command', + function() { + if (!isNaN(Number(ml.value))) { + addCSSClass(hbox,'copy_editor_field_changed'); + if (xulG.unified_interface) { + xulG.notify_of_templatable_field_change('batch_suffix_menulist',ml.value); + } + } else { + removeCSSClass(hbox,'copy_editor_field_changed'); + } + }, + false + ); } g.render_batch_button = function() { - var hbox = $('batch_button'); + var hbox = $('batch_button_box'); var btn = document.createElement('button'); + btn.setAttribute('id','batch_button'); btn.setAttribute('label',$('catStrings').getString('staff.cat.volume_copy_creator.my_init.btn.label')); btn.setAttribute('accesskey',$('catStrings').getString('staff.cat.volume_copy_creator.my_init.btn.accesskey')); btn.setAttribute('image','/xul/server/skin/media/images/down_arrow.gif'); @@ -1341,7 +1407,7 @@ g.render_batch_button = function() { for (var i = 0; i < nl.length; i++) { /* classification */ if (nl[i].getAttribute('rel_vert_pos')==rel_vert_pos_call_number_classification && !nl[i].disabled) { - var value = $('batch_class').firstChild.value; + var value = $('batch_class_menulist').value; if (!isNaN( Number(value) )) { nl[i].value = value; util.widgets.dispatch('command',nl[i]); @@ -1349,7 +1415,7 @@ g.render_batch_button = function() { } /* prefix */ if (nl[i].getAttribute('rel_vert_pos')==rel_vert_pos_call_number_prefix && !nl[i].disabled) { - var value = $('batch_prefix').firstChild.value; + var value = $('batch_prefix_menulist').value; if (!isNaN( Number(value) )) { nl[i].value = value; util.widgets.dispatch('command',nl[i]); @@ -1357,7 +1423,7 @@ g.render_batch_button = function() { } /* suffix */ if (nl[i].getAttribute('rel_vert_pos')==rel_vert_pos_call_number_suffix && !nl[i].disabled) { - var value = $('batch_suffix').firstChild.value; + var value = $('batch_suffix_menulist').value; if (!isNaN( Number(value) )) { nl[i].value = value; util.widgets.dispatch('command',nl[i]); 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 0d4338f10a..88559f3d84 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 @@ -6,6 +6,7 @@ + @@ -56,7 +57,7 @@