silverstripe/silverstripe-framework — pull request #3031 by tractorcow (2014-04-14 05:25:20+00:00)
Title: BUG Fix jstree when duplicating subtrees

This fixes an annoying issue with recursive duplication of sitetrees. After duplicating a page with children the user would have to refresh the CMS to see the children appear.

The issue is caused by partial loading of subtrees not correctly passing in the jstree-closed, jstree-open, or jstree-leaf classes. There was a partial hack in place to ignore this field, and "fix" it after the fact, but this broke the load on demand feature of js tree.

`Hierarchy::markingClasses` also behaved a little inconsistently; If a node has any children at all, it should always return one of jstree-closed or jstree-open, otherwise the front end can't tell if there are any children. It looks like the 'unexpanded' class is a legacy class from the tree.js library not related to the new jstree we use these days. In terror of potentially breaking something unintentionally I've attempted to only alter the behaviour of the jstree classes returned from this method. Having the whole concept of separate expanded / opened states seems a little redundant to me, but I'm sure there's a good reason why this is the case.

There are some behat tests necessary, but these will need to be added to the CMS module.

`Hierarchy::markChildren` method has been cleaned up a little for readability.

If anyone can add to my understanding I'd appreciate this. :) cc @chillu @hafriedlander

ref: CWPBUG-146