From bbd6908af344142503a6526d2193fb7e4648b75f Mon Sep 17 00:00:00 2001 From: Claus Date: Tue, 12 Jan 2016 13:06:33 +0100 Subject: [PATCH] Ensuring you can create new document types in root. Parsing result of webservice call as integer. Ensuring the correct error messages are shown. --- .../Services/ContentTypeServiceExtensions.cs | 17 +++++++++-------- .../components/umbgroupsbuilder.directive.js | 2 +- .../compositions/compositions.html | 7 +++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Umbraco.Core/Services/ContentTypeServiceExtensions.cs b/src/Umbraco.Core/Services/ContentTypeServiceExtensions.cs index 6b440c6b2c..d16e7946b9 100644 --- a/src/Umbraco.Core/Services/ContentTypeServiceExtensions.cs +++ b/src/Umbraco.Core/Services/ContentTypeServiceExtensions.cs @@ -15,8 +15,6 @@ namespace Umbraco.Core.Services IContentTypeComposition source, IContentTypeComposition[] allContentTypes) { - - if (source == null) throw new ArgumentNullException("source"); //below is all ported from the old doc type editor and comes with the same weaknesses /insanity / magic // note: there are many sanity checks missing here and there ;-(( @@ -24,12 +22,15 @@ namespace Umbraco.Core.Services //if (allContentTypes.Any(x => x.ParentId > 0 && x.ContentTypeComposition.Any(y => y.Id == x.ParentId) == false)) // throw new Exception("A parent does not belong to a composition."); - // find out if any content type uses this content type - var isUsing = allContentTypes.Where(x => x.ContentTypeComposition.Any(y => y.Id == source.Id)).ToArray(); - if (isUsing.Length > 0) + if (source != null) { - //if already in use a composition, do not allow any composited types - return new List(); + // find out if any content type uses this content type + var isUsing = allContentTypes.Where(x => x.ContentTypeComposition.Any(y => y.Id == source.Id)).ToArray(); + if (isUsing.Length > 0) + { + //if already in use a composition, do not allow any composited types + return new List(); + } } // if it is not used then composition is possible @@ -61,7 +62,7 @@ namespace Umbraco.Core.Services // .ToArray(); return list - .Where(x => x.Id != source.Id) + .Where(x => x.Id != (source != null ? source.Id : 0)) .OrderBy(x => x.Name) .ToList(); } diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbgroupsbuilder.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbgroupsbuilder.directive.js index 3ab653a3c3..c8ea32110e 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbgroupsbuilder.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbgroupsbuilder.directive.js @@ -251,7 +251,7 @@ }), //get content type count countContentTypeResource().then(function (result) { - scope.compositionsDialogModel.totalContentTypes = result; + scope.compositionsDialogModel.totalContentTypes = parseInt(result, 10); }) ]).then(function () { //resolves when both other promises are done, now show it diff --git a/src/Umbraco.Web.UI.Client/src/views/common/overlays/contenttypeeditor/compositions/compositions.html b/src/Umbraco.Web.UI.Client/src/views/common/overlays/contenttypeeditor/compositions/compositions.html index c9ca6695a6..2cdcef5ee6 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/overlays/contenttypeeditor/compositions/compositions.html +++ b/src/Umbraco.Web.UI.Client/src/views/common/overlays/contenttypeeditor/compositions/compositions.html @@ -15,13 +15,12 @@ There are no content types available to use as a composition. - This content type is used in a composition, and therefore cannot be composed itself. @@ -42,4 +41,4 @@ - + \ No newline at end of file