I am having an issue getting the first child node in a tree to resync it’s children after performing a sorting operation.
Here is a screen cast demonstrating the problem.
https://drive.google.com/file/d/0B0o-8ZqA1sebTm5mMVZJTHNWZzg/view?usp=sharing
Methodology
I have a tree action that opens a dialog to sort similar to the way Umbraco sorts content (drag/drop). When the save button is clicked, an API call is made to save the sort orders that need to be updated.
I think I’m close as my code successfully saves the sort data correctly to the database and actually does update the tree UI for children other than the first child in the tree.
If I delete the client dependency temp file the tree will refresh, albeit this is also true for tapping the web.config - which at first led me to believe I had a caching problem in my service layer. However, since the sub trees are acting as expected using the exact same service calls it seems like a less likely suspect.
I’ve tried:
- Completely clearing the treeCache using Umbraco’s Angular treeService
- Resyncing the tree using the treeService (using the parent node and path)
The dialogs for creating and deleting these nodes work just fine, but they don’t require refreshing more than a single child. Delete simply removes the node after the deletion and the way I implemented adding a node just adds one to the bottom of the list so treeService.loadNodeChildren({ node: $scope.currentNode }); did the trick.
Here is my save method for the sort:
/**
* @ngdoc method
* @name save
* @function
*
* @description - Saves the newly sorted nodes and updates the tree UI.
*/
function save() {
// set the sorts here
for(var i = 0; i < $scope.entityCollections.length; i++) {
$scope.entityCollections[i].sortOrder = i;
}
// save updated sort orders
var promise = entityCollectionResource.updateSortOrders($scope.entityCollections);
promise.then(function() {
// reload the children of the parent
var childPromise = treeService.loadNodeChildren({ node: $scope.currentNode });
childPromise.then(function(children) {
navigationService.hideNavigation();
notificationsService.success('Collections sorted success.');
}, function(reason) {
notificationsService.error('failed to load node children ' + reason)
});
});
}
Anyone have any thoughts? I’ve been banging my head against the wall =)
This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/70377-back-office-tree-first-child-tree-sync