Commits

Anonymous committed 8d2408a

Fri Feb 26 12:46:12 MSK 2010

  • Participants
  • Parent commits 12bd75f

Comments (0)

Files changed (2)

File mpttadmin/__init__.py

         <script src="media/js/lib/jquery-1.3.2.min.js"></script>
         <script src="media/js/lib/jquery.tree.min.js"></script>
         <script src="media/js/lib/plugins/jquery.tree.contextmenu.js"></script>
-        <script>var permissions={{permissions|safe}};</script>
+        <script>var permissions={{permissions|safe}};var parent_attr={{parent_attr}};</script>
         <script src="media/js/jstree_admin.js"></script>
         {% endblock %}
         {% block search %}{% endblock %}{% block date_hierarchy %}{% endblock %}
             'app_label': app_label,
             'tree':self._tree_tpl.render(template.Context()),
             'permissions': permissions,
+            'parent_attr': self._meta.parent_attr,
         }
         context.update(extra_context or {})
         context_instance = template.RequestContext(request, current_app=self.admin_site.name)

File mpttadmin/media/js/jstree_admin.js

                                 return treeobj.check("creatable", node);
                             },
                             action: function(node, treeobj) {
-                                location.href = 'add/?parent=' + node.attr('id').replace('n','');
+                                location.href = 'add/?'+parent_attr+'='+node.attr('id').replace('n','');
                                 },
                             separator_after: true
                         },
             },
 
             callback: {
-                /*onmove: function(node, ref_node, TYPE, treeobj, RB) {
-
-                },*/
                 beforemove: function(node, ref_node, TYPE, treeobj) {
                     if(treeobj._moving){
                         treeobj._moving=false;
                     treeobj.settings.data.opts.method='POST';
                     treeobj._params={node:node.id.replace('n',''),target:ref_node.id.replace('n',''),position:position};
                     treeobj.refresh();
-                    /*$.ajax({url:'move_node/',type:'POST',success: function(data) {
-                    //$.tree.reference(window.jtree).refresh();
-                        treeobj.refresh();
-                        //treeobj.moved($(node),$(ref_node).children("ul:eq(0)").children("li:last").children("a:eq(0)"),TYPE);
-                    },data: ({node:node.id.replace('n',''),target:ref_node.id.replace('n',''),
-                    position:position})
-                    });*/
                     return false;
                 },
                 ondblclk: function(node, treeobj) {
                     treeobj.open_all();
                 },
                 onrename: function(node, treeobj, RB) {
-                    //treeobj.settings.data._node=node;
                     var new_name=$(node).children('a:first').text();//.replace(/^\s\s*/, '');
                     treeobj._params={node:node.id.replace('n',''),name:new_name};
                     treeobj.settings.data.opts.url = 'rename/';
                     treeobj.settings.data.opts.method = 'POST';
                     treeobj.refresh();
-                    /*$.ajax({url:'rename/',type:'POST',success:
-                            function(data) {
-                                treeobj.rename(RB,new_name);
-                        //$.tree.reference(window.jtree).refresh();
-                        },
-                    data: ({node:node.id.replace('n',''),name:new_name})
-                    });*/
                     return false;
                 },
                 beforedelete: function(node, treeobj) {
                     treeobj.settings.data.opts.url = 'remove/';
                     treeobj.settings.data.opts.method = 'POST';
                     treeobj.refresh();
-                    /*$.ajax({url:'remove/',type:'POST',success:
-                        function(data) {
-                        //$.tree.reference(window.jtree).refresh();
-                        //$.tree.reference(window.jtree).refresh();
-                        treeobj.remove(node);
-                        //treeobj.refresh();
-                        },data: ({node:node.id.replace('n','')})
-                    });*/
                     return false;
                 },
                 onsearch : function (n,t) {
             },
             data: {
                 type: "html",async: false
-                //opts : { method: "POST", url: "tree/" }
             },
             "types": {
                 "default": permissions
             }
         });
     });
-    //jQuery.tree.reference('#tree')._params={};
     $('#changelist').removeClass('module');
 
 });