Updates UI and mapping to update a property type to allow being culture variant

This commit is contained in:
Shannon
2018-04-24 15:27:33 +10:00
parent de2784c281
commit d552d5dadb
9 changed files with 150 additions and 106 deletions

View File

@@ -46,5 +46,8 @@ namespace Umbraco.Web.Models.ContentEditing
//SD: Is this really needed ?
[DataMember(Name = "groupId")]
public int GroupId { get; set; }
[DataMember(Name = "allowCultureVariant")]
public bool AllowCultureVariant { get; set; }
}
}

View File

@@ -163,7 +163,7 @@ namespace Umbraco.Web.Models.Mapping
.ForMember(dest => dest.PropertyEditorAlias, opt => opt.Ignore())
.ForMember(dest => dest.DeleteDate, opt => opt.Ignore())
.ForMember(dto => dto.Variations, opt => opt.Ignore()) // fixme - change when UI supports it!
.ForMember(dto => dto.Variations, opt => opt.ResolveUsing<PropertyTypeVariationsResolver>())
//only map if it is actually set
.ForMember(dest => dest.Id, opt => opt.Condition(source => source.Id > 0))

View File

@@ -220,7 +220,8 @@ namespace Umbraco.Web.Models.Mapping
DataTypeId = p.DataTypeId,
SortOrder = p.SortOrder,
ContentTypeId = contentType.Id,
ContentTypeName = contentType.Name
ContentTypeName = contentType.Name,
AllowCultureVariant = p.Variations.HasFlag(Core.Models.ContentVariation.CultureNeutral)
});
}

View File

@@ -0,0 +1,23 @@
using AutoMapper;
using Umbraco.Core.Models;
using Umbraco.Web.Models.ContentEditing;
using ContentVariation = Umbraco.Core.Models.ContentVariation;
namespace Umbraco.Web.Models.Mapping
{
internal class PropertyTypeVariationsResolver: IValueResolver<PropertyTypeBasic, PropertyType, ContentVariation>
{
public ContentVariation Resolve(PropertyTypeBasic source, PropertyType destination, ContentVariation destMember, ResolutionContext context)
{
//this will always be the case, a content type will always be allowed to be invariant
var result = ContentVariation.InvariantNeutral;
if (source.AllowCultureVariant)
{
result |= ContentVariation.CultureNeutral;
}
return result;
}
}
}