Updated trees to get children nodes from the server... nearly working and also works with proxying

to legacy trees. In fact there are not new trees created yet, just focusing on adapting for legacy trees
which so far seems to be good.
This commit is contained in:
Shannon Deminick
2013-05-31 17:20:56 -10:00
parent 4a57dcfd01
commit f3fbae7173
9 changed files with 294 additions and 130 deletions

View File

@@ -8,13 +8,21 @@ define(['angular'], function(angular) {
**/
function umbTreeResource($q, $http) {
//internal method to get the tree app url
/** internal method to get the tree app url */
function getTreeAppUrl(section) {
return Umbraco.Sys.ServerVariables.treeApplicationApiBaseUrl + "GetApplicationTrees?application=" + section;
}
/** internal method to get the tree node's children url */
function getTreeNodesUrl(node) {
if (!node.childNodesUrl)
throw "No childNodesUrl property found on the tree node, cannot load child nodes";
return node.childNodesUrl;
}
//the factory object returned
return {
/** Loads in the data to display the nodes for an application */
loadApplication: function (section) {
var deferred = $q.defer();
@@ -29,6 +37,23 @@ define(['angular'], function(angular) {
});
return deferred.promise;
},
/** Loads in the data to display the child nodes for a given node */
loadNodes: function(section, node) {
var deferred = $q.defer();
//go and get the tree data
$http.get(getTreeNodesUrl(node)).
success(function (data, status, headers, config) {
deferred.resolve(data);
}).
error(function (data, status, headers, config) {
deferred.reject('Failed to retreive data for child nodes ' + node.nodeId);
});
return deferred.promise;
}
};
}