From 3778bb02a99edf36409b38b642c56921911cb97b Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Fri, 4 Mar 2011 02:29:56 -0500 Subject: [PATCH] create part button --- .../staff_client/server/cat/volume_copy_creator.js | 72 +++++++++++++++++++--- .../server/locale/en-US/cat.properties | 1 + 2 files changed, 64 insertions(+), 9 deletions(-) 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 b468b0cd8b..4c151c8f55 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 @@ -115,11 +115,11 @@ function my_init() { get_contentWindow(summary).xulG = { 'docid' : g.doc_id }; /***********************************************************************************************************/ - /* Fetch the monographic parts for this bib */ + /* Setup pcrud and fetch the monographic parts for this bib */ dojo.require('openils.PermaCrud'); - var pcrud = new openils.PermaCrud({'authtoken':ses()}); - g.parts = pcrud.search('bmp',{'record':g.doc_id},{'order_by': { 'bmp' : 'label_sortkey' } }); + g.pcrud = new openils.PermaCrud({'authtoken':ses()}); + g.parts = g.pcrud.search('bmp',{'record':g.doc_id},{'order_by': { 'bmp' : 'label_sortkey' } }); /***********************************************************************************************************/ /* For the call number drop down */ @@ -364,16 +364,70 @@ g.render_callnumber_copy_count_entry = function(row,ou_id,count) { } g.render_part_menu = function() { + var hbox = document.createElement('hbox'); var menulist = document.createElement('menulist'); - menulist.setAttribute('editable','true'); + menulist.setAttribute('editable','true'); + hbox.appendChild(menulist); + var button = document.createElement('button'); + button.setAttribute('label',$('catStrings').getString('staff.cat.volume_copy_creator.create_part.btn.label')); + button.hidden = true; + hbox.appendChild(button); + var menupopup = document.createElement('menupopup'); - menulist.appendChild(menupopup); + menulist.appendChild(menupopup); + g.render_part_menuitems(menupopup); + + button.addEventListener( + 'command', + function(ev) { + var new_part = new bmp(); + new_part.isnew(1); + new_part.label(menulist.value); + new_part.record(g.doc_id); + g.pcrud.create(new_part); + // FIXME - is the following authoritative with a replicated database? + g.parts = g.pcrud.search('bmp',{'record':g.doc_id},{'order_by': { 'bmp' : 'label_sortkey' } }); + g.render_part_menuitems(menupopup); + if (menulist.selectedItem) { + button.hidden = true; + } + }, + false + ); + + menulist.addEventListener( + 'change', + function(ev) { + if (! ev.target.selectedItem) { + button.hidden = false; + } + }, + false + ); + menulist.addEventListener( + 'command', + function(ev) { + button.hidden = true; + }, + false + ); + + return hbox; +} + +g.render_part_menuitems = function(menupopup) { + util.widgets.remove_children(menupopup); + var menuitem = document.createElement('menuitem'); + menuitem.setAttribute('label',''); + menuitem.setAttribute('value',''); + menupopup.appendChild(menuitem); for (var i = 0; i < g.parts.length; i++) { var menuitem = document.createElement('menuitem'); menuitem.setAttribute('label',g.parts[i].label()); + menuitem.setAttribute('value',g.parts[i].id()); menupopup.appendChild(menuitem); } - return menulist; + } g.render_barcode_entry = function(node,callnumber,count,ou_id) { @@ -410,7 +464,7 @@ g.render_barcode_entry = function(node,callnumber,count,ou_id) { tb.setAttribute('ou_id',ou_id); tb.setAttribute('callnumber',callnumber); tb.setAttribute('rel_vert_pos','4'); - part_menu.setAttribute('rel_vert_pos','5'); + part_menu.firstChild.setAttribute('rel_vert_pos','5'); 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()); @@ -427,8 +481,8 @@ g.render_barcode_entry = function(node,callnumber,count,ou_id) { function() { ready_to_create({'target':tb}); setTimeout(function(){util.widgets.vertical_tab(tb);},0); } ); util.widgets.apply_vertical_tab_on_enter_handler( - part_menu, - function() { setTimeout(function(){util.widgets.vertical_tab(part_menu);},0); } + part_menu.firstChild, + function() { setTimeout(function(){util.widgets.vertical_tab(part_menu.firstChild);},0); } ); tb.addEventListener('change', function(ev) { var barcode = String( ev.target.value ).replace(/\s/g,''); diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties index 1195262b28..5228b6dc67 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties @@ -392,6 +392,7 @@ staff.cat.util.mark_item_missing_pieces.circ_not_found=No circulation found for staff.cat.volume_buckets.window_tab_name=Volume Buckets staff.cat.volume_copy_creator.my_init.btn.label=Apply staff.cat.volume_copy_creator.my_init.btn.accesskey=A +staff.cat.volume_copy_creator.create_part.btn.label=Create Part Designator staff.cat.volume_copy_creator.edit_then_create.btn.label=Edit then Create staff.cat.volume_copy_creator.edit_then_create.btn.accesskey=C staff.cat.volume_copy_creator.create_with_defaults.btn.label=Create with Defaults -- 2.11.0