Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ordering the tree causes the action_icons of it's subnodes to become equal to it's own action_icons #11

Open
mvdwaeter opened this issue Dec 11, 2013 · 2 comments

Comments

@mvdwaeter
Copy link
Contributor

When I have the following PolymorphicTree:

class BaseTreeNode(PolymorphicMPTTModel):
    pass

class Edition(BaseTreeNode):
    pass

class Chapter(BaseTreeNode):
    pass

class ContentPage(BaseTreeNode):
    pass

class Text(BaseTreeNode):
    pass

The tree in the django-admin may look like this:

- Edition1    [actions: add-chapter]
-- Chapter1    [actions: add-contentpage]
--- ContentPage1.1    [actions: add-text]
--- ContentPage1.2    [actions: add-text]
-- Chapter2    [actions: add-contentpage]
--- ContentPage2.1    [actions: add-text]

When I move Chapter2 above Chapter1, all the actions of it's subnodes will become equal to the Chapter node. (While they should remain ContentPage-actions).

In other words, the tree will look like this:

- Edition1    [actions: add-chapter]
-- Chapter2    [actions: add-contentpage]
--- ContentPage2.1    [actions: add-contentpage]    <---- this is not correct
-- Chapter1    [actions: add-contentpage]
--- ContentPage1.1    [actions: add-text]
--- ContentPage1.2    [actions: add-text]
@mvdwaeter
Copy link
Contributor Author

In polymorphic_tree/admin/parentadmin.py:

# Report back to client.
return HttpResponse(json.dumps({
        'action': 'success',
        'error': None,
        'moved_id': moved_id,
        'action_column': self.actions_column(moved),
    }), content_type='application/json')

This should return a json for the node and all it's child-nodes. Instead of only the node itself.
Then the node + it's childnodes should be updated in the frontend in:
polymorphic_tree/templates/admin/polymorphic_tree/jstree_list_results.html

  success: function onMoveSuccess(data, status, xhr) {
    // Replace the action column, the preview URL changed.
    if( data.action_column && data.moved_id == move_info.moved_node.id ) {
      $(".col-actions_column", move_info.moved_node.element).html(data.action_column);
    }
  },

@vdboor
Copy link
Member

vdboor commented Dec 12, 2013

Hi, thanks for the bug report!

I just checked in the code, and the call to self.actions_column(moved) should be called with the polymorphic model. Can you verify what happens in your get_actions_column code? (e.g. with step through debugging). So far I can't see any obvious error in the the parentadmin.py code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants