diff --git a/build/NuSpecs/tools/trees.config.install.xdt b/build/NuSpecs/tools/trees.config.install.xdt
index 580c619547..1a56c81271 100644
--- a/build/NuSpecs/tools/trees.config.install.xdt
+++ b/build/NuSpecs/tools/trees.config.install.xdt
@@ -41,7 +41,7 @@
-
+
@@ -31,7 +32,7 @@
-
+
diff --git a/src/Umbraco.Web.UI/config/trees.config b/src/Umbraco.Web.UI/config/trees.config
index 1bad226db8..b1820c3460 100644
--- a/src/Umbraco.Web.UI/config/trees.config
+++ b/src/Umbraco.Web.UI/config/trees.config
@@ -31,7 +31,7 @@
-
+
diff --git a/src/Umbraco.Web.UI/umbraco/config/create/UI.Release.xml b/src/Umbraco.Web.UI/umbraco/config/create/UI.Release.xml
index 9fca6d082a..fdb8697398 100644
--- a/src/Umbraco.Web.UI/umbraco/config/create/UI.Release.xml
+++ b/src/Umbraco.Web.UI/umbraco/config/create/UI.Release.xml
@@ -115,14 +115,7 @@
-
- Dictionary editor egenskab
- /create/simple.ascx
-
-
-
-
-
+
Dictionary editor egenskab
/create/simple.ascx
diff --git a/src/Umbraco.Web.UI/umbraco/config/create/UI.xml b/src/Umbraco.Web.UI/umbraco/config/create/UI.xml
index da74f6527b..d8d3064f7b 100644
--- a/src/Umbraco.Web.UI/umbraco/config/create/UI.xml
+++ b/src/Umbraco.Web.UI/umbraco/config/create/UI.xml
@@ -110,14 +110,7 @@
-
- Dictionary editor egenskab
- /create/simple.ascx
-
-
-
-
-
+
Dictionary editor egenskab
/create/simple.ascx
diff --git a/src/Umbraco.Web/Trees/DictionaryTreeController.cs b/src/Umbraco.Web/Trees/DictionaryTreeController.cs
new file mode 100644
index 0000000000..dec233a61e
--- /dev/null
+++ b/src/Umbraco.Web/Trees/DictionaryTreeController.cs
@@ -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("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(Services.TextService.Localize("actions", ActionNew.Instance.Alias))
+ .ConvertLegacyMenuItem(null, "dictionary", queryStrings.GetValue("application"));
+
+ menu.Items.Add(
+ 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(Services.TextService.Localize("actions", ActionNew.Instance.Alias))
+ .ConvertLegacyMenuItem(entity, "dictionary", queryStrings.GetValue("application"));
+
+ menu.Items.Add(Services.TextService.Localize("actions", ActionDelete.Instance.Alias))
+ .ConvertLegacyMenuItem(null, "dictionary", queryStrings.GetValue("application"));
+
+ menu.Items.Add(
+ Services.TextService.Localize("actions", ActionRefresh.Instance.Alias), true);
+ }
+
+ return menu;
+ }
+
+ private IEnumerable 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("application"),
+ Uri.EscapeDataString("settings/editDictionaryItem.aspx?id=" +
+ dictionaryItem.Id)));
+
+ return node;
+ }
+
+ private int ValidateId(string id)
+ {
+ var intId = id.TryConvertTo();
+ if (intId == false)
+ {
+ throw new InvalidOperationException("Id must be an integer");
+ }
+
+ return intId.Result;
+ }
+ }
+}
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index 965c1f2531..f94b259318 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -328,6 +328,7 @@
+
@@ -1549,7 +1550,6 @@
xml.aspx
-
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadDictionary.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadDictionary.cs
deleted file mode 100644
index 03ae754f5c..0000000000
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadDictionary.cs
+++ /dev/null
@@ -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 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);
- }
-
- }
- }
-
-
- }
-
-}
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx.cs
index b5bed0d759..2d63a6593b 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditDictionaryItem.aspx.cs
@@ -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().Tree.Alias)
- .SyncTree(path, false);
+ .SetActiveTreeType(Constants.Trees.Dictionary)
+ .SyncTree(path, false);
}