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)
|
if (model.ParentId < 0)
|
||||||
{
|
{
|
||||||
//cannot move if the content item is not allowed at the root
|
//cannot move if the content item is not allowed at the root unless there are
|
||||||
if (toMove.ContentType.AllowedAsRoot == false)
|
//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(
|
throw new HttpResponseException(
|
||||||
Request.CreateNotificationValidationErrorResponse(
|
Request.CreateNotificationValidationErrorResponse(
|
||||||
|
|||||||
@@ -393,7 +393,11 @@ namespace Umbraco.Web.Editors
|
|||||||
IEnumerable<IContentType> types;
|
IEnumerable<IContentType> types;
|
||||||
if (contentId == Constants.System.Root)
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -870,8 +870,10 @@ namespace Umbraco.Web.Editors
|
|||||||
}
|
}
|
||||||
if (model.ParentId < 0)
|
if (model.ParentId < 0)
|
||||||
{
|
{
|
||||||
//cannot move if the content item is not allowed at the root
|
//cannot move if the content item is not allowed at the root unless there are
|
||||||
if (toMove.ContentType.AllowedAsRoot == false)
|
//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();
|
var notificationModel = new SimpleNotificationModel();
|
||||||
notificationModel.AddErrorNotification(Services.TextService.Localize("moveOrCopy/notAllowedAtRoot"), "");
|
notificationModel.AddErrorNotification(Services.TextService.Localize("moveOrCopy/notAllowedAtRoot"), "");
|
||||||
|
|||||||
Reference in New Issue
Block a user