From ec4eeb5de68dc080d71f0786284862a9aa776cae Mon Sep 17 00:00:00 2001 From: perploug Date: Mon, 7 Oct 2013 10:09:03 +0200 Subject: [PATCH] tree syncing --- .../src/common/directives/umbtree.directive.js | 15 +++++++++++++-- .../src/views/content/content.edit.controller.js | 9 +++++++-- src/Umbraco.Web/Editors/ContentController.cs | 4 +--- .../Models/ContentEditing/ContentItemDisplay.cs | 4 +++- .../BasePages/ClientTools.cs | 3 ++- 5 files changed, 26 insertions(+), 9 deletions(-) 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 d964fb8901..1d7d299973 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 @@ -123,8 +123,7 @@ angular.module("umbraco.directives") //watch for section changes scope.$watch("section", function (newVal, oldVal) { - - if(!scope.tree){ + if(!scope.tree){ loadTree(); } @@ -141,6 +140,18 @@ angular.module("umbraco.directives") } }); + //watch for path changes + scope.$watch("path", function (newVal, oldVal) { + + if(!scope.tree){ + loadTree(); + } + if (newVal && newVal !== oldVal) { + //only reload the tree data and Dom if the newval is different from the old one + loadTree(); + } + }); + //watch for active tree changes scope.$watch("activetree", function (newVal, oldVal) { 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 69328d6e3d..0d7c5223c2 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 @@ -6,7 +6,7 @@ * @description * The controller for the content editor */ -function ContentEditController($scope, $routeParams, $q, $timeout, $window, contentResource, notificationsService, angularHelper, serverValidationManager, contentEditingHelper, fileManager, editorContextService) { +function ContentEditController($scope, $routeParams, $q, $timeout, $window, contentResource, navigationService, notificationsService, angularHelper, serverValidationManager, contentEditingHelper, fileManager, editorContextService) { //initialize the file manager fileManager.clearFiles(); @@ -49,6 +49,8 @@ function ContentEditController($scope, $routeParams, $q, $timeout, $window, cont newContent: data, rebindCallback: contentEditingHelper.reBindChangedProperties($scope.content, data) }); + + navigationService.syncPath(data.path.split(",")); }); }; @@ -73,6 +75,8 @@ function ContentEditController($scope, $routeParams, $q, $timeout, $window, cont rebindCallback: contentEditingHelper.reBindChangedProperties($scope.content, data) }); + navigationService.syncPath(data.path.split(",")); + }, function (err) { contentEditingHelper.handleSaveError({ @@ -124,8 +128,9 @@ function ContentEditController($scope, $routeParams, $q, $timeout, $window, cont rebindCallback: contentEditingHelper.reBindChangedProperties($scope.content, data) }); - deferred.resolve(data); + navigationService.syncPath(data.path.split(",")); + deferred.resolve(data); }, function (err) { contentEditingHelper.handleSaveError({ err: err, diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs index c5a955da17..9784b6027d 100644 --- a/src/Umbraco.Web/Editors/ContentController.cs +++ b/src/Umbraco.Web/Editors/ContentController.cs @@ -339,11 +339,9 @@ namespace Umbraco.Web.Editors /// attributed with EnsureUserPermissionForContent to verify the user has access to the recycle bin /// [HttpDelete] - [EnsureUserPermissionForContent(Constants.System.RecycleBinContent)] + /* [EnsureUserPermissionForContent(Constants.System.RecycleBinContent)]*/ public HttpResponseMessage EmptyRecycleBin() { - //TODO: We need to check if the user is allowed access to the recycle bin! - Services.ContentService.EmptyRecycleBin(); return Request.CreateResponse(HttpStatusCode.OK); } diff --git a/src/Umbraco.Web/Models/ContentEditing/ContentItemDisplay.cs b/src/Umbraco.Web/Models/ContentEditing/ContentItemDisplay.cs index 89c600251f..3987fbbeae 100644 --- a/src/Umbraco.Web/Models/ContentEditing/ContentItemDisplay.cs +++ b/src/Umbraco.Web/Models/ContentEditing/ContentItemDisplay.cs @@ -14,7 +14,9 @@ namespace Umbraco.Web.Models.ContentEditing [DataContract(Name = "content", Namespace = "")] public class ContentItemDisplay : ContentItemDisplayBase { - + [DataMember(Name = "path")] + public string Path { get; set; } + [DataMember(Name = "publishDate")] public DateTime? PublishDate { get; set; } diff --git a/src/umbraco.businesslogic/BasePages/ClientTools.cs b/src/umbraco.businesslogic/BasePages/ClientTools.cs index f291f32844..c164b086f1 100644 --- a/src/umbraco.businesslogic/BasePages/ClientTools.cs +++ b/src/umbraco.businesslogic/BasePages/ClientTools.cs @@ -51,6 +51,7 @@ namespace umbraco.BasePages public static string ReloadContentFrameUrlIfPathLoaded(string url) { return string.Format(ClientMgrScript + ".reloadContentFrameUrlIfPathLoaded('{0}');", url); } + public static string ChildNodeCreated = GetMainTree + ".childNodeCreated();"; public static string SyncTree { get { return GetMainTree + ".syncTree('{0}', {1});"; } } public static string ClearTreeCache { get { return GetMainTree + ".clearTreeCache();"; } } @@ -240,7 +241,7 @@ namespace umbraco.BasePages /// public ClientTools SyncTree(string path, bool forceReload) { - //RegisterClientScript(string.Format(Scripts.SyncTree, path, forceReload.ToString().ToLower())); + RegisterClientScript(string.Format(Scripts.SyncTree, path, forceReload.ToString().ToLower())); return this; }