Merge remote-tracking branch 'origin/dev-v8' into dev-v8
Conflicts: src/Umbraco.Web.UI/config/trees.Release.config src/Umbraco.Web/Umbraco.Web.csproj
This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
<add application="settings" alias="scripts" title="Scripts" type="umbraco.loadScripts, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="4"
|
||||
xdt:Locator="Match(application,alias)"
|
||||
xdt:Transform="SetAttributes()" />
|
||||
<add application="settings" alias="dictionary" title="Dictionary" type="umbraco.loadDictionary, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="6"
|
||||
<add application="settings" alias="dictionary" title="Dictionary" type="Umbraco.Web.Trees.DictionaryTreeController, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="6"
|
||||
xdt:Locator="Match(application,alias)"
|
||||
xdt:Transform="SetAttributes()" />
|
||||
<add alias="dictionary" application="settings"
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<add application="settings" alias="stylesheets" title="Stylesheets" type="Umbraco.Web.Trees.StylesheetsTreeController, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="3" />
|
||||
<add application="settings" alias="scripts" title="Scripts" type="Umbraco.Web.Trees.ScriptsTreeController, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="4" />
|
||||
<add application="settings" alias="languages" title="Languages" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Web.Trees.LanguageTreeController, umbraco" sortOrder="5" />
|
||||
<add application="settings" alias="dictionary" title="Dictionary" type="Umbraco.Web.Trees.DictionaryTreeController, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="6" />
|
||||
<add initialize="true" sortOrder="7" alias="dataTypes" application="settings" title="Data Types" iconClosed="icon-folder" iconOpen="icon-folder" type="Umbraco.Web.Trees.DataTypeTreeController, umbraco" />
|
||||
<add initialize="true" sortOrder="8" alias="mediaTypes" application="settings" title="Media Types" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Web.Trees.MediaTypeTreeController, umbraco" />
|
||||
<!--Developer-->
|
||||
@@ -31,7 +32,7 @@
|
||||
<add initialize="true" sortOrder="1" alias="memberTypes" application="member" title="Member Types" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Web.Trees.MemberTypeTreeController, umbraco" />
|
||||
<add application="member" sortOrder="2" alias="memberGroups" title="Member Groups" type="umbraco.loadMemberGroups, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" />
|
||||
<!--Translation-->
|
||||
<add application="translation" alias="dictionary" title="Dictionary" type="umbraco.loadDictionary, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="0" />
|
||||
<add application="translation" alias="dictionary" title="Dictionary" type="Umbraco.Web.Trees.DictionaryTreeController, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="0" />
|
||||
<add silent="false" initialize="true" sortOrder="1" alias="openTasks" application="translation" title="Tasks assigned to you" iconClosed="icon-folder" iconOpen="icon-folder" type="umbraco.loadOpenTasks, umbraco" />
|
||||
<add silent="false" initialize="true" sortOrder="2" alias="yourTasks" application="translation" title="Tasks created by you" iconClosed="icon-folder" iconOpen="icon-folder" type="umbraco.loadYourTasks, umbraco" />
|
||||
<!-- Custom -->
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<add initialize="true" sortOrder="1" alias="memberTypes" application="member" title="Member Types" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Web.Trees.MemberTypeTreeController, umbraco" />
|
||||
<add application="member" sortOrder="2" alias="memberGroups" title="Member Groups" type="umbraco.loadMemberGroups, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" />
|
||||
<!--Translation-->
|
||||
<add application="translation" alias="dictionary" title="Dictionary" type="umbraco.loadDictionary, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="0" />
|
||||
<add application="translation" alias="dictionary" title="Dictionary" type="Umbraco.Web.Trees.DictionaryTreeController, umbraco" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="0" />
|
||||
<add silent="false" initialize="true" sortOrder="1" alias="openTasks" application="translation" title="Tasks assigned to you" iconClosed="icon-folder" iconOpen="icon-folder" type="umbraco.loadOpenTasks, umbraco" />
|
||||
<add silent="false" initialize="true" sortOrder="2" alias="yourTasks" application="translation" title="Tasks created by you" iconClosed="icon-folder" iconOpen="icon-folder" type="umbraco.loadYourTasks, umbraco" />
|
||||
<!-- Custom -->
|
||||
|
||||
@@ -115,14 +115,7 @@
|
||||
<delete assembly="umbraco" type="stylesheetPropertyTasks" />
|
||||
</tasks>
|
||||
</nodeType>
|
||||
<nodeType alias="initdictionary">
|
||||
<header>Dictionary editor egenskab</header>
|
||||
<usercontrol>/create/simple.ascx</usercontrol>
|
||||
<tasks>
|
||||
<create assembly="umbraco" type="dictionaryTasks" />
|
||||
</tasks>
|
||||
</nodeType>
|
||||
<nodeType alias="DictionaryItem">
|
||||
<nodeType alias="dictionary">
|
||||
<header>Dictionary editor egenskab</header>
|
||||
<usercontrol>/create/simple.ascx</usercontrol>
|
||||
<tasks>
|
||||
|
||||
@@ -110,14 +110,7 @@
|
||||
<delete assembly="umbraco" type="stylesheetPropertyTasks" />
|
||||
</tasks>
|
||||
</nodeType>
|
||||
<nodeType alias="initdictionary">
|
||||
<header>Dictionary editor egenskab</header>
|
||||
<usercontrol>/create/simple.ascx</usercontrol>
|
||||
<tasks>
|
||||
<create assembly="umbraco" type="dictionaryTasks" />
|
||||
</tasks>
|
||||
</nodeType>
|
||||
<nodeType alias="DictionaryItem">
|
||||
<nodeType alias="dictionary">
|
||||
<header>Dictionary editor egenskab</header>
|
||||
<usercontrol>/create/simple.ascx</usercontrol>
|
||||
<tasks>
|
||||
|
||||
124
src/Umbraco.Web/Trees/DictionaryTreeController.cs
Normal file
124
src/Umbraco.Web/Trees/DictionaryTreeController.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Formatting;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
using Umbraco.Web.WebApi.Filters;
|
||||
using Umbraco.Web._Legacy.Actions;
|
||||
|
||||
namespace Umbraco.Web.Trees
|
||||
{
|
||||
[UmbracoTreeAuthorize(Constants.Trees.Dictionary)]
|
||||
[Tree(Constants.Applications.Settings, Constants.Trees.Dictionary, null, sortOrder: 3)]
|
||||
[Mvc.PluginController("UmbracoTrees")]
|
||||
[CoreTree]
|
||||
public class DictionaryTreeController : TreeController
|
||||
{
|
||||
protected override TreeNode CreateRootNode(FormDataCollection queryStrings)
|
||||
{
|
||||
var node = base.CreateRootNode(queryStrings);
|
||||
|
||||
// For now, this is using the legacy webforms view but will need refactoring
|
||||
// when the dictionary has been converted to Angular.
|
||||
node.RoutePath = String.Format("{0}/framed/{1}", queryStrings.GetValue<string>("application"),
|
||||
Uri.EscapeDataString("settings/DictionaryItemList.aspx"));
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
|
||||
{
|
||||
var intId = ValidateId(id);
|
||||
|
||||
var nodes = new TreeNodeCollection();
|
||||
nodes.AddRange(GetDictionaryItems(intId)
|
||||
.OrderBy(dictionaryItem => dictionaryItem.ItemKey)
|
||||
.Select(dictionaryItem => CreateTreeNode(id, queryStrings, dictionaryItem)));
|
||||
|
||||
return nodes;
|
||||
}
|
||||
|
||||
protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
|
||||
{
|
||||
var intId = ValidateId(id);
|
||||
|
||||
var menu = new MenuItemCollection();
|
||||
|
||||
if (intId == Constants.System.Root)
|
||||
{
|
||||
// Again, menu actions will need to use legacy views as this section hasn't been converted to Angular (yet!)
|
||||
menu.Items.Add<ActionNew>(Services.TextService.Localize("actions", ActionNew.Instance.Alias))
|
||||
.ConvertLegacyMenuItem(null, "dictionary", queryStrings.GetValue<string>("application"));
|
||||
|
||||
menu.Items.Add<RefreshNode, ActionRefresh>(
|
||||
Services.TextService.Localize("actions", ActionRefresh.Instance.Alias), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var dictionaryItem = Services.LocalizationService.GetDictionaryItemById(intId);
|
||||
var entity = new UmbracoEntity
|
||||
{
|
||||
Id = dictionaryItem.Id,
|
||||
Level = 1,
|
||||
ParentId = -1,
|
||||
Name = dictionaryItem.ItemKey
|
||||
};
|
||||
|
||||
menu.Items.Add<ActionNew>(Services.TextService.Localize("actions", ActionNew.Instance.Alias))
|
||||
.ConvertLegacyMenuItem(entity, "dictionary", queryStrings.GetValue<string>("application"));
|
||||
|
||||
menu.Items.Add<ActionDelete>(Services.TextService.Localize("actions", ActionDelete.Instance.Alias))
|
||||
.ConvertLegacyMenuItem(null, "dictionary", queryStrings.GetValue<string>("application"));
|
||||
|
||||
menu.Items.Add<RefreshNode, ActionRefresh>(
|
||||
Services.TextService.Localize("actions", ActionRefresh.Instance.Alias), true);
|
||||
}
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
private IEnumerable<IDictionaryItem> GetDictionaryItems(int id)
|
||||
{
|
||||
if (id > Constants.System.Root)
|
||||
{
|
||||
var dictionaryItem = Services.LocalizationService.GetDictionaryItemById(id);
|
||||
|
||||
if (dictionaryItem != null)
|
||||
{
|
||||
return Services.LocalizationService.GetDictionaryItemChildren(dictionaryItem.Key);
|
||||
}
|
||||
}
|
||||
|
||||
return Services.LocalizationService.GetRootDictionaryItems();
|
||||
}
|
||||
|
||||
private TreeNode CreateTreeNode(string id, FormDataCollection queryStrings, IDictionaryItem dictionaryItem)
|
||||
{
|
||||
var hasChildren = Services.LocalizationService.GetDictionaryItemChildren(dictionaryItem.Key).Any();
|
||||
|
||||
// Again, menu actions will need to use legacy views as this section hasn't been converted to Angular (yet!)
|
||||
var node = CreateTreeNode(dictionaryItem.Id.ToInvariantString(), id, queryStrings, dictionaryItem.ItemKey,
|
||||
"icon-book-alt", hasChildren,
|
||||
String.Format("{0}/framed/{1}", queryStrings.GetValue<string>("application"),
|
||||
Uri.EscapeDataString("settings/editDictionaryItem.aspx?id=" +
|
||||
dictionaryItem.Id)));
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
private int ValidateId(string id)
|
||||
{
|
||||
var intId = id.TryConvertTo<int>();
|
||||
if (intId == false)
|
||||
{
|
||||
throw new InvalidOperationException("Id must be an integer");
|
||||
}
|
||||
|
||||
return intId.Result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -328,6 +328,7 @@
|
||||
<Compile Include="HtmlHelperBackOfficeExtensions.cs" />
|
||||
<Compile Include="Trees\MacrosTreeController.cs" />
|
||||
<Compile Include="Trees\ScriptsTreeController.cs" />
|
||||
<Compile Include="Trees\DictionaryTreeController.cs" />
|
||||
<Compile Include="Trees\StylesheetsTreeController.cs" />
|
||||
<Compile Include="Trees\UserTypesTreeController.cs" />
|
||||
<Compile Include="Trees\XsltTreeController.cs" />
|
||||
@@ -1549,7 +1550,6 @@
|
||||
<DependentUpon>xml.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\Trees\BaseTree.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\Trees\loadDictionary.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\Trees\loadMemberGroups.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\Trees\loadPackages.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\Trees\loadTranslationTasks.cs" />
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using umbraco.cms.businesslogic;
|
||||
using umbraco.cms.presentation.Trees;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Trees;
|
||||
using Umbraco.Web._Legacy.Actions;
|
||||
|
||||
|
||||
namespace umbraco
|
||||
{
|
||||
|
||||
[Tree(Constants.Applications.Translation, Constants.Trees.Dictionary, "Dictionary", sortOrder: 0)]
|
||||
public class loadDictionary : BaseTree
|
||||
{
|
||||
public loadDictionary(string application) : base(application) { }
|
||||
|
||||
protected override void CreateRootNode(ref XmlTreeNode rootNode)
|
||||
{
|
||||
rootNode.NodeType = "init" + TreeAlias;
|
||||
rootNode.NodeID = "init";
|
||||
rootNode.Action = "javascript:openDictionary()";
|
||||
}
|
||||
|
||||
protected override void CreateAllowedActions(ref List<IAction> actions)
|
||||
{
|
||||
actions.Clear();
|
||||
actions.Add(ActionNew.Instance);
|
||||
actions.Add(ActionDelete.Instance);
|
||||
actions.Add(ContextMenuSeperator.Instance);
|
||||
actions.Add(ActionRefresh.Instance);
|
||||
}
|
||||
|
||||
public override void RenderJS(ref StringBuilder Javascript)
|
||||
{
|
||||
Javascript.Append(
|
||||
@"
|
||||
function openDictionary() {
|
||||
UmbClientMgr.contentFrame('settings/DictionaryItemList.aspx');
|
||||
}
|
||||
function openDictionaryItem(id) {
|
||||
UmbClientMgr.contentFrame('settings/editDictionaryItem.aspx?id=' + id);
|
||||
}");
|
||||
}
|
||||
|
||||
public override void Render(ref XmlTree tree)
|
||||
{
|
||||
|
||||
Dictionary.DictionaryItem[] tmp;
|
||||
if (this.id == this.StartNodeID)
|
||||
tmp = Dictionary.getTopMostItems;
|
||||
else
|
||||
tmp = new Dictionary.DictionaryItem(this.id).Children;
|
||||
|
||||
foreach (Dictionary.DictionaryItem di in tmp.OrderBy(a => a.key))
|
||||
{
|
||||
XmlTreeNode xNode = XmlTreeNode.Create(this);
|
||||
xNode.NodeID = di.id.ToString(); //dictionary_ + id..
|
||||
xNode.Text = di.key;
|
||||
xNode.Action = string.Format("javascript:openDictionaryItem({0});", di.id);
|
||||
xNode.Icon = "icon-book-alt";
|
||||
xNode.NodeType = "DictionaryItem"; //this shouldn't be like this, it should be this.TreeAlias but the ui.config file points to this name.
|
||||
xNode.Source = this.GetTreeServiceUrl(di.id);
|
||||
xNode.HasChildren = di.hasChildren;
|
||||
|
||||
OnBeforeNodeRender(ref tree, ref xNode, EventArgs.Empty);
|
||||
if (xNode != null)
|
||||
{
|
||||
tree.Add(xNode);
|
||||
OnAfterNodeRender(ref tree, ref xNode, EventArgs.Empty);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System.Web.UI.WebControls;
|
||||
using umbraco.cms.presentation.Trees;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.UI;
|
||||
|
||||
namespace umbraco.settings
|
||||
@@ -61,8 +62,8 @@ namespace umbraco.settings
|
||||
{
|
||||
var path = BuildPath(currentItem);
|
||||
ClientTools
|
||||
.SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree<loadDictionary>().Tree.Alias)
|
||||
.SyncTree(path, false);
|
||||
.SetActiveTreeType(Constants.Trees.Dictionary)
|
||||
.SyncTree(path, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user