U4-9470 - Mini list view: only show expand option for nodes with children

Created by Mads Rasmussen 02 Feb 2017, 14:18:44 Updated by Emil Wangaa 21 Feb 2017, 08:01:06

Relates to: U4-9545

Is required for: U4-7385

Subtask of: U4-9272


Sebastiaan Janssen 06 Feb 2017, 10:25:13

Needs API change in GetChildren to know if each node has children

Sebastiaan Janssen 12 Feb 2017, 21:43:09

Umbraco.Web.Editors.ContentController.GetChildren has Items, each has a PersistedContent.HasChildren() method but the result is not exposed in the API call. It doesn't seem that there's a property that can be set to get that bool out. Anything we can do here @Shandem ?

Shannon Deminick 14 Feb 2017, 04:27:43

PersistedContent is used internally for inbound mapping, it has nothing to do with the outgoing model - i'll add more notes. However, that wouldn't solve the problem anyways. IContent doesn't contain a reference to whether it has children or not, you'd need to make a Service call to get that but then you'll end up with N+1 queries and performance will die.

The EntityService/EntityController supports HasChildren, and we cannot update the ContentService to have this because to do this is another outer join and then another aggregate Count which would really kill performance for looking up a full content item.

This needs to be refactored to use the EntityController since the data returned is really just an Id + name + icon, a whole content item and it's properties doesn't need to be returned. Otherwise a whole new ContentService method needs to be made to determine if there are children for a subset of IDs, this would require a bit of (unecessary) work.

I'll update.

Shannon Deminick 15 Feb 2017, 06:51:59

PR for review: https://github.com/umbraco/Umbraco-CMS/pull/1755

@madsrasmussen and @emil could both review this, changes made:

  • New EntityController.GetPagedChildren which supports the same mechanisms as the Content/Media controller's GetChildren method including searching/filtering
  • This required updates the underlying EntityRepository, I've added unit tests for the changes
  • I've updated the mini list view to use the entityResource regardless of entity type: Media, Member, Document and updated the logic when the data is fetched to assign the hasChildren and published properties based on the result item's metaData property which contains this info, then updated the html view to deal with these changes

For testing, ensure you test this with Media/Content/Members with search and with children of children. Works on my machine :)

Mads Rasmussen 15 Feb 2017, 09:22:59

@Shannon and @emil: I am still testing but I have found these issues so far:

  • I Get a 404 on getPagedChildren for entityType Member
  • Media: items always show as unpublished
  • For nested list views the small arrow makes the items "jump". We will have to indent all of the items an then hide the small arrow so they all align. (we do the same thing for the tree)

I can help fix the unpublished media and the "nested list view indent"

Shannon Deminick 15 Feb 2017, 09:37:29

@madsrasmussen sounds good, I can look at the 404 tomorrow, can you paste the URL that is returning the 404 here for me?

Mads Rasmussen 15 Feb 2017, 10:05:41

@Shandem I have updated the PR with my fixes. I havn't found any other issues from my testing. Client side code looks good and everything is nice and fast.

Sorry, it wasn't a 404 but 400: The URL is UmbracoApi/Entity/GetPagedChildren?id=all-members&type=Member&pageNumber=1&pageSize=10&orderBy=SortOrder&orderDirection=Ascending&filter=

Mads Rasmussen 15 Feb 2017, 10:07:21

@emil I will set the issue back to reopened but I still need your eyes on the server code.

Shannon Deminick 20 Feb 2017, 10:25:12

@madsrasmussen + @emil I've pushed an update on this one to fix the members id 404/400 issue, it will now accept "all-members" as a node id (will treat it as -1 since members don't have a hierarchy), my tests show it works so please have a look :)

Emil Wangaa 20 Feb 2017, 13:21:21

@Shandem I can't get it to work - maybe it's "just" a typo? Okay so the members doesn't have a hierarchy but we show the member types in the mini list view like in the tree in the members section - but that is maybe not possible?

Shannon Deminick 21 Feb 2017, 02:52:09

@emil Ok, all fixed up and working, have tested the member mini list view with paging, all members and member types. Updating the entity service to support searching on member type will take too much work, so for now the entity service is used for paging/filtering all members but if we are filtering based on member type it reverts to using the Examine search, which has been updated to support paging. Also note that part of this PR fixes this too: http://issues.umbraco.org/issue/U4-9552

Emil Wangaa 21 Feb 2017, 07:28:13

Yeah everything is working now - this is great :D

Priority: Normal

Type: Task

State: Fixed


Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version: 7.6.0

Sprint: Sprint 53

Story Points: 1