diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/umboptionsmenu.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/umboptionsmenu.directive.js index dc5c935c3e..56c7b97e11 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/umboptionsmenu.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/umboptionsmenu.directive.js @@ -1,10 +1,9 @@ angular.module("umbraco.directives") -.directive('umbOptionsMenu', function ($injector, treeService, navigationService, umbModelMapper) { +.directive('umbOptionsMenu', function ($injector, treeService, navigationService, umbModelMapper, appState) { return { scope: { - content: "=", currentSection: "@", - treeAlias: "@" + currentNode: "=" }, restrict: 'E', replace: true, @@ -15,9 +14,6 @@ angular.module("umbraco.directives") //depending on what the menu item is supposed to do. scope.executeMenuItem = function (action) { - //map our content object to a basic entity to pass in to the handlers - var currentEntity = umbModelMapper.convertToEntityBasic(scope.content); - if (action.metaData && action.metaData["jsAction"] && angular.isString(action.metaData["jsAction"])) { //we'll try to get the jsAction from the injector @@ -43,10 +39,10 @@ angular.module("umbraco.directives") } method.apply(this, [{ - entity: currentEntity, + entity: umbModelMapper.convertToEntityBasic(scope.currentNode), action: action, section: scope.currentSection, - treeAlias: scope.treeAlias + treeAlias: treeService.getTreeAlias(scope.currentNode) }]); } } @@ -57,18 +53,19 @@ angular.module("umbraco.directives") // the problem with all these dialogs is were passing other object's scopes around which isn't nice at all. // Each of these passed scopes expects a .nav property assigned to it which is a reference to the navigationService, // which should not be happenning... should simply be using the navigation service, no ?! - scope.$parent.openDialog(currentEntity, action, scope.currentSection); + scope.$parent.openDialog(scope.currentNode, action, scope.currentSection); } }; //callback method to go and get the options async scope.getOptions = function () { - if (!scope.content.id) { + + if (!scope.currentNode) { return; } - + if (!scope.actions) { - treeService.getMenu({ treeNode: navigationService.ui.currentNode }) + treeService.getMenu({ treeNode: scope.currentNode }) .then(function (data) { scope.actions = data.menuItems; }); diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/umbtree.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/umbtree.directive.js index 5e0b2f0b16..2b3798481c 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/umbtree.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/umbtree.directive.js @@ -114,6 +114,14 @@ function umbTreeDirective($compile, $log, $q, $rootScope, treeService, notificat throw "args.path cannot be null"; } + var deferred = $q.defer(); + + //this is super complex but seems to be working in other places, here we're listening for our + // own events, once the tree is sycned we'll resolve our promise. + scope.eventhandler.one("treeSynced", function (e, syncArgs) { + deferred.resolve(syncArgs); + }); + //this should normally be set unless it is being called from legacy // code, so set the active tree type before proceeding. if (args.tree) { @@ -130,6 +138,8 @@ function umbTreeDirective($compile, $log, $q, $rootScope, treeService, notificat //filter the path for root node ids args.path = _.filter(args.path, function (item) { return (item !== "init" && item !== "-1"); }); loadPath(args.path, args.forceReload); + + return deferred.promise; }; /** diff --git a/src/Umbraco.Web.UI.Client/src/common/services/angularhelper.service.js b/src/Umbraco.Web.UI.Client/src/common/services/angularhelper.service.js index 89a6990b54..fcc3cd59b1 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/angularhelper.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/angularhelper.service.js @@ -17,7 +17,7 @@ function angularHelper($log, $q) { * * @description * In some situations we need to return a promise as a rejection, normally based on invalid data. This - * is a wrapper to do that so we can save one writing a bit of code. + * is a wrapper to do that so we can save on writing a bit of code. * * @param {object} objReject The object to send back with the promise rejection */ diff --git a/src/Umbraco.Web.UI.Client/src/common/services/menuactions.service.js b/src/Umbraco.Web.UI.Client/src/common/services/menuactions.service.js index ebaabca44a..a0fb04dd16 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/menuactions.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/menuactions.service.js @@ -27,11 +27,11 @@ function umbracoMenuActions($q, treeService, $location, navigationService, appSt */ "RefreshNode": function (args) { - //just in case clear any tree cache for this node/section - treeService.clearCache({ - cacheKey: "__" + args.section, //each item in the tree cache is cached by the section name - childrenOf: args.entity.parentId //clear the children of the parent - }); + ////just in case clear any tree cache for this node/section + //treeService.clearCache({ + // cacheKey: "__" + args.section, //each item in the tree cache is cached by the section name + // childrenOf: args.entity.parentId //clear the children of the parent + //}); //since we're dealing with an entity, we need to attempt to find it's tree node, in the main tree // this action is purely a UI thing so if for whatever reason there is no loaded tree node in the UI diff --git a/src/Umbraco.Web.UI.Client/src/common/services/navigation.service.js b/src/Umbraco.Web.UI.Client/src/common/services/navigation.service.js index b2fb5045b0..d488810180 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/navigation.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/navigation.service.js @@ -15,7 +15,7 @@ * Section navigation and search, and maintain their state for the entire application lifetime * */ -function navigationService($rootScope, $routeParams, $log, $location, $q, $timeout, dialogService, treeService, notificationsService, historyService, appState) { +function navigationService($rootScope, $routeParams, $log, $location, $q, $timeout, dialogService, treeService, notificationsService, historyService, appState, angularHelper) { var minScreenSize = 1100; //used to track the current dialog object @@ -297,7 +297,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo * @methodOf umbraco.services.navigationService * * @description - * Syncs a tree with a given path + * Syncs a tree with a given path, returns a promise * The path format is: ["itemId","itemId"], and so on * so to sync to a specific document type node do: *
@@ -320,8 +320,12 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
}
if (mainTreeEventHandler) {
- mainTreeEventHandler.syncTree(args);
+ //returns a promise
+ return mainTreeEventHandler.syncTree(args);
}
+
+ //couldn't sync
+ return angularHelper.rejectedPromise();
},
/**
diff --git a/src/Umbraco.Web.UI.Client/src/views/content/content.edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/content.edit.controller.js
index 7fd1832545..e0cb009d69 100644
--- a/src/Umbraco.Web.UI.Client/src/views/content/content.edit.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/content/content.edit.controller.js
@@ -13,6 +13,7 @@ function ContentEditController($scope, $routeParams, $q, $timeout, $window, appS
$scope.subButtons = [];
$scope.nav = navigationService;
$scope.currentSection = appState.getSectionState("currentSection");
+ $scope.currentNode = null; //the editors affiliated node
//This sets up the action buttons based on what permissions the user has.
//The allowedActions parameter contains a list of chars, each represents a button by permission so
@@ -125,7 +126,9 @@ function ContentEditController($scope, $routeParams, $q, $timeout, $window, appS
configureButtons(data);
- navigationService.syncTree({ tree: "content", path: data.path.split(","), forceReload: true });
+ navigationService.syncTree({ tree: "content", path: data.path.split(","), forceReload: true }).then(function (syncArgs) {
+ $scope.currentNode = syncArgs.node;
+ });
deferred.resolve(data);
@@ -171,7 +174,9 @@ function ContentEditController($scope, $routeParams, $q, $timeout, $window, appS
// if there are any and then clear them so the collection no longer persists them.
serverValidationManager.executeAndClearAllSubscriptions();
- navigationService.syncTree({ tree: "content", path: data.path.split(",") });
+ navigationService.syncTree({ tree: "content", path: data.path.split(",") }).then(function(syncArgs) {
+ $scope.currentNode = syncArgs.node;
+ });
});
}
@@ -193,7 +198,9 @@ function ContentEditController($scope, $routeParams, $q, $timeout, $window, appS
configureButtons(data);
- navigationService.syncTree({ tree: "content", path: data.path.split(","), forceReload: true });
+ navigationService.syncTree({ tree: "content", path: data.path.split(","), forceReload: true }).then(function (syncArgs) {
+ $scope.currentNode = syncArgs.node;
+ });
});
}
diff --git a/src/Umbraco.Web.UI.Client/src/views/content/edit.html b/src/Umbraco.Web.UI.Client/src/views/content/edit.html
index 4c80a5b83c..45fa4a8d10 100644
--- a/src/Umbraco.Web.UI.Client/src/views/content/edit.html
+++ b/src/Umbraco.Web.UI.Client/src/views/content/edit.html
@@ -22,7 +22,10 @@
{{formStatus}}
-
+
+
diff --git a/src/Umbraco.Web.UI.Client/src/views/datatype/datatype.edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/datatype/datatype.edit.controller.js
index 9750a420bd..5a83003c46 100644
--- a/src/Umbraco.Web.UI.Client/src/views/datatype/datatype.edit.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/datatype/datatype.edit.controller.js
@@ -11,6 +11,7 @@ function DataTypeEditController($scope, $routeParams, $location, appState, navig
//setup scope vars
$scope.nav = navigationService;
$scope.currentSection = appState.getSectionState("currentSection");
+ $scope.currentNode = null; //the editors affiliated node
//method used to configure the pre-values when we retreive them from the server
function createPreValueProps(preVals) {
@@ -68,7 +69,9 @@ function DataTypeEditController($scope, $routeParams, $location, appState, navig
// if there are any and then clear them so the collection no longer persists them.
serverValidationManager.executeAndClearAllSubscriptions();
- navigationService.syncTree({ tree: "datatype", path: [String(data.id)] });
+ navigationService.syncTree({ tree: "datatype", path: [String(data.id)] }).then(function (syncArgs) {
+ $scope.currentNode = syncArgs.node;
+ });
});
}
@@ -104,7 +107,9 @@ function DataTypeEditController($scope, $routeParams, $location, appState, navig
}
});
- navigationService.syncTree({ tree: "datatype", path: [String(data.id)], forceReload: true });
+ navigationService.syncTree({ tree: "datatype", path: [String(data.id)], forceReload: true }).then(function (syncArgs) {
+ $scope.currentNode = syncArgs.node;
+ });
}, function(err) {
diff --git a/src/Umbraco.Web.UI.Client/src/views/datatype/edit.html b/src/Umbraco.Web.UI.Client/src/views/datatype/edit.html
index 155e65534f..115df8503f 100644
--- a/src/Umbraco.Web.UI.Client/src/views/datatype/edit.html
+++ b/src/Umbraco.Web.UI.Client/src/views/datatype/edit.html
@@ -18,7 +18,10 @@
diff --git a/src/Umbraco.Web.UI.Client/src/views/media/edit.html b/src/Umbraco.Web.UI.Client/src/views/media/edit.html
index 4a0dcee588..2df792ba14 100644
--- a/src/Umbraco.Web.UI.Client/src/views/media/edit.html
+++ b/src/Umbraco.Web.UI.Client/src/views/media/edit.html
@@ -20,7 +20,10 @@
{{formStatus}}
-
+
+
diff --git a/src/Umbraco.Web.UI.Client/src/views/media/media.edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/media/media.edit.controller.js
index cba63b5078..99f21c3fb9 100644
--- a/src/Umbraco.Web.UI.Client/src/views/media/media.edit.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/media/media.edit.controller.js
@@ -11,6 +11,7 @@ function mediaEditController($scope, $routeParams, appState, mediaResource, navi
//setup scope vars
$scope.nav = navigationService;
$scope.currentSection = appState.getSectionState("currentSection");
+ $scope.currentNode = null; //the editors affiliated node
if ($routeParams.create) {
@@ -33,7 +34,9 @@ function mediaEditController($scope, $routeParams, appState, mediaResource, navi
// if there are any and then clear them so the collection no longer persists them.
serverValidationManager.executeAndClearAllSubscriptions();
- navigationService.syncTree({ tree: "media", path: data.path });
+ navigationService.syncTree({ tree: "media", path: data.path }).then(function (syncArgs) {
+ $scope.currentNode = syncArgs.node;
+ });
});
}
@@ -53,7 +56,9 @@ function mediaEditController($scope, $routeParams, appState, mediaResource, navi
rebindCallback: contentEditingHelper.reBindChangedProperties($scope.content, data)
});
- navigationService.syncTree({ tree: "media", path: data.path, forceReload: true });
+ navigationService.syncTree({ tree: "media", path: data.path, forceReload: true }).then(function (syncArgs) {
+ $scope.currentNode = syncArgs.node;
+ });
}, function(err) {
diff --git a/src/Umbraco.Web.UI.Client/src/views/member/edit.html b/src/Umbraco.Web.UI.Client/src/views/member/edit.html
index 488c2830ab..9a11f3a757 100644
--- a/src/Umbraco.Web.UI.Client/src/views/member/edit.html
+++ b/src/Umbraco.Web.UI.Client/src/views/member/edit.html
@@ -20,7 +20,10 @@
{{formStatus}}
-
+
+
diff --git a/src/Umbraco.Web.UI.Client/src/views/member/member.edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/member/member.edit.controller.js
index 9c473c6c5a..f1ade8b374 100644
--- a/src/Umbraco.Web.UI.Client/src/views/member/member.edit.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/member/member.edit.controller.js
@@ -11,6 +11,7 @@ function MemberEditController($scope, $routeParams, $location, $q, $window, appS
//setup scope vars
$scope.nav = navigationService;
$scope.currentSection = appState.getSectionState("currentSection");
+ $scope.currentNode = null; //the editors affiliated node
if ($routeParams.create) {
//we are creating so get an empty member item
@@ -43,7 +44,9 @@ function MemberEditController($scope, $routeParams, $location, $q, $window, appS
var path = data.name[0]+"," + data.key;
path = path.replace(/-/g,'');
- navigationService.syncTree({ tree: "member", path: path.split(",") });
+ navigationService.syncTree({ tree: "member", path: path.split(",") }).then(function (syncArgs) {
+ $scope.currentNode = syncArgs.node;
+ });
//in one particular special case, after we've created a new item we redirect back to the edit
// route but there might be server validation errors in the collection which we need to display
@@ -71,6 +74,10 @@ function MemberEditController($scope, $routeParams, $location, $q, $window, appS
redirectId: data.key,
rebindCallback: contentEditingHelper.reBindChangedProperties($scope.content, data)
});
+
+ navigationService.syncTree({ tree: "member", path: path.split(",") }).then(function (syncArgs) {
+ $scope.currentNode = syncArgs.node;
+ });
}, function (err) {