CRM-17176 - Improve report-menu-cleanup button
authorColeman Watts <coleman@civicrm.org>
Thu, 15 Oct 2015 01:13:29 +0000 (21:13 -0400)
committerColeman Watts <coleman@civicrm.org>
Thu, 15 Oct 2015 01:13:29 +0000 (21:13 -0400)
templates/CRM/Admin/Page/Navigation.tpl

index 0ba4b3ba9ce8e851d7387915254fe3777c390861..ade8db52ee43101e5662de7c98398fee962ece5f 100644 (file)
@@ -42,7 +42,8 @@
     <div id="navigation-tree" class="navigation-tree" style="height:auto; border-collapse:separate; background-color:#FFFFFF;"></div>
     <div class="spacer"></div>
     <div>
-      <a href="{crmURL p="#"}" id='nav-reset'><span>{ts}Click here{/ts}</span></a> {ts}to reset the reports menu structure to the default.{/ts}
+      {* TODO: fa-broom would be better, but not implemented yet. https://github.com/FortAwesome/Font-Awesome/issues/239 *}
+      <a href="#" class="nav-reset crm-hover-button"><i class="crm-i fa-undo"></i> {ts}Cleanup reports menu{/ts}</a>
     </div>
     <div class="spacer"></div>
   </div>
   </style>
   <script type="text/javascript">
     CRM.$(function($) {
-      $('#nav-reset').on('click', function(e) {
-        e.preventDefault();
-        CRM.api3('Navigation', 'reset', {'for' : 'report'}, ts('Report menu reset. Changes will be visible when you refresh'))
-      });
       $("#navigation-tree").jstree({
         plugins: [ "themes", "json_data", "dnd","ui", "crrm","contextmenu" ],
         json_data: {
           $("#navigation-tree").jstree('refresh');
           $("#reset-menu").show();
         });
+
+      $('a.nav-reset').on('click', function(e) {
+        e.preventDefault();
+        CRM.confirm({message: '{/literal}{ts escape='js'}This will rebuild the "Reports" menu to include all currently active reports.{/ts}{literal}'})
+          .on('crmConfirm:yes', function () {
+            CRM.api3('Navigation', 'reset', {'for': 'report'}, true)
+              .done(function() {
+                $("#navigation-tree").jstree('refresh');
+                $("#reset-menu").show();
+              })
+          });
+      });
     });
 </script>
 {/literal}