Ensures that we don't set IsChildOfListView when it's a user's start node since we are actually rendering that tree node when that is the case
This commit is contained in:
@@ -869,7 +869,7 @@ namespace Umbraco.Web.Editors
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to perform the saving of the content and add the notifications to the result
|
||||
@@ -1161,14 +1161,14 @@ namespace Umbraco.Web.Editors
|
||||
//validate if we can publish based on the mandatory language requirements
|
||||
var canPublish = ValidatePublishingMandatoryLanguages(
|
||||
cultureErrors,
|
||||
contentItem, cultureVariants, mandatoryCultures,
|
||||
contentItem, cultureVariants, mandatoryCultures,
|
||||
mandatoryVariant => mandatoryVariant.Publish);
|
||||
|
||||
//Now check if there are validation errors on each variant.
|
||||
//If validation errors are detected on a variant and it's state is set to 'publish', then we
|
||||
//need to change it to 'save'.
|
||||
//It is a requirement that this is performed AFTER ValidatePublishingMandatoryLanguages.
|
||||
|
||||
|
||||
foreach (var variant in contentItem.Variants)
|
||||
{
|
||||
if (cultureErrors.Contains(variant.Culture))
|
||||
@@ -1656,14 +1656,14 @@ namespace Umbraco.Web.Editors
|
||||
[HttpPost]
|
||||
public DomainSave PostSaveLanguageAndDomains(DomainSave model)
|
||||
{
|
||||
foreach(var domain in model.Domains)
|
||||
foreach (var domain in model.Domains)
|
||||
{
|
||||
try
|
||||
{
|
||||
var uri = DomainUtilities.ParseUriFromDomainName(domain.Name, Request.RequestUri);
|
||||
}
|
||||
catch (UriFormatException)
|
||||
{
|
||||
{
|
||||
var response = Request.CreateValidationErrorResponse(Services.TextService.Localize("assignDomain/invalidDomain"));
|
||||
throw new HttpResponseException(response);
|
||||
}
|
||||
@@ -1829,7 +1829,7 @@ namespace Umbraco.Web.Editors
|
||||
base.HandleInvalidModelState(display);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Maps the dto property values and names to the persisted model
|
||||
/// </summary>
|
||||
@@ -1842,7 +1842,7 @@ namespace Umbraco.Web.Editors
|
||||
var culture = property.PropertyType.VariesByCulture() ? variant.Culture : null;
|
||||
var segment = property.PropertyType.VariesBySegment() ? variant.Segment : null;
|
||||
return (culture, segment);
|
||||
}
|
||||
}
|
||||
|
||||
var variantIndex = 0;
|
||||
|
||||
@@ -1884,15 +1884,15 @@ namespace Umbraco.Web.Editors
|
||||
(save, property) =>
|
||||
{
|
||||
// Get property value
|
||||
(var culture, var segment) = PropertyCultureAndSegment(property, variant);
|
||||
return property.GetValue(culture, segment);
|
||||
(var culture, var segment) = PropertyCultureAndSegment(property, variant);
|
||||
return property.GetValue(culture, segment);
|
||||
},
|
||||
(save, property, v) =>
|
||||
{
|
||||
// Set property value
|
||||
(var culture, var segment) = PropertyCultureAndSegment(property, variant);
|
||||
property.SetValue(v, culture, segment);
|
||||
},
|
||||
property.SetValue(v, culture, segment);
|
||||
},
|
||||
variant.Culture);
|
||||
|
||||
variantIndex++;
|
||||
@@ -2172,7 +2172,10 @@ namespace Umbraco.Web.Editors
|
||||
/// <returns></returns>
|
||||
private ContentItemDisplay MapToDisplay(IContent content)
|
||||
{
|
||||
var display = Mapper.Map<ContentItemDisplay>(content);
|
||||
var display = Mapper.Map<ContentItemDisplay>(content, context =>
|
||||
{
|
||||
context.Items["CurrentUser"] = Security.CurrentUser;
|
||||
});
|
||||
display.AllowPreview = display.AllowPreview && content.Trashed == false && content.ContentType.IsElement == false;
|
||||
return display;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Mapping;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Routing;
|
||||
@@ -80,7 +81,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
target.Icon = source.ContentType.Icon;
|
||||
target.Id = source.Id;
|
||||
target.IsBlueprint = source.Blueprint;
|
||||
target.IsChildOfListView = DermineIsChildOfListView(source);
|
||||
target.IsChildOfListView = DetermineIsChildOfListView(source, context);
|
||||
target.IsContainer = source.ContentType.IsContainer;
|
||||
target.IsElement = source.ContentType.IsElement;
|
||||
target.Key = source.Key;
|
||||
@@ -211,8 +212,33 @@ namespace Umbraco.Web.Models.Mapping
|
||||
return source.CultureInfos.TryGetValue(culture, out var name) && !name.Name.IsNullOrWhiteSpace() ? name.Name : $"({source.Name})";
|
||||
}
|
||||
|
||||
private bool DermineIsChildOfListView(IContent source)
|
||||
/// <summary>
|
||||
/// Checks if the content item is a descendant of a list view
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="context"></param>
|
||||
/// <returns>
|
||||
/// Returns true if the content item is a descendant of a list view and where the content is
|
||||
/// not a current user's start node.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// We must check if it's the current user's start node because in that case we will actually be
|
||||
/// rendering the tree node underneath the list view to visually show context. In this case we return
|
||||
/// false because the item is technically not being rendered as part of a list view but instead as a
|
||||
/// real tree node. If we didn't perform this check then tree syncing wouldn't work correctly.
|
||||
/// </remarks>
|
||||
private bool DetermineIsChildOfListView(IContent source, MapperContext context)
|
||||
{
|
||||
// In cases where a user's start node is below a list view, we will actually render
|
||||
// out the tree to that start node and in that case for that start node, we want to return
|
||||
// false here.
|
||||
if (context.HasItems && context.Items.TryGetValue("CurrentUser", out var usr) && usr is IUser currentUser)
|
||||
{
|
||||
if (currentUser.StartContentIds.Contains(source.Id))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// map the IsChildOfListView (this is actually if it is a descendant of a list view!)
|
||||
var parent = _contentService.GetParent(source);
|
||||
return parent != null && (parent.ContentType.IsContainer || _contentTypeService.HasContainerInPath(parent.Path));
|
||||
|
||||
Reference in New Issue
Block a user