vpusher / paper-tree

Browsable tree of nodes with expandable/collapsible capabilities and actions menu
MIT License
27 stars 24 forks source link

Deep linking support #14

Open chisholmd opened 6 years ago

chisholmd commented 6 years ago

How is deep linking supported? I was expecting to see a "selected" property that I could bind to my JSON but there is only "open".

Here is an example of deep linking to a tree.
http://52.90.210.88/kb/#/en-US/home/2/3/4?topic=kidH4_775_c1

When you follow the link the tree is opened to reveal the "Screen Frozen" node, and that node is selected.

option 1: load the tree and then imperativly traverse the tree looking for the right node and imperativly firing its "selected" state.

option 2: have the open and selected state in the JSON and bind it.

jsTree has a nice section in tree JSON for state info including selected, that's what I would like to see. https://www.jstree.com/docs/json/

{ id : "string" // will be autogenerated if omitted text : "string" // node text icon : "string" // string for custom state : { opened : boolean // is the node open disabled : boolean // is the node disabled selected : boolean // is the node selected }, children : [] // array of strings or objects li_attr : {} // attributes for the generated LI node a_attr : {} // attributes for the generated A node }

chisholmd commented 6 years ago

added a "selected" boolean to my data.json then in paper-tree-node.html

connectedCallback() { super.connectedCallback(); if(this.selected){ this.select(); }
}

Seems to do the trick nicely