From e2c06852d5376b11a4437691bcb58f6922941dd6 Mon Sep 17 00:00:00 2001 From: perploug Date: Thu, 10 Oct 2013 13:32:53 +0200 Subject: [PATCH] adds "overload" to member editor so it can accept a member ID --- .../views/member/member.edit.controller.js | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) 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 43500e10e3..adc1a85796 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 @@ -6,7 +6,7 @@ * @description * The controller for the member editor */ -function MemberEditController($scope, $routeParams, $q, $timeout, $window, memberResource, notificationsService, angularHelper, serverValidationManager, contentEditingHelper, fileManager, editorContextService) { +function MemberEditController($scope, $routeParams, $location, $q, $timeout, $window, memberResource, entityResource, notificationsService, angularHelper, serverValidationManager, contentEditingHelper, fileManager, editorContextService) { //initialize the file manager fileManager.clearFiles(); @@ -21,19 +21,29 @@ function MemberEditController($scope, $routeParams, $q, $timeout, $window, membe }); } else { - //we are editing so get the content item from the server - memberResource.getByKey($routeParams.id) - .then(function(data) { - $scope.loaded = true; - $scope.content = data; - editorContextService.setContext($scope.content); - - //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 - // after the redirect, so we will bind all subscriptions which will show the server validation errors - // if there are any and then clear them so the collection no longer persists them. - serverValidationManager.executeAndClearAllSubscriptions(); + //so, we usually refernce all editors with the Int ID, but with members we have + //a different pattern, adding a route-redirect here to handle this: + //isNumber doesnt work here since its seen as a string + if($routeParams.id && $routeParams.id.length < 9){ + entityResource.getById($routeParams.id, "Member").then(function(entity){ + $location.path("member/member/edit/" + entity.key); }); + }else{ + //we are editing so get the content item from the server + memberResource.getByKey($routeParams.id) + .then(function(data) { + $scope.loaded = true; + $scope.content = data; + editorContextService.setContext($scope.content); + + //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 + // after the redirect, so we will bind all subscriptions which will show the server validation errors + // if there are any and then clear them so the collection no longer persists them. + serverValidationManager.executeAndClearAllSubscriptions(); + }); + } + } //TODO: Need to figure out a way to share the saving and event broadcasting with all editors!