g.map_acn = {};
function $(id) { return document.getElementById(id); }
+function $_(x) { return $('catStrings').getString(x); }
function my_init() {
try {
$('catStrings').getString('staff.cat.copy_editor.field.barcode.label'),
{
render: 'fm.barcode();',
+ input:
+ 'c = function (v) {'
+ + 'g.apply("barcode", v);'
+ + 'if (typeof post_c === "function") post_c(v);'
+ + '};'
+ + 'x = document.createElement("textbox");',
+ attr: { 'class': 'disabled' },
}
],
[
groupbox.setAttribute('style','');
}
- vbox.addEventListener('mouseover',on_mouseover,false);
- vbox.addEventListener('mouseout',on_mouseout,false);
groupbox.addEventListener('mouseover',on_mouseover,false);
groupbox.addEventListener('mouseout',on_mouseout,false);
- groupbox.firstChild.addEventListener('mouseover',on_mouseover,false);
- groupbox.firstChild.addEventListener('mouseout',on_mouseout,false);
function on_click(ev){
try {
- if (block || g.disabled || !g.edit) {
+ if (block || g.disabled || !g.edit || ev.currentTarget.classList.contains('disabled')) {
return;
}
block = true;
g.error.standard_unexpected_error_alert('render_input',E);
}
}
- vbox.addEventListener('click',on_click, false);
- hbox.addEventListener('click',on_click, false);
- caption.addEventListener('click',on_click, false);
- caption.addEventListener('keypress',function(ev) {
+ groupbox.addEventListener('click',on_click, false);
+ groupbox.addEventListener('keypress',function(ev) {
if (ev.keyCode == 13 /* enter */ || ev.keyCode == 77 /* mac enter */) on_click();
}, false);
caption.setAttribute('style','-moz-user-focus: normal');
/* store the copies in the global xpcom stash */
g.stash_and_close = function() {
+ var r = {textcode: ''};
try {
oils_unlock_page();
if (g.handle_update) {
try {
- var r = g.network.request(
+ r = g.network.request(
api.FM_ACP_FLESHED_BATCH_UPDATE.app,
api.FM_ACP_FLESHED_BATCH_UPDATE.method,
[ ses(), g.copies, true ]
);
- if (typeof r.ilsevent != 'undefined') {
+ if (r.textcode === 'ITEM_BARCODE_EXISTS') {
+ alert('error with item update: ' + r.desc);
+ var barcode = $($_('staff.cat.copy_editor.field.barcode.label'));
+ barcode.parentNode.classList.remove('disabled');
+ barcode.click();
+ }
+ else if (typeof r.ilsevent !== 'undefined') {
g.error.standard_unexpected_error_alert('copy update',r);
}
/* FIXME -- revisit the return value here */
//g.data.temp_copies = js2JSON( g.copies );
//g.data.stash('temp_copies');
xulG.copies = g.copies;
- JSAN.use('util.widgets');
- util.widgets.dispatch('close',window);
+ if (r.textcode !== 'ITEM_BARCODE_EXISTS') {
+ JSAN.use('util.widgets');
+ util.widgets.dispatch('close',window);
+ }
} catch(E) {
alert('Error in copy_editor.js, g.stash_and_close(): '+E);
}
var label_editor_func;
if (copies.length > 0) {
- if (param == 'edit') {
+ if (param === 'edit') {
JSAN.use('cat.util');
- copies = cat.util.spawn_copy_editor( { 'edit' : true, 'docid' : g.doc_id, 'copies' : copies, 'caller_handles_update' : true });
+ copies = cat.util.spawn_copy_editor({
+ 'edit' : true
+ , 'docid' : g.doc_id
+ , 'copies' : copies
+ , 'caller_handles_update' : false
+ });
}
- if (typeof xul_param('update_copy') == 'function') {
- xul_param('update_copy')(copies);
- } else {
- var r = g.network.simple_request(
- 'FM_ACP_FLESHED_BATCH_UPDATE',
- [ ses(),copies, true ]
- );
- if (typeof r.ilsevent != 'undefined') {
- alert('error with copy update:' + js2JSON(r));
+ else {
+ if (typeof xul_param('update_copy') === 'function') {
+ xul_param('update_copy')(copies);
+ } else {
+ var r = g.network.simple_request(
+ 'FM_ACP_FLESHED_BATCH_UPDATE',
+ [ ses(),copies, true ]
+ );
+ if (r.textcode === 'ITEM_BARCODE_EXISTS') {
+ alert('error with item update: ' + r.desc);
+ dont_close = true;
+ }
+ else if (typeof r.ilsevent != 'undefined') {
+ alert('error with copy update:' + js2JSON(r));
+ }
}
}
try {