Navigation admin - live refresh and links to related settings
authorColeman Watts <coleman@civicrm.org>
Mon, 8 Apr 2019 18:39:13 +0000 (14:39 -0400)
committerColeman Watts <coleman@civicrm.org>
Mon, 8 Apr 2019 18:39:13 +0000 (14:39 -0400)
templates/CRM/Admin/Page/Navigation.hlp
templates/CRM/Admin/Page/Navigation.tpl

index b2e6ddd951b263c3dfa1070ee0612b1aaab7fcea..038ac93e0cb78539993b9c1abd3bd4af2b5d60bf 100644 (file)
@@ -40,5 +40,5 @@
   <li>{ts}Change the permissions for a menu item. Right-click and select 'Edit'.{/ts}</li>
   <li>{ts}Re-order menu items (including moving them from one branch of the menu 'tree' to another. Simply use your mouse to 'drag and drop' the menu item to the new location.{/ts}</li>
 </ul>
-<p><em>{ts}Changes you make to the menu are saved immediately. However, you will need reload this page to see your changes in the menu bar above.{/ts}</em></p>
+<p><em>{ts}Changes you make to the menu are saved immediately.{/ts}</em></p>
 {/htxt}
index 9165e8a9d9d842194a28f93d186390af93ddacdf..5c826b8488d9e978feabd9b5fd3cca80787778de 100644 (file)
   {include file="CRM/Admin/Form/Navigation.tpl"}
 {else}
   <div class="help">
-    {ts}Customize the CiviCRM navigation menu bar for your users here.{/ts} {help id="id-navigation"}
+    {capture assign="displayPrefUrl"}href="{crmURL p='civicrm/admin/setting/preferences/display' q='reset=1'}"{/capture}
+    {capture assign="searchPrefUrl"}href="{crmURL p='civicrm/admin/setting/search' q='reset=1'}"{/capture}
+    <p>{ts}Customize the CiviCRM navigation menu bar for your users here.{/ts} {help id="id-navigation"}</p>
+    <p>{ts 1=$displayPrefUrl}The menu color and position can be adjusted on the <a %1>Display Preferences</a> screen.{/ts}</p>
+    <p>{ts 1=$searchPrefUrl}Quicksearch options can be edited on the <a %1>Search Preferences</a> screen.{/ts}</p>
   </div>
 
   <div class="crm-block crm-content-block">
     <div id="new-menu-item">
-      {crmButton p="civicrm/admin/menu" q="action=add&reset=1" id="newMenuItem" icon="crm-i fa-plus-circle" style="margin-left: 6px;"}{ts}Add Menu Item{/ts}{/crmButton}&nbsp;&nbsp;&nbsp;&nbsp;
-        <span id="reset-menu" class="status" style="display:none">
-        {capture assign=rebuildURL}{crmURL p='civicrm/admin/menu' q="reset=1"}{/capture}
-          {ts 1=$rebuildURL}<a href='%1' title="Reload page"><strong>Click here</strong></a> to reload the page and see your changes in the menu bar above.{/ts}
-        </span><br/><br/>
+      {crmButton p="civicrm/admin/menu" q="action=add&reset=1" id="newMenuItem" icon="crm-i fa-plus-circle" style="margin-left: 6px;"}{ts}Add Menu Item{/ts}{/crmButton}
     </div>
     <div class="spacer"></div>
-    <div style="padding-left: 25px;"><div class="crm-logo-sm"></div></div>
+    <div style="padding-left: 48px;"><img src="{$config->resourceBase}i/logo_sm.png" /></div>
     <div id="navigation-tree" class="navigation-tree" style="height:auto; border-collapse:separate; background-color:#FFFFFF;"></div>
     <div class="spacer"></div>
     <div>
@@ -63,7 +63,7 @@
               return: ['label', 'parent_id', 'icon'],
               name: {'!=': 'Home'},
               sequential: 1
-            }).done(function(data) {
+            }).then(function(data) {
               var items = [];
               $.each(data.values, function(key, value) {
                 items.push({
                   }
                   CRM.confirm({message: deleteMsg})
                     .on('crmConfirm:yes', function() {
-                      CRM.api3('Navigation', 'delete', {id: nodeID}, true);
+                      CRM.api3('Navigation', 'delete', {id: nodeID}, true).then(refreshMenubar);
                       $("#navigation-tree").jstree(true).delete_node(menu.reference.closest('li'));
-                      $("#reset-menu").show();
                     });
                 }
               }
         var refID = data.parent === '#' ? '' : data.parent;
         var ps = data.position;
         var postURL = {/literal}"{crmURL p='civicrm/ajax/menutree' h=0 q='key='}{crmKey name='civicrm/ajax/menutree'}"{literal};
-        CRM.status({}, $.get( postURL + '&type=move&id=' +  nodeID + '&ref_id=' + refID + '&ps='+ps));
-        $("#reset-menu").show();
+        CRM.status({}, $.get( postURL + '&type=move&id=' +  nodeID + '&ref_id=' + refID + '&ps='+ps).then(refreshMenubar));
       });
 
       function editForm(menu) {
         }
         CRM.loadForm(CRM.url('civicrm/admin/menu', args)).on('crmFormSuccess', function() {
           $("#navigation-tree").jstree(true).refresh();
-          $("#reset-menu").show();
+          refreshMenubar();
         });
       }
 
         .on('click', CRM.popup)
         .on('crmPopupFormSuccess', function() {
           $("#navigation-tree").jstree(true).refresh();
-          $("#reset-menu").show();
+          refreshMenubar();
         });
 
       $('a.nav-reset').on('click', function(e) {
           .on('crmConfirm:yes', function() {
             $('#crm-container').block();
             CRM.api3('Navigation', 'reset', {'for': 'report'}, true)
-              .done(function() {
+              .then(function() {
                 $('#crm-container').unblock();
                 $("#navigation-tree").jstree(true).refresh();
-                $("#reset-menu").show();
-              })
+                refreshMenubar();
+              });
           });
       });
+
+      // Force-refresh the menubar by resetting the cache code
+      function refreshMenubar() {
+        CRM.menubar.destroy();
+        CRM.menubar.cacheCode = Math.random();
+        CRM.menubar.initialize();
+      }
     });
 </script>
 {/literal}