Merge branch temp8 into temp8-11502

This commit is contained in:
Stephan
2018-10-03 15:08:12 +02:00
155 changed files with 7853 additions and 3879 deletions

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace Umbraco.Web.Models.ContentEditing
{
/// <summary>
/// Used to unpublish content and variants
/// </summary>
[DataContract(Name = "unpublish", Namespace = "")]
public class UnpublishContent
{
[DataMember(Name = "id")]
public int Id { get; set; }
[DataMember(Name = "cultures")]
public string[] Cultures { get; set; }
}
}

View File

@@ -33,6 +33,7 @@ namespace Umbraco.Web.Models.Mapping
{
PublishedState publishedState;
bool isEdited;
bool isCreated;
if (source.ContentType.VariesByCulture())
{
@@ -50,6 +51,7 @@ namespace Umbraco.Web.Models.Mapping
: PublishedState.Unpublished;
isEdited = source.IsCultureEdited(culture);
isCreated = source.Id > 0 && source.IsCultureAvailable(culture);
}
else
{
@@ -58,10 +60,14 @@ namespace Umbraco.Web.Models.Mapping
: PublishedState.Published;
isEdited = source.Edited;
isCreated = source.Id > 0;
}
if (!isCreated)
return ContentSavedState.NotCreated;
if (publishedState == PublishedState.Unpublished)
return isEdited && source.Id > 0 ? ContentSavedState.Draft : ContentSavedState.NotCreated;
return ContentSavedState.Draft;
if (publishedState == PublishedState.Published)
return isEdited ? ContentSavedState.PublishedPendingChanges : ContentSavedState.Published;

View File

@@ -11,10 +11,17 @@ namespace Umbraco.Web.Models.Mapping
{
internal class DataTypeConfigurationFieldDisplayResolver
{
private readonly ILogger _logger;
public DataTypeConfigurationFieldDisplayResolver(ILogger logger)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
/// <summary>
/// Maps pre-values in the dictionary to the values for the fields
/// </summary>
internal static void MapConfigurationFields(DataTypeConfigurationFieldDisplay[] fields, IDictionary<string, object> configuration)
internal static void MapConfigurationFields(ILogger logger, DataTypeConfigurationFieldDisplay[] fields, IDictionary<string, object> configuration)
{
if (fields == null) throw new ArgumentNullException(nameof(fields));
if (configuration == null) throw new ArgumentNullException(nameof(configuration));
@@ -24,8 +31,12 @@ namespace Umbraco.Web.Models.Mapping
{
if (configuration.TryGetValue(field.Key, out var value))
field.Value = value;
else // weird - just leave the field without a value - but warn
Current.Logger.Warn<DataTypeConfigurationFieldDisplayResolver>("Could not find a value for configuration field '{ConfigField}'", field.Key);
else
{
// weird - just leave the field without a value - but warn
logger.Warn<DataTypeConfigurationFieldDisplayResolver>("Could not find a value for configuration field '{ConfigField}'", field.Key);
}
}
}
@@ -45,7 +56,7 @@ namespace Umbraco.Web.Models.Mapping
var fields = configurationEditor.Fields.Select(Mapper.Map<DataTypeConfigurationFieldDisplay>).ToArray();
var configurationDictionary = configurationEditor.ToConfigurationEditor(dataType.Configuration);
MapConfigurationFields(fields, configurationDictionary);
MapConfigurationFields(_logger, fields, configurationDictionary);
return fields;
}

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using AutoMapper;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Configuration;
using Umbraco.Core.Models;
using Umbraco.Core.PropertyEditors;
@@ -16,11 +17,11 @@ namespace Umbraco.Web.Models.Mapping
/// </summary>
internal class DataTypeMapperProfile : Profile
{
public DataTypeMapperProfile(PropertyEditorCollection propertyEditors)
public DataTypeMapperProfile(PropertyEditorCollection propertyEditors, ILogger logger)
{
// create, capture, cache
var availablePropertyEditorsResolver = new AvailablePropertyEditorsResolver(UmbracoConfig.For.UmbracoSettings().Content);
var configurationDisplayResolver = new DataTypeConfigurationFieldDisplayResolver();
var configurationDisplayResolver = new DataTypeConfigurationFieldDisplayResolver(logger);
var databaseTypeResolver = new DatabaseTypeResolver();
CreateMap<IDataEditor, PropertyEditorBasic>();
@@ -119,7 +120,7 @@ namespace Umbraco.Web.Models.Mapping
var defaultConfiguration = configurationEditor.DefaultConfiguration;
if (defaultConfiguration != null)
DataTypeConfigurationFieldDisplayResolver.MapConfigurationFields(fields, defaultConfiguration);
DataTypeConfigurationFieldDisplayResolver.MapConfigurationFields(logger, fields, defaultConfiguration);
return fields;
});