Fixes more angular promise chaining, fixes issue with the tree node UI not updating when sycn tree is called.
This commit is contained in:
@@ -249,9 +249,6 @@ angular.module("umbraco.directives")
|
||||
$compile(newElement)(scope);
|
||||
element.append(newElement);
|
||||
|
||||
},
|
||||
controller: function ($scope) {
|
||||
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* @description
|
||||
* Defines the methods that are called when menu items declare only an action to execute
|
||||
*/
|
||||
function umbracoMenuActions($q, treeService, $location, navigationService, appState, localizationService, userResource, umbRequestHelper, notificationsService) {
|
||||
function umbracoMenuActions(treeService, $location, navigationService, appState, localizationService, usersResource, umbRequestHelper, notificationsService) {
|
||||
|
||||
return {
|
||||
|
||||
@@ -34,7 +34,7 @@ function umbracoMenuActions($q, treeService, $location, navigationService, appSt
|
||||
localizationService.localize("defaultdialogs_confirmdisable").then(function (txtConfirmDisable) {
|
||||
var currentMenuNode = UmbClientMgr.mainTree().getActionNode();
|
||||
if (confirm(txtConfirmDisable + ' "' + args.entity.name + '"?\n\n')) {
|
||||
userResource.disableUser(args.entity.id).then(function () {
|
||||
usersResource.disableUser(args.entity.id).then(function () {
|
||||
navigationService.syncTree({ tree: args.treeAlias, path: [args.entity.parentId, args.entity.id], forceReload: true });
|
||||
});
|
||||
}
|
||||
@@ -103,4 +103,4 @@ function umbracoMenuActions($q, treeService, $location, navigationService, appSt
|
||||
};
|
||||
}
|
||||
|
||||
angular.module('umbraco.services').factory('umbracoMenuActions', umbracoMenuActions);
|
||||
angular.module('umbraco.services').factory('umbracoMenuActions', umbracoMenuActions);
|
||||
|
||||
@@ -298,8 +298,14 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS
|
||||
if (args.node.children && args.node.children.length > 0) {
|
||||
args.node.expanded = true;
|
||||
args.node.hasChildren = true;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
//Since we've removed the children & reloaded them, we need to refresh the UI now because the tree node UI doesn't operate on normal angular $watch since that will be pretty slow
|
||||
if (angular.isFunction(args.node.updateNodeData)) {
|
||||
args.node.updateNodeData(args.node);
|
||||
}
|
||||
|
||||
return $q.when(data);
|
||||
|
||||
}, function(reason) {
|
||||
|
||||
@@ -312,7 +318,7 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS
|
||||
//tell notications about the error
|
||||
notificationsService.error(reason);
|
||||
|
||||
return reason;
|
||||
return $q.reject(reason);
|
||||
});
|
||||
|
||||
},
|
||||
@@ -609,7 +615,7 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS
|
||||
.then(function (data) {
|
||||
//now that we have the data, we need to add the level property to each item and the view
|
||||
self._formatNodeDataForUseInUI(treeItem, data, section, treeItem.level + 1);
|
||||
return data;
|
||||
return $q.when(data);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -634,12 +640,10 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS
|
||||
throw "cannot reload a single node without an assigned node.section";
|
||||
}
|
||||
|
||||
var deferred = $q.defer();
|
||||
|
||||
//set the node to loading
|
||||
node.loading = true;
|
||||
|
||||
this.getChildren({ node: node.parent(), section: node.section }).then(function(data) {
|
||||
return this.getChildren({ node: node.parent(), section: node.section }).then(function(data) {
|
||||
|
||||
//ok, now that we have the children, find the node we're reloading
|
||||
var found = _.find(data, function(item) {
|
||||
@@ -662,17 +666,15 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS
|
||||
|
||||
//set the node loading
|
||||
node.parent().children[index].loading = false;
|
||||
//return
|
||||
deferred.resolve(node.parent().children[index]);
|
||||
//return
|
||||
return $q.when(node.parent().children[index]);
|
||||
}
|
||||
else {
|
||||
deferred.reject();
|
||||
return $q.reject();
|
||||
}
|
||||
}, function() {
|
||||
deferred.reject();
|
||||
return $q.reject();
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -726,8 +728,6 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS
|
||||
args.path.push("-1");
|
||||
}
|
||||
|
||||
var deferred = $q.defer();
|
||||
|
||||
//get the rootNode for the current node, we'll sync based on that
|
||||
var root = this.getTreeRoot(args.node);
|
||||
if (!root) {
|
||||
@@ -741,8 +741,7 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS
|
||||
if (String(args.path[currPathIndex]).toLowerCase() === String(args.node.id).toLowerCase()) {
|
||||
if (args.path.length === 1) {
|
||||
//return the root
|
||||
deferred.resolve(root);
|
||||
return deferred.promise;
|
||||
return $q.when(root);
|
||||
}
|
||||
else {
|
||||
//move to the next path part and continue
|
||||
@@ -762,16 +761,12 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS
|
||||
if (args.path.length === (currPathIndex + 1)) {
|
||||
//woot! synced the node
|
||||
if (!args.forceReload) {
|
||||
deferred.resolve(child);
|
||||
return $q.when(child);
|
||||
}
|
||||
else {
|
||||
//even though we've found the node if forceReload is specified
|
||||
//we want to go update this single node from the server
|
||||
self.reloadNode(child).then(function (reloaded) {
|
||||
deferred.resolve(reloaded);
|
||||
}, function () {
|
||||
deferred.reject();
|
||||
});
|
||||
return self.reloadNode(child);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -779,42 +774,40 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS
|
||||
currPathIndex++;
|
||||
node = child;
|
||||
//recurse
|
||||
doSync();
|
||||
return doSync();
|
||||
}
|
||||
}
|
||||
else {
|
||||
//couldn't find it in the
|
||||
self.loadNodeChildren({ node: node, section: node.section }).then(function () {
|
||||
return self.loadNodeChildren({ node: node, section: node.section }).then(function () {
|
||||
//ok, got the children, let's find it
|
||||
var found = self.getChildNode(node, args.path[currPathIndex]);
|
||||
if (found) {
|
||||
if (args.path.length === (currPathIndex + 1)) {
|
||||
//woot! synced the node
|
||||
deferred.resolve(found);
|
||||
return $q.when(found);
|
||||
}
|
||||
else {
|
||||
//now we need to recurse with the updated node/currPathIndex
|
||||
currPathIndex++;
|
||||
node = found;
|
||||
//recurse
|
||||
doSync();
|
||||
return doSync();
|
||||
}
|
||||
}
|
||||
else {
|
||||
//fail!
|
||||
deferred.reject();
|
||||
return $q.reject();
|
||||
}
|
||||
}, function () {
|
||||
//fail!
|
||||
deferred.reject();
|
||||
return $q.reject();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//start
|
||||
doSync();
|
||||
|
||||
return deferred.promise;
|
||||
return doSync();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -236,13 +236,12 @@ function NavigationController($scope, $rootScope, $location, $log, $q, $routePar
|
||||
languageResource.getAll().then(function(languages) {
|
||||
$scope.languages = languages;
|
||||
|
||||
// select the default language
|
||||
$scope.languages.forEach(function(language) {
|
||||
if(language.isDefault) {
|
||||
$scope.selectLanguage(language);
|
||||
// make the default language selected
|
||||
$scope.languages.forEach(function (language) {
|
||||
if (language.isDefault) {
|
||||
$scope.selectedLanguage = language;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}));
|
||||
@@ -274,7 +273,7 @@ function NavigationController($scope, $rootScope, $location, $log, $q, $routePar
|
||||
}
|
||||
}
|
||||
|
||||
$scope.selectLanguage = function(language, languages) {
|
||||
$scope.selectLanguage = function(language) {
|
||||
$scope.selectedLanguage = language;
|
||||
// close the language selector
|
||||
$scope.page.languageSelectorIsOpen = false;
|
||||
@@ -293,7 +292,7 @@ function NavigationController($scope, $rootScope, $location, $log, $q, $routePar
|
||||
//starting with syncing to the currently selected node if there is one
|
||||
if (currNode) {
|
||||
var path = treeService.getPath(currNode);
|
||||
promises.push($scope.treeApi.syncTree({ path: path, activate: true }));
|
||||
promises.push($scope.treeApi.syncTree({ path: path, activate: true, forceReload: true }));
|
||||
}
|
||||
//for (var i = 0; i < expandedPaths.length; i++) {
|
||||
// promises.push($scope.treeApi.syncTree({ path: expandedPaths[i], activate: false, forceReload: true }));
|
||||
|
||||
Reference in New Issue
Block a user