Cleanup editing
This commit is contained in:
@@ -4,6 +4,7 @@ using AutoMapper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
|
||||
@@ -27,7 +28,13 @@ namespace Umbraco.Web.Models.Mapping
|
||||
|
||||
//configure the editor for display with the pre-values
|
||||
var valEditor = display.PropertyEditor.ValueEditor;
|
||||
valEditor.Configuration = config;
|
||||
// fixme - the value editor REQUIRES the configuration to operate
|
||||
// at the moment, only for richtext and nested, where it's used to set HideLabel
|
||||
// but, this is the ONLY place where it's assigned? it is also the only place where
|
||||
// .HideLabel is used - and basically all the rest kinda never depends on config,
|
||||
// but... it should?
|
||||
var ve = (ValueEditor) valEditor;
|
||||
ve.Configuration = config;
|
||||
|
||||
//set the display properties after mapping
|
||||
display.Alias = originalProp.Alias;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
/// <summary>
|
||||
/// Maps pre-values in the dictionary to the values for the fields
|
||||
/// </summary>
|
||||
internal static void MapPreValueValuesToPreValueFields(DataTypeConfigurationFieldDisplay[] fields, IDictionary<string, object> configuration)
|
||||
internal static void MapConfigurationFields(DataTypeConfigurationFieldDisplay[] fields, IDictionary<string, object> configuration)
|
||||
{
|
||||
if (fields == null) throw new ArgumentNullException(nameof(fields));
|
||||
if (configuration == null) throw new ArgumentNullException(nameof(configuration));
|
||||
@@ -49,14 +49,15 @@ namespace Umbraco.Web.Models.Mapping
|
||||
// and convert configuration to editor
|
||||
if (editor != null)
|
||||
{
|
||||
fields = editor.ConfigurationEditor.Fields.Select(Mapper.Map<DataTypeConfigurationFieldDisplay>).ToArray();
|
||||
configurationDictionary = editor.ConfigurationEditor.ToConfigurationEditor(configuration);
|
||||
var configurationEditor = editor.ConfigurationEditor;
|
||||
fields = configurationEditor.Fields.Select(Mapper.Map<DataTypeConfigurationFieldDisplay>).ToArray();
|
||||
configurationDictionary = configurationEditor.ToConfigurationEditor(configuration);
|
||||
}
|
||||
|
||||
if (configurationDictionary == null)
|
||||
configurationDictionary = new Dictionary<string, object>();
|
||||
|
||||
MapPreValueValuesToPreValueFields(fields, configurationDictionary);
|
||||
MapConfigurationFields(fields, configurationDictionary);
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
@@ -108,12 +108,18 @@ namespace Umbraco.Web.Models.Mapping
|
||||
CreateMap<PropertyEditor, IEnumerable<DataTypeConfigurationFieldDisplay>>()
|
||||
.ConvertUsing(src =>
|
||||
{
|
||||
// this is a new data type, so just return the field editors, with default values - there are no values yet
|
||||
var fields = src.ConfigurationEditor.Fields.Select(Mapper.Map<DataTypeConfigurationFieldDisplay>).ToArray();
|
||||
// this is a new data type, initialize default configuration
|
||||
// get the configuration editor,
|
||||
// get the configuration fields and map to UI,
|
||||
// get the configuration default values and map to UI
|
||||
|
||||
var defaultConfiguration = src.DefaultConfiguration;
|
||||
var configurationEditor = src.ConfigurationEditor;
|
||||
|
||||
var fields = configurationEditor.Fields.Select(Mapper.Map<DataTypeConfigurationFieldDisplay>).ToArray();
|
||||
|
||||
var defaultConfiguration = configurationEditor.DefaultConfiguration;
|
||||
if (defaultConfiguration != null)
|
||||
DataTypeConfigurationFieldDisplayResolver.MapPreValueValuesToPreValueFields(fields, defaultConfiguration);
|
||||
DataTypeConfigurationFieldDisplayResolver.MapConfigurationFields(fields, defaultConfiguration);
|
||||
|
||||
return fields;
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
|
||||
@@ -17,7 +18,9 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
throw new InvalidOperationException("Could not find property editor with id " + source.EditorAlias);
|
||||
}
|
||||
return propertyEditor.ValueEditor.GetDatabaseType();
|
||||
|
||||
var valueType = propertyEditor.ValueEditor.ValueType;
|
||||
return ValueTypes.ToStorageType(valueType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user