Open gwenael-alizon opened 13 years ago
With a bit of luck, enabling this plugin should do the trick: http://www.jstree.com/documentation/cookies
this should be added in tree.js
I've added plugin and jQuery cookie plugin (as this depends on it). It does save the state of selection, but not open/close state. It seems that controller gives nodes with status open at each load, I think that might be the issue.
@manuelbernhardt can u confirm this, I didn't manage to find where status of nodes is set for each tree (if closed/opened).
I was not able either to find how the cookie gets overwritten, but the value in the DB is definitely used somehow: when the "opened" is set to false / 0 / empty in tm_ProjectTreeNode, the cookie seems to work just fine. Now somewhere (tree module?) the value is set to true upon creation.
Allright so this is related to the way the tree data is serialized with taking into account the "open" value all the time (i.e. the value stored in the database). I am not entirely sure how the tree behaves if there is no status passed for the nodes, I suppose it shows them as closed by default tough.
So a fix of the tree plugin involving a configuration parameter to add to application.conf should take care of this, I will have a look.
Thanks Manu to have looked into it. The proper value for the "save_opened" param in tree.js is "jstree_open" I believe (it is also the default value), otherwise it does not save the state properly.
Now even then the behavior is still funky (checked both in FF and Chrome). Here are a couple of examples (true also the other way round):
Still not working for me. Looking at the cookie values that are stored (both jstree_open and jstree_select), the issue seems to be that the cookie only contain the state of one given tree (the last one). Additionally I get a number of "PLAY_ERRORS" cookies, but without any visible content, when moving from one tree to another.
I tested this in firefox. Make sure you:
PLAY_ERRORS is a cookie of Play for storing the error scope, this should not be a problem
The cookie still seems to only store the status of one tree at a time. It gives the impression that the status is stored for 2 trees when one node is selected only because the node selected in jstree_selected makes the parents being opened
That would mean that perhaps jsTree expects to be explicitly given a different cookie name in the configuration, one for each tree. It would be somewhat strange tough because even if two trees were to use the same cookie, given that the nodes are namespaced, this should still work.
One way of testing this would be to modify tree.js so that the configuration parameters for the cookie plugin in regards to cookie name (opened, selected - I think) are prefixed with the tree name. the tree name variable should be declared somewhere early in tree.js so it should be possible to pass it to the plugin configuration if I am not mistaken
At the moment the status of the tree nodes, open or closed, is stored at treeNode level. It however likely makes sense to have this status depend on the logged in user.