I have a custom section with a Tree in it, and I have a custom way of resorting some nodes on the page of each node.
So my tree looks like this
Other thing 1
Other thing 2
Tags
Location tags
Location NY
Location LA
Other tag category
I have that if you click for instance "Location NY" you get to the page to edit Location NY and once there you can resort it under Location tags... so you can make Location NY come after Location LA in the list.
All of this works fantastically... that is as long as I reload the page... because the tree refuses to update the order unless i reload the page.
I have tried to use navigationService.syncTree on the parent, that did not help (does not seem to be the correct thing).
I want to use: navigationService.reloadNode($scope.currentNode.parent);
But $scope.currentNode gives me undefined
All my attempts at using navigationService.reloadNode gives me: Uncaught No childNodesUrl property found on the tree node, cannot load child nodes
Probably because I can't get hold of the node I need to refresh.
I am in a controller in a directive when i try to run this code.
I also tried navigationService.reloadSection("XXXXX") and I have tried different things where it says XXXXX but either I clear the tree or completely remove it entirely.
So questions
Can I reload the node from the path (like I use when I use syncTree?)
Or, is there another way for me to get the Id I need?
This is what I did, I was using a custom list view in my section so I don't think you will need the final route.reload I just used it to get my view back in sync after sorting. Note I was sorting from a menu action and so I had access to the node id from dialogOptions.
'use strict';
(function () {
//create the controller
function MySettingsSortSubTopicsController($scope, $routeParams, mySettingsResource, $q, navigationService, $route) {
$scope.editSortView = Umbraco.Sys.ServerVariables.umbracoSettings.appPluginsPath + "/" + $routeParams.section + "/backoffice/Settings/edit-sort.html";
var dialogOptions = $scope.dialogOptions;
$scope.save = function (items) {
if (!$scope.busy) {
$scope.busy = true;
var saveIds = [];
for (var i = 0; i < items.length; i++) {
saveIds.push(items[i].id);
}
mySettingsResource.saveSortOrder(saveIds, "subtopic").then(function (result) {
navigationService.syncTree({ tree: "mySettings", path: ["-1", "topics", $scope.contentId], forceReload: true }).then(function (syncArgs) {
$scope.busy = false;
$scope.currentNode = syncArgs.node;
if ($routeParams.id == $scope.currentNode.id) {
$route.reload();
}
});
deferred.resolve(result);
});
var deferred = $q.defer();
}
return deferred.promise;
}
function init() {
$scope.contentId = dialogOptions.currentNode.id;
$scope.loaded = true;
};
init();
};
//register the controller
angular.module("umbraco").controller('MySettings.SortSubTopicsController', MySettingsSortSubTopicsController);
})();
This is nearly working for us - but we're trying to load a different tree - and the problem seems to be that we need to switch to the new section before reloading.
The problem there is that the call to changeSection is not blocking and doesn't return a promise - so I think I need to add an event handler for when the treeService has finished switching to the new tree - is that even possible?
We can get it to work with yukky timeouts. I want to know the correct way to deal with the non-blocking call to changeSection?
Reload node in custom tree
I have a custom section with a Tree in it, and I have a custom way of resorting some nodes on the page of each node.
So my tree looks like this
I have that if you click for instance "Location NY" you get to the page to edit Location NY and once there you can resort it under Location tags... so you can make Location NY come after Location LA in the list.
All of this works fantastically... that is as long as I reload the page... because the tree refuses to update the order unless i reload the page.
I have tried to use navigationService.syncTree on the parent, that did not help (does not seem to be the correct thing).
I want to use: navigationService.reloadNode($scope.currentNode.parent); But $scope.currentNode gives me undefined
All my attempts at using navigationService.reloadNode gives me: Uncaught No childNodesUrl property found on the tree node, cannot load child nodes
Probably because I can't get hold of the node I need to refresh. I am in a controller in a directive when i try to run this code.
I also tried navigationService.reloadSection("XXXXX") and I have tried different things where it says XXXXX but either I clear the tree or completely remove it entirely.
So questions
This is what I did, I was using a custom list view in my section so I don't think you will need the final route.reload I just used it to get my view back in sync after sorting. Note I was sorting from a menu action and so I had access to the node id from dialogOptions.
This part
was exactly what I needed, thanks!!
This is nearly working for us - but we're trying to load a different tree - and the problem seems to be that we need to switch to the new section before reloading.
The problem there is that the call to changeSection is not blocking and doesn't return a promise - so I think I need to add an event handler for when the treeService has finished switching to the new tree - is that even possible?
We can get it to work with yukky timeouts. I want to know the correct way to deal with the non-blocking call to changeSection?
(Umbraco 7.4.1)
is working on a reply...