From 4db1599bcb155c02edea88536313c1ff98ce98cc Mon Sep 17 00:00:00 2001 From: Claus Date: Thu, 7 Jan 2016 16:56:32 +0100 Subject: [PATCH] Null checks for when using folders. Updated tree menu items. --- src/Umbraco.Web/Editors/ContentTypeController.cs | 4 +--- src/Umbraco.Web/Editors/ContentTypeControllerBase.cs | 3 ++- src/Umbraco.Web/Trees/ContentTypeTreeController.cs | 10 ++++++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web/Editors/ContentTypeController.cs b/src/Umbraco.Web/Editors/ContentTypeController.cs index aa414009f1..cd9caec397 100644 --- a/src/Umbraco.Web/Editors/ContentTypeController.cs +++ b/src/Umbraco.Web/Editors/ContentTypeController.cs @@ -191,12 +191,10 @@ namespace Umbraco.Web.Editors parentId != Constants.System.Root) { var parent = Services.ContentTypeService.GetContentType(parentId); - ct = new ContentType(parent, String.Empty); + ct = parent != null ? new ContentType(parent, String.Empty) : new ContentType(parentId); } else - { ct = new ContentType(parentId); - } ct.Icon = "icon-document"; diff --git a/src/Umbraco.Web/Editors/ContentTypeControllerBase.cs b/src/Umbraco.Web/Editors/ContentTypeControllerBase.cs index e3799c3c88..aa518b1bb6 100644 --- a/src/Umbraco.Web/Editors/ContentTypeControllerBase.cs +++ b/src/Umbraco.Web/Editors/ContentTypeControllerBase.cs @@ -129,7 +129,8 @@ namespace Umbraco.Web.Editors if (parentId > 0) { var parent = allContentTypes.FirstOrDefault(x => x.Id == parentId); - ancestorIds = parent.Path.Split(',').Select(int.Parse).ToArray(); + if (parent != null) + ancestorIds = parent.Path.Split(',').Select(int.Parse).ToArray(); } // add all ancestors as compositions (since they are implicitly compositions by inheritance) diff --git a/src/Umbraco.Web/Trees/ContentTypeTreeController.cs b/src/Umbraco.Web/Trees/ContentTypeTreeController.cs index 94753afd16..b6a0bfab66 100644 --- a/src/Umbraco.Web/Trees/ContentTypeTreeController.cs +++ b/src/Umbraco.Web/Trees/ContentTypeTreeController.cs @@ -95,7 +95,7 @@ namespace Umbraco.Web.Trees if (container.HasChildren() == false) { //can delete doc type - menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionDelete.Instance.Alias))); + menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionDelete.Instance.Alias)), true); } menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true); } @@ -104,8 +104,12 @@ namespace Umbraco.Web.Trees if (enableInheritedDocumentTypes) { menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionNew.Instance.Alias))); + menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionMove.Instance.Alias)), true); + } + else + { + menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionMove.Instance.Alias))); } - menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionMove.Instance.Alias))); menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionExport.Instance.Alias)), true).ConvertLegacyMenuItem(new UmbracoEntity { Id = int.Parse(id), @@ -114,6 +118,8 @@ namespace Umbraco.Web.Trees Name = "" }, "documenttypes", "settings"); menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionDelete.Instance.Alias)), true); + if (enableInheritedDocumentTypes) + menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true); } return menu;