From df1c4faeb96b5538ccae8cd8dbb6d2c7b14fad37 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Wed, 24 Oct 2018 08:26:13 +0200 Subject: [PATCH] Create doctype collections under the chosen parent --- .../Editors/ContentTypeController.cs | 32 ++++--------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/src/Umbraco.Web/Editors/ContentTypeController.cs b/src/Umbraco.Web/Editors/ContentTypeController.cs index ac58b764f029..3f6df5c4b765 100644 --- a/src/Umbraco.Web/Editors/ContentTypeController.cs +++ b/src/Umbraco.Web/Editors/ContentTypeController.cs @@ -209,20 +209,6 @@ public HttpResponseMessage PostRenameContainer(int id, string name) public DocumentTypeCollectionDisplay PostCreateCollection(int parentId, string collectionName, bool collectionCreateTemplate, string collectionItemName, bool collectionItemCreateTemplate, string collectionIcon, string collectionItemIcon) { - var storeInContainer = false; - var allowUnderDocType = -1; - // check if it's a folder - if (Services.ContentTypeService.GetContentType(parentId) == null) - { - storeInContainer = true; - } else - { - // if it's not a container, we'll change the parentid to the root, - // and use the parent id as the doc type the collection should be allowed under - allowUnderDocType = parentId; - parentId = -1; - } - // create item doctype var itemDocType = new ContentType(parentId); itemDocType.Name = collectionItemName; @@ -260,20 +246,16 @@ public DocumentTypeCollectionDisplay PostCreateCollection(int parentId, string c // save collection doctype Services.ContentTypeService.Save(collectionDocType); - // test if the parent id exist and then allow the collection underneath - if (storeInContainer == false && allowUnderDocType != -1) + // test if the parent exist and then allow the collection underneath + var parentCt = Services.ContentTypeService.GetContentType(parentId); + if (parentCt != null) { - var parentCt = Services.ContentTypeService.GetContentType(allowUnderDocType); - if (parentCt != null) - { - var allowedCts = parentCt.AllowedContentTypes.ToList(); - allowedCts.Add(new ContentTypeSort(collectionDocType.Id, allowedCts.Count())); - parentCt.AllowedContentTypes = allowedCts; - Services.ContentTypeService.Save(parentCt); - } + var allowedCts = parentCt.AllowedContentTypes.ToList(); + allowedCts.Add(new ContentTypeSort(collectionDocType.Id, allowedCts.Count())); + parentCt.AllowedContentTypes = allowedCts; + Services.ContentTypeService.Save(parentCt); } - return new DocumentTypeCollectionDisplay { CollectionId = collectionDocType.Id,