diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs
index 7b5b728e7d..de2481f090 100644
--- a/src/Umbraco.Web/Editors/ContentController.cs
+++ b/src/Umbraco.Web/Editors/ContentController.cs
@@ -25,12 +25,10 @@ using Umbraco.Core.Persistence.Querying;
using Umbraco.Web.PublishedCache;
using Umbraco.Core.Events;
using Umbraco.Core.Models.Validation;
-using Umbraco.Web.Models;
-using Umbraco.Web.WebServices;
using Umbraco.Web._Legacy.Actions;
using Constants = Umbraco.Core.Constants;
-using ContentVariation = Umbraco.Core.Models.ContentVariation;
using Language = Umbraco.Web.Models.ContentEditing.Language;
+using SortNode = Umbraco.Web.Models.ContentEditing.SortNode;
namespace Umbraco.Web.Editors
{
@@ -957,6 +955,35 @@ namespace Umbraco.Web.Editors
return Request.CreateNotificationSuccessResponse(Services.TextService.Localize("defaultdialogs/recycleBinIsEmpty"));
}
+ ///
+ /// Gets child nodes of the current node (parentId) to be sorted
+ ///
+ /// The current node in which to sort its children
+ ///
+ [HttpGet]
+ public SortNode GetContentSortOrder(int parentId)
+ {
+ var nodes = new List();
+ var parent = new SortNode { Id = parentId };
+
+ var entityService = Services.EntityService;
+
+ // Root node
+ if (parentId == -1)
+ {
+ var rootContent = entityService.GetRootEntities(UmbracoObjectTypes.Document);
+ nodes.AddRange(rootContent.Select(content => new SortNode(content.Id, content.SortOrder, content.Name, content.CreateDate)));
+ }
+ else
+ {
+ var children = entityService.GetChildren(parentId);
+ nodes.AddRange(children.Select(child => new SortNode(child.Id, child.SortOrder, child.Name, child.CreateDate)));
+ }
+
+ parent.SortNodes = nodes.ToArray();
+ return parent;
+ }
+
///
/// Change the sort order for content
///
diff --git a/src/Umbraco.Web/Models/ContentEditing/SortNode.cs b/src/Umbraco.Web/Models/ContentEditing/SortNode.cs
new file mode 100644
index 0000000000..8b53d38808
--- /dev/null
+++ b/src/Umbraco.Web/Models/ContentEditing/SortNode.cs
@@ -0,0 +1,26 @@
+using System;
+
+namespace Umbraco.Web.Models.ContentEditing
+{
+ [Serializable]
+ public class SortNode
+ {
+ public int Id { get; set; }
+ public int SortOrder { get; set; }
+ public string Name { get; set; }
+ public DateTime CreateDate { get; set; }
+ public SortNode[] SortNodes { get; set; }
+
+ public SortNode()
+ {
+ }
+
+ public SortNode(int id, int sortOrder, string name, DateTime createDate)
+ {
+ Id = Id;
+ SortOrder = sortOrder;
+ Name = name;
+ CreateDate = createDate;
+ }
+ }
+}
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index 427c7fdd66..20dca7ee54 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -226,6 +226,7 @@
+