CRM-13863 - Menu Admin - Ajaxify adding/editing menu items
authorColeman Watts <coleman@civicrm.org>
Fri, 29 Nov 2013 00:07:16 +0000 (16:07 -0800)
committerColeman Watts <coleman@civicrm.org>
Fri, 29 Nov 2013 00:07:16 +0000 (16:07 -0800)
templates/CRM/Admin/Page/Navigation.tpl

index 4a379e04fad9bdf14971fc68ac4c5cffee7a2f96..3210863ac3b2f0a3c3b3faacef07ca05003c455f 100644 (file)
     }
   </style>
   <script type="text/javascript">
-    cj(function () {
+  cj(function () {
     cj("#navigation-tree").jstree({
     plugins : [ "themes", "json_data", "dnd","ui", "crrm","contextmenu" ],
     json_data  : {
       ajax:{
         dataType : "json",
-        async : true,
         url : {/literal}"{crmURL p='civicrm/ajax/menu' h=0 q='key='}{crmKey name='civicrm/ajax/menu'}"{literal}
-      }
+      },
+      progressive_render: true
     },
     themes: {
       "theme": 'classic',
       items: {
         create : false,
           ccp : {
-            label   : "Edit",
+            label   : "{/literal}{ts escape='js'}Edit{/ts}{literal}",
             visible : function (node, obj) { if(node.length != 1) return false;
               return obj.check("renameable", node); },
             action  : function (node, obj) {
               var nid = cj(node).prop('id');
               var nodeID = nid.substr( 5 );
               var editURL = {/literal}"{crmURL p='civicrm/admin/menu' h=0 q='action=update&reset=1&id='}"{literal} + nodeID;
-              location.href =  editURL;
+              CRM.loadForm(editURL).on('crmFormSuccess', function() {
+                cj("#navigation-tree").jstree('refresh');
+                cj("#reset-menu").show( );
+              });
             },
             submenu : false
           }
           });
       });
     });
+    cj('#new-menu-item a.button').click(function() {
+      CRM.loadForm(this.href).on('crmFormSuccess', function() {
+        cj("#navigation-tree").jstree('refresh');
+        cj("#reset-menu").show( );
+      });
+      return false;
+    })
   });
 </script>
 {/literal}