From 6d5b4a8f818c6ebf50dd46c0d9fd0b0ca40dda5e Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Wed, 28 Mar 2012 11:37:12 -0400 Subject: [PATCH] fix editing of multiple toolbarseparators and toolbarspacers. Also beef up the hardcoded toolbar to match the stock circ toolbar. Signed-off-by: Jason Etheridge Signed-off-by: Thomas Berezansky --- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 4 +-- .../sql/Pg/upgrade/XXXX.schema.custom_toolbars.sql | 4 +-- .../xul/staff_client/chrome/content/main/menu.js | 37 ++++++++++------------ Open-ILS/xul/staff_client/server/admin/toolbar.js | 21 ++++++------ 4 files changed, 31 insertions(+), 35 deletions(-) diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index b9ebb7ec16..b6b88d4295 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -11512,5 +11512,5 @@ INSERT INTO action_trigger.environment (event_def, path) ); INSERT INTO actor.toolbar(org,label,layout) VALUES - ( 1, 'circ', '["circ_checkout","circ_checkin","toolbarseparator","search_opac","copy_status","toolbarseparator","patron_search","patron_register","toolbarspacer","hotkeys_toggle"]' ), - ( 1, 'cat', '["circ_checkin","toolbarseparator","search_opac","copy_status","toolbarseparator","create_marc","authority_manage","retrieve_last_record","toolbarspacer","hotkeys_toggle"]' ); + ( 1, 'circ', '["circ_checkout","circ_checkin","toolbarseparator.1","search_opac","copy_status","toolbarseparator.2","patron_search","patron_register","toolbarspacer.3","hotkeys_toggle"]' ), + ( 1, 'cat', '["circ_checkin","toolbarseparator.1","search_opac","copy_status","toolbarseparator.2","create_marc","authority_manage","retrieve_last_record","toolbarspacer.3","hotkeys_toggle"]' ); diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.custom_toolbars.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.custom_toolbars.sql index 386f0526e2..63c7a61b4e 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.custom_toolbars.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.custom_toolbars.sql @@ -50,7 +50,7 @@ INSERT INTO permission.perm_list ( id, code, description ) VALUES ( -- INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) SELECT pgt.id, perm.id, aout.depth, FALSE FROM permission.grp_tree pgt, permission.perm_list perm, actor.org_unit_type aout WHERE pgt.name = 'Staff' AND aout.name = 'Branch' AND perm.code = 'ADMIN_TOOLBAR'; INSERT INTO actor.toolbar(org,label,layout) VALUES - ( 1, 'circ', '["circ_checkout","circ_checkin","toolbarseparator","search_opac","copy_status","toolbarseparator","patron_search","patron_register","toolbarspacer","hotkeys_toggle"]' ), - ( 1, 'cat', '["circ_checkin","toolbarseparator","search_opac","copy_status","toolbarseparator","create_marc","authority_manage","retrieve_last_record","toolbarspacer","hotkeys_toggle"]' ); + ( 1, 'circ', '["circ_checkout","circ_checkin","toolbarseparator.1","search_opac","copy_status","toolbarseparator.2","patron_search","patron_register","toolbarspacer.3","hotkeys_toggle"]' ), + ( 1, 'cat', '["circ_checkin","toolbarseparator.1","search_opac","copy_status","toolbarseparator.2","create_marc","authority_manage","retrieve_last_record","toolbarspacer.3","hotkeys_toggle"]' ); -- delete from permission.grp_perm_map where perm in (select id from permission.perm_list where code ~ 'TOOLBAR'); delete from permission.perm_list where code ~ 'TOOLBAR'; drop table actor.toolbar ; 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 ac27aec506..4d8b482349 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -2605,7 +2605,7 @@ commands: 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' ]; + layout = ["circ_checkout","circ_checkin","toolbarseparator","search_opac","copy_status","toolbarseparator","patron_search","patron_register","toolbarspacer","hotkeys_toggle"]; } else { layout = JSON2js(def.layout()); } @@ -2634,26 +2634,23 @@ commands: // create new one for (var i = 0; i < layout.length; i++) { var e = layout[i]; - switch(e) { - case 'toolbarseparator': + if (e.match('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 ); - } + } else if (e.match('toolbarspacer')) { + var spacer = document.createElement('toolbarspacer'); + spacer.setAttribute('flex','1'); + toolbar.appendChild( spacer ); + } else { + 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'); diff --git a/Open-ILS/xul/staff_client/server/admin/toolbar.js b/Open-ILS/xul/staff_client/server/admin/toolbar.js index 717a87a737..8e899be046 100644 --- a/Open-ILS/xul/staff_client/server/admin/toolbar.js +++ b/Open-ILS/xul/staff_client/server/admin/toolbar.js @@ -279,17 +279,13 @@ function populate_list2_list3(list3_idx) { var value = g.layout[i]; var label; - switch(value) { - case 'toolbarseparator': - label = $('adminStrings').getString('staff.admin.toolbar.toolbar_separator.list_entry'); - break; - case 'toolbarspacer': - label = $('adminStrings').getString('staff.admin.toolbar.toolbar_spacer.list_entry'); - break; - default: - label = g.data.toolbar_buttons[value]; - seen[value] = true; - break; + if (value.match('toolbarseparator')) { + label = $('adminStrings').getString('staff.admin.toolbar.toolbar_separator.list_entry'); + } else if (value.match('toolbarspacer')) { + label = $('adminStrings').getString('staff.admin.toolbar.toolbar_spacer.list_entry'); + } else { + label = g.data.toolbar_buttons[value]; + seen[value] = true; } var rdata3 = g.list3.append({ @@ -406,6 +402,9 @@ function Add(ev) { for (var i = values_to_add.length - 1; i >= 0; i--) { // iterate backwards so that we add them forwards if (!values_to_add[i]) { continue; } + if (values_to_add[i].match('toolbarseparator') || values_to_add[i].match('toolbarspacer')) { + values_to_add[i] = values_to_add[i] + '.' + (new Date()).getTime(); + } g.layout.splice(add_after_this_position,0,values_to_add[i]); } -- 2.11.0