some toolbar fixes collab/phasefx/toolbar
authorJason Etheridge <jason@esilibrary.com>
Wed, 13 Jun 2012 06:30:36 +0000 (02:30 -0400)
committerJason Etheridge <jason@esilibrary.com>
Tue, 18 Sep 2012 20:35:36 +0000 (16:35 -0400)
* 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 <jason@esilibrary.com>
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.data.org-setting-ui.general.button_bar.sql [new file with mode: 0644]
Open-ILS/xul/staff_client/chrome/content/main/menu.js
Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties

index e5daf85..539b6d7 100644 (file)
@@ -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 (file)
index 0000000..daeac32
--- /dev/null
@@ -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;
index 55a3682..a7a09dc 100644 (file)
@@ -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());
index 5a5b0c4..2efc05b 100644 (file)
@@ -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: