Updates doc type editor to be able to change update the doc type to support being culture variant
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
var saveModel = _.pick(displayModel,
|
||||
'compositeContentTypes', 'isContainer', 'allowAsRoot', 'allowedTemplates', 'allowedContentTypes',
|
||||
'alias', 'description', 'thumbnail', 'name', 'id', 'icon', 'trashed',
|
||||
'key', 'parentId', 'alias', 'path');
|
||||
'key', 'parentId', 'alias', 'path', 'allowCultureVariant');
|
||||
|
||||
//TODO: Map these
|
||||
saveModel.allowedTemplates = _.map(displayModel.allowedTemplates, function (t) { return t.alias; });
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<small><localize key="contentTypeEditor_allowAsRootDescription" /></small>
|
||||
</div>
|
||||
<div class="sub-view-column-right">
|
||||
<label class="checkbox no-indent" >
|
||||
<label class="checkbox no-indent">
|
||||
<input type="checkbox" ng-model="model.allowAsRoot" hotkey="alt+shift+r" />
|
||||
<localize key="contentTypeEditor_allowAsRootCheckbox" />
|
||||
</label>
|
||||
@@ -23,25 +23,38 @@
|
||||
</div>
|
||||
|
||||
<div class="sub-view-column-right">
|
||||
<umb-child-selector
|
||||
selected-children="vm.selectedChildren"
|
||||
available-children="vm.contentTypes"
|
||||
parent-name="model.name"
|
||||
parent-icon="model.icon"
|
||||
parent-id="model.id"
|
||||
on-add="vm.addChild"
|
||||
on-remove="vm.removeChild">
|
||||
<umb-child-selector selected-children="vm.selectedChildren"
|
||||
available-children="vm.contentTypes"
|
||||
parent-name="model.name"
|
||||
parent-icon="model.icon"
|
||||
parent-id="model.id"
|
||||
on-add="vm.addChild"
|
||||
on-remove="vm.removeChild">
|
||||
</umb-child-selector>
|
||||
|
||||
<umb-overlay
|
||||
ng-if="vm.childNodeSelectorOverlay.show"
|
||||
model="vm.childNodeSelectorOverlay"
|
||||
position="target"
|
||||
view="vm.childNodeSelectorOverlay.view">
|
||||
<umb-overlay ng-if="vm.childNodeSelectorOverlay.show"
|
||||
model="vm.childNodeSelectorOverlay"
|
||||
position="target"
|
||||
view="vm.childNodeSelectorOverlay.view">
|
||||
</umb-overlay>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="sub-view-columns">
|
||||
|
||||
<div class="sub-view-column-left">
|
||||
<h5>Content Type Variation</h5>
|
||||
<small>Define the rules for how this content type's properties can be varied</small>
|
||||
</div>
|
||||
<div class="sub-view-column-right">
|
||||
<label class="checkbox no-indent">
|
||||
<input type="checkbox" ng-model="model.allowCultureVariant" />
|
||||
Allow varying by Culture
|
||||
</label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -57,6 +57,15 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
Groups = new List<PropertyGroupBasic<TPropertyType>>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A rule for defining how a content type can be varied
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is only supported on document types right now but in the future it could be media types too
|
||||
/// </remarks>
|
||||
[DataMember(Name = "allowCultureVariant")]
|
||||
public bool AllowCultureVariant { get; set; }
|
||||
|
||||
//Tabs
|
||||
[DataMember(Name = "groups")]
|
||||
public IEnumerable<PropertyGroupBasic<TPropertyType>> Groups { get; set; }
|
||||
|
||||
@@ -20,6 +20,9 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
|
||||
[DataMember(Name = "defaultTemplate")]
|
||||
public EntityBasic DefaultTemplate { get; set; }
|
||||
|
||||
[DataMember(Name = "allowCultureVariant")]
|
||||
public bool AllowCultureVariant { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
/// <returns></returns>
|
||||
public override IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (AllowedTemplates.Any(x => StringExtensions.IsNullOrWhiteSpace(x)))
|
||||
if (AllowedTemplates.Any(x => x.IsNullOrWhiteSpace()))
|
||||
yield return new ValidationResult("Template value cannot be null", new[] { "AllowedTemplates" });
|
||||
|
||||
foreach (var v in base.Validate(validationContext))
|
||||
|
||||
@@ -10,11 +10,11 @@ using Language = Umbraco.Web.Models.ContentEditing.Language;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
internal class VariationResolver : IValueResolver<IContent, ContentItemDisplay, IEnumerable<ContentVariation>>
|
||||
internal class ContentItemDisplayVariationResolver : IValueResolver<IContent, ContentItemDisplay, IEnumerable<ContentVariation>>
|
||||
{
|
||||
private readonly ILocalizationService _localizationService;
|
||||
|
||||
public VariationResolver(ILocalizationService localizationService)
|
||||
public ContentItemDisplayVariationResolver(ILocalizationService localizationService)
|
||||
{
|
||||
_localizationService = localizationService ?? throw new ArgumentNullException(nameof(localizationService));
|
||||
}
|
||||
@@ -25,7 +25,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
var contentTreeNodeUrlResolver = new ContentTreeNodeUrlResolver<IContent, ContentTreeController>();
|
||||
var defaultTemplateResolver = new DefaultTemplateResolver();
|
||||
var contentUrlResolver = new ContentUrlResolver();
|
||||
var variantResolver = new VariationResolver(localizationService);
|
||||
var variantResolver = new ContentItemDisplayVariationResolver(localizationService);
|
||||
|
||||
//FROM IContent TO ContentItemDisplay
|
||||
CreateMap<IContent, ContentItemDisplay>()
|
||||
|
||||
@@ -6,6 +6,7 @@ using Umbraco.Core.Models;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Core.Services;
|
||||
using ContentVariation = Umbraco.Core.Models.ContentVariation;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
@@ -26,7 +27,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
dest.AllowedTemplates = source.AllowedTemplates
|
||||
.Where(x => x != null)
|
||||
.Select(s => fileService.GetTemplate(s))
|
||||
.Select(fileService.GetTemplate)
|
||||
.ToArray();
|
||||
|
||||
if (source.DefaultTemplate != null)
|
||||
@@ -111,6 +112,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(dto => dto.AllowedTemplates, opt => opt.Ignore())
|
||||
.ForMember(dto => dto.DefaultTemplate, opt => opt.Ignore())
|
||||
.ForMember(display => display.Notifications, opt => opt.Ignore())
|
||||
.ForMember(display => display.AllowCultureVariant, opt => opt.MapFrom(type => type.Variations.HasFlag(ContentVariation.CultureNeutral)))
|
||||
.AfterMap((source, dest) =>
|
||||
{
|
||||
//sync templates
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
// ignore, composition is managed in AfterMapContentTypeSaveToEntity
|
||||
.ForMember(dest => dest.ContentTypeComposition, opt => opt.Ignore())
|
||||
|
||||
.ForMember(dto => dto.Variations, opt => opt.Ignore()) // fixme - change when UI supports it!
|
||||
.ForMember(dto => dto.Variations, opt => opt.ResolveUsing<ContentTypeVariationsResolver<TSource, TSourcePropertyType, TDestination>>())
|
||||
|
||||
.ForMember(
|
||||
dest => dest.AllowedContentTypes,
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using AutoMapper;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using ContentVariation = Umbraco.Core.Models.ContentVariation;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
internal class ContentTypeVariationsResolver<TSource, TSourcePropertyType, TDestination> : IValueResolver<TSource, TDestination, ContentVariation>
|
||||
where TSource : ContentTypeSave<TSourcePropertyType>
|
||||
where TDestination : IContentTypeComposition
|
||||
where TSourcePropertyType : PropertyTypeBasic
|
||||
{
|
||||
public ContentVariation Resolve(TSource source, TDestination 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -238,6 +238,7 @@
|
||||
<Compile Include="Models\ContentEditing\Language.cs" />
|
||||
<Compile Include="Models\Mapping\ActionButtonsResolver.cs" />
|
||||
<Compile Include="Models\Mapping\AuditMapperProfile.cs" />
|
||||
<Compile Include="Models\Mapping\ContentTypeVariationsResolver.cs" />
|
||||
<Compile Include="Models\Mapping\ContextMapper.cs" />
|
||||
<Compile Include="Models\Mapping\ContentChildOfListViewResolver.cs" />
|
||||
<Compile Include="Models\Mapping\ContentUrlResolver.cs" />
|
||||
@@ -259,7 +260,7 @@
|
||||
<Compile Include="Models\Mapping\RedirectUrlMapperProfile.cs" />
|
||||
<Compile Include="Models\Mapping\TemplateMapperProfile.cs" />
|
||||
<Compile Include="Models\Mapping\UserGroupDefaultPermissionsResolver.cs" />
|
||||
<Compile Include="Models\Mapping\VariationResolver.cs" />
|
||||
<Compile Include="Models\Mapping\ContentItemDisplayVariationResolver.cs" />
|
||||
<Compile Include="Models\RelatedLink.cs" />
|
||||
<Compile Include="Models\RelatedLinkBase.cs" />
|
||||
<Compile Include="Models\RelatedLinks.cs" />
|
||||
|
||||
Reference in New Issue
Block a user