diff --git a/src/Umbraco.Web.UI/App_Plugins/MyPackage/Trees/LegacyTestTree.cs b/src/Umbraco.Web.UI/App_Plugins/MyPackage/Trees/LegacyTestTree.cs index bfc0583813..3d6832282f 100644 --- a/src/Umbraco.Web.UI/App_Plugins/MyPackage/Trees/LegacyTestTree.cs +++ b/src/Umbraco.Web.UI/App_Plugins/MyPackage/Trees/LegacyTestTree.cs @@ -2,9 +2,9 @@ using System.Net.Http.Formatting; using System.Text; using Umbraco.Core; +using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; using Umbraco.Web.Trees; -using Umbraco.Web.Trees.Menu; using umbraco.cms.presentation.Trees; using Constants = Umbraco.Core.Constants; diff --git a/src/Umbraco.Web/Trees/SearchResultItem.cs b/src/Umbraco.Web/Models/ContentEditing/SearchResultItem.cs similarity index 91% rename from src/Umbraco.Web/Trees/SearchResultItem.cs rename to src/Umbraco.Web/Models/ContentEditing/SearchResultItem.cs index 37513f6ea5..573ce75366 100644 --- a/src/Umbraco.Web/Trees/SearchResultItem.cs +++ b/src/Umbraco.Web/Models/ContentEditing/SearchResultItem.cs @@ -1,25 +1,25 @@ -namespace Umbraco.Web.Trees -{ - public class SearchResultItem - { - /// - /// The string representation of the ID, used for Web responses - /// - public string Id { get; set; } - - /// - /// The name/title of the search result item - /// - public string Title { get; set; } - - /// - /// The rank of the search result - /// - public int Rank { get; set; } - - /// - /// Description/Synopsis of the item - /// - public string Description { get; set; } - } +namespace Umbraco.Web.Models.ContentEditing +{ + public class SearchResultItem + { + /// + /// The string representation of the ID, used for Web responses + /// + public string Id { get; set; } + + /// + /// The name/title of the search result item + /// + public string Title { get; set; } + + /// + /// The rank of the search result + /// + public int Rank { get; set; } + + /// + /// Description/Synopsis of the item + /// + public string Description { get; set; } + } } \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/Menu/ActionMenuItem.cs b/src/Umbraco.Web/Models/Trees/ActionMenuItem.cs similarity index 96% rename from src/Umbraco.Web/Trees/Menu/ActionMenuItem.cs rename to src/Umbraco.Web/Models/Trees/ActionMenuItem.cs index 74d7cb0364..d8e259dbbd 100644 --- a/src/Umbraco.Web/Trees/Menu/ActionMenuItem.cs +++ b/src/Umbraco.Web/Models/Trees/ActionMenuItem.cs @@ -1,42 +1,42 @@ -using System; -using Umbraco.Core; - -namespace Umbraco.Web.Trees.Menu -{ - /// - /// A menu item that represents some JS that needs to execute when the menu item is clicked. - /// - /// - /// These types of menu items are rare but they do exist. Things like refresh node simply execute - /// JS and don't launch a dialog. - /// - /// Each action menu item describes what angular service that it's method exists in and what the method name is. - /// - /// An action menu item must describe the angular service name for which it's method exists. It may also define what the - /// method name is that will be called in this service but if one is not specified then we will assume the method name is the - /// same as the Type name of the current action menu class. - /// - public abstract class ActionMenuItem : MenuItem - { - protected ActionMenuItem() - : base() - { - var attribute = GetType().GetCustomAttribute(false); - if (attribute == null) - { - throw new InvalidOperationException("All " + typeof (ActionMenuItem).FullName + " instances must be attributed with " + typeof (ActionMenuItemAttribute).FullName); - } - - //add the current type to the metadata - if (attribute.MethodName.IsNullOrWhiteSpace()) - { - //if no method name is supplied we will assume that the menu action is the type name of the current menu class - AdditionalData.Add("jsAction", string.Format("{0}.{1}", attribute.ServiceName, this.GetType().Name)); - } - else - { - AdditionalData.Add("jsAction", string.Format("{0}.{1}", attribute.ServiceName, attribute.MethodName)); - } - } - } +using System; +using Umbraco.Core; + +namespace Umbraco.Web.Models.Trees +{ + /// + /// A menu item that represents some JS that needs to execute when the menu item is clicked. + /// + /// + /// These types of menu items are rare but they do exist. Things like refresh node simply execute + /// JS and don't launch a dialog. + /// + /// Each action menu item describes what angular service that it's method exists in and what the method name is. + /// + /// An action menu item must describe the angular service name for which it's method exists. It may also define what the + /// method name is that will be called in this service but if one is not specified then we will assume the method name is the + /// same as the Type name of the current action menu class. + /// + public abstract class ActionMenuItem : MenuItem + { + protected ActionMenuItem() + : base() + { + var attribute = GetType().GetCustomAttribute(false); + if (attribute == null) + { + throw new InvalidOperationException("All " + typeof (ActionMenuItem).FullName + " instances must be attributed with " + typeof (ActionMenuItemAttribute).FullName); + } + + //add the current type to the metadata + if (attribute.MethodName.IsNullOrWhiteSpace()) + { + //if no method name is supplied we will assume that the menu action is the type name of the current menu class + AdditionalData.Add("jsAction", string.Format("{0}.{1}", attribute.ServiceName, this.GetType().Name)); + } + else + { + AdditionalData.Add("jsAction", string.Format("{0}.{1}", attribute.ServiceName, attribute.MethodName)); + } + } + } } \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/Menu/ActionMenuItemAttribute.cs b/src/Umbraco.Web/Models/Trees/ActionMenuItemAttribute.cs similarity index 94% rename from src/Umbraco.Web/Trees/Menu/ActionMenuItemAttribute.cs rename to src/Umbraco.Web/Models/Trees/ActionMenuItemAttribute.cs index fe36e6d1c5..a08a7293ea 100644 --- a/src/Umbraco.Web/Trees/Menu/ActionMenuItemAttribute.cs +++ b/src/Umbraco.Web/Models/Trees/ActionMenuItemAttribute.cs @@ -1,39 +1,39 @@ -using System; -using Umbraco.Core; - -namespace Umbraco.Web.Trees.Menu -{ - /// - /// The attribute to assign to any ActionMenuItem objects. - /// - [AttributeUsage(AttributeTargets.Class)] - public sealed class ActionMenuItemAttribute : Attribute - { - /// - /// This constructor defines both the angular service and method name to use - /// - /// - /// - public ActionMenuItemAttribute(string serviceName, string methodName) - { - Mandate.ParameterNotNullOrEmpty(serviceName, "serviceName"); - Mandate.ParameterNotNullOrEmpty(methodName, "methodName"); - MethodName = methodName; - ServiceName = serviceName; - } - - /// - /// This constructor will assume that the method name equals the type name of the action menu class - /// - /// - public ActionMenuItemAttribute(string serviceName) - { - Mandate.ParameterNotNullOrEmpty(serviceName, "serviceName"); - MethodName = ""; - ServiceName = serviceName; - } - - public string MethodName { get; private set; } - public string ServiceName { get; private set; } - } +using System; +using Umbraco.Core; + +namespace Umbraco.Web.Models.Trees +{ + /// + /// The attribute to assign to any ActionMenuItem objects. + /// + [AttributeUsage(AttributeTargets.Class)] + public sealed class ActionMenuItemAttribute : Attribute + { + /// + /// This constructor defines both the angular service and method name to use + /// + /// + /// + public ActionMenuItemAttribute(string serviceName, string methodName) + { + Mandate.ParameterNotNullOrEmpty(serviceName, "serviceName"); + Mandate.ParameterNotNullOrEmpty(methodName, "methodName"); + MethodName = methodName; + ServiceName = serviceName; + } + + /// + /// This constructor will assume that the method name equals the type name of the action menu class + /// + /// + public ActionMenuItemAttribute(string serviceName) + { + Mandate.ParameterNotNullOrEmpty(serviceName, "serviceName"); + MethodName = ""; + ServiceName = serviceName; + } + + public string MethodName { get; private set; } + public string ServiceName { get; private set; } + } } \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/Menu/CreateChildEntity.cs b/src/Umbraco.Web/Models/Trees/CreateChildEntity.cs similarity index 81% rename from src/Umbraco.Web/Trees/Menu/CreateChildEntity.cs rename to src/Umbraco.Web/Models/Trees/CreateChildEntity.cs index 3a211fa114..6d1d64373e 100644 --- a/src/Umbraco.Web/Trees/Menu/CreateChildEntity.cs +++ b/src/Umbraco.Web/Models/Trees/CreateChildEntity.cs @@ -1,10 +1,10 @@ -namespace Umbraco.Web.Trees.Menu -{ - /// - /// Represents the refresh node menu item - /// - [ActionMenuItem("umbracoMenuActions")] - public sealed class CreateChildEntity : ActionMenuItem - { - } +namespace Umbraco.Web.Models.Trees +{ + /// + /// Represents the refresh node menu item + /// + [ActionMenuItem("umbracoMenuActions")] + public sealed class CreateChildEntity : ActionMenuItem + { + } } \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/Menu/MenuItem.cs b/src/Umbraco.Web/Models/Trees/MenuItem.cs similarity index 95% rename from src/Umbraco.Web/Trees/Menu/MenuItem.cs rename to src/Umbraco.Web/Models/Trees/MenuItem.cs index 031c585930..708f078a33 100644 --- a/src/Umbraco.Web/Trees/Menu/MenuItem.cs +++ b/src/Umbraco.Web/Models/Trees/MenuItem.cs @@ -1,69 +1,69 @@ -using System.ComponentModel.DataAnnotations; -using System.Runtime.Serialization; -using umbraco.interfaces; -using System.Collections.Generic; -using Umbraco.Core; - -namespace Umbraco.Web.Trees.Menu -{ - /// - /// A context menu item - /// - [DataContract(Name = "menuItem", Namespace = "")] - public class MenuItem - { - public MenuItem() - { - AdditionalData = new Dictionary(); - Icon = "folder"; - } - - public MenuItem(string alias, string name) - : this() - { - Alias = alias; - Name = name; - } - - public MenuItem(IAction legacyMenu, string name = "") - : this() - { - Name = name.IsNullOrWhiteSpace() ? legacyMenu.Alias : name; - Alias = legacyMenu.Alias; - SeperatorBefore = false; - Icon = legacyMenu.Icon; - Action = legacyMenu; - } - - internal IAction Action { get; set; } - - /// - /// A dictionary to support any additional meta data that should be rendered for the node which is - /// useful for custom action commands such as 'create', 'copy', etc... - /// - /// - /// We will also use the meta data collection for dealing with legacy menu items (i.e. for loading custom URLs or - /// executing custom JS). - /// - [DataMember(Name = "metaData")] - public Dictionary AdditionalData { get; private set; } - - [DataMember(Name = "name", IsRequired = true)] - [Required] - public string Name { get; set; } - - [DataMember(Name = "alias", IsRequired = true)] - [Required] - public string Alias { get; set; } - - /// - /// Ensures a menu separator will exist before this menu item - /// - [DataMember(Name = "seperator")] - public bool SeperatorBefore { get; set; } - - [DataMember(Name = "cssclass")] - public string Icon { get; set; } - - } +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using umbraco.interfaces; +using System.Collections.Generic; +using Umbraco.Core; + +namespace Umbraco.Web.Models.Trees +{ + /// + /// A context menu item + /// + [DataContract(Name = "menuItem", Namespace = "")] + public class MenuItem + { + public MenuItem() + { + AdditionalData = new Dictionary(); + Icon = "folder"; + } + + public MenuItem(string alias, string name) + : this() + { + Alias = alias; + Name = name; + } + + public MenuItem(IAction legacyMenu, string name = "") + : this() + { + Name = name.IsNullOrWhiteSpace() ? legacyMenu.Alias : name; + Alias = legacyMenu.Alias; + SeperatorBefore = false; + Icon = legacyMenu.Icon; + Action = legacyMenu; + } + + internal IAction Action { get; set; } + + /// + /// A dictionary to support any additional meta data that should be rendered for the node which is + /// useful for custom action commands such as 'create', 'copy', etc... + /// + /// + /// We will also use the meta data collection for dealing with legacy menu items (i.e. for loading custom URLs or + /// executing custom JS). + /// + [DataMember(Name = "metaData")] + public Dictionary AdditionalData { get; private set; } + + [DataMember(Name = "name", IsRequired = true)] + [Required] + public string Name { get; set; } + + [DataMember(Name = "alias", IsRequired = true)] + [Required] + public string Alias { get; set; } + + /// + /// Ensures a menu separator will exist before this menu item + /// + [DataMember(Name = "seperator")] + public bool SeperatorBefore { get; set; } + + [DataMember(Name = "cssclass")] + public string Icon { get; set; } + + } } \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/Menu/MenuItemCollection.cs b/src/Umbraco.Web/Models/Trees/MenuItemCollection.cs similarity index 89% rename from src/Umbraco.Web/Trees/Menu/MenuItemCollection.cs rename to src/Umbraco.Web/Models/Trees/MenuItemCollection.cs index ea57fb7a07..d92b0c71d4 100644 --- a/src/Umbraco.Web/Trees/Menu/MenuItemCollection.cs +++ b/src/Umbraco.Web/Models/Trees/MenuItemCollection.cs @@ -1,45 +1,44 @@ -using System.Collections; -using System.Collections.Generic; -using System.Runtime.Serialization; - -namespace Umbraco.Web.Trees.Menu -{ - /// - /// A menu item collection for a given tree node - /// - [DataContract(Name = "menuItems", Namespace = "")] - public class MenuItemCollection - { - private readonly MenuItemList _menuItems = new MenuItemList(); - - public MenuItemCollection() - { - } - - public MenuItemCollection(IEnumerable items) - { - _menuItems = new MenuItemList(items); - } - - /// - /// Sets the default menu item alias to be shown when the menu is launched - this is optional and if not set then the menu will just be shown normally. - /// - [DataMember(Name = "defaultAlias")] - public string DefaultMenuAlias { get; set; } - - /// - /// The list of menu items - /// - /// - /// We require this so the json serialization works correctly - /// - [DataMember(Name = "menuItems")] - public MenuItemList Items - { - get { return _menuItems; } - } - - - - } +using System.Collections.Generic; +using System.Runtime.Serialization; + +namespace Umbraco.Web.Models.Trees +{ + /// + /// A menu item collection for a given tree node + /// + [DataContract(Name = "menuItems", Namespace = "")] + public class MenuItemCollection + { + private readonly MenuItemList _menuItems = new MenuItemList(); + + public MenuItemCollection() + { + } + + public MenuItemCollection(IEnumerable items) + { + _menuItems = new MenuItemList(items); + } + + /// + /// Sets the default menu item alias to be shown when the menu is launched - this is optional and if not set then the menu will just be shown normally. + /// + [DataMember(Name = "defaultAlias")] + public string DefaultMenuAlias { get; set; } + + /// + /// The list of menu items + /// + /// + /// We require this so the json serialization works correctly + /// + [DataMember(Name = "menuItems")] + public MenuItemList Items + { + get { return _menuItems; } + } + + + + } } \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/Menu/MenuItemExtensions.cs b/src/Umbraco.Web/Models/Trees/MenuItemExtensions.cs similarity index 97% rename from src/Umbraco.Web/Trees/Menu/MenuItemExtensions.cs rename to src/Umbraco.Web/Models/Trees/MenuItemExtensions.cs index 32dfecc13a..fc911ef8c3 100644 --- a/src/Umbraco.Web/Trees/Menu/MenuItemExtensions.cs +++ b/src/Umbraco.Web/Models/Trees/MenuItemExtensions.cs @@ -1,95 +1,96 @@ -using Umbraco.Core; -using Umbraco.Core.Models.EntityBase; -using umbraco; - -namespace Umbraco.Web.Trees.Menu -{ - public static class MenuItemExtensions - { - /// - /// Used as a key for the AdditionalData to specify a specific dialog title instead of the menu title - /// - internal const string DialogTitleKey = "dialogTitle"; - - /// - /// Used to specify the URL that the dialog will launch to in an iframe - /// - internal const string ActionUrlKey = "actionUrl"; - - //TODO: some action's want to launch a new window like live editing, we support this in the menu item's metadata with - // a key called: "actionUrlMethod" which can be set to either: Dialog, BlankWindow. Normally this is always set to Dialog - // if a URL is specified in the "actionUrl" metadata. For now I'm not going to implement launching in a blank window, - // though would be v-easy, just not sure we want to ever support that? - internal const string ActionUrlMethodKey = "actionUrlMethod"; - - /// - /// Used to specify the angular view that the dialog will launch - /// - internal const string ActionViewKey = "actionView"; - - /// - /// Sets the menu item to display a dialog based on an angular view path - /// - /// - /// - /// - public static void LaunchDialogView(this MenuItem menuItem, string view, string dialogTitle) - { - menuItem.SetDialogTitle(dialogTitle); - menuItem.AdditionalData[ActionViewKey] = view; - } - - /// - /// Sets the menu item to display a dialog based on a url path in an iframe - /// - /// - /// - /// - public static void LaunchDialogUrl(this MenuItem menuItem, string url, string dialogTitle) - { - menuItem.SetDialogTitle(dialogTitle); - menuItem.SetActionUrl(url); - } - - /// - /// Puts a dialog title into the meta data to be displayed on the dialog of the menu item (if there is one) - /// instead of the menu name - /// - /// - /// - private static void SetDialogTitle(this MenuItem menuItem, string dialogTitle) - { - menuItem.AdditionalData[DialogTitleKey] = dialogTitle; - } - - /// - /// Configures the menu item to launch a URL with the specified action (dialog or new window) - /// - /// - /// - /// - private static void SetActionUrl(this MenuItem menuItem, string url, ActionUrlMethod method = ActionUrlMethod.Dialog) - { - menuItem.AdditionalData[ActionUrlKey] = url; - menuItem.AdditionalData[ActionUrlMethodKey] = url; - } - - internal static void ConvertLegacyMenuItem(this MenuItem menuItem, IUmbracoEntity item, string nodeType, string currentSection) - { - //First try to get a URL/title from the legacy action, - // if that doesn't work, try to get the legacy confirm view - - //in some edge cases, item can be null so we'll just convert those to "-1" and "" for id and name since these edge cases don't need that. - Attempt - .Try(LegacyTreeDataConverter.GetUrlAndTitleFromLegacyAction(menuItem.Action, - item == null ? "-1" : item.Id.ToInvariantString(), - nodeType, - item == null ? "" : item.Name, currentSection), - action => menuItem.LaunchDialogUrl(action.Url, action.DialogTitle)) - .OnFailure(() => LegacyTreeDataConverter.GetLegacyConfirmView(menuItem.Action, currentSection), - view => menuItem.LaunchDialogView( - view, - ui.GetText("defaultdialogs", "confirmdelete") + " '" + item.Name + "' ?")); - } - } +using Umbraco.Core; +using Umbraco.Core.Models.EntityBase; +using Umbraco.Web.Trees; +using umbraco; + +namespace Umbraco.Web.Models.Trees +{ + public static class MenuItemExtensions + { + /// + /// Used as a key for the AdditionalData to specify a specific dialog title instead of the menu title + /// + internal const string DialogTitleKey = "dialogTitle"; + + /// + /// Used to specify the URL that the dialog will launch to in an iframe + /// + internal const string ActionUrlKey = "actionUrl"; + + //TODO: some action's want to launch a new window like live editing, we support this in the menu item's metadata with + // a key called: "actionUrlMethod" which can be set to either: Dialog, BlankWindow. Normally this is always set to Dialog + // if a URL is specified in the "actionUrl" metadata. For now I'm not going to implement launching in a blank window, + // though would be v-easy, just not sure we want to ever support that? + internal const string ActionUrlMethodKey = "actionUrlMethod"; + + /// + /// Used to specify the angular view that the dialog will launch + /// + internal const string ActionViewKey = "actionView"; + + /// + /// Sets the menu item to display a dialog based on an angular view path + /// + /// + /// + /// + public static void LaunchDialogView(this MenuItem menuItem, string view, string dialogTitle) + { + menuItem.SetDialogTitle(dialogTitle); + menuItem.AdditionalData[ActionViewKey] = view; + } + + /// + /// Sets the menu item to display a dialog based on a url path in an iframe + /// + /// + /// + /// + public static void LaunchDialogUrl(this MenuItem menuItem, string url, string dialogTitle) + { + menuItem.SetDialogTitle(dialogTitle); + menuItem.SetActionUrl(url); + } + + /// + /// Puts a dialog title into the meta data to be displayed on the dialog of the menu item (if there is one) + /// instead of the menu name + /// + /// + /// + private static void SetDialogTitle(this MenuItem menuItem, string dialogTitle) + { + menuItem.AdditionalData[DialogTitleKey] = dialogTitle; + } + + /// + /// Configures the menu item to launch a URL with the specified action (dialog or new window) + /// + /// + /// + /// + private static void SetActionUrl(this MenuItem menuItem, string url, ActionUrlMethod method = ActionUrlMethod.Dialog) + { + menuItem.AdditionalData[ActionUrlKey] = url; + menuItem.AdditionalData[ActionUrlMethodKey] = url; + } + + internal static void ConvertLegacyMenuItem(this MenuItem menuItem, IUmbracoEntity item, string nodeType, string currentSection) + { + //First try to get a URL/title from the legacy action, + // if that doesn't work, try to get the legacy confirm view + + //in some edge cases, item can be null so we'll just convert those to "-1" and "" for id and name since these edge cases don't need that. + Attempt + .Try(LegacyTreeDataConverter.GetUrlAndTitleFromLegacyAction(menuItem.Action, + item == null ? "-1" : item.Id.ToInvariantString(), + nodeType, + item == null ? "" : item.Name, currentSection), + action => menuItem.LaunchDialogUrl(action.Url, action.DialogTitle)) + .OnFailure(() => LegacyTreeDataConverter.GetLegacyConfirmView(menuItem.Action, currentSection), + view => menuItem.LaunchDialogView( + view, + ui.GetText("defaultdialogs", "confirmdelete") + " '" + item.Name + "' ?")); + } + } } \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/Menu/MenuItemList.cs b/src/Umbraco.Web/Models/Trees/MenuItemList.cs similarity index 99% rename from src/Umbraco.Web/Trees/Menu/MenuItemList.cs rename to src/Umbraco.Web/Models/Trees/MenuItemList.cs index 60c32b02e0..490e964eb8 100644 --- a/src/Umbraco.Web/Trees/Menu/MenuItemList.cs +++ b/src/Umbraco.Web/Models/Trees/MenuItemList.cs @@ -4,7 +4,7 @@ using Umbraco.Core; using umbraco.BusinessLogic.Actions; using umbraco.interfaces; -namespace Umbraco.Web.Trees.Menu +namespace Umbraco.Web.Models.Trees { /// /// A custom menu list diff --git a/src/Umbraco.Web/Trees/Menu/RefreshNode.cs b/src/Umbraco.Web/Models/Trees/RefreshNode.cs similarity index 81% rename from src/Umbraco.Web/Trees/Menu/RefreshNode.cs rename to src/Umbraco.Web/Models/Trees/RefreshNode.cs index 317a8c07de..282b44b069 100644 --- a/src/Umbraco.Web/Trees/Menu/RefreshNode.cs +++ b/src/Umbraco.Web/Models/Trees/RefreshNode.cs @@ -1,10 +1,10 @@ -namespace Umbraco.Web.Trees.Menu -{ - /// - /// Represents the refresh node menu item - /// - [ActionMenuItem("umbracoMenuActions")] - public sealed class RefreshNode : ActionMenuItem - { - } +namespace Umbraco.Web.Models.Trees +{ + /// + /// Represents the refresh node menu item + /// + [ActionMenuItem("umbracoMenuActions")] + public sealed class RefreshNode : ActionMenuItem + { + } } \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/SectionRootNode.cs b/src/Umbraco.Web/Models/Trees/SectionRootNode.cs similarity index 95% rename from src/Umbraco.Web/Trees/SectionRootNode.cs rename to src/Umbraco.Web/Models/Trees/SectionRootNode.cs index 0e8037e0f3..ea3c0afdbc 100644 --- a/src/Umbraco.Web/Trees/SectionRootNode.cs +++ b/src/Umbraco.Web/Models/Trees/SectionRootNode.cs @@ -1,48 +1,48 @@ -using System.Runtime.Serialization; - -namespace Umbraco.Web.Trees -{ - /// - /// A special tree node that represents the section root node for any section. - /// - /// - /// This is required to return the tree data for a given section. Some sections may only contain one tree which means it's section - /// root should also display a menu, whereas other sections have multiple trees and the section root shouldn't display a menu. - /// - /// The section root also contains an explicit collection of children. - /// - [DataContract(Name = "node", Namespace = "")] - public sealed class SectionRootNode : TreeNode - { - public static SectionRootNode CreateMultiTreeSectionRoot(string nodeId, TreeNodeCollection children) - { - return new SectionRootNode(nodeId, "", "") - { - IsContainer = true, - Children = children - }; - } - - public static SectionRootNode CreateSingleTreeSectionRoot(string nodeId, string getChildNodesUrl, string menuUrl, string title, TreeNodeCollection children) - { - return new SectionRootNode(nodeId, getChildNodesUrl, menuUrl) - { - Children = children, - Title = title - }; - } - - private SectionRootNode(string nodeId, string getChildNodesUrl, string menuUrl) - : base(nodeId, getChildNodesUrl, menuUrl) - { - //default to false - IsContainer = false; - } - - [DataMember(Name = "isContainer")] - public bool IsContainer { get; private set; } - - [DataMember(Name = "children")] - public TreeNodeCollection Children { get; private set; } - } +using System.Runtime.Serialization; + +namespace Umbraco.Web.Models.Trees +{ + /// + /// A special tree node that represents the section root node for any section. + /// + /// + /// This is required to return the tree data for a given section. Some sections may only contain one tree which means it's section + /// root should also display a menu, whereas other sections have multiple trees and the section root shouldn't display a menu. + /// + /// The section root also contains an explicit collection of children. + /// + [DataContract(Name = "node", Namespace = "")] + public sealed class SectionRootNode : TreeNode + { + public static SectionRootNode CreateMultiTreeSectionRoot(string nodeId, TreeNodeCollection children) + { + return new SectionRootNode(nodeId, "", "") + { + IsContainer = true, + Children = children + }; + } + + public static SectionRootNode CreateSingleTreeSectionRoot(string nodeId, string getChildNodesUrl, string menuUrl, string title, TreeNodeCollection children) + { + return new SectionRootNode(nodeId, getChildNodesUrl, menuUrl) + { + Children = children, + Title = title + }; + } + + private SectionRootNode(string nodeId, string getChildNodesUrl, string menuUrl) + : base(nodeId, getChildNodesUrl, menuUrl) + { + //default to false + IsContainer = false; + } + + [DataMember(Name = "isContainer")] + public bool IsContainer { get; private set; } + + [DataMember(Name = "children")] + public TreeNodeCollection Children { get; private set; } + } } \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/TreeNode.cs b/src/Umbraco.Web/Models/Trees/TreeNode.cs similarity index 95% rename from src/Umbraco.Web/Trees/TreeNode.cs rename to src/Umbraco.Web/Models/Trees/TreeNode.cs index fefd5e6f80..7f270fa500 100644 --- a/src/Umbraco.Web/Trees/TreeNode.cs +++ b/src/Umbraco.Web/Models/Trees/TreeNode.cs @@ -1,133 +1,130 @@ -using System.Runtime.Serialization; -using Newtonsoft.Json; -using Umbraco.Core.IO; -using System; -using System.Collections; -using System.Collections.Generic; -using Umbraco.Core; - -namespace Umbraco.Web.Trees -{ - /// - /// Represents a model in the tree - /// - /// - /// TreeNode is sealed to prevent developers from adding additional json data to the response - /// - [DataContract(Name = "node", Namespace = "")] - public class TreeNode - { - /// - /// Internal constructor, to create a tree node use the CreateTreeNode methods of the TreeApiController. - /// - /// - /// - /// - internal TreeNode(string nodeId, string getChildNodesUrl, string menuUrl) - { - //_menuItems = menuItems; - //Style = new NodeStyle(); - NodeId = nodeId; - AdditionalData = new Dictionary(); - ChildNodesUrl = getChildNodesUrl; - MenuUrl = menuUrl; - //default - Icon = "icon-folder-close"; - } - - /// - /// The unique identifier for the node - /// - [DataMember(Name = "id")] - public string NodeId { get; private set; } - - /// - /// A flag to set whether or not this node has children - /// - [DataMember(Name = "hasChildren")] - public bool HasChildren { get; set; } - - /// - /// The text title of the node that is displayed in the tree - /// - [DataMember(Name = "name")] - public string Title { get; set; } - - /// - /// The icon to use for the node, this can be either a path to an image or a Css class. - /// If a '/' is found in the string then it will be considered a path to an image. - /// - [DataMember(Name = "icon")] - public string Icon { get; set; } - - /// - /// The tree nodetype which refers to the type of node rendered in the tree - /// - [DataMember(Name = "nodetype")] - public string NodeType { get; set; } - - /// - /// Returns true if the icon represents a CSS class instead of a file path - /// - [DataMember(Name = "iconIsClass")] - public bool IconIsClass - { - get - { - if (Icon.IsNullOrWhiteSpace()) - { - return true; - } - //if it starts with a '.' or doesn't contain a '.' at all then it is a class - return Icon.StartsWith(".") || Icon.Contains(".") == false; - } - } - - /// - /// Returns the icon file path if the icon is not a class, otherwise returns an empty string - /// - [DataMember(Name = "iconFilePath")] - public string IconFilePath - { - get - { - return IconIsClass - ? string.Empty - : IOHelper.ResolveUrl("~/umbraco/images/umbraco/" + Icon); - } - } - - /// - /// Optional: The Route path for the editor for this node - /// - /// - /// If this is not set, then the route path will be automatically determined by: {section}/edit/{id} - /// - [DataMember(Name = "routePath")] - public string RoutePath { get; set; } - - /// - /// The JSON url to load the nodes children - /// - [DataMember(Name = "childNodesUrl")] - public string ChildNodesUrl { get; set; } - - /// - /// The JSON url to load the menu from - /// - [DataMember(Name = "menuUrl")] - public string MenuUrl { get; set; } - - /// - /// A dictionary to support any additional meta data that should be rendered for the node which is - /// useful for custom action commands such as 'create', 'copy', etc... - /// - [DataMember(Name = "metaData")] - public Dictionary AdditionalData { get; private set; } - - ///// - ///// The UI style to give the model - ///// - //public NodeStyle Style { get; private set; } - } -} +using System.Runtime.Serialization; +using Umbraco.Core.IO; +using System.Collections.Generic; +using Umbraco.Core; + +namespace Umbraco.Web.Models.Trees +{ + /// + /// Represents a model in the tree + /// + /// + /// TreeNode is sealed to prevent developers from adding additional json data to the response + /// + [DataContract(Name = "node", Namespace = "")] + public class TreeNode + { + /// + /// Internal constructor, to create a tree node use the CreateTreeNode methods of the TreeApiController. + /// + /// + /// + /// + internal TreeNode(string nodeId, string getChildNodesUrl, string menuUrl) + { + //_menuItems = menuItems; + //Style = new NodeStyle(); + NodeId = nodeId; + AdditionalData = new Dictionary(); + ChildNodesUrl = getChildNodesUrl; + MenuUrl = menuUrl; + //default + Icon = "icon-folder-close"; + } + + /// + /// The unique identifier for the node + /// + [DataMember(Name = "id")] + public string NodeId { get; private set; } + + /// + /// A flag to set whether or not this node has children + /// + [DataMember(Name = "hasChildren")] + public bool HasChildren { get; set; } + + /// + /// The text title of the node that is displayed in the tree + /// + [DataMember(Name = "name")] + public string Title { get; set; } + + /// + /// The icon to use for the node, this can be either a path to an image or a Css class. + /// If a '/' is found in the string then it will be considered a path to an image. + /// + [DataMember(Name = "icon")] + public string Icon { get; set; } + + /// + /// The tree nodetype which refers to the type of node rendered in the tree + /// + [DataMember(Name = "nodetype")] + public string NodeType { get; set; } + + /// + /// Returns true if the icon represents a CSS class instead of a file path + /// + [DataMember(Name = "iconIsClass")] + public bool IconIsClass + { + get + { + if (Icon.IsNullOrWhiteSpace()) + { + return true; + } + //if it starts with a '.' or doesn't contain a '.' at all then it is a class + return Icon.StartsWith(".") || Icon.Contains(".") == false; + } + } + + /// + /// Returns the icon file path if the icon is not a class, otherwise returns an empty string + /// + [DataMember(Name = "iconFilePath")] + public string IconFilePath + { + get + { + return IconIsClass + ? string.Empty + : IOHelper.ResolveUrl("~/umbraco/images/umbraco/" + Icon); + } + } + + /// + /// Optional: The Route path for the editor for this node + /// + /// + /// If this is not set, then the route path will be automatically determined by: {section}/edit/{id} + /// + [DataMember(Name = "routePath")] + public string RoutePath { get; set; } + + /// + /// The JSON url to load the nodes children + /// + [DataMember(Name = "childNodesUrl")] + public string ChildNodesUrl { get; set; } + + /// + /// The JSON url to load the menu from + /// + [DataMember(Name = "menuUrl")] + public string MenuUrl { get; set; } + + /// + /// A dictionary to support any additional meta data that should be rendered for the node which is + /// useful for custom action commands such as 'create', 'copy', etc... + /// + [DataMember(Name = "metaData")] + public Dictionary AdditionalData { get; private set; } + + ///// + ///// The UI style to give the model + ///// + //public NodeStyle Style { get; private set; } + } +} diff --git a/src/Umbraco.Web/Trees/TreeNodeCollection.cs b/src/Umbraco.Web/Models/Trees/TreeNodeCollection.cs similarity index 76% rename from src/Umbraco.Web/Trees/TreeNodeCollection.cs rename to src/Umbraco.Web/Models/Trees/TreeNodeCollection.cs index f4d65bb5e6..4de242ed4f 100644 --- a/src/Umbraco.Web/Trees/TreeNodeCollection.cs +++ b/src/Umbraco.Web/Models/Trees/TreeNodeCollection.cs @@ -1,11 +1,10 @@ -using System.Collections.Generic; -using System.Runtime.Serialization; -using Newtonsoft.Json.Linq; - -namespace Umbraco.Web.Trees -{ - [CollectionDataContract(Name = "nodes", Namespace = "")] - public sealed class TreeNodeCollection : List - { - } +using System.Collections.Generic; +using System.Runtime.Serialization; + +namespace Umbraco.Web.Models.Trees +{ + [CollectionDataContract(Name = "nodes", Namespace = "")] + public sealed class TreeNodeCollection : List + { + } } \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/TreeNodeExtensions.cs b/src/Umbraco.Web/Models/Trees/TreeNodeExtensions.cs similarity index 92% rename from src/Umbraco.Web/Trees/TreeNodeExtensions.cs rename to src/Umbraco.Web/Models/Trees/TreeNodeExtensions.cs index 320224b3d4..17eab1fb85 100644 --- a/src/Umbraco.Web/Trees/TreeNodeExtensions.cs +++ b/src/Umbraco.Web/Models/Trees/TreeNodeExtensions.cs @@ -1,17 +1,17 @@ -namespace Umbraco.Web.Trees -{ - public static class TreeNodeExtensions - { - internal const string LegacyJsCallbackKey = "jsClickCallback"; - - /// - /// Legacy tree node's assign a JS method callback for when an item is clicked, this method facilitates that. - /// - /// - /// - internal static void AssignLegacyJsCallback(this TreeNode treeNode, string jsCallback) - { - treeNode.AdditionalData[LegacyJsCallbackKey] = jsCallback; - } - } +namespace Umbraco.Web.Models.Trees +{ + public static class TreeNodeExtensions + { + internal const string LegacyJsCallbackKey = "jsClickCallback"; + + /// + /// Legacy tree node's assign a JS method callback for when an item is clicked, this method facilitates that. + /// + /// + /// + internal static void AssignLegacyJsCallback(this TreeNode treeNode, string jsCallback) + { + treeNode.AdditionalData[LegacyJsCallbackKey] = jsCallback; + } + } } \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/ApplicationTreeController.cs b/src/Umbraco.Web/Trees/ApplicationTreeController.cs index 1cf8f22e1b..de013c79c6 100644 --- a/src/Umbraco.Web/Trees/ApplicationTreeController.cs +++ b/src/Umbraco.Web/Trees/ApplicationTreeController.cs @@ -7,6 +7,7 @@ using System.Web.Mvc; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Services; +using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; using Umbraco.Web.WebApi; using Umbraco.Web.WebApi.Filters; diff --git a/src/Umbraco.Web/Trees/ApplicationTreeExtensions.cs b/src/Umbraco.Web/Trees/ApplicationTreeExtensions.cs index e074496c15..381c92b2cd 100644 --- a/src/Umbraco.Web/Trees/ApplicationTreeExtensions.cs +++ b/src/Umbraco.Web/Trees/ApplicationTreeExtensions.cs @@ -10,7 +10,7 @@ using System.Threading.Tasks; using System.Web.Http.Controllers; using System.Web.Mvc; using Umbraco.Core; -using Umbraco.Web.Trees.Menu; +using Umbraco.Web.Models.Trees; using Umbraco.Web.WebApi; using umbraco.BusinessLogic; using umbraco.cms.presentation.Trees; diff --git a/src/Umbraco.Web/Trees/ContentTreeController.cs b/src/Umbraco.Web/Trees/ContentTreeController.cs index 0e7aef2a2d..3628e9e714 100644 --- a/src/Umbraco.Web/Trees/ContentTreeController.cs +++ b/src/Umbraco.Web/Trees/ContentTreeController.cs @@ -9,8 +9,8 @@ using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; using Umbraco.Core.Services; +using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; -using Umbraco.Web.Trees.Menu; using umbraco; using umbraco.BusinessLogic.Actions; using umbraco.businesslogic; diff --git a/src/Umbraco.Web/Trees/ContentTreeControllerBase.cs b/src/Umbraco.Web/Trees/ContentTreeControllerBase.cs index c97c586e10..57e4039251 100644 --- a/src/Umbraco.Web/Trees/ContentTreeControllerBase.cs +++ b/src/Umbraco.Web/Trees/ContentTreeControllerBase.cs @@ -5,7 +5,7 @@ using System.Net.Http.Formatting; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; -using Umbraco.Web.Trees.Menu; +using Umbraco.Web.Models.Trees; using umbraco; using umbraco.BusinessLogic.Actions; diff --git a/src/Umbraco.Web/Trees/CoreTreeAttribute.cs b/src/Umbraco.Web/Trees/CoreTreeAttribute.cs new file mode 100644 index 0000000000..33c559c863 --- /dev/null +++ b/src/Umbraco.Web/Trees/CoreTreeAttribute.cs @@ -0,0 +1,16 @@ +using System; + +namespace Umbraco.Web.Trees +{ + /// + /// Indicates that a tree is a core tree and shouldn't be treated as a plugin tree + /// + /// + /// This ensures that umbraco will look in the umbraco folders for views for this tree + /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] + internal class CoreTreeAttribute : Attribute + { + + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/DataTypeTreeController.cs b/src/Umbraco.Web/Trees/DataTypeTreeController.cs index c627de0bc4..76d934c9cf 100644 --- a/src/Umbraco.Web/Trees/DataTypeTreeController.cs +++ b/src/Umbraco.Web/Trees/DataTypeTreeController.cs @@ -5,8 +5,8 @@ using System.Net; using System.Net.Http.Formatting; using System.Web.Http; using Umbraco.Core; +using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; -using Umbraco.Web.Trees.Menu; using umbraco; using umbraco.BusinessLogic.Actions; using Constants = Umbraco.Core.Constants; diff --git a/src/Umbraco.Web/Trees/ISearchableTree.cs b/src/Umbraco.Web/Trees/ISearchableTree.cs index 3fcae9bb1e..680256f304 100644 --- a/src/Umbraco.Web/Trees/ISearchableTree.cs +++ b/src/Umbraco.Web/Trees/ISearchableTree.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Umbraco.Web.Models.ContentEditing; namespace Umbraco.Web.Trees { diff --git a/src/Umbraco.Web/Trees/LegacyTreeController.cs b/src/Umbraco.Web/Trees/LegacyTreeController.cs index cdb6958570..97e1d68c88 100644 --- a/src/Umbraco.Web/Trees/LegacyTreeController.cs +++ b/src/Umbraco.Web/Trees/LegacyTreeController.cs @@ -5,8 +5,8 @@ using System.Net.Http.Formatting; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Services; +using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; -using Umbraco.Web.Trees.Menu; using Umbraco.Web.WebApi; using Umbraco.Web.WebApi.Filters; diff --git a/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs b/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs index f0400712ea..161d9d1abc 100644 --- a/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs +++ b/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs @@ -9,7 +9,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Services; -using Umbraco.Web.Trees.Menu; +using Umbraco.Web.Models.Trees; using umbraco; using umbraco.BusinessLogic; using umbraco.BusinessLogic.Actions; diff --git a/src/Umbraco.Web/Trees/MediaTreeController.cs b/src/Umbraco.Web/Trees/MediaTreeController.cs index 247337ff3d..8736987083 100644 --- a/src/Umbraco.Web/Trees/MediaTreeController.cs +++ b/src/Umbraco.Web/Trees/MediaTreeController.cs @@ -7,8 +7,8 @@ using System.Web.Http; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Services; +using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; -using Umbraco.Web.Trees.Menu; using umbraco; using umbraco.BusinessLogic.Actions; using Constants = Umbraco.Core.Constants; diff --git a/src/Umbraco.Web/Trees/MemberTreeController.cs b/src/Umbraco.Web/Trees/MemberTreeController.cs index d4920cd9c4..58aba7d3eb 100644 --- a/src/Umbraco.Web/Trees/MemberTreeController.cs +++ b/src/Umbraco.Web/Trees/MemberTreeController.cs @@ -3,8 +3,8 @@ using System.Linq; using System.Net.Http.Formatting; using System.Web.Security; using Umbraco.Core; +using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; -using Umbraco.Web.Trees.Menu; using umbraco; using umbraco.BusinessLogic.Actions; using umbraco.cms.businesslogic.member; diff --git a/src/Umbraco.Web/Trees/MenuRenderingEventArgs.cs b/src/Umbraco.Web/Trees/MenuRenderingEventArgs.cs index 72e203f2e0..387f4edd81 100644 --- a/src/Umbraco.Web/Trees/MenuRenderingEventArgs.cs +++ b/src/Umbraco.Web/Trees/MenuRenderingEventArgs.cs @@ -1,5 +1,5 @@ using System.Net.Http.Formatting; -using Umbraco.Web.Trees.Menu; +using Umbraco.Web.Models.Trees; namespace Umbraco.Web.Trees { diff --git a/src/Umbraco.Web/Trees/TreeAttribute.cs b/src/Umbraco.Web/Trees/TreeAttribute.cs index 5acf367738..72ae4044e9 100644 --- a/src/Umbraco.Web/Trees/TreeAttribute.cs +++ b/src/Umbraco.Web/Trees/TreeAttribute.cs @@ -2,18 +2,6 @@ namespace Umbraco.Web.Trees { - /// - /// Indicates that a tree is a core tree and shouldn't be treated as a plugin tree - /// - /// - /// This ensures that umbraco will look in the umbraco folders for views for this tree - /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] - internal class CoreTreeAttribute : Attribute - { - - } - /// /// Identifies an application tree /// diff --git a/src/Umbraco.Web/Trees/TreeController.cs b/src/Umbraco.Web/Trees/TreeController.cs index 374e251763..5d385d1d88 100644 --- a/src/Umbraco.Web/Trees/TreeController.cs +++ b/src/Umbraco.Web/Trees/TreeController.cs @@ -5,8 +5,8 @@ using System.Linq; using System.Net.Http.Formatting; using Umbraco.Core; using Umbraco.Core.Events; +using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; -using Umbraco.Web.Trees.Menu; using Umbraco.Web.WebApi; using Umbraco.Web.WebApi.Filters; using Constants = Umbraco.Core.Constants; diff --git a/src/Umbraco.Web/Trees/TreeNodeRenderingEventArgs.cs b/src/Umbraco.Web/Trees/TreeNodeRenderingEventArgs.cs index 883579a964..f978619156 100644 --- a/src/Umbraco.Web/Trees/TreeNodeRenderingEventArgs.cs +++ b/src/Umbraco.Web/Trees/TreeNodeRenderingEventArgs.cs @@ -1,4 +1,5 @@ using System.Net.Http.Formatting; +using Umbraco.Web.Models.Trees; namespace Umbraco.Web.Trees { diff --git a/src/Umbraco.Web/Trees/TreeNodesRenderingEventArgs.cs b/src/Umbraco.Web/Trees/TreeNodesRenderingEventArgs.cs index 338f00f8b8..cb7f1fdbde 100644 --- a/src/Umbraco.Web/Trees/TreeNodesRenderingEventArgs.cs +++ b/src/Umbraco.Web/Trees/TreeNodesRenderingEventArgs.cs @@ -1,4 +1,5 @@ using System.Net.Http.Formatting; +using Umbraco.Web.Models.Trees; namespace Umbraco.Web.Trees { diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index d96a0e5b42..c6a18f95f0 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -376,11 +376,12 @@ + - - + + ASPXCodeBehind @@ -441,8 +442,8 @@ - - + + @@ -451,18 +452,18 @@ - - - - - - + + + + + + - - - + + +