This commit is contained in:
committed by
Sebastiaan Janssen
parent
30b5dd4d04
commit
ecfc8d819f
@@ -34,11 +34,7 @@ namespace Umbraco.Core
|
||||
/// </summary>
|
||||
public const string ContentPicker = "Umbraco.ContentPicker";
|
||||
|
||||
/// <summary>
|
||||
/// Date.
|
||||
/// </summary>
|
||||
public const string Date = "Umbraco.Date";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// DateTime.
|
||||
/// </summary>
|
||||
|
||||
@@ -281,7 +281,7 @@ namespace Umbraco.Core.Migrations.Install
|
||||
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -37, EditorAlias = Constants.PropertyEditors.Aliases.ColorPicker, DbType = "Nvarchar" });
|
||||
InsertDataTypeDto(Constants.DataTypes.DropDownSingle, Constants.PropertyEditors.Aliases.DropDownListFlexible, "Nvarchar", "{\"multiple\":false}");
|
||||
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -40, EditorAlias = Constants.PropertyEditors.Aliases.RadioButtonList, DbType = "Nvarchar" });
|
||||
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -41, EditorAlias = Constants.PropertyEditors.Aliases.Date, DbType = "Date" });
|
||||
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -41, EditorAlias = "Umbraco.Date", DbType = "Date" });
|
||||
InsertDataTypeDto(Constants.DataTypes.DropDownMultiple, Constants.PropertyEditors.Aliases.DropDownListFlexible, "Nvarchar", "{\"multiple\":true}");
|
||||
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -43, EditorAlias = Constants.PropertyEditors.Aliases.CheckBoxList, DbType = "Nvarchar" });
|
||||
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1041, EditorAlias = Constants.PropertyEditors.Aliases.Tags, DbType = "Ntext",
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace Umbraco.Core.Migrations.Upgrade
|
||||
.As("{0576E786-5C30-4000-B969-302B61E90CA3}");
|
||||
|
||||
To<RenameLabelAndRichTextPropertyEditorAliases>("{E0CBE54D-A84F-4A8F-9B13-900945FD7ED9}");
|
||||
|
||||
To<MergeDateAndDateTimePropertyEditor>("{78BAF571-90D0-4D28-8175-EF96316DA789}");
|
||||
//FINAL
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
{
|
||||
public class MergeDateAndDateTimePropertyEditor : MigrationBase
|
||||
{
|
||||
public MergeDateAndDateTimePropertyEditor(IMigrationContext context)
|
||||
: base(context)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
{
|
||||
var dataTypes = GetDataTypes("Umbraco.Date");
|
||||
|
||||
foreach (var dataType in dataTypes)
|
||||
{
|
||||
DateTimeConfiguration config;
|
||||
try
|
||||
{
|
||||
config = (DateTimeConfiguration) new CustomDateTimeConfigurationEditor().FromDatabase(
|
||||
dataType.Configuration);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error<DropDownPropertyEditorsMigration>(
|
||||
ex,
|
||||
"Invalid property editor configuration detected: \"{Configuration}\", cannot convert editor, values will be cleared",
|
||||
dataType.Configuration);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
config.OffsetTime = false;
|
||||
|
||||
dataType.EditorAlias = Constants.PropertyEditors.Aliases.DateTime;
|
||||
dataType.Configuration = ConfigurationEditor.ToDatabase(config);
|
||||
|
||||
Database.Update(dataType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private List<DataTypeDto> GetDataTypes(string editorAlias)
|
||||
{
|
||||
//need to convert the old drop down data types to use the new one
|
||||
var dataTypes = Database.Fetch<DataTypeDto>(Sql()
|
||||
.Select<DataTypeDto>()
|
||||
.From<DataTypeDto>()
|
||||
.Where<DataTypeDto>(x => x.EditorAlias == editorAlias));
|
||||
return dataTypes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private class CustomDateTimeConfigurationEditor : ConfigurationEditor<DateTimeConfiguration>
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Web.PropertyEditors
|
||||
namespace Umbraco.Core.PropertyEditors
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the configuration for the datetime value editor.
|
||||
/// </summary>
|
||||
public class DateTimeConfiguration : DateConfiguration
|
||||
public class DateTimeConfiguration
|
||||
{
|
||||
[ConfigurationField("format", "Date format", "textstring", Description = "If left empty then the format is YYYY-MM-DD. (see momentjs.com for supported formats)")]
|
||||
public string Format { get; set; }
|
||||
|
||||
public DateTimeConfiguration()
|
||||
{
|
||||
// different default values
|
||||
@@ -16,4 +17,4 @@ namespace Umbraco.Web.PropertyEditors
|
||||
[ConfigurationField("offsetTime", "Offset time", "boolean", Description = "When enabled the time displayed will be offset with the server's timezone, this is useful for scenarios like scheduled publishing when an editor is in a different timezone than the hosted server")]
|
||||
public bool OffsetTime { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,14 +8,8 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
|
||||
[DefaultPropertyValueConverter]
|
||||
public class DatePickerValueConverter : PropertyValueConverterBase
|
||||
{
|
||||
private static readonly string[] PropertyEditorAliases =
|
||||
{
|
||||
Constants.PropertyEditors.Aliases.DateTime,
|
||||
Constants.PropertyEditors.Aliases.Date
|
||||
};
|
||||
|
||||
public override bool IsConverter(PublishedPropertyType propertyType)
|
||||
=> PropertyEditorAliases.Contains(propertyType.EditorAlias);
|
||||
=> propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.DateTime);
|
||||
|
||||
public override Type GetPropertyValueType(PublishedPropertyType propertyType)
|
||||
=> typeof (DateTime);
|
||||
|
||||
@@ -205,6 +205,8 @@
|
||||
<Compile Include="Composing\TypeFinder.cs" />
|
||||
<Compile Include="Composing\TypeHelper.cs" />
|
||||
<Compile Include="Composing\TypeLoader.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_8_0_0\MergeDateAndDateTimePropertyEditor.cs" />
|
||||
<Compile Include="PropertyEditors\DateTimeConfiguration.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_8_0_0\RenameLabelAndRichTextPropertyEditorAliases.cs" />
|
||||
<Compile Include="TypeLoaderExtensions.cs" />
|
||||
<Compile Include="Composing\WeightAttribute.cs" />
|
||||
|
||||
@@ -278,7 +278,7 @@ AnotherContentFinder
|
||||
public void GetDataEditors()
|
||||
{
|
||||
var types = _typeLoader.GetDataEditors();
|
||||
Assert.AreEqual(39, types.Count());
|
||||
Assert.AreEqual(38, types.Count());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -879,7 +879,7 @@ namespace Umbraco.Tests.Services
|
||||
public void Get_By_Property_Int_Value_Less_Than()
|
||||
{
|
||||
IMemberType memberType = MockedContentTypes.CreateSimpleMemberType();
|
||||
memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Date, ValueStorageType.Date, "number")
|
||||
memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.DateTime, ValueStorageType.Date, "number")
|
||||
{
|
||||
Name = "Number",
|
||||
//NOTE: This is what really determines the db type - the above definition doesn't really do anything
|
||||
|
||||
@@ -364,7 +364,7 @@ namespace Umbraco.Tests.TestHelpers.Entities
|
||||
contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.ColorPicker, ValueStorageType.Nvarchar) { Alias = "colorPicker", Name = "Color Picker", Mandatory = false, SortOrder = 9, DataTypeId = -37 });
|
||||
contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.DropDownListFlexible, ValueStorageType.Nvarchar) { Alias = "ddlMultiple", Name = "Dropdown List Multiple", Mandatory = false, SortOrder = 11, DataTypeId = -39 });
|
||||
contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.RadioButtonList, ValueStorageType.Nvarchar) { Alias = "rbList", Name = "Radio Button List", Mandatory = false, SortOrder = 12, DataTypeId = -40 });
|
||||
contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Date, ValueStorageType.Date) { Alias = "date", Name = "Date", Mandatory = false, SortOrder = 13, DataTypeId = -41 });
|
||||
contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.DateTime, ValueStorageType.Date) { Alias = "date", Name = "Date", Mandatory = false, SortOrder = 13, DataTypeId = -36 });
|
||||
contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.DropDownListFlexible, ValueStorageType.Integer) { Alias = "ddl", Name = "Dropdown List", Mandatory = false, SortOrder = 14, DataTypeId = -42 });
|
||||
contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.CheckBoxList, ValueStorageType.Nvarchar) { Alias = "chklist", Name = "Checkbox List", Mandatory = false, SortOrder = 15, DataTypeId = -43 });
|
||||
contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.ContentPicker, ValueStorageType.Integer) { Alias = "contentPicker", Name = "Content Picker", Mandatory = false, SortOrder = 16, DataTypeId = 1046 });
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Web.PropertyEditors
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the configuration for the date value editor.
|
||||
/// </summary>
|
||||
public class DateConfiguration
|
||||
{
|
||||
[ConfigurationField("format", "Date format", "textstring", Description = "If left empty then the format is YYYY-MM-DD. (see momentjs.com for supported formats)")]
|
||||
public string Format { get; set; } = "YYYY-MM-DD";
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Web.PropertyEditors
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the configuration editor for the date value editor.
|
||||
/// </summary>
|
||||
public class DateConfigurationEditor : ConfigurationEditor<DateConfiguration>
|
||||
{
|
||||
public override IDictionary<string, object> ToValueEditor(object configuration)
|
||||
{
|
||||
var d = base.ToValueEditor(configuration);
|
||||
d["pickTime"] = false;
|
||||
return d;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Web.PropertyEditors
|
||||
{
|
||||
[DataEditor(Constants.PropertyEditors.Aliases.Date, "Date", "datepicker", ValueType = ValueTypes.Date, Icon="icon-calendar")]
|
||||
public class DatePropertyEditor : DataEditor
|
||||
{
|
||||
public DatePropertyEditor(ILogger logger): base(logger)
|
||||
{ }
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override IDataValueEditor CreateValueEditor() => new DateValueEditor(Attribute);
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override IConfigurationEditor CreateConfigurationEditor() => new DateConfigurationEditor();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Web.PropertyEditors
|
||||
@@ -11,7 +12,11 @@ namespace Umbraco.Web.PropertyEditors
|
||||
public override IDictionary<string, object> ToValueEditor(object configuration)
|
||||
{
|
||||
var d = base.ToValueEditor(configuration);
|
||||
d["pickTime"] = true;
|
||||
|
||||
var format = d["format"].ToString();
|
||||
|
||||
d["pickTime"] = format.ContainsAny(new string[] { "H", "m", "s" });
|
||||
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,9 +456,7 @@
|
||||
<Compile Include="PropertyEditors\ContentPickerPropertyEditor.cs" />
|
||||
<Compile Include="PropertyEditors\ContentPickerConfiguration.cs" />
|
||||
<Compile Include="PropertyEditors\ContentPickerConfigurationEditor.cs" />
|
||||
<Compile Include="PropertyEditors\DateConfiguration.cs" />
|
||||
<Compile Include="PropertyEditors\DateValueEditor.cs" />
|
||||
<Compile Include="PropertyEditors\DateTimeConfiguration.cs" />
|
||||
<Compile Include="PropertyEditors\DecimalConfigurationEditor.cs" />
|
||||
<Compile Include="PropertyEditors\DropDownFlexiblePropertyEditor.cs" />
|
||||
<Compile Include="PropertyEditors\DropDownFlexibleConfigurationEditor.cs" />
|
||||
@@ -667,7 +665,6 @@
|
||||
<Compile Include="Mvc\UmbracoRequireHttpsAttribute.cs" />
|
||||
<Compile Include="Mvc\ValidateMvcAngularAntiForgeryTokenAttribute.cs" />
|
||||
<Compile Include="OwinMiddlewareConfiguredEventArgs.cs" />
|
||||
<Compile Include="PropertyEditors\DateConfigurationEditor.cs" />
|
||||
<Compile Include="PropertyEditors\DateTimeConfigurationEditor.cs" />
|
||||
<Compile Include="PropertyEditors\DecimalPropertyEditor.cs" />
|
||||
<Compile Include="Routing\RedirectTrackingComponent.cs" />
|
||||
@@ -862,7 +859,6 @@
|
||||
<Compile Include="Models\Mapping\DataTypeConfigurationFieldDisplayResolver.cs" />
|
||||
<Compile Include="PropertyEditors\CheckBoxListPropertyEditor.cs" />
|
||||
<Compile Include="PropertyEditors\ColorPickerPropertyEditor.cs" />
|
||||
<Compile Include="PropertyEditors\DatePropertyEditor.cs" />
|
||||
<Compile Include="PropertyEditors\DateTimePropertyEditor.cs" />
|
||||
<Compile Include="PropertyEditors\DateTimeValidator.cs" />
|
||||
<Compile Include="PropertyEditors\IntegerPropertyEditor.cs" />
|
||||
|
||||
Reference in New Issue
Block a user