Updates the Create/AddMenu overloads to ensure a name is specified, fixes all localization of all menu items for all new trees.
This commit is contained in:
@@ -1,59 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
(function () {
|
||||
|
||||
angular.module("myPackage.directives", []);
|
||||
angular.module("myPackage.controllers", []);
|
||||
|
||||
angular.module("myPackage.directives").directive('valPostcode', function () {
|
||||
|
||||
/// <summary>
|
||||
/// A custom directive to validate for postcodes
|
||||
///</summary>
|
||||
|
||||
return {
|
||||
require: 'ngModel',
|
||||
link: function (scope, elm, attrs, ctrl) {
|
||||
|
||||
if (!attrs.valPostcode)
|
||||
throw "valPostcode requires an attribute value specifying the country for the postcode";
|
||||
|
||||
var patternValidator = function (viewValue) {
|
||||
//NOTE: we don't validate on empty values, use required validator for that
|
||||
if (viewValue) {
|
||||
var country = scope.$eval(attrs.valPostcode);
|
||||
switch (country) {
|
||||
case "Australia":
|
||||
if (/^\d{4}$/.test(viewValue)) {
|
||||
ctrl.$setValidity('valPostcode', true);
|
||||
//reset the error msg
|
||||
ctrl.errorMsg = "";
|
||||
return viewValue;
|
||||
}
|
||||
else {
|
||||
// it is invalid, return undefined (no model update)
|
||||
ctrl.$setValidity('valPostcode', false);
|
||||
//assign an error msg property to the current validator
|
||||
ctrl.errorMsg = "Australian postcodes must be a 4 digit number";
|
||||
return undefined;
|
||||
}
|
||||
|
||||
default:
|
||||
throw "The country specified does not have validation logic applied";
|
||||
}
|
||||
}
|
||||
else {
|
||||
// there is no value to validate so return that it is valid.
|
||||
ctrl.$setValidity('valPostcode', true);
|
||||
return viewValue;
|
||||
}
|
||||
};
|
||||
|
||||
ctrl.$formatters.push(patternValidator);
|
||||
ctrl.$parsers.push(patternValidator);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
})();
|
||||
@@ -1,15 +0,0 @@
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Umbraco.Web.UI.App_Plugins.MyPackage.Controllers
|
||||
{
|
||||
|
||||
public class ServerSidePropertyEditorsController : Controller
|
||||
{
|
||||
[HttpGet]
|
||||
public ActionResult ServerEnvironment()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.UI.JavaScript;
|
||||
|
||||
namespace Umbraco.Web.UI.App_Plugins.MyPackage.System
|
||||
{
|
||||
public class MyStartupHandler : ApplicationEventHandler
|
||||
{
|
||||
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
base.ApplicationStarted(umbracoApplication, applicationContext);
|
||||
|
||||
//create a custom server variable to be exposed in JS
|
||||
ServerVariablesParser.Parsing += (sender, dictionary) =>
|
||||
{
|
||||
|
||||
var httpContext = HttpContext.Current;
|
||||
if (httpContext == null) return;
|
||||
|
||||
var urlHelper = new UrlHelper(new RequestContext(new HttpContextWrapper(httpContext), new RouteData()));
|
||||
|
||||
dictionary.Add("MyPackage", new Dictionary<string, object>()
|
||||
{
|
||||
{"serverEnvironmentView", urlHelper.Action("ServerEnvironment", "ServerSidePropertyEditors", new {area = "MyPackage"})}
|
||||
});
|
||||
};
|
||||
|
||||
//For testing for now we'll route to /Belle/Main
|
||||
var route = RouteTable.Routes.MapRoute(
|
||||
"umbraco-server-side-property-editors",
|
||||
"Belle/PropertyEditors/{controller}/{action}/{id}",
|
||||
new { controller = "ServerSidePropertyEditors", action = "Index", id = UrlParameter.Optional });
|
||||
//assign it to an area so that the plugin view engine looks for us
|
||||
route.DataTokens.Add("area", "MyPackage");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,41 @@
|
||||
using System.Text;
|
||||
using System;
|
||||
using System.Net.Http.Formatting;
|
||||
using System.Text;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.Trees;
|
||||
using Umbraco.Web.Trees.Menu;
|
||||
using umbraco.cms.presentation.Trees;
|
||||
using Constants = Umbraco.Core.Constants;
|
||||
|
||||
namespace Umbraco.Web.UI.App_Plugins.MyPackage.Trees
|
||||
{
|
||||
//[Tree(Constants.Applications.Settings, "myTree", "My Tree")]
|
||||
//[PluginController("MyPackage")]
|
||||
//public class MyCustomTree : TreeController
|
||||
//{
|
||||
// protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
|
||||
// {
|
||||
// if (id == Constants.System.Root.ToInvariantString())
|
||||
// {
|
||||
// var tree = new TreeNodeCollection
|
||||
// {
|
||||
// CreateTreeNode("1", queryStrings, "My Node 1"),
|
||||
// CreateTreeNode("2", queryStrings, "My Node 2"),
|
||||
// CreateTreeNode("3", queryStrings, "My Node 3")
|
||||
// };
|
||||
// return tree;
|
||||
// }
|
||||
// throw new NotSupportedException();
|
||||
// }
|
||||
|
||||
// protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
|
||||
// {
|
||||
// var menu = new MenuItemCollection();
|
||||
// menu.AddMenuItem(new MenuItem("create", "Create"));
|
||||
// }
|
||||
//}
|
||||
|
||||
public class LegacyTestTree : BaseTree
|
||||
{
|
||||
public LegacyTestTree(string application) : base(application)
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
@model dynamic
|
||||
|
||||
|
||||
<p>
|
||||
<strong>Computer Name</strong><span>@Environment.MachineName</span>
|
||||
</p>
|
||||
<p>
|
||||
<strong>Computer Time</strong><span>@DateTime.Now</span>
|
||||
</p>
|
||||
@@ -1,58 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
|
||||
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
|
||||
<system.web.webPages.razor>
|
||||
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
|
||||
<pages pageBaseType="System.Web.Mvc.WebViewPage">
|
||||
<namespaces>
|
||||
<add namespace="System.Web.Mvc" />
|
||||
<add namespace="System.Web.Mvc.Ajax" />
|
||||
<add namespace="System.Web.Mvc.Html" />
|
||||
<add namespace="System.Web.Routing" />
|
||||
</namespaces>
|
||||
</pages>
|
||||
</system.web.webPages.razor>
|
||||
|
||||
<appSettings>
|
||||
<add key="webpages:Enabled" value="false" />
|
||||
</appSettings>
|
||||
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
|
||||
</httpHandlers>
|
||||
|
||||
<!--
|
||||
Enabling request validation in view pages would cause validation to occur
|
||||
after the input has already been processed by the controller. By default
|
||||
MVC performs request validation before a controller processes the input.
|
||||
To change this behavior apply the ValidateInputAttribute to a
|
||||
controller or action.
|
||||
-->
|
||||
<pages
|
||||
validateRequest="false"
|
||||
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
|
||||
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
|
||||
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||
<controls>
|
||||
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
|
||||
</controls>
|
||||
</pages>
|
||||
</system.web>
|
||||
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false" />
|
||||
|
||||
<handlers>
|
||||
<remove name="BlockViewHandler"/>
|
||||
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
@@ -292,11 +292,9 @@
|
||||
<Compile Include="..\SolutionInfo.cs">
|
||||
<Link>Properties\SolutionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="App_Plugins\MyPackage\Controllers\ServerSidePropertyEditorsController.cs" />
|
||||
<Compile Include="App_Plugins\MyPackage\PropertyEditors\PostcodePropertyEditor.cs" />
|
||||
<Compile Include="App_Plugins\MyPackage\PropertyEditors\PostcodeValidator.cs" />
|
||||
<Compile Include="App_Plugins\MyPackage\PropertyEditors\ServerInfoPropertyEditor.cs" />
|
||||
<Compile Include="App_Plugins\MyPackage\System\MyStartupHandler.cs" />
|
||||
<Compile Include="App_Plugins\MyPackage\Trees\LegacyTestTree.cs" />
|
||||
<Compile Include="Install\Default.aspx.cs">
|
||||
<DependentUpon>default.aspx</DependentUpon>
|
||||
@@ -590,7 +588,6 @@
|
||||
</Compile>
|
||||
<Content Include="Umbraco\create.aspx" />
|
||||
<Content Include="Umbraco_Client\IconPicker\iconpicker.js" />
|
||||
<Content Include="App_Plugins\MyPackage\Common\Js\MyPackage.js" />
|
||||
<Content Include="App_Plugins\MyPackage\PropertyEditors\Js\CsvEditor.js" />
|
||||
<Content Include="App_Plugins\MyPackage\PropertyEditors\Js\PostcodeEditor.js" />
|
||||
<Content Include="App_Plugins\MyPackage\PropertyEditors\Js\RegexEditor.js" />
|
||||
@@ -615,8 +612,6 @@
|
||||
</SubType>
|
||||
</Content>
|
||||
<Content Include="App_Plugins\MyPackage\Package.manifest" />
|
||||
<Content Include="App_Plugins\MyPackage\Views\ServerSidePropertyEditors\ServerEnvironment.cshtml" />
|
||||
<Content Include="App_Plugins\MyPackage\Views\Web.config" />
|
||||
<None Include="Config\404handlers.Release.config">
|
||||
<DependentUpon>404handlers.config</DependentUpon>
|
||||
</None>
|
||||
@@ -2540,8 +2535,8 @@
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Code\" />
|
||||
<Folder Include="App_Data\" />
|
||||
<Folder Include="App_Plugins\MyPackage\Common\Css\" />
|
||||
<Folder Include="App_Plugins\MyPackage\PropertyEditors\Css\" />
|
||||
<Folder Include="App_Plugins\MyPackage\Views\" />
|
||||
<Folder Include="Css\" />
|
||||
<Folder Include="MasterPages\" />
|
||||
<Folder Include="Media\" />
|
||||
|
||||
@@ -106,8 +106,8 @@ namespace Umbraco.Web.Trees
|
||||
.Select(x => new MenuItem(x));
|
||||
|
||||
//these two are the standard items
|
||||
menu.AddMenuItem<ActionNew>();
|
||||
menu.AddMenuItem<ActionSort>(true).ConvertLegacyMenuItem(null, "content", "content");
|
||||
menu.AddMenuItem<ActionNew>(ui.Text("actions", ActionNew.Instance.Alias));
|
||||
menu.AddMenuItem<ActionSort>(ui.Text("actions", ActionSort.Instance.Alias), true).ConvertLegacyMenuItem(null, "content", "content");
|
||||
|
||||
//filter the standard items
|
||||
FilterUserAllowedMenuItems(menu, nodeActions);
|
||||
@@ -118,14 +118,9 @@ namespace Umbraco.Web.Trees
|
||||
}
|
||||
|
||||
// add default actions for *all* users
|
||||
menu.AddMenuItem<ActionRePublish>().ConvertLegacyMenuItem(null, "content", "content");
|
||||
menu.AddMenuItem<RefreshNode, ActionRefresh>(true);
|
||||
|
||||
foreach (var menuItem in menu.MenuItems)
|
||||
{
|
||||
menuItem.Name = ui.Text("actions", menuItem.Alias);
|
||||
}
|
||||
|
||||
menu.AddMenuItem<ActionRePublish>(ui.Text("actions", ActionRePublish.Instance.Alias)).ConvertLegacyMenuItem(null, "content", "content");
|
||||
menu.AddMenuItem<RefreshNode, ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true);
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
@@ -150,10 +145,6 @@ namespace Umbraco.Web.Trees
|
||||
//set the default to create
|
||||
nodeMenu.DefaultMenuAlias = ActionNew.Instance.Alias;
|
||||
|
||||
foreach (var menuItem in nodeMenu.MenuItems)
|
||||
{
|
||||
menuItem.Name = ui.Text("actions", menuItem.Alias);
|
||||
}
|
||||
return nodeMenu;
|
||||
}
|
||||
|
||||
@@ -170,26 +161,26 @@ namespace Umbraco.Web.Trees
|
||||
protected MenuItemCollection GetAllNodeMenuItems(IUmbracoEntity item)
|
||||
{
|
||||
var menu = new MenuItemCollection();
|
||||
menu.AddMenuItem<ActionNew>();
|
||||
menu.AddMenuItem<ActionDelete>(true);
|
||||
menu.AddMenuItem<ActionNew>(ui.Text("actions", ActionNew.Instance.Alias));
|
||||
menu.AddMenuItem<ActionDelete>(ui.Text("actions", ActionDelete.Instance.Alias));
|
||||
|
||||
//need to ensure some of these are converted to the legacy system - until we upgrade them all to be angularized.
|
||||
menu.AddMenuItem<ActionMove>(true);
|
||||
menu.AddMenuItem<ActionCopy>();
|
||||
|
||||
menu.AddMenuItem<ActionSort>(true).ConvertLegacyMenuItem(item, "content", "content");
|
||||
menu.AddMenuItem<ActionMove>(ui.Text("actions", ActionMove.Instance.Alias), true);
|
||||
menu.AddMenuItem<ActionCopy>(ui.Text("actions", ActionCopy.Instance.Alias));
|
||||
|
||||
menu.AddMenuItem<ActionRollback>().ConvertLegacyMenuItem(item, "content", "content");
|
||||
menu.AddMenuItem<ActionPublish>(true).ConvertLegacyMenuItem(item, "content", "content");
|
||||
menu.AddMenuItem<ActionToPublish>().ConvertLegacyMenuItem(item, "content", "content");
|
||||
menu.AddMenuItem<ActionAssignDomain>().ConvertLegacyMenuItem(item, "content", "content");
|
||||
menu.AddMenuItem<ActionRights>().ConvertLegacyMenuItem(item, "content", "content");
|
||||
menu.AddMenuItem<ActionProtect>(true).ConvertLegacyMenuItem(item, "content", "content");
|
||||
menu.AddMenuItem<ActionUnPublish>(true).ConvertLegacyMenuItem(item, "content", "content");
|
||||
menu.AddMenuItem<ActionNotify>(true).ConvertLegacyMenuItem(item, "content", "content");
|
||||
menu.AddMenuItem<ActionSendToTranslate>().ConvertLegacyMenuItem(item, "content", "content");
|
||||
menu.AddMenuItem<ActionSort>(ui.Text("actions", ActionSort.Instance.Alias), true).ConvertLegacyMenuItem(item, "content", "content");
|
||||
|
||||
menu.AddMenuItem<RefreshNode, ActionRefresh>(true);
|
||||
menu.AddMenuItem<ActionRollback>(ui.Text("actions", ActionRollback.Instance.Alias)).ConvertLegacyMenuItem(item, "content", "content");
|
||||
menu.AddMenuItem<ActionPublish>(ui.Text("actions", ActionPublish.Instance.Alias), true).ConvertLegacyMenuItem(item, "content", "content");
|
||||
menu.AddMenuItem<ActionToPublish>(ui.Text("actions", ActionToPublish.Instance.Alias)).ConvertLegacyMenuItem(item, "content", "content");
|
||||
menu.AddMenuItem<ActionAssignDomain>(ui.Text("actions", ActionAssignDomain.Instance.Alias)).ConvertLegacyMenuItem(item, "content", "content");
|
||||
menu.AddMenuItem<ActionRights>(ui.Text("actions", ActionRights.Instance.Alias)).ConvertLegacyMenuItem(item, "content", "content");
|
||||
menu.AddMenuItem<ActionProtect>(ui.Text("actions", ActionProtect.Instance.Alias), true).ConvertLegacyMenuItem(item, "content", "content");
|
||||
menu.AddMenuItem<ActionUnPublish>(ui.Text("actions", ActionUnPublish.Instance.Alias), true).ConvertLegacyMenuItem(item, "content", "content");
|
||||
menu.AddMenuItem<ActionNotify>(ui.Text("actions", ActionNotify.Instance.Alias), true).ConvertLegacyMenuItem(item, "content", "content");
|
||||
menu.AddMenuItem<ActionSendToTranslate>(ui.Text("actions", ActionSendToTranslate.Instance.Alias)).ConvertLegacyMenuItem(item, "content", "content");
|
||||
|
||||
menu.AddMenuItem<RefreshNode, ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true);
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
@@ -96,8 +96,8 @@ namespace Umbraco.Web.Trees
|
||||
if (RecycleBinId.ToInvariantString() == id)
|
||||
{
|
||||
var menu = new MenuItemCollection();
|
||||
menu.AddMenuItem<ActionEmptyTranscan>();
|
||||
menu.AddMenuItem<ActionRefresh>(true);
|
||||
menu.AddMenuItem<ActionEmptyTranscan>(ui.Text("actions", ActionEmptyTranscan.Instance.Alias));
|
||||
menu.AddMenuItem<ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true);
|
||||
return menu;
|
||||
}
|
||||
return PerformGetMenuForNode(id, queryStrings);
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Web.Http;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.Trees.Menu;
|
||||
using umbraco;
|
||||
using umbraco.BusinessLogic.Actions;
|
||||
using Constants = Umbraco.Core.Constants;
|
||||
|
||||
@@ -45,13 +46,13 @@ namespace Umbraco.Web.Trees
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
{
|
||||
// root actions
|
||||
menu.AddMenuItem<CreateChildEntity, ActionNew>();
|
||||
menu.AddMenuItem<RefreshNode, ActionRefresh>(true);
|
||||
menu.AddMenuItem<CreateChildEntity, ActionNew>(ui.Text("actions", ActionNew.Instance.Alias));
|
||||
menu.AddMenuItem<RefreshNode, ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true);
|
||||
return menu;
|
||||
}
|
||||
|
||||
//only have delete for each node
|
||||
menu.AddMenuItem<ActionDelete>();
|
||||
menu.AddMenuItem<ActionDelete>(ui.Text("actions", ActionDelete.Instance.Alias));
|
||||
return menu;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace Umbraco.Web.Trees
|
||||
}
|
||||
else
|
||||
{
|
||||
var menuItem = collection.AddMenuItem(t);
|
||||
var menuItem = collection.AddMenuItem(t, ui.Text("actions", t.Alias));
|
||||
|
||||
var currentAction = t;
|
||||
|
||||
|
||||
@@ -76,9 +76,9 @@ namespace Umbraco.Web.Trees
|
||||
}
|
||||
|
||||
// root actions
|
||||
menu.AddMenuItem<ActionNew>();
|
||||
menu.AddMenuItem<ActionSort>(true).ConvertLegacyMenuItem(null, "media", "media");
|
||||
menu.AddMenuItem<RefreshNode, ActionRefresh>(true);
|
||||
menu.AddMenuItem<ActionNew>(ui.Text("actions", ActionNew.Instance.Alias));
|
||||
menu.AddMenuItem<ActionSort>(ui.Text("actions", ActionSort.Instance.Alias), true).ConvertLegacyMenuItem(null, "media", "media");
|
||||
menu.AddMenuItem<RefreshNode, ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true);
|
||||
return menu;
|
||||
}
|
||||
|
||||
@@ -93,11 +93,11 @@ namespace Umbraco.Web.Trees
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
}
|
||||
//return a normal node menu:
|
||||
menu.AddMenuItem<ActionNew>();
|
||||
menu.AddMenuItem<ActionMove>();
|
||||
menu.AddMenuItem<ActionDelete>();
|
||||
menu.AddMenuItem<ActionSort>().ConvertLegacyMenuItem(null, "media", "media");
|
||||
menu.AddMenuItem<ActionRefresh>(true);
|
||||
menu.AddMenuItem<ActionNew>(ui.Text("actions", ActionNew.Instance.Alias));
|
||||
menu.AddMenuItem<ActionMove>(ui.Text("actions", ActionMove.Instance.Alias));
|
||||
menu.AddMenuItem<ActionDelete>(ui.Text("actions", ActionDelete.Instance.Alias));
|
||||
menu.AddMenuItem<ActionSort>(ui.Text("actions", ActionSort.Instance.Alias)).ConvertLegacyMenuItem(null, "media", "media");
|
||||
menu.AddMenuItem<ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true);
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
||||
@@ -79,13 +79,13 @@ namespace Umbraco.Web.Trees
|
||||
menu.DefaultMenuAlias = ActionNew.Instance.Alias;
|
||||
|
||||
// root actions
|
||||
menu.AddMenuItem<ActionNew>();
|
||||
menu.AddMenuItem<RefreshNode, ActionRefresh>(true);
|
||||
menu.AddMenuItem<ActionNew>(ui.Text("actions", ActionNew.Instance.Alias));
|
||||
menu.AddMenuItem<RefreshNode, ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true);
|
||||
return menu;
|
||||
}
|
||||
|
||||
menu.AddMenuItem<ActionDelete>();
|
||||
menu.AddMenuItem<RefreshNode, ActionRefresh>(true);
|
||||
menu.AddMenuItem<ActionDelete>(ui.Text("actions", ActionDelete.Instance.Alias));
|
||||
menu.AddMenuItem<RefreshNode, ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true);
|
||||
return menu;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Runtime.Serialization;
|
||||
using umbraco.interfaces;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core;
|
||||
|
||||
namespace Umbraco.Web.Trees.Menu
|
||||
{
|
||||
@@ -16,10 +17,17 @@ namespace Umbraco.Web.Trees.Menu
|
||||
AdditionalData = new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
public MenuItem(IAction legacyMenu)
|
||||
public MenuItem(string alias, string name)
|
||||
: this()
|
||||
{
|
||||
Name = legacyMenu.Alias;
|
||||
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;
|
||||
|
||||
@@ -42,7 +42,9 @@ namespace Umbraco.Web.Trees.Menu
|
||||
/// <summary>
|
||||
/// Adds a menu item
|
||||
/// </summary>
|
||||
internal MenuItem AddMenuItem(IAction action)
|
||||
/// <param name="action"></param>
|
||||
/// <param name="name">The text to display for the menu item, will default to the IAction alias if not specified</param>
|
||||
internal MenuItem AddMenuItem(IAction action, string name)
|
||||
{
|
||||
var item = new MenuItem(action);
|
||||
|
||||
@@ -68,14 +70,21 @@ namespace Umbraco.Web.Trees.Menu
|
||||
{
|
||||
_menuItems.Add(item);
|
||||
}
|
||||
|
||||
//TODO: Implement more overloads for MenuItem with dictionary vals
|
||||
|
||||
public TMenuItem AddMenuItem<TMenuItem, TAction>(bool hasSeparator = false, IDictionary<string, object> additionalData = null)
|
||||
|
||||
/// <summary>
|
||||
/// Adds a menu item
|
||||
/// </summary>
|
||||
/// <typeparam name="TMenuItem"></typeparam>
|
||||
/// <typeparam name="TAction"></typeparam>
|
||||
/// <param name="hasSeparator"></param>
|
||||
/// <param name="name">The text to display for the menu item, will default to the IAction alias if not specified</param>
|
||||
/// <param name="additionalData"></param>
|
||||
/// <returns></returns>
|
||||
public TMenuItem AddMenuItem<TMenuItem, TAction>(string name, bool hasSeparator = false, IDictionary<string, object> additionalData = null)
|
||||
where TAction : IAction
|
||||
where TMenuItem : MenuItem, new()
|
||||
{
|
||||
var item = CreateMenuItem<TAction>(hasSeparator, additionalData);
|
||||
var item = CreateMenuItem<TAction>(name, hasSeparator, additionalData);
|
||||
if (item == null) return null;
|
||||
|
||||
var customMenuItem = new TMenuItem
|
||||
@@ -95,11 +104,12 @@ namespace Umbraco.Web.Trees.Menu
|
||||
/// <summary>
|
||||
/// Adds a menu item
|
||||
/// </summary>
|
||||
/// <param name="name">The text to display for the menu item, will default to the IAction alias if not specified</param>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public MenuItem AddMenuItem<T>()
|
||||
public MenuItem AddMenuItem<T>(string name)
|
||||
where T : IAction
|
||||
{
|
||||
return AddMenuItem<T>(false, null);
|
||||
return AddMenuItem<T>(name, false, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -108,23 +118,51 @@ namespace Umbraco.Web.Trees.Menu
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="name">The text to display for the menu item, will default to the IAction alias if not specified</param>
|
||||
/// <param name="hasSeparator"></param>
|
||||
public MenuItem AddMenuItem<T>(string key, string value, bool hasSeparator = false)
|
||||
public MenuItem AddMenuItem<T>(string name, string key, string value, bool hasSeparator = false)
|
||||
where T : IAction
|
||||
{
|
||||
return AddMenuItem<T>(hasSeparator, new Dictionary<string, object> { { key, value } });
|
||||
return AddMenuItem<T>(name, hasSeparator, new Dictionary<string, object> { { key, value } });
|
||||
}
|
||||
|
||||
internal MenuItem CreateMenuItem<T>(bool hasSeparator = false, IDictionary<string, object> additionalData = null)
|
||||
/// <summary>
|
||||
/// Adds a menu item with a dictionary which is merged to the AdditionalData bag
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="hasSeparator"></param>
|
||||
/// /// <param name="name">The text to display for the menu item, will default to the IAction alias if not specified</param>
|
||||
/// <param name="additionalData"></param>
|
||||
public MenuItem AddMenuItem<T>(string name, bool hasSeparator = false, IDictionary<string, object> additionalData = null)
|
||||
where T : IAction
|
||||
{
|
||||
var item = CreateMenuItem<T>(name, hasSeparator, additionalData);
|
||||
if (item != null)
|
||||
{
|
||||
_menuItems.Add(item);
|
||||
return item;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="hasSeparator"></param>
|
||||
/// <param name="name">The text to display for the menu item, will default to the IAction alias if not specified</param>
|
||||
/// <param name="additionalData"></param>
|
||||
/// <returns></returns>
|
||||
internal MenuItem CreateMenuItem<T>(string name, bool hasSeparator = false, IDictionary<string, object> additionalData = null)
|
||||
where T : IAction
|
||||
{
|
||||
var item = ActionsResolver.Current.GetAction<T>();
|
||||
if (item != null)
|
||||
{
|
||||
var menuItem = new MenuItem(item)
|
||||
{
|
||||
SeperatorBefore = hasSeparator
|
||||
};
|
||||
var menuItem = new MenuItem(item, name)
|
||||
{
|
||||
SeperatorBefore = hasSeparator
|
||||
};
|
||||
|
||||
if (additionalData != null)
|
||||
{
|
||||
@@ -134,7 +172,7 @@ namespace Umbraco.Web.Trees.Menu
|
||||
}
|
||||
}
|
||||
|
||||
DetectLegacyActionMenu(typeof (T), menuItem);
|
||||
DetectLegacyActionMenu(typeof(T), menuItem);
|
||||
|
||||
//TODO: Once we implement 'real' menu items, not just IActions we can implement this since
|
||||
// people may need to pass specific data to their menu items
|
||||
@@ -147,24 +185,6 @@ namespace Umbraco.Web.Trees.Menu
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a menu item with a dictionary which is merged to the AdditionalData bag
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="hasSeparator"></param>
|
||||
/// <param name="additionalData"></param>
|
||||
public MenuItem AddMenuItem<T>(bool hasSeparator = false, IDictionary<string, object> additionalData = null)
|
||||
where T : IAction
|
||||
{
|
||||
var item = CreateMenuItem<T>(hasSeparator, additionalData);
|
||||
if (item != null)
|
||||
{
|
||||
_menuItems.Add(item);
|
||||
return item;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the IAction type passed in is attributed with LegacyActionMenuItemAttribute and if so
|
||||
/// ensures that the correct action metadata is added.
|
||||
|
||||
Reference in New Issue
Block a user