[open-ils-commits] r17709 - branches/rel_2_0/Open-ILS/xul/staff_client/server/cat (phasefx)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Sep 15 16:14:56 EDT 2010
Author: phasefx
Date: 2010-09-15 16:14:51 -0400 (Wed, 15 Sep 2010)
New Revision: 17709
Modified:
branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js
Log:
merge r17707-r17708 from trunk for batch call number updates in same UI as batch barcode updates
Modified: branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js 2010-09-15 20:09:34 UTC (rev 17708)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js 2010-09-15 20:14:51 UTC (rev 17709)
@@ -29,16 +29,25 @@
// g.existing_copies = [ copy1, copy2, ... ]
g.existing_copies = xul_param('existing_copies') || [];
+ function set_attr(id,attr,msgcat_key) {
+ var x = $(id);
+ if (x) {
+ x.setAttribute(
+ attr,
+ $('catStrings').getString(msgcat_key)
+ );
+ }
+ }
if (g.existing_copies.length > 0) {
- document.getElementById('EditThenCreate').setAttribute('label',$('catStrings').getString('staff.cat.volume_copy_creator.edit_then_rebarcode.btn.label'));
- document.getElementById('EditThenCreate').setAttribute('accesskey',$('catStrings').getString('staff.cat.volume_copy_creator.edit_then_rebarcode.btn.accesskey'));
- document.getElementById('CreateWithDefaults').setAttribute('label',$('catStrings').getString('staff.cat.volume_copy_creator.rebarcode.btn.label'));
- document.getElementById('CreateWithDefaults').setAttribute('accesskey',$('catStrings').getString('staff.cat.volume_copy_creator.rebarcode.btn.accesskey'));
+ set_attr('EditThenCreate','label','staff.cat.volume_copy_creator.edit_then_rebarcode.btn.label');
+ set_attr('EditThenCreate','accesskey','staff.cat.volume_copy_creator.edit_then_rebarcode.btn.accesskey');
+ set_attr('CreateWithDefaults','label','staff.cat.volume_copy_creator.rebarcode.btn.label');
+ set_attr('CreateWithDefaults','accesskey','staff.cat.volume_copy_creator.rebarcode.btn.accesskey');
} else {
- document.getElementById('EditThenCreate').setAttribute('label',$('catStrings').getString('staff.cat.volume_copy_creator.edit_then_create.btn.label'));
- document.getElementById('EditThenCreate').setAttribute('accesskey',$('catStrings').getString('staff.cat.volume_copy_creator.edit_then_create.btn.accesskey'));
- document.getElementById('CreateWithDefaults').setAttribute('label',$('catStrings').getString('staff.cat.volume_copy_creator.create_with_defaults.btn.label'));
- document.getElementById('CreateWithDefaults').setAttribute('accesskey',$('catStrings').getString('staff.cat.volume_copy_creator.create_with_defaults.btn.accesskey'));
+ set_attr('EditThenCreate','label','staff.cat.volume_copy_creator.edit_then_create.btn.label');
+ set_attr('EditThenCreate','accesskey','staff.cat.volume_copy_creator.edit_then_create.btn.accesskey');
+ set_attr('CreateWithDefaults','label','staff.cat.volume_copy_creator.create_with_defaults.btn.label');
+ set_attr('CreateWithDefaults','accesskey','staff.cat.volume_copy_creator.create_with_defaults.btn.accesskey');
}
//g.error.sdump('D_ERROR','location.href = ' + location.href + '\n\ncopy_short cut = ' + g.copy_shortcut + '\n\nou_ids = ' + xul_param('ou_ids'));
@@ -97,7 +106,7 @@
/***********************************************************************************************************/
/* For the call number drop down */
- if (!g.copy_shortcut) {
+ if (g.existing_copies.length > 0 || !g.copy_shortcut) {
g.list_callnumbers(g.doc_id, label_class);
}
@@ -205,14 +214,16 @@
return;
}
- //if (call_number_column_textbox.disabled || number_of_copies_column_textbox.disabled) return;
+ while (barcode_column_box.childNodes.length > Number(number_of_copies_column_textbox.value)) {
+ barcode_column_box.removeChild( barcode_column_box.lastChild );
+ }
+ g.render_barcode_entry(
+ barcode_column_box,
+ call_number_column_textbox.value,
+ Number(number_of_copies_column_textbox.value),
+ ou_id
+ );
- //call_number_column_textbox.disabled = true;
- //number_of_copies_column_textbox.disabled = true;
-
- util.widgets.remove_children(barcode_column_box);
-
- g.render_barcode_entry(barcode_column_box,call_number_column_textbox.value,Number(number_of_copies_column_textbox.value),ou_id);
document.getElementById("EditThenCreate").disabled = false;
document.getElementById("CreateWithDefaults").disabled = false;
}
@@ -283,7 +294,9 @@
}
call_number_column_textbox.value = label;
handle_change_call_number_column_textbox({'target':call_number_column_textbox});
- call_number_column_textbox.disabled = true;
+ if (g.existing_copies.length < 1) {
+ call_number_column_textbox.disabled = true;
+ }
}
} catch(E) {
alert(E);
@@ -306,32 +319,40 @@
JSAN.use('util.barcode');
for (var i = 0; i < count; i++) {
- var tb = document.createElement('textbox'); node.appendChild(tb);
+ var tb; var set_handlers = false;
+ if (typeof node.childNodes[i] == 'undefined') {
+ tb = document.createElement('textbox'); node.appendChild(tb);
+ set_handlers = true;
+ } else {
+ tb = node.childNodes[i];
+ }
tb.setAttribute('ou_id',ou_id);
tb.setAttribute('callnumber',callnumber);
tb.setAttribute('rel_vert_pos','4');
- if (g.org_label_existing_copy_map[ ou_id ]) {
+ if (!tb.value && g.org_label_existing_copy_map[ ou_id ]) {
tb.value = g.org_label_existing_copy_map[ ou_id ][ callnumber ][i].barcode();
tb.setAttribute('acp_id', g.org_label_existing_copy_map[ ou_id ][ callnumber ][i].id());
tb.select();
if (! g.first_focus) { g.first_focus = tb; }
}
- util.widgets.apply_vertical_tab_on_enter_handler(
- tb,
- function() { ready_to_create({'target':tb}); setTimeout(function(){util.widgets.vertical_tab(tb);},0); }
- );
- tb.addEventListener('change', function(ev) {
- var barcode = String( ev.target.value ).replace(/\s/g,'');
- if (barcode != ev.target.value) ev.target.value = barcode;
- if ($('check_barcodes').checked && ! util.barcode.check(barcode) ) {
- g.error.yns_alert($("catStrings").getFormattedString('staff.cat.volume_copy_creator.render_barcode_entry.alert_message', [barcode]),
- $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_title'),
- $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_ok_button'),null,null,
- $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_confirm'));
- setTimeout( function() { ev.target.select(); ev.target.focus(); }, 0);
- }
- }, false);
- tb.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false );
+ if (set_handlers) {
+ util.widgets.apply_vertical_tab_on_enter_handler(
+ tb,
+ function() { ready_to_create({'target':tb}); setTimeout(function(){util.widgets.vertical_tab(tb);},0); }
+ );
+ tb.addEventListener('change', function(ev) {
+ var barcode = String( ev.target.value ).replace(/\s/g,'');
+ if (barcode != ev.target.value) ev.target.value = barcode;
+ if ($('check_barcodes').checked && ! util.barcode.check(barcode) ) {
+ g.error.yns_alert($("catStrings").getFormattedString('staff.cat.volume_copy_creator.render_barcode_entry.alert_message', [barcode]),
+ $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_title'),
+ $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_ok_button'),null,null,
+ $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_confirm'));
+ setTimeout( function() { ev.target.select(); ev.target.focus(); }, 0);
+ }
+ }, false);
+ tb.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false );
+ }
}
setTimeout( function() { if (g.first_focus) { g.first_focus.focus(); } }, 0 );
@@ -457,7 +478,7 @@
} else {
copy = g.id_copy_map[ acp_id ];
copy.barcode( barcode );
- copy.call_number( copy.call_number().id() );
+ copy.call_number( acn_id );
copy.ischanged('1');
}
copies.push( copy );
@@ -589,7 +610,11 @@
var nl = document.getElementsByTagName('textbox');
for (var i = 0; i < nl.length; i++) {
if (nl[i].getAttribute('rel_vert_pos')==2
- && !nl[i].disabled) nl[i].value = ml.value;
+ && !nl[i].disabled)
+ {
+ nl[i].value = ml.value;
+ util.widgets.dispatch('change',nl[i]);
+ }
}
if (g.last_focus) setTimeout( function() { g.last_focus.focus(); }, 0 );
},
More information about the open-ils-commits
mailing list