Merge pull request #2944 from umbraco/temp8-18-ListViewVariants

List View - Updates Node Name based on selected Variant
This commit is contained in:
Shannon Deminick
2018-09-10 18:31:18 +10:00
committed by GitHub
4 changed files with 84 additions and 64 deletions

View File

@@ -456,7 +456,8 @@ namespace Umbraco.Web.Editors
string orderBy = "SortOrder",
Direction orderDirection = Direction.Ascending,
bool orderBySystemField = true,
string filter = "")
string filter = "",
string cultureName = "")
{
long totalChildren;
IContent[] children;
@@ -493,13 +494,16 @@ namespace Umbraco.Web.Editors
Mapper.Map<IContent, ContentItemBasic<ContentPropertyBasic>>(content,
opts =>
{
opts.Items[ResolutionContextExtensions.CultureKey] = cultureName;
// if there's a list of property aliases to map - we will make sure to store this in the mapping context.
if (String.IsNullOrWhiteSpace(includeProperties) == false)
if (string.IsNullOrWhiteSpace(includeProperties) == false)
{
opts.Items["IncludeProperties"] = includeProperties.Split(new[] { ", ", "," }, StringSplitOptions.RemoveEmptyEntries);
}
}));
return pagedResult;
}

View File

@@ -79,11 +79,20 @@ namespace Umbraco.Web.Models.Mapping
.ForMember(dest => dest.Trashed, opt => opt.MapFrom(src => src.Trashed))
.ForMember(dest => dest.ContentTypeAlias, opt => opt.MapFrom(src => src.ContentType.Alias))
.ForMember(dest => dest.Alias, opt => opt.Ignore())
.ForMember(dest => dest.AdditionalData, opt => opt.Ignore());
.ForMember(dest => dest.AdditionalData, opt => opt.Ignore())
.ForMember(dest => dest.Name, opt => opt.ResolveUsing<CultureNameResolver>());
//FROM IContent TO ContentPropertyCollectionDto
//NOTE: the property mapping for cultures relies on a culture being set in the mapping context
CreateMap<IContent, ContentPropertyCollectionDto>();
}
}
internal class CultureNameResolver : IValueResolver<IContent, ContentItemBasic<ContentPropertyBasic>, string>
{
public string Resolve(IContent source, ContentItemBasic<ContentPropertyBasic> destination, string destMember, ResolutionContext context)
{
return source.GetCultureName(context.GetCulture());
}
}
}