Merge branch 'U4-8195' of https://github.com/Mantus667/Umbraco-CMS into Mantus667-U4-8195
# Conflicts: # src/Umbraco.Web.UI/config/trees.Release.config # src/Umbraco.Web.UI/config/trees.config # src/Umbraco.Web/Umbraco.Web.csproj
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
<add application="developer" alias="macros" title="Macros" type="Umbraco.Web.Trees.MacrosTreeController, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="2" />
|
||||
<add application="developer" alias="packager" title="Packages" type="umbraco.loadPackager, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="3" />
|
||||
<add application="developer" alias="packagerPackages" title="Packager Packages" type="umbraco.loadPackages, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" initialize="false" sortOrder="3" />
|
||||
<add application="developer" alias="relationTypes" title="Relation Types" type="umbraco.loadRelationTypes, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="4" />
|
||||
<add application="developer" alias="relationTypes" title="Relation Types" type="Umbraco.Web.Trees.RelationTypeTreeController, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="4" />
|
||||
<add application="developer" alias="xslt" title="XSLT Files" type="Umbraco.Web.Trees.XsltTreeController, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="5" />
|
||||
<add application="developer" alias="partialViewMacros" type="Umbraco.Web.Trees.PartialViewMacrosTreeController, umbraco" silent="false" initialize="true" sortOrder="6" title="Partial View Macro Files" iconClosed="icon-folder" iconOpen="icon-folder" />
|
||||
<!--Users-->
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<add application="developer" alias="macros" title="Macros" type="Umbraco.Web.Trees.MacrosTreeController, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="2" />
|
||||
<add application="developer" alias="packager" title="Packages" type="umbraco.loadPackager, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="3" />
|
||||
<add application="developer" alias="packagerPackages" title="Packager Packages" type="umbraco.loadPackages, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" initialize="false" sortOrder="3" />
|
||||
<add application="developer" alias="relationTypes" title="Relation Types" type="umbraco.loadRelationTypes, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="4" />
|
||||
<add application="developer" alias="relationTypes" title="Relation Types" type="Umbraco.Web.Trees.RelationTypeTreeController, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="4" />
|
||||
<add application="developer" alias="xslt" title="XSLT Files" type="Umbraco.Web.Trees.XsltTreeController, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="5" />
|
||||
<add application="developer" alias="partialViewMacros" type="Umbraco.Web.Trees.PartialViewMacrosTreeController, umbraco" silent="false" initialize="true" sortOrder="6" title="Partial View Macro Files" iconClosed="icon-folder" iconOpen="icon-folder" />
|
||||
<!--Users-->
|
||||
|
||||
76
src/Umbraco.Web/Trees/RelationTypeTreeController.cs
Normal file
76
src/Umbraco.Web/Trees/RelationTypeTreeController.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Formatting;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
using Umbraco.Web.WebApi.Filters;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web._Legacy.Actions;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Umbraco.Web.Trees
|
||||
{
|
||||
[UmbracoTreeAuthorize(Constants.Trees.RelationTypes)]
|
||||
[Tree(Constants.Applications.Developer, Constants.Trees.RelationTypes, null, sortOrder: 4)]
|
||||
[Mvc.PluginController("UmbracoTrees")]
|
||||
[CoreTree]
|
||||
public class RelationTypeTreeController : TreeController
|
||||
{
|
||||
protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
|
||||
{
|
||||
var menu = new MenuItemCollection();
|
||||
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
{
|
||||
//Create the normal create action
|
||||
menu.Items.Add<ActionNew>(Services.TextService.Localize("actions", ActionNew.Instance.Alias))
|
||||
//Since we haven't implemented anything for relationtypes in angular, this needs to be converted to
|
||||
//use the legacy format
|
||||
.ConvertLegacyMenuItem(null, "initrelationTypes", queryStrings.GetValue<string>("application"));
|
||||
//refresh action
|
||||
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize("actions", ActionRefresh.Instance.Alias), true);
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
var relationType = Services.RelationService.GetRelationTypeById(int.Parse(id));
|
||||
if (relationType == null) return new MenuItemCollection();
|
||||
|
||||
//add delete option for all macros
|
||||
menu.Items.Add<ActionDelete>(Services.TextService.Localize("actions", ActionDelete.Instance.Alias))
|
||||
//Since we haven't implemented anything for relationtypes in angular, this needs to be converted to
|
||||
//use the legacy format
|
||||
.ConvertLegacyMenuItem(new UmbracoEntity
|
||||
{
|
||||
Id = relationType.Id,
|
||||
Level = 1,
|
||||
ParentId = -1,
|
||||
Name = relationType.Name
|
||||
}, "relationTypes", queryStrings.GetValue<string>("application"));
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
|
||||
{
|
||||
var nodes = new TreeNodeCollection();
|
||||
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
{
|
||||
nodes.AddRange(Services.RelationService
|
||||
.GetAllRelationTypes().Select(rt => CreateTreeNode(
|
||||
rt.Id.ToString(),
|
||||
id,
|
||||
queryStrings,
|
||||
rt.Name,
|
||||
"icon-trafic",
|
||||
false,
|
||||
//TODO: Rebuild the macro editor in angular, then we dont need to have this at all (which is just a path to the legacy editor)
|
||||
"/" + queryStrings.GetValue<string>("application") + "/framed/" +
|
||||
Uri.EscapeDataString("/umbraco/developer/RelationTypes/EditRelationType.aspx?id=" + rt.Id)
|
||||
)));
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -334,6 +334,7 @@
|
||||
<Compile Include="Editors\EditorModelEventManager.cs" />
|
||||
<Compile Include="HtmlHelperBackOfficeExtensions.cs" />
|
||||
<Compile Include="Models\Trees\DisableUser.cs" />
|
||||
<Compile Include="Trees\RelationTypeTreeController.cs" />
|
||||
<Compile Include="Trees\MacrosTreeController.cs" />
|
||||
<Compile Include="Trees\ScriptsTreeController.cs" />
|
||||
<Compile Include="Trees\DictionaryTreeController.cs" />
|
||||
@@ -1496,7 +1497,6 @@
|
||||
<Compile Include="umbraco.presentation\umbraco\Trees\ITreeService.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\Trees\loadRelationTypes.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\Trees\NodeActionsEventArgs.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\Trees\TreeEventArgs.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\Trees\TreeRequestParams.cs" />
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using umbraco.cms.businesslogic.relation;
|
||||
using umbraco.cms.presentation.Trees;
|
||||
using umbraco.DataLayer;
|
||||
using umbraco.cms.presentation.developer.RelationTypes.TreeMenu;
|
||||
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Trees;
|
||||
using Umbraco.Web._Legacy.Actions;
|
||||
|
||||
namespace umbraco
|
||||
{
|
||||
/// <summary>
|
||||
/// RelationTypes tree for developer section
|
||||
/// </summary>
|
||||
[Tree(Constants.Applications.Developer, "relationTypes", "Relation Types", sortOrder: 4)]
|
||||
public class loadRelationTypes : BaseTree
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the RelationTypeTree class.
|
||||
/// </summary>
|
||||
/// <param name="application">name of umbraco app to which this tree has been added, (in this case "developer")</param>
|
||||
public loadRelationTypes(string application)
|
||||
: base(application)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds the javascript methods for use by the nodes in this tree
|
||||
/// </summary>
|
||||
/// <param name="javascript">string container for javascript</param>
|
||||
public override void RenderJS(ref StringBuilder javascript)
|
||||
{
|
||||
javascript.Append(@"
|
||||
function openRelationType(id) {
|
||||
UmbClientMgr.contentFrame('developer/RelationTypes/EditRelationType.aspx?id=' + id);
|
||||
}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is called if the tree has been expanded, and it's used to render and child nodes for this tree
|
||||
/// </summary>
|
||||
/// <param name="tree">current tree</param>
|
||||
public override void Render(ref XmlTree tree)
|
||||
{
|
||||
XmlTreeNode node;
|
||||
|
||||
foreach (RelationType relationType in RelationType.GetAll().OrderBy(relationType => relationType.Name))
|
||||
{
|
||||
node = XmlTreeNode.Create(this);
|
||||
node.NodeID = relationType.Id.ToString();
|
||||
node.Text = relationType.Name;
|
||||
node.Icon = "icon-trafic";
|
||||
node.Action = string.Concat("javascript:openRelationType('", node.NodeID, "');");
|
||||
|
||||
tree.Add(node);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds right click context tree actions for each child node
|
||||
/// </summary>
|
||||
/// <param name="actions">collection of actions (expected to be empty)</param>
|
||||
protected override void CreateAllowedActions(ref List<IAction> actions)
|
||||
{
|
||||
actions.Clear();
|
||||
actions.Add(ActionDeleteRelationType.Instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds right click context tree actions for the root 'Relation Types' node
|
||||
/// </summary>
|
||||
/// <param name="actions">collection of actions (expected to be empty)</param>
|
||||
protected override void CreateRootNodeActions(ref List<IAction> actions)
|
||||
{
|
||||
actions.Clear();
|
||||
actions.Add(ActionNewRelationType.Instance);
|
||||
actions.Add(ContextMenuSeperator.Instance);
|
||||
actions.Add(ActionRefresh.Instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures root node 'Relation Types' properties
|
||||
/// </summary>
|
||||
/// <param name="rootNode">the 'Relation Types' root node</param>
|
||||
protected override void CreateRootNode(ref XmlTreeNode rootNode)
|
||||
{
|
||||
rootNode.Text = "Relation Types";
|
||||
rootNode.Icon = BaseTree.FolderIcon;
|
||||
rootNode.OpenIcon = BaseTree.FolderIconOpen;
|
||||
rootNode.NodeType = this.TreeAlias; // (Was prefixed with init)
|
||||
rootNode.NodeID = "init";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user