From: Jason Etheridge Date: Tue, 20 Mar 2012 20:52:13 +0000 (-0400) Subject: reworked toolbars for dynamism X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=5785841ead89c506102c236fd57d766b7dde259d;p=evergreen%2Fjoelewis.git reworked toolbars for dynamism uses the data from action.toolbar also a Toolbar Configuration UI also added more toolbar buttons, though they need icons Signed-off-by: Jason Etheridge Signed-off-by: Thomas Berezansky --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 28f8ee3e1b..484c1ed7c7 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -2795,7 +2795,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - + diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index a20ea1f4aa..7acd10d83e 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -190,6 +190,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -664,9 +684,6 @@ - - - @@ -846,6 +863,8 @@ + + diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js index cf31b799b7..f31ab3e574 100644 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js +++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js @@ -973,6 +973,40 @@ OpenILS.data.prototype = { this.chain.push( function() { var f = gen_fm_retrieval_func( + 'atb', + [ + api.FM_ATB_RETRIEVE_VIA_PCRUD.app, + api.FM_ATB_RETRIEVE_VIA_PCRUD.method, + [ + obj.session.key, + { + "-or": [ + { "ws" : obj.list.au[0].wsid() }, + { "usr" : obj.list.au[0].id() }, + { "org" : util.functional.map_list( obj.list.my_aou, function(o) { return o.id(); } ) } + ] + }, + { + "order_by":{"atb":"label"} + } + ], + false + ] + ); + try { + f(); + } catch(E) { + var error = 'Error: ' + js2JSON(E); + obj.error.sdump('D_ERROR',error); + throw(E); + } + } + ); + + + this.chain.push( + function() { + var f = gen_fm_retrieval_func( 'acnp', [ api.FM_ACNP_RETRIEVE_VIA_PCRUD.app, diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index eea83a4aa4..6bc4d44868 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -100,6 +100,7 @@ var api = { 'FM_ACNC_RETRIEVE_VIA_PCRUD' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.search.acnc.atomic' }, 'FM_ACNP_RETRIEVE_VIA_PCRUD' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.search.acnp.atomic' }, 'FM_ACNS_RETRIEVE_VIA_PCRUD' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.search.acns.atomic' }, + 'FM_ATB_RETRIEVE_VIA_PCRUD' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.search.atb.atomic' }, 'FM_ACP_DETAILS' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_details.retrieve' }, 'FM_ACP_DETAILS_VIA_BARCODE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_details.retrieve.barcode' }, 'FM_ACP_DETAILS_VIA_BARCODE.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_details.retrieve.barcode.authoritative' }, @@ -490,6 +491,7 @@ var urls = { 'XUL_STAT_CAT_EDIT' : '/xul/server/admin/stat_cat_editor.xhtml', 'XUL_SURVEY_WIZARD' : 'chrome://open_ils_staff_client/content/admin/survey_wizard.xul', 'XUL_TIMESTAMP_DIALOG' : '/xul/server/util/timestamp.xul', + 'XUL_TOOLBAR_CONFIG' : '/xul/server/admin/toolbar.xul', 'XUL_TRIGGER_EVENTS' : '/xul/server/patron/trigger_events.xul', 'XUL_USER_BUCKETS' : '/xul/server/patron/user_buckets.xul', 'XUL_VERIFY_CREDENTIALS' : '/xul/server/main/verify_credentials.xul', diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu.js b/Open-ILS/xul/staff_client/chrome/content/main/menu.js index d541553d91..ac27aec506 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -72,73 +72,7 @@ main.menu.prototype = { eval( r.responseText ); } - // Try workstation pref for button bar - var button_bar = xulG.pref.getCharPref('open-ils.menu.toolbar'); - - if (!button_bar) // No workstation pref? Try org unit pref. - button_bar = String( obj.data.hash.aous['ui.general.button_bar'] ); - - if (button_bar) { - var x = document.getElementById('toolbar_' + button_bar); - if (x) x.setAttribute('hidden','false'); - this.toolbar = button_bar; - } - - // Check for alternate Size pref - var toolbar_size = xulG.pref.getCharPref('open-ils.menu.toolbar.iconsize'); - if(toolbar_size) this.toolbar_size = toolbar_size; - // Check for alternate Mode pref - var toolbar_mode = xulG.pref.getCharPref('open-ils.menu.toolbar.mode'); - if(toolbar_mode) this.toolbar_mode = toolbar_mode; - // Check for alternate Label Position pref - var toolbar_labelpos = xulG.pref.getBoolPref('open-ils.menu.toolbar.labelbelow'); - if(toolbar_labelpos) this.toolbar_labelpos = toolbar_labelpos; - - if(button_bar || toolbar_size || toolbar_mode || toolbar_labelpos) { - var toolbox = document.getElementById('main_toolbox'); - var toolbars = toolbox.getElementsByTagName('toolbar'); - for(var i = 0; i < toolbars.length; i++) { - if(toolbars[i].id == 'toolbar_' + button_bar) - toolbars[i].setAttribute('hidden', 'false'); - else - toolbars[i].setAttribute('hidden', 'true'); - if(toolbar_mode) toolbars[i].setAttribute('mode', toolbar_mode); - if(toolbar_size) toolbars[i].setAttribute('iconsize', toolbar_size); - if(toolbar_labelpos) addCSSClass(toolbars[i], 'labelbelow'); - } - } - - if(button_bar) { - var x = document.getElementById('main.menu.admin.client.toolbars.current.popup'); - if (x) { - var selectitems = x.getElementsByAttribute('value',button_bar); - if(selectitems.length > 0) selectitems[0].setAttribute('checked','true'); - } - } - - if(toolbar_size) { - var x = document.getElementById('main.menu.admin.client.toolbars.size.popup'); - if (x) { - var selectitems = x.getElementsByAttribute('value',toolbar_size); - if(selectitems.length > 0) selectitems[0].setAttribute('checked','true'); - } - } - - if(toolbar_mode) { - var x = document.getElementById('main.menu.admin.client.toolbars.mode.popup'); - if (x) { - var selectitems = x.getElementsByAttribute('value',toolbar_mode); - if(selectitems.length > 0) selectitems[0].setAttribute('checked','true'); - } - } - - if(toolbar_labelpos) { - var x = document.getElementById('main.menu.admin.client.toolbars.label_position.popup'); - if (x) { - var selectitems = x.getElementsByAttribute('value',"under"); - if(selectitems.length > 0) selectitems[0].setAttribute('checked','true'); - } - } + this.button_bar_init(); var cl_first = xulG.pref.getBoolPref('oils.copy_editor.copy_location_name_first'); var menuitems = document.getElementsByAttribute('command','cmd_copy_editor_copy_location_first_toggle'); @@ -1564,14 +1498,7 @@ main.menu.prototype = { ['oncommand'], function(event) { var newToolbar = event.explicitOriginalTarget.getAttribute('value'); - var toolbox = document.getElementById('main_toolbox'); - var toolbars = toolbox.getElementsByTagName('toolbar'); - for(var i = 0; i < toolbars.length; i++) { - if(toolbars[i].id == 'toolbar_' + newToolbar) - toolbars[i].setAttribute('hidden', 'false'); - else - toolbars[i].setAttribute('hidden', 'true'); - } + obj.render_toolbar(newToolbar); obj.toolbar = newToolbar; } ], @@ -1612,6 +1539,13 @@ main.menu.prototype = { obj.toolbar_labelpos = (altPosition ? "under" : "side"); } ], + 'cmd_toolbar_configure' : [ + ['oncommand'], + function(event) { + var url = obj.url_prefix( urls.XUL_TOOLBAR_CONFIG ); + obj.command_tab(event,url,{},{}); + } + ], 'cmd_toolbar_setworkstation' : [ ['oncommand'], function() { @@ -1708,6 +1642,130 @@ main.menu.prototype = { } }, + 'button_bar_init' : function() { + try { + + var obj = this; + + JSAN.use('util.widgets'); + + // populate the menu of available toolbars + var x = document.getElementById('main.menu.admin.client.toolbars.current.popup'); + if (x) { + util.widgets.remove_children(x); + + function create_menuitem(label,value,checked) { + var menuitem = document.createElement('menuitem'); + menuitem.setAttribute('name','current_toolbar'); + menuitem.setAttribute('type','radio'); + menuitem.setAttribute('label',label); + menuitem.setAttribute('value',value); + menuitem.setAttribute('command','cmd_toolbar_set'); + if (checked) menuitem.setAttribute('checked','true'); + return menuitem; + } + + x.appendChild( + create_menuitem( + offlineStrings.getString('staff.main.button_bar.none'), + 'none', + true + ) + ); + + for (var i = 0; i < this.data.list.atb.length; i++) { + var def = this.data.list.atb[i]; + x.appendChild( + create_menuitem( + def.label(), + def.id() + ) + ); + } + } + + // Try workstation pref for button bar + var button_bar = xulG.pref.getCharPref('open-ils.menu.toolbar'); + + if (!button_bar) { // No workstation pref? Try org unit pref. + if (obj.data.hash.aous['ui.general.button_bar']) { + button_bar = String( obj.data.hash.aous['ui.general.button_bar'] ); + } + } + + if (button_bar) { + this.render_toolbar(button_bar); + this.toolbar = button_bar; + } + + // Check for alternate Size pref + var toolbar_size = xulG.pref.getCharPref('open-ils.menu.toolbar.iconsize'); + if(toolbar_size) this.toolbar_size = toolbar_size; + // Check for alternate Mode pref + var toolbar_mode = xulG.pref.getCharPref('open-ils.menu.toolbar.mode'); + if(toolbar_mode) this.toolbar_mode = toolbar_mode; + // Check for alternate Label Position pref + var toolbar_labelpos = xulG.pref.getBoolPref('open-ils.menu.toolbar.labelbelow'); + if(toolbar_labelpos) this.toolbar_labelpos = toolbar_labelpos; + + if(button_bar || toolbar_size || toolbar_mode || toolbar_labelpos) { + var toolbar = document.getElementById('toolbar_main'); + if(toolbar_mode) toolbar.setAttribute('mode', toolbar_mode); + if(toolbar_size) toolbar.setAttribute('iconsize', toolbar_size); + if(toolbar_labelpos) addCSSClass(toolbar, 'labelbelow'); + } + + if(button_bar) { + var x = document.getElementById('main.menu.admin.client.toolbars.current.popup'); + if (x) { + var selectitems = x.getElementsByAttribute('value',button_bar); + if(selectitems.length > 0) selectitems[0].setAttribute('checked','true'); + } + } + + if(toolbar_size) { + var x = document.getElementById('main.menu.admin.client.toolbars.size.popup'); + if (x) { + var selectitems = x.getElementsByAttribute('value',toolbar_size); + if(selectitems.length > 0) selectitems[0].setAttribute('checked','true'); + } + } + + if(toolbar_mode) { + var x = document.getElementById('main.menu.admin.client.toolbars.mode.popup'); + if (x) { + var selectitems = x.getElementsByAttribute('value',toolbar_mode); + if(selectitems.length > 0) selectitems[0].setAttribute('checked','true'); + } + } + + if(toolbar_labelpos) { + var x = document.getElementById('main.menu.admin.client.toolbars.label_position.popup'); + if (x) { + var selectitems = x.getElementsByAttribute('value',"under"); + if(selectitems.length > 0) selectitems[0].setAttribute('checked','true'); + } + } + + // stash the available toolbar buttons for later use in the toolbar editing interface + if (typeof this.data.toolbar_buttons == 'undefined') { + this.data.toolbar_buttons = {}; + var nl = $('palette').childNodes; + for (var i = 0; i < nl.length; i++) { + var id = nl[i].getAttribute('templateid'); + var label = nl[i].getAttribute('label'); + if (id && label) { + this.data.toolbar_buttons[ id ] = label; + } + } + this.data.stash('toolbar_buttons'); + } + + } catch(E) { + alert('Error in menu.js, button_bar_init(): ' + E); + } + }, + 'spawn_search' : function(s) { var obj = this; obj.error.sdump('D_TRACE', offlineStrings.getFormattedString('menu.spawn_search.msg', [js2JSON(s)]) ); @@ -2217,6 +2275,7 @@ commands: content_params.network_meter = obj.network_meter; content_params.page_meter = obj.page_meter; content_params.get_barcode = obj.get_barcode; + content_params.render_toolbar_layout = function(layout) { return obj.render_toolbar_layout(layout); }; content_params.set_statusbar = function(slot,text,tooltiptext,click_handler) { var e = document.getElementById('statusbarpanel'+slot); if (e) { @@ -2525,6 +2584,83 @@ commands: 'stop_observing' : function() { xulG.pref.removeObserver('oils.copy_editor.*', this); + }, + + 'render_toolbar' : function(button_bar) { + try { + + this.last_sanctioned_toolbar = button_bar; + + var toolbar = document.getElementById('toolbar_main'); + + if (button_bar == 'none' || typeof button_bar == 'undefined') { + toolbar.setAttribute('hidden','true'); + return; + } + + // find the layout + var layout; + JSAN.use('util.widgets'); JSAN.use('util.functional'); + var def = this.data.hash.atb[ button_bar ]; + if (!def) def = util.functional.find_list( this.data.list.atb, function(e) { return e.label == button_bar; } ); + if (!def) { + dump('Could not find layout for specified toolbar. Defaulting to a stock toolbar.\n'); + layout = [ 'circ_checkin', 'toolbarseparator', 'toolbarspacer', 'hotkeys_toggle' ]; + } else { + layout = JSON2js(def.layout()); + } + + this.render_toolbar_layout(layout); + + } catch(E) { + alert('Error in menu.js, render_toolbar('+button_bar+'): ' + E); + } + }, + + 'render_toolbar_layout' : function(layout) { + try { + + if (!layout) { + this.data.stash_retrieve(); + this.render_toolbar( this.last_sanctioned_toolbar ); + return; + } + + var toolbar = document.getElementById('toolbar_main'); + + // destroy existing toolbar + util.widgets.remove_children(toolbar); + + // create new one + for (var i = 0; i < layout.length; i++) { + var e = layout[i]; + switch(e) { + case 'toolbarseparator': + toolbar.appendChild( document.createElement('toolbarseparator') ); + break; + case 'toolbarspacer': + var spacer = document.createElement('toolbarspacer'); + spacer.setAttribute('flex','1'); + toolbar.appendChild( spacer ); + break; + default: + var templates = $('palette').getElementsByAttribute('templateid',e); + var template = templates.length > 0 ? templates[0] : null; + if (template) { + var clone = template.cloneNode(true); + toolbar.appendChild( clone ); + } else { + var label = document.createElement('label'); + label.setAttribute('value',e); + toolbar.appendChild( label ); + } + } + } + toolbar.setAttribute('hidden','false'); + + } catch(E) { + alert('Error in menu.js, render_toolbar_layout('+layout+'): ' + E); + } } } diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul index c71f8e1f33..bd98d4bb8d 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul @@ -256,6 +256,7 @@ + @@ -457,9 +458,6 @@ - - - @@ -482,6 +480,8 @@ + + diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_overlay.xul b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_overlay.xul index ad4686e3c1..eb75d9883a 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_overlay.xul +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_overlay.xul @@ -60,6 +60,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -74,140 +280,8 @@ - - +