Merge pull request #4418 from kjac/v8-feature-allow-all-at-root
V8: Allow all content types at root if none are explicitly allowed
This commit is contained in:
@@ -1830,8 +1830,10 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
if (model.ParentId < 0)
|
||||
{
|
||||
//cannot move if the content item is not allowed at the root
|
||||
if (toMove.ContentType.AllowedAsRoot == false)
|
||||
//cannot move if the content item is not allowed at the root unless there are
|
||||
//none allowed at root (in which case all should be allowed at root)
|
||||
var contentTypeService = Services.ContentTypeService;
|
||||
if (toMove.ContentType.AllowedAsRoot == false && contentTypeService.GetAll().Any(ct => ct.AllowedAsRoot))
|
||||
{
|
||||
throw new HttpResponseException(
|
||||
Request.CreateNotificationValidationErrorResponse(
|
||||
|
||||
@@ -393,7 +393,11 @@ namespace Umbraco.Web.Editors
|
||||
IEnumerable<IContentType> types;
|
||||
if (contentId == Constants.System.Root)
|
||||
{
|
||||
types = Services.ContentTypeService.GetAll().Where(x => x.AllowedAsRoot).ToList();
|
||||
var allContentTypes = Services.ContentTypeService.GetAll().ToList();
|
||||
bool AllowedAsRoot(IContentType x) => x.AllowedAsRoot;
|
||||
types = allContentTypes.Any(AllowedAsRoot)
|
||||
? allContentTypes.Where(AllowedAsRoot).ToList()
|
||||
: allContentTypes;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -870,8 +870,10 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
if (model.ParentId < 0)
|
||||
{
|
||||
//cannot move if the content item is not allowed at the root
|
||||
if (toMove.ContentType.AllowedAsRoot == false)
|
||||
//cannot move if the content item is not allowed at the root unless there are
|
||||
//none allowed at root (in which case all should be allowed at root)
|
||||
var mediaTypeService = Services.MediaTypeService;
|
||||
if (toMove.ContentType.AllowedAsRoot == false && mediaTypeService.GetAll().Any(ct => ct.AllowedAsRoot))
|
||||
{
|
||||
var notificationModel = new SimpleNotificationModel();
|
||||
notificationModel.AddErrorNotification(Services.TextService.Localize("moveOrCopy/notAllowedAtRoot"), "");
|
||||
|
||||
Reference in New Issue
Block a user