Duplicating resource folder with hidden children does not ask to duplicate children #13298

Open
sonicpunk opened this Issue Feb 17, 2017 · 1 comment

Projects

None yet

2 participants

@sonicpunk

Summary

Another issue - when you have children that are hidden from the resource tree, like when using the Collections extra for example. Clicking duplicate on the parent resource will not duplicate the children if they are not shown in the resource tree. Also the checkbox option for duplicating children does not show up in the modal.

It seems that duplicating children only works with resources that are actually shown in the resource tree.

Attribute hasChildren=false, even though it technically does have children, just that they are not shown in the tree.

Step to reproduce

Make a parent resource with children. Change the children show_in_tree value to 0 in the database. These children resources are no longer shown in the resource tree.

Observed behavior

Right click on the parent resource. The checkbox for duplicating the children does not show.

Expected behavior

Technically the children do exist, therefore I would expect the ability to duplicate them as well.

Environment

MODX version 2.5.5

@sonicpunk sonicpunk changed the title from Duplicating resource folder with hidden children does not duplicate children to Duplicating resource folder with hidden children does not ask to duplicate children Feb 17, 2017
@wuuti
Contributor
wuuti commented Feb 17, 2017

Can confirm that. In the ResourceGetNodesProcessor the children count (L376) is only populated with resources not hidden tree (L170). But this value is then used in modx.tree.resource.js (L124) to configure the duplicate modal (window.js), where it is then used to show up the opton "Duplicate children" or not.
IMHO the option should be visible always if there are any children, regardless of whether they are visible or not. As the processor returned attribute "hasChildren" might be used elsewhere, it would be a good idea to add something like "hasAnyChildren" here, which is then evaluated by the duplicate modal.
I can also think of a more verbose modal where a checkbox labelled with "Duplicate children (15 total, 3 hidden in tree)", which would warn you then if you dare to duplicate a collection with thousands of children.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment