fix editing of multiple toolbarseparators
authorJason Etheridge <jason@esilibrary.com>
Wed, 28 Mar 2012 15:37:12 +0000 (11:37 -0400)
committerThomas Berezansky <tsbere@mvlc.org>
Wed, 28 Mar 2012 19:32:34 +0000 (15:32 -0400)
and toolbarspacers.  Also beef up the hardcoded toolbar to match the stock circ
toolbar.

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.custom_toolbars.sql
Open-ILS/xul/staff_client/chrome/content/main/menu.js
Open-ILS/xul/staff_client/server/admin/toolbar.js

index b9ebb7e..b6b88d4 100644 (file)
@@ -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"]' );
index 386f052..63c7a61 100644 (file)
@@ -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 ;
index ac27aec..4d8b482 100644 (file)
@@ -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');
index 717a87a..8e899be 100644 (file)
@@ -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]);
         }