More manual merging
This commit is contained in:
@@ -16,15 +16,17 @@ namespace Umbraco.Web.Models.Mapping
|
||||
internal class ContentPropertyBasicMapper<TDestination>
|
||||
where TDestination : ContentPropertyBasic, new()
|
||||
{
|
||||
private readonly IEntityService _entityService;
|
||||
private readonly ILogger _logger;
|
||||
private readonly PropertyEditorCollection _propertyEditors;
|
||||
protected IDataTypeService DataTypeService { get; }
|
||||
|
||||
public ContentPropertyBasicMapper(IDataTypeService dataTypeService, ILogger logger, PropertyEditorCollection propertyEditors)
|
||||
public ContentPropertyBasicMapper(IDataTypeService dataTypeService, IEntityService entityService, ILogger logger, PropertyEditorCollection propertyEditors)
|
||||
{
|
||||
_logger = logger;
|
||||
_propertyEditors = propertyEditors;
|
||||
DataTypeService = dataTypeService;
|
||||
_entityService = entityService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -49,6 +51,11 @@ namespace Umbraco.Web.Models.Mapping
|
||||
dest.PropertyEditor = editor;
|
||||
dest.Editor = editor.Alias;
|
||||
|
||||
var dataTypeKey = _entityService.GetKey(property.PropertyType.DataTypeId, UmbracoObjectTypes.DataType);
|
||||
if (!dataTypeKey.Success)
|
||||
throw new InvalidOperationException("Can't get the unique key from the id: " + property.PropertyType.DataTypeId);
|
||||
dest.DataTypeId = dataTypeKey.Result;
|
||||
|
||||
// if there's a set of property aliases specified, we will check if the current property's value should be mapped.
|
||||
// if it isn't one of the ones specified in 'includeProperties', we will just return the result without mapping the Value.
|
||||
var includedProperties = context.GetIncludedProperties();
|
||||
|
||||
@@ -146,19 +146,26 @@ namespace Umbraco.Web.Models.Mapping
|
||||
var fields = context.MapEnumerable<ConfigurationField,DataTypeConfigurationFieldDisplay>(configurationEditor.Fields);
|
||||
var configurationDictionary = configurationEditor.ToConfigurationEditor(dataType.Configuration);
|
||||
|
||||
MapConfigurationFields(fields, configurationDictionary);
|
||||
MapConfigurationFields(dataType, fields, configurationDictionary);
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
private void MapConfigurationFields(List<DataTypeConfigurationFieldDisplay> fields, IDictionary<string, object> configuration)
|
||||
|
||||
private void MapConfigurationFields(IDataType dataType, List<DataTypeConfigurationFieldDisplay> fields, IDictionary<string, object> configuration)
|
||||
{
|
||||
if (fields == null) throw new ArgumentNullException(nameof(fields));
|
||||
if (configuration == null) throw new ArgumentNullException(nameof(configuration));
|
||||
|
||||
// now we need to wire up the pre-values values with the actual fields defined
|
||||
foreach (var field in fields)
|
||||
foreach (var field in fields.ToList())
|
||||
{
|
||||
//filter out the not-supported pre-values for built-in data types
|
||||
if (dataType != null && dataType.IsBuildInDataType() && field.Key.InvariantEquals(Constants.DataTypes.ReservedPreValueKeys.IgnoreUserStartNodes))
|
||||
{
|
||||
fields.Remove(field);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (configuration.TryGetValue(field.Key, out var value))
|
||||
{
|
||||
field.Value = value;
|
||||
@@ -194,7 +201,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
|
||||
var defaultConfiguration = configurationEditor.DefaultConfiguration;
|
||||
if (defaultConfiguration != null)
|
||||
MapConfigurationFields(fields, defaultConfiguration);
|
||||
MapConfigurationFields(null, fields, defaultConfiguration);
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user