Refactor editing
This commit is contained in:
@@ -35,7 +35,7 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
/// Used internally during model mapping
|
||||
/// </summary>
|
||||
[IgnoreDataMember]
|
||||
internal PropertyEditor PropertyEditor { get; set; }
|
||||
internal IConfiguredDataEditor PropertyEditor { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
/// Gets or sets the property editor.
|
||||
/// </summary>
|
||||
[IgnoreDataMember]
|
||||
internal PropertyEditor PropertyEditor { get; set; }
|
||||
internal ConfiguredDataEditor PropertyEditor { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
// 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;
|
||||
var ve = (DataValueEditor) valEditor;
|
||||
ve.Configuration = config;
|
||||
|
||||
//set the display properties after mapping
|
||||
|
||||
@@ -36,10 +36,16 @@ namespace Umbraco.Web.Models.Mapping
|
||||
/// </summary>
|
||||
public IEnumerable<DataTypeConfigurationFieldDisplay> Resolve(IDataType dataType)
|
||||
{
|
||||
PropertyEditor editor = null;
|
||||
if (!string.IsNullOrWhiteSpace(dataType.EditorAlias) && !Current.PropertyEditors.TryGet(dataType.EditorAlias, out editor))
|
||||
throw new InvalidOperationException($"Could not find a property editor with alias \"{dataType.EditorAlias}\".");
|
||||
|
||||
ConfiguredDataEditor editor = null;
|
||||
if (!string.IsNullOrWhiteSpace(dataType.EditorAlias))
|
||||
{
|
||||
if (!Current.PropertyEditors.TryGet(dataType.EditorAlias, out var e1))
|
||||
throw new InvalidOperationException($"Could not find a property editor with alias \"{dataType.EditorAlias}\".");
|
||||
if (!(e1 is ConfiguredDataEditor e2))
|
||||
throw new InvalidOperationException($"Property editor with alias \"{dataType.EditorAlias}\" is not configurable.");
|
||||
editor = e2;
|
||||
}
|
||||
|
||||
var configuration = dataType.Configuration;
|
||||
Dictionary<string, object> configurationDictionary = null;
|
||||
var fields = Array.Empty<DataTypeConfigurationFieldDisplay>();
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
var configurationDisplayResolver = new DataTypeConfigurationFieldDisplayResolver();
|
||||
var databaseTypeResolver = new DatabaseTypeResolver();
|
||||
|
||||
CreateMap<PropertyEditor, PropertyEditorBasic>();
|
||||
CreateMap<ConfiguredDataEditor, PropertyEditorBasic>();
|
||||
|
||||
// map the standard properties, not the values
|
||||
CreateMap<ConfigurationField, DataTypeConfigurationFieldDisplay>()
|
||||
@@ -36,7 +36,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
Constants.DataTypes.DefaultMembersListView
|
||||
};
|
||||
|
||||
CreateMap<PropertyEditor, DataTypeBasic>()
|
||||
CreateMap<ConfiguredDataEditor, DataTypeBasic>()
|
||||
.ForMember(dest => dest.Udi, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.HasPrevalues, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.IsSystemDataType, opt => opt.Ignore())
|
||||
@@ -105,7 +105,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(dest => dest.Editor, opt => opt.MapFrom(src => propertyEditors[src.EditorAlias]));
|
||||
|
||||
//Converts a property editor to a new list of pre-value fields - used when creating a new data type or changing a data type with new pre-vals
|
||||
CreateMap<PropertyEditor, IEnumerable<DataTypeConfigurationFieldDisplay>>()
|
||||
CreateMap<ConfiguredDataEditor, IEnumerable<DataTypeConfigurationFieldDisplay>>()
|
||||
.ConvertUsing(src =>
|
||||
{
|
||||
// this is a new data type, initialize default configuration
|
||||
|
||||
Reference in New Issue
Block a user