From 2bdea2ef309fc97e7022e6bfd2a4f658cd2a29d1 Mon Sep 17 00:00:00 2001 From: Claus Date: Wed, 6 Jan 2016 09:23:55 +0100 Subject: [PATCH 1/7] Fixes: U4-7556 Export/import document types isn't available in 7.4 Added in export to context menu on document types using the legacy dialog. --- src/Umbraco.Web/Trees/ContentTypeTreeController.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web/Trees/ContentTypeTreeController.cs b/src/Umbraco.Web/Trees/ContentTypeTreeController.cs index 43cf60a178..31ad9f10bb 100644 --- a/src/Umbraco.Web/Trees/ContentTypeTreeController.cs +++ b/src/Umbraco.Web/Trees/ContentTypeTreeController.cs @@ -94,8 +94,15 @@ namespace Umbraco.Web.Trees } else { - menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionDelete.Instance.Alias))); - menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionMove.Instance.Alias)), hasSeparator: true); + 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)), hasSeparator: true).ConvertLegacyMenuItem(new UmbracoEntity + { + Id = int.Parse(id), + Level = 1, + ParentId = -1, + Name = "" + }, "documenttypes", "settings"); ; + menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionDelete.Instance.Alias)), hasSeparator: true); } return menu; From 83963003f9f311e21874974183ae943a9dfa8907 Mon Sep 17 00:00:00 2001 From: Claus Date: Wed, 6 Jan 2016 09:25:15 +0100 Subject: [PATCH 2/7] Ensures XML serializer doesn't fail when trying to serialize null properties. Some properties can now be nulls instead of string.Empty when using the new content type editor. --- src/Umbraco.Core/Services/EntityXmlSerializer.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Core/Services/EntityXmlSerializer.cs b/src/Umbraco.Core/Services/EntityXmlSerializer.cs index 712f98aeb2..fca29ddd6e 100644 --- a/src/Umbraco.Core/Services/EntityXmlSerializer.cs +++ b/src/Umbraco.Core/Services/EntityXmlSerializer.cs @@ -374,14 +374,15 @@ namespace Umbraco.Core.Services : contentType.PropertyGroups.FirstOrDefault(x => x.Id == propertyType.PropertyGroupId.Value); var genericProperty = new XElement("GenericProperty", - new XElement("Name", propertyType.Name), - new XElement("Alias", propertyType.Alias), - new XElement("Type", propertyType.PropertyEditorAlias), + propertyType.Name != null ? new XElement("Name", propertyType.Name) : null, + propertyType.Alias != null ? new XElement("Alias", propertyType.Alias) : null, + propertyType.PropertyEditorAlias != null ? new XElement("Type", propertyType.PropertyEditorAlias) : null, new XElement("Definition", definition.Key), new XElement("Tab", propertyGroup == null ? "" : propertyGroup.Name), new XElement("Mandatory", propertyType.Mandatory.ToString()), - new XElement("Validation", propertyType.ValidationRegExp), - new XElement("Description", new XCData(propertyType.Description))); + propertyType.ValidationRegExp != null ? new XElement("Validation", propertyType.ValidationRegExp) : null, + propertyType.Description != null ? new XElement("Description", new XCData(propertyType.Description)) : null); + genericProperties.Add(genericProperty); } From e489cffa3dd237b8dc3a5129ef32c5f215d21f00 Mon Sep 17 00:00:00 2001 From: Claus Date: Wed, 6 Jan 2016 09:26:58 +0100 Subject: [PATCH 3/7] Removed unused namespaces and cleanup. --- src/Umbraco.Web/Trees/ContentTypeTreeController.cs | 6 +----- .../umbraco.presentation/umbraco/Trees/loadNodeTypes.cs | 3 --- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/Umbraco.Web/Trees/ContentTypeTreeController.cs b/src/Umbraco.Web/Trees/ContentTypeTreeController.cs index 31ad9f10bb..6cb38c6480 100644 --- a/src/Umbraco.Web/Trees/ContentTypeTreeController.cs +++ b/src/Umbraco.Web/Trees/ContentTypeTreeController.cs @@ -1,14 +1,10 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Net.Http.Formatting; -using System.Text; -using System.Threading.Tasks; using umbraco; using umbraco.BusinessLogic.Actions; using Umbraco.Core; using Umbraco.Core.Models; -using Umbraco.Core.Models.EntityBase; using Umbraco.Web.Models.Trees; using Umbraco.Web.WebApi.Filters; using Umbraco.Core.Services; @@ -101,7 +97,7 @@ namespace Umbraco.Web.Trees Level = 1, ParentId = -1, Name = "" - }, "documenttypes", "settings"); ; + }, "documenttypes", "settings"); menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionDelete.Instance.Alias)), hasSeparator: true); } diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadNodeTypes.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadNodeTypes.cs index c2940a8a5d..af3da401e8 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadNodeTypes.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadNodeTypes.cs @@ -1,14 +1,11 @@ using System; using System.Collections.Generic; using System.Globalization; -using System.Linq; using System.Text; using Umbraco.Core.Services; -using umbraco.businesslogic; using umbraco.interfaces; using umbraco.BusinessLogic.Actions; using umbraco.cms.presentation.Trees; -using Umbraco.Core; using Umbraco.Web.umbraco.presentation.umbraco.Trees; From e49033a602bc5f5be6fe66d3cb9de0a2d8a680e7 Mon Sep 17 00:00:00 2001 From: Claus Date: Wed, 6 Jan 2016 09:44:12 +0100 Subject: [PATCH 4/7] Added import document type option to context menu on root node. --- .../Trees/ContentTypeTreeController.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web/Trees/ContentTypeTreeController.cs b/src/Umbraco.Web/Trees/ContentTypeTreeController.cs index 6cb38c6480..c9b0551217 100644 --- a/src/Umbraco.Web/Trees/ContentTypeTreeController.cs +++ b/src/Umbraco.Web/Trees/ContentTypeTreeController.cs @@ -69,7 +69,14 @@ namespace Umbraco.Web.Trees // root actions menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionNew.Instance.Alias))); - menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias))); + menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionImport.Instance.Alias)), true).ConvertLegacyMenuItem(new UmbracoEntity + { + Id = int.Parse(id), + Level = 1, + ParentId = -1, + Name = "" + }, "documenttypes", "settings"); + menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true); return menu; } @@ -86,19 +93,19 @@ namespace Umbraco.Web.Trees //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}", ActionRefresh.Instance.Alias)), hasSeparator: true); + menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.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}", ActionExport.Instance.Alias)), hasSeparator: true).ConvertLegacyMenuItem(new UmbracoEntity + menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionExport.Instance.Alias)), true).ConvertLegacyMenuItem(new UmbracoEntity { Id = int.Parse(id), Level = 1, ParentId = -1, Name = "" }, "documenttypes", "settings"); - menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionDelete.Instance.Alias)), hasSeparator: true); + menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionDelete.Instance.Alias)), true); } return menu; From 2dcb9c93f7b0760da6b70200ff42f5eaf327029b Mon Sep 17 00:00:00 2001 From: Claus Date: Wed, 6 Jan 2016 10:26:09 +0100 Subject: [PATCH 5/7] Dropped these null checks to avoid serializing invalid objects. --- src/Umbraco.Core/Services/EntityXmlSerializer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Core/Services/EntityXmlSerializer.cs b/src/Umbraco.Core/Services/EntityXmlSerializer.cs index fca29ddd6e..16f33a1ce9 100644 --- a/src/Umbraco.Core/Services/EntityXmlSerializer.cs +++ b/src/Umbraco.Core/Services/EntityXmlSerializer.cs @@ -374,15 +374,15 @@ namespace Umbraco.Core.Services : contentType.PropertyGroups.FirstOrDefault(x => x.Id == propertyType.PropertyGroupId.Value); var genericProperty = new XElement("GenericProperty", - propertyType.Name != null ? new XElement("Name", propertyType.Name) : null, - propertyType.Alias != null ? new XElement("Alias", propertyType.Alias) : null, - propertyType.PropertyEditorAlias != null ? new XElement("Type", propertyType.PropertyEditorAlias) : null, + new XElement("Name", propertyType.Name), + new XElement("Alias", propertyType.Alias), + new XElement("Type", propertyType.PropertyEditorAlias), new XElement("Definition", definition.Key), new XElement("Tab", propertyGroup == null ? "" : propertyGroup.Name), new XElement("Mandatory", propertyType.Mandatory.ToString()), propertyType.ValidationRegExp != null ? new XElement("Validation", propertyType.ValidationRegExp) : null, propertyType.Description != null ? new XElement("Description", new XCData(propertyType.Description)) : null); - + genericProperties.Add(genericProperty); } From bfa9c80ed603b283aa1e1742ea28340772209145 Mon Sep 17 00:00:00 2001 From: Claus Date: Wed, 6 Jan 2016 10:27:39 +0100 Subject: [PATCH 6/7] Added null checks for elements on import. --- src/Umbraco.Core/Services/PackagingService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Core/Services/PackagingService.cs b/src/Umbraco.Core/Services/PackagingService.cs index 8ca9d3e3da..0d1d8388b6 100644 --- a/src/Umbraco.Core/Services/PackagingService.cs +++ b/src/Umbraco.Core/Services/PackagingService.cs @@ -655,9 +655,9 @@ namespace Umbraco.Core.Services var propertyType = new PropertyType(dataTypeDefinition, property.Element("Alias").Value) { Name = property.Element("Name").Value, - Description = property.Element("Description").Value, - Mandatory = property.Element("Mandatory").Value.ToLowerInvariant().Equals("true"), - ValidationRegExp = property.Element("Validation").Value, + Description = property.Element("Description") != null ? property.Element("Description").Value : null, + Mandatory = property.Element("Mandatory") != null ? property.Element("Mandatory").Value.ToLowerInvariant().Equals("true") : false, + ValidationRegExp = property.Element("Validation") != null ? property.Element("Validation").Value : null, }; var tab = property.Element("Tab").Value; From f1cc32771ec77f242c726ba84c3ce60dbb9cddaa Mon Sep 17 00:00:00 2001 From: Claus Date: Wed, 6 Jan 2016 10:31:21 +0100 Subject: [PATCH 7/7] Using constants instead of -1. --- src/Umbraco.Web/Trees/ContentTypeTreeController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web/Trees/ContentTypeTreeController.cs b/src/Umbraco.Web/Trees/ContentTypeTreeController.cs index c9b0551217..e29f9d6be9 100644 --- a/src/Umbraco.Web/Trees/ContentTypeTreeController.cs +++ b/src/Umbraco.Web/Trees/ContentTypeTreeController.cs @@ -73,7 +73,7 @@ namespace Umbraco.Web.Trees { Id = int.Parse(id), Level = 1, - ParentId = -1, + ParentId = Constants.System.Root, Name = "" }, "documenttypes", "settings"); menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true); @@ -102,7 +102,7 @@ namespace Umbraco.Web.Trees { Id = int.Parse(id), Level = 1, - ParentId = -1, + ParentId = Constants.System.Root, Name = "" }, "documenttypes", "settings"); menu.Items.Add(Services.TextService.Localize(string.Format("actions/{0}", ActionDelete.Instance.Alias)), true);