From 25bf4ecd08f32d2828a476257b679fc521289e38 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Wed, 13 Jun 2012 02:30:36 -0400 Subject: [PATCH] some toolbar fixes * tweak "GUI: Button Bar" org unit setting to accept either the label or id for an existing toolbar, and have it actually work when a window is opened * expose hard-coded toolbar layout option as a Default menu entry If the open-ils.menu.toolbar preference or ui.general.button_bar org unit setting references a non-existent toolbar, then a hard-coded stock toolbar will render. However, the menu entry 'None' will be selected under the Admin -> Workstation Administration -> Toolbars -> Current menu, which is confusing. With this change, a Default menu entry will be selected whenever the hard- coded layout has cause to render, and you can also explicitly select that menu entry to use the default and save it as your workstation default. Signed-off-by: Jason Etheridge --- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 2 +- ...XXXX.data.org-setting-ui.general.button_bar.sql | 14 +++++ .../xul/staff_client/chrome/content/main/menu.js | 59 +++++++++++++++------- .../chrome/locale/en-US/offline.properties | 1 + 4 files changed, 58 insertions(+), 18 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.org-setting-ui.general.button_bar.sql 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 e5daf85d12..539b6d7c26 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -4009,7 +4009,7 @@ INSERT into config.org_unit_setting_type 'Button bar', 'coust', 'label'), oils_i18n_gettext('ui.general.button_bar', - 'Set to "circ" or "cat" for stock circulator or cataloger toolbar, respectively.', + 'Set to the label or id for a defined toolbar, or use "Default".', 'coust', 'description'), 'string', null) diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.org-setting-ui.general.button_bar.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.org-setting-ui.general.button_bar.sql new file mode 100644 index 0000000000..daeac32fc6 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.org-setting-ui.general.button_bar.sql @@ -0,0 +1,14 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +UPDATE config.org_unit_setting_type + SET description = oils_i18n_gettext( + 'ui.general.button_bar', + 'Set to the label or id for a defined toolbar, or use "Default".', + 'coust', + 'description' + ) + WHERE name = 'ui.general.button_bar'; + +COMMIT; 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 55a36826ce..a7a09dc132 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -1714,22 +1714,33 @@ main.menu.prototype = { return menuitem; } - x.appendChild( - create_menuitem( - offlineStrings.getString('staff.main.button_bar.none'), - 'none', - true - ) + var none_entry = create_menuitem( + offlineStrings.getString('staff.main.button_bar.none'), + 'none', + false ); + x.appendChild(none_entry); + + var default_entry = create_menuitem( + offlineStrings.getString('staff.main.button_bar.default'), + 'default', + false + ); + x.appendChild(default_entry); + + var other_entries_by_label = {}; + var other_entries_by_id = {}; 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() - ) + var other_entry = create_menuitem( + def.label(), + def.id(), + false ); + other_entries_by_label[def.label()] = other_entry; + other_entries_by_id[def.id()] = other_entry; + x.appendChild(other_entry); } } @@ -1765,11 +1776,25 @@ main.menu.prototype = { } 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'); + var entry_to_check; + for (var i in other_entries_by_label) { + if (button_bar == i) { + entry_to_check = other_entries_by_label[i]; + } + } + if (!entry_to_check) { + for (var i in other_entries_by_id) { + if (button_bar == i) { + entry_to_check = other_entries_by_id[i]; + } + } } + if (!entry_to_check) { + entry_to_check = default_entry; + } + entry_to_check.setAttribute('checked','true'); + } else { + none_entry.setAttribute('checked','true'); } if(toolbar_size) { @@ -2701,9 +2726,9 @@ commands: 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) def = util.functional.find_list( this.data.list.atb, function(e) { return e.label() == button_bar || e.id() == button_bar; } ); if (!def) { - dump('Could not find layout for specified toolbar. Defaulting to a stock toolbar.\n'); + dump('Could not find layout for specified toolbar ('+button_bar+'). Defaulting to a stock toolbar.\n'); layout = ["circ_checkout","circ_checkin","toolbarseparator","search_opac","copy_status","toolbarseparator","patron_search","patron_register","toolbarspacer","hotkeys_toggle"]; } else { layout = JSON2js(def.layout()); diff --git a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties index 5a5b0c474b..2efc05bc96 100644 --- a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties +++ b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties @@ -320,6 +320,7 @@ barcode_choice.asset_label=Item : %1$s barcode_choice.serial_label=Serial : %1$s barcode_choice.booking_label=Booking : %1$s staff.main.button_bar.none=None +staff.main.button_bar.default=Default util.hide_elements.title=Hide UI Elements util.hide_elements.desc=This is a list of hideable elements for this interface. Check the ones that you want hidden and the library (and descendants) you want to affect: util.hide_elements.current_setting_preamble=Workstation library %1$s is currently hiding these elements based on a setting inherited from %2$s: -- 2.11.0