Cleanup
This commit is contained in:
@@ -143,7 +143,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
where (string)doc.Attribute("isDoc") == ""
|
||||
select doc;
|
||||
|
||||
var contents = ParseDocumentRootXml(roots, parentId);
|
||||
var contents = ParseDocumentRootXml(roots, parentId).ToList();
|
||||
if (contents.Any())
|
||||
_contentService.Save(contents, userId);
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
//This is a single doc import
|
||||
var elements = new List<XElement> { element };
|
||||
var contents = ParseDocumentRootXml(elements, parentId);
|
||||
var contents = ParseDocumentRootXml(elements, parentId).ToList();
|
||||
if (contents.Any())
|
||||
_contentService.Save(contents, userId);
|
||||
|
||||
@@ -187,9 +187,10 @@ namespace Umbraco.Core.Services.Implement
|
||||
var content = CreateContentFromXml(root, _importedContentTypes[contentTypeAlias], null, parentId);
|
||||
contents.Add(content);
|
||||
|
||||
var children = from child in root.Elements()
|
||||
var children = (from child in root.Elements()
|
||||
where (string)child.Attribute("isDoc") == ""
|
||||
select child;
|
||||
select child)
|
||||
.ToList();
|
||||
if (children.Any())
|
||||
contents.AddRange(CreateContentFromXml(children, content));
|
||||
}
|
||||
@@ -215,9 +216,9 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
//Recursive call
|
||||
XElement child1 = child;
|
||||
var grandChildren = from grand in child1.Elements()
|
||||
where (string)grand.Attribute("isDoc") == ""
|
||||
select grand;
|
||||
var grandChildren = (from grand in child1.Elements()
|
||||
where (string) grand.Attribute("isDoc") == ""
|
||||
select grand).ToList();
|
||||
|
||||
if (grandChildren.Any())
|
||||
list.AddRange(CreateContentFromXml(grandChildren, content));
|
||||
@@ -907,7 +908,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
if (!_propertyEditors.TryGet(editorAlias, out var editor))
|
||||
editor = new VoidEditor(_logger) { Alias = editorAlias };
|
||||
|
||||
var dataTypeDefinition = new DataType(editor)
|
||||
var dataType = new DataType(editor)
|
||||
{
|
||||
Key = dataTypeDefinitionId,
|
||||
Name = dataTypeDefinitionName,
|
||||
@@ -915,14 +916,11 @@ namespace Umbraco.Core.Services.Implement
|
||||
ParentId = parentId
|
||||
};
|
||||
|
||||
// fixme - so what?
|
||||
var configurationAttribute = dataTypeElement.Attribute("Configuration");
|
||||
if (!string.IsNullOrWhiteSpace(configurationAttribute?.Value))
|
||||
{
|
||||
dataTypeDefinition.Configuration = editor.ConfigurationEditor.FromDatabase(configurationAttribute.Value);
|
||||
}
|
||||
var configurationAttributeValue = dataTypeElement.Attribute("Configuration")?.Value;
|
||||
if (!string.IsNullOrWhiteSpace(configurationAttributeValue))
|
||||
dataType.Configuration = editor.ConfigurationEditor.FromDatabase(configurationAttributeValue);
|
||||
|
||||
dataTypes.Add(dataTypeDefinition);
|
||||
dataTypes.Add(dataType);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -33,7 +33,12 @@ namespace Umbraco.Web.Editors
|
||||
[EnableOverrideAuthorization]
|
||||
public class DataTypeController : BackOfficeNotificationsController
|
||||
{
|
||||
private PropertyEditorCollection PropertyEditors => Current.PropertyEditors; // fixme inject
|
||||
private readonly PropertyEditorCollection _propertyEditors;
|
||||
|
||||
public DataTypeController(PropertyEditorCollection propertyEditors)
|
||||
{
|
||||
_propertyEditors = propertyEditors;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets data type by name
|
||||
@@ -84,7 +89,7 @@ namespace Umbraco.Web.Editors
|
||||
public DataTypeDisplay GetEmpty(int parentId)
|
||||
{
|
||||
// cannot create an "empty" data type, so use something by default.
|
||||
var editor = PropertyEditors[Constants.PropertyEditors.Aliases.NoEdit];
|
||||
var editor = _propertyEditors[Constants.PropertyEditors.Aliases.NoEdit];
|
||||
var dt = new DataType(editor, parentId);
|
||||
return Mapper.Map<IDataType, DataTypeDisplay>(dt);
|
||||
}
|
||||
@@ -117,7 +122,7 @@ namespace Umbraco.Web.Editors
|
||||
//if it doesnt exist yet, we will create it.
|
||||
if (dt == null)
|
||||
{
|
||||
var editor = PropertyEditors[Constants.PropertyEditors.Aliases.ListView];
|
||||
var editor = _propertyEditors[Constants.PropertyEditors.Aliases.ListView];
|
||||
dt = new DataType(editor);
|
||||
dt.Name = Constants.Conventions.DataTypes.ListViewPrefix + contentTypeAlias;
|
||||
Services.DataTypeService.Save(dt);
|
||||
|
||||
@@ -16,9 +16,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
/// </summary>
|
||||
internal class DataTypeMapperProfile : Profile
|
||||
{
|
||||
private PropertyEditorCollection PropertyEditors => Current.PropertyEditors; // fixme inject
|
||||
|
||||
public DataTypeMapperProfile()
|
||||
public DataTypeMapperProfile(PropertyEditorCollection propertyEditors)
|
||||
{
|
||||
// create, capture, cache
|
||||
var availablePropertyEditorsResolver = new AvailablePropertyEditorsResolver(UmbracoConfig.For.UmbracoSettings().Content);
|
||||
@@ -93,7 +91,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ConvertUsing(src => configurationDisplayResolver.Resolve(src));
|
||||
|
||||
CreateMap<DataTypeSave, IDataType>()
|
||||
.ConstructUsing(src => new DataType(PropertyEditors[src.EditorAlias]) {CreateDate = DateTime.Now})
|
||||
.ConstructUsing(src => new DataType(propertyEditors[src.EditorAlias]) {CreateDate = DateTime.Now})
|
||||
.IgnoreEntityCommonProperties()
|
||||
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => Convert.ToInt32(src.Id)))
|
||||
.ForMember(dest => dest.Key, opt => opt.Ignore()) // ignore key, else resets UniqueId - U4-3911
|
||||
@@ -104,7 +102,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(dest => dest.Level, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.SortOrder, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Configuration, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Editor, opt => opt.MapFrom(src => PropertyEditors[src.EditorAlias]));
|
||||
.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>>()
|
||||
|
||||
Reference in New Issue
Block a user