From 97a058b8176ed5a6accfded772be1eee276d1d75 Mon Sep 17 00:00:00 2001 From: Stephan Date: Sat, 20 Jan 2018 12:09:15 +0100 Subject: [PATCH] DataType refactoring --- src/Umbraco.Core/Constants-Conventions.cs | 18 +- src/Umbraco.Core/Constants-PropertyEditors.cs | 634 ++++++------------ src/Umbraco.Core/IO/IOHelper.cs | 5 + .../Migrations/Install/DatabaseDataCreator.cs | 48 +- src/Umbraco.Core/Models/DataTypeExtensions.cs | 36 + .../Models/Editors/ContentPropertyData.cs | 8 +- src/Umbraco.Core/Models/MediaExtensions.cs | 4 +- .../PublishedContent/PublishedContentType.cs | 20 +- .../Persistence/Factories/PropertyFactory.cs | 2 +- .../DataTypeConfigurationEditor.cs | 130 ++++ .../DataTypeConfigurationField.cs | 92 +++ .../DataTypeConfigurationFieldAttribute.cs | 70 ++ .../PropertyEditors/IDataTypeConfiguration.cs | 13 + .../PropertyEditors/IParameterEditor.cs | 6 +- .../PropertyEditors/IValueEditor.cs | 2 +- .../ImageCropperEditorConfiguration.cs | 22 + .../LegacyParameterEditorAliasConverter.cs | 8 +- .../LegacyPropertyEditorIdToAliasConverter.cs | 60 +- .../PropertyEditors/PreValueEditor.cs | 12 +- .../PropertyEditors/PreValueField.cs | 97 --- .../PropertyEditors/PreValueFieldAttribute.cs | 68 -- .../PropertyEditors/PropertyEditor.cs | 4 +- .../PropertyEditors/PropertyValueEditor.cs | 1 + .../SliderPropertyEditorConfiguration.cs | 10 + .../PropertyEditors/TagPropertyDefinition.cs | 11 +- .../TagsPropertyEditorConfiguration.cs | 16 + .../{ => Validators}/DecimalValidator.cs | 3 +- .../DelimitedManifestValueValidator.cs | 123 ++-- .../{ => Validators}/EmailValidator.cs | 65 +- .../{ => Validators}/IntegerValidator.cs | 59 +- .../{ => Validators}/RegexValidator.cs | 131 ++-- .../CheckboxListValueConverter.cs | 2 +- .../ColorPickerValueConverter.cs | 2 +- .../DatePickerValueConverter.cs | 4 +- .../ValueConverters/DecimalValueConverter.cs | 2 +- .../DropdownListMultipleValueConverter.cs | 2 +- ...pdownListMultipleWithKeysValueConverter.cs | 2 +- .../DropdownListValueConverter.cs | 2 +- .../DropdownListWithKeysValueConverter.cs | 2 +- .../EmailAddressValueConverter.cs | 2 +- .../ValueConverters/GridValueConverter.cs | 2 +- .../ImageCropperValueConverter.cs | 112 ++-- .../ValueConverters/IntegerValueConverter.cs | 2 +- .../ValueConverters/LabelValueConverter.cs | 2 +- .../MarkdownEditorValueConverter.cs | 2 +- .../MemberGroupPickerValueConverter.cs | 2 +- .../MultipleTextStringValueConverter.cs | 2 +- .../RadioButtonListValueConverter.cs | 2 +- .../ValueConverters/SliderValueConverter.cs | 12 +- .../ValueConverters/TagsValueConverter.cs | 12 +- .../TextStringValueConverter.cs | 4 +- .../ValueConverters/TinyMceValueConverter.cs | 2 +- .../UploadPropertyConverter.cs | 2 +- .../ValueConverters/YesNoValueConverter.cs | 2 +- .../Runtime/CoreRuntimeComponent.cs | 5 +- .../Serialization/JsonReadConverter.cs | 13 +- .../Services/EntityXmlSerializer.cs | 20 +- .../Services/Implement/MemberService.cs | 12 +- .../Services/Implement/NotificationService.cs | 2 +- .../Services/Implement/PackagingService.cs | 54 +- src/Umbraco.Core/Umbraco.Core.csproj | 20 +- .../Mapping/ContentTypeModelMappingTests.cs | 12 +- .../Mapping/ContentWebModelMappingTests.cs | 4 +- .../Querying/ContentTypeSqlMappingTests.cs | 2 +- .../Repositories/ContentRepositoryTest.cs | 2 +- .../DataTypeDefinitionRepositoryTest.cs | 20 +- .../Published/NestedContentTests.cs | 6 +- .../PublishedContentTestBase.cs | 2 +- .../PublishedContent/PublishedContentTests.cs | 10 +- .../ContentTypeServiceExtensionsTests.cs | 6 +- .../Services/ContentTypeServiceTests.cs | 82 +-- .../Services/DataTypeServiceTests.cs | 10 +- .../Services/EntityServiceTests.cs | 2 +- .../Services/Importing/PackageImportTests.cs | 2 +- .../Services/MemberServiceTests.cs | 20 +- .../Entities/MockedContentTypes.cs | 74 +- .../Editors/BackOfficeController.cs | 11 +- .../Editors/ContentTypeController.cs | 4 +- src/Umbraco.Web/Editors/DataTypeController.cs | 24 +- .../Editors/DataTypeValidateAttribute.cs | 6 +- .../EnsureListViewDataTypeIsCreated.cs | 6 +- .../ContentEditing/ContentPropertyDto.cs | 6 - ...s => DataTypeConfigurationFieldDisplay.cs} | 87 ++- ...e.cs => DataTypeConfigurationFieldSave.cs} | 46 +- .../Models/ContentEditing/DataTypeDisplay.cs | 2 +- .../Models/ContentEditing/DataTypeSave.cs | 25 +- .../Models/Mapping/ContentMapperProfile.cs | 6 +- .../Mapping/ContentPropertyBasicConverter.cs | 2 +- .../ContentPropertyDisplayConverter.cs | 4 +- .../Mapping/ContentPropertyDtoConverter.cs | 3 - ...aTypeConfigurationFieldDisplayResolver.cs} | 156 ++--- .../Models/Mapping/DataTypeMapperProfile.cs | 32 +- .../Models/Mapping/DatabaseTypeResolver.cs | 4 +- .../Models/Mapping/MacroMapperProfile.cs | 2 +- .../Models/Mapping/MediaMapperProfile.cs | 2 +- .../Models/Mapping/MemberMapperProfile.cs | 2 +- .../Mapping/PropertyTypeGroupResolver.cs | 4 +- .../Mapping/TabsAndPropertiesResolver.cs | 6 +- .../Models/PublishedContentBase.cs | 4 +- .../CheckBoxListPropertyEditor.cs | 4 +- .../ColorListPreValueEditor.cs | 2 +- .../ColorPickerPropertyEditor.cs | 4 +- .../ContentPicker2PropertyEditor.cs | 8 +- .../ContentPickerPropertyEditor.cs | 4 +- .../DateConfigurationEditor.cs | 10 + .../PropertyEditors/DatePreValueEditor.cs | 10 - .../PropertyEditors/DatePropertyEditor.cs | 6 +- .../PropertyEditors/DateTimePreValueEditor.cs | 4 +- .../PropertyEditors/DateTimePropertyEditor.cs | 4 +- .../PropertyEditors/DecimalPropertyEditor.cs | 11 +- .../DropDownMultiplePropertyEditor.cs | 2 +- .../DropDownMultipleWithKeysPropertyEditor.cs | 6 +- .../PropertyEditors/DropDownPropertyEditor.cs | 2 +- .../DropDownWithKeysPropertyEditor.cs | 4 +- .../EmailAddressPropertyEditor.cs | 7 +- .../FileUploadPropertyEditor.cs | 8 +- .../FolderBrowserPropertyEditor.cs | 2 +- .../PropertyEditors/GridPropertyEditor.cs | 8 +- .../ImageCropperPropertyEditor.cs | 10 +- .../ImageCropperPropertyValueEditor.cs | 2 +- .../PropertyEditors/IntegerPropertyEditor.cs | 11 +- .../PropertyEditors/LabelPropertyEditor.cs | 58 +- .../PropertyEditors/ListViewPropertyEditor.cs | 20 +- .../MacroContainerPropertyEditor.cs | 8 +- .../PropertyEditors/MarkdownPropertyEditor.cs | 8 +- .../MediaPicker2PropertyEditor.cs | 12 +- .../MediaPickerPropertyEditor.cs | 4 +- .../MemberGroupPickerPropertyEditor.cs | 2 +- .../MemberPicker2PropertyEditor.cs | 2 +- .../MultiNodeTreePicker2PropertyEditor.cs | 14 +- .../MultiNodeTreePickerPropertyEditor.cs | 4 +- .../MultipleMediaPickerPropertyEditor.cs | 4 +- .../MultipleTextStringPropertyEditor.cs | 9 +- .../NestedContentPropertyEditor.cs | 34 +- .../RadioButtonsPropertyEditor.cs | 2 +- .../RelatedLinks2PropertyEditor.cs | 6 +- .../PropertyEditors/RichTextPreValueEditor.cs | 4 +- .../PropertyEditors/RichTextPropertyEditor.cs | 4 +- .../PropertyEditors/SliderPropertyEditor.cs | 40 +- .../PropertyEditors/TagsPropertyEditor.cs | 34 +- .../PropertyEditors/TextAreaPropertyEditor.cs | 6 +- .../PropertyEditors/TextboxPropertyEditor.cs | 6 +- .../TrueFalsePropertyEditor.cs | 6 +- .../UserPickerPropertyEditor.cs | 2 +- .../ContentPickerValueConverter.cs | 2 +- .../MacroContainerValueConverter.cs | 2 +- .../MarkdownEditorValueConverter.cs | 2 +- .../MediaPickerValueConverter.cs | 2 +- .../MemberPickerValueConverter.cs | 2 +- .../MultiNodeTreePickerValueConverter.cs | 6 +- .../NestedContentValueConverterBase.cs | 2 +- .../RelatedLinksLegacyValueConverter.cs | 4 +- .../RelatedLinksValueConverter.cs | 2 +- .../TextStringValueConverter.cs | 4 +- .../ValueListPreValueEditor.cs | 8 +- src/Umbraco.Web/Umbraco.Web.csproj | 8 +- src/Umbraco.Web/UmbracoHelper.cs | 9 - .../developer/Macros/assemblyBrowser.aspx.cs | 8 +- 158 files changed, 1602 insertions(+), 1659 deletions(-) create mode 100644 src/Umbraco.Core/Models/DataTypeExtensions.cs create mode 100644 src/Umbraco.Core/PropertyEditors/DataTypeConfigurationEditor.cs create mode 100644 src/Umbraco.Core/PropertyEditors/DataTypeConfigurationField.cs create mode 100644 src/Umbraco.Core/PropertyEditors/DataTypeConfigurationFieldAttribute.cs create mode 100644 src/Umbraco.Core/PropertyEditors/IDataTypeConfiguration.cs create mode 100644 src/Umbraco.Core/PropertyEditors/ImageCropperEditorConfiguration.cs delete mode 100644 src/Umbraco.Core/PropertyEditors/PreValueField.cs delete mode 100644 src/Umbraco.Core/PropertyEditors/PreValueFieldAttribute.cs create mode 100644 src/Umbraco.Core/PropertyEditors/SliderPropertyEditorConfiguration.cs create mode 100644 src/Umbraco.Core/PropertyEditors/TagsPropertyEditorConfiguration.cs rename src/Umbraco.Core/PropertyEditors/{ => Validators}/DecimalValidator.cs (94%) rename src/Umbraco.Core/PropertyEditors/{ => Validators}/DelimitedManifestValueValidator.cs (94%) rename src/Umbraco.Core/PropertyEditors/{ => Validators}/EmailValidator.cs (91%) rename src/Umbraco.Core/PropertyEditors/{ => Validators}/IntegerValidator.cs (91%) rename src/Umbraco.Core/PropertyEditors/{ => Validators}/RegexValidator.cs (94%) rename src/Umbraco.Web/Models/ContentEditing/{PreValueFieldDisplay.cs => DataTypeConfigurationFieldDisplay.cs} (88%) rename src/Umbraco.Web/Models/ContentEditing/{PreValueFieldSave.cs => DataTypeConfigurationFieldSave.cs} (60%) rename src/Umbraco.Web/Models/Mapping/{PreValueDisplayResolver.cs => DataTypeConfigurationFieldDisplayResolver.cs} (50%) create mode 100644 src/Umbraco.Web/PropertyEditors/DateConfigurationEditor.cs delete mode 100644 src/Umbraco.Web/PropertyEditors/DatePreValueEditor.cs diff --git a/src/Umbraco.Core/Constants-Conventions.cs b/src/Umbraco.Core/Constants-Conventions.cs index 80260aab4e..2c1c604bb5 100644 --- a/src/Umbraco.Core/Constants-Conventions.cs +++ b/src/Umbraco.Core/Constants-Conventions.cs @@ -225,63 +225,63 @@ namespace Umbraco.Core { { Comments, - new PropertyType(PropertyEditors.TextboxMultipleAlias, DataTypeDatabaseType.Ntext, true, Comments) + new PropertyType(PropertyEditors.Aliases.TextboxMultiple, DataTypeDatabaseType.Ntext, true, Comments) { Name = CommentsLabel } }, { FailedPasswordAttempts, - new PropertyType(PropertyEditors.NoEditAlias, DataTypeDatabaseType.Integer, true, FailedPasswordAttempts) + new PropertyType(PropertyEditors.Aliases.NoEdit, DataTypeDatabaseType.Integer, true, FailedPasswordAttempts) { Name = FailedPasswordAttemptsLabel } }, { IsApproved, - new PropertyType(PropertyEditors.TrueFalseAlias, DataTypeDatabaseType.Integer, true, IsApproved) + new PropertyType(PropertyEditors.Aliases.Boolean, DataTypeDatabaseType.Integer, true, IsApproved) { Name = IsApprovedLabel } }, { IsLockedOut, - new PropertyType(PropertyEditors.TrueFalseAlias, DataTypeDatabaseType.Integer, true, IsLockedOut) + new PropertyType(PropertyEditors.Aliases.Boolean, DataTypeDatabaseType.Integer, true, IsLockedOut) { Name = IsLockedOutLabel } }, { LastLockoutDate, - new PropertyType(PropertyEditors.NoEditAlias, DataTypeDatabaseType.Date, true, LastLockoutDate) + new PropertyType(PropertyEditors.Aliases.NoEdit, DataTypeDatabaseType.Date, true, LastLockoutDate) { Name = LastLockoutDateLabel } }, { LastLoginDate, - new PropertyType(PropertyEditors.NoEditAlias, DataTypeDatabaseType.Date, true, LastLoginDate) + new PropertyType(PropertyEditors.Aliases.NoEdit, DataTypeDatabaseType.Date, true, LastLoginDate) { Name = LastLoginDateLabel } }, { LastPasswordChangeDate, - new PropertyType(PropertyEditors.NoEditAlias, DataTypeDatabaseType.Date, true, LastPasswordChangeDate) + new PropertyType(PropertyEditors.Aliases.NoEdit, DataTypeDatabaseType.Date, true, LastPasswordChangeDate) { Name = LastPasswordChangeDateLabel } }, { PasswordAnswer, - new PropertyType(PropertyEditors.NoEditAlias, DataTypeDatabaseType.Nvarchar, true, PasswordAnswer) + new PropertyType(PropertyEditors.Aliases.NoEdit, DataTypeDatabaseType.Nvarchar, true, PasswordAnswer) { Name = PasswordAnswerLabel } }, { PasswordQuestion, - new PropertyType(PropertyEditors.NoEditAlias, DataTypeDatabaseType.Nvarchar, true, PasswordQuestion) + new PropertyType(PropertyEditors.Aliases.NoEdit, DataTypeDatabaseType.Nvarchar, true, PasswordQuestion) { Name = PasswordQuestionLabel } diff --git a/src/Umbraco.Core/Constants-PropertyEditors.cs b/src/Umbraco.Core/Constants-PropertyEditors.cs index c31fdf1544..b2912eea16 100644 --- a/src/Umbraco.Core/Constants-PropertyEditors.cs +++ b/src/Umbraco.Core/Constants-PropertyEditors.cs @@ -4,10 +4,8 @@ namespace Umbraco.Core { public static partial class Constants { - // fixme - kill the Whatever2! - /// - /// Defines the identifiers for Umbraco Property Editors as constants for easy centralized access/management. + /// Defines property editors constants. /// public static class PropertyEditors { @@ -17,439 +15,209 @@ namespace Umbraco.Core public const string InternalGenericPropertiesPrefix = "_umb_"; /// - /// Guid for the Checkbox list datatype. + /// Defines Umbraco built-in property editor aliases. /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string CheckBoxList = "B4471851-82B6-4C75-AFA4-39FA9C6A75E9"; - - /// - /// Alias for Checkbox list datatype. - /// - public const string CheckBoxListAlias = "Umbraco.CheckBoxList"; - - /// - /// Guid for the Color Picker datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string ColorPicker = "F8D60F68-EC59-4974-B43B-C46EB5677985"; - - /// - /// Alias for the Color Picker datatype. - /// - public const string ColorPickerAlias = "Umbraco.ColorPickerAlias"; - - /// - /// Guid for the Content Picker datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string ContentPicker = "158AA029-24ED-4948-939E-C3DA209E5FBA"; - - - [Obsolete("This is an obsoleted content picker, use ContentPicker2Alias instead")] - public const string ContentPickerAlias = "Umbraco.ContentPickerAlias"; - - /// - /// Alias for the Content Picker datatype. - /// - public const string ContentPicker2Alias = "Umbraco.ContentPicker2"; - - /// - /// Guid for the Date datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string Date = "23E93522-3200-44E2-9F29-E61A6FCBB79A"; - - /// - /// Alias for the Date datatype. - /// - public const string DateAlias = "Umbraco.Date"; - - /// - /// Guid for the Date/Time datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string DateTime = "B6FB1622-AFA5-4BBF-A3CC-D9672A442222"; - - /// - /// Alias for the Date/Time datatype. - /// - public const string DateTimeAlias = "Umbraco.DateTime"; - - /// - /// Guid for the Dictionary Picker datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string DictionaryPicker = "17B70066-F764-407D-AB05-3717F1E1C513"; - - /// - /// Guid for the Dropdown list datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string DropDownList = "A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6"; - - /// - /// Alias for the Dropdown list datatype. - /// - public const string DropDownListAlias = "Umbraco.DropDown"; - - /// - /// Guid for the Dropdown list multiple datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string DropDownListMultiple = "928639ED-9C73-4028-920C-1E55DBB68783"; - - /// - /// Alias for the Dropdown list multiple datatype. - /// - public const string DropDownListMultipleAlias = "Umbraco.DropDownMultiple"; - - /// - /// Guid for the Dropdown list multiple, publish keys datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string DropdownlistMultiplePublishKeys = "928639AA-9C73-4028-920C-1E55DBB68783"; - - /// - /// Alias for the Dropdown list multiple, publish keys datatype. - /// - public const string DropdownlistMultiplePublishKeysAlias = "Umbraco.DropdownlistMultiplePublishKeys"; - - /// - /// Guid for the Dropdown list, publishing keys datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string DropdownlistPublishingKeys = "A74EA9E1-8E18-4D2A-8CF6-73C6206C5DA6"; - - /// - /// Alias for the Dropdown list, publishing keys datatype. - /// - public const string DropdownlistPublishingKeysAlias = "Umbraco.DropdownlistPublishingKeys"; - - /// - /// Guid for the Folder browser datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string FolderBrowser = "CCCD4AE9-F399-4ED2-8038-2E88D19E810C"; - - /// - /// Alias for the Folder browser datatype. - /// - public const string FolderBrowserAlias = "Umbraco.FolderBrowser"; - - /// - /// Alias for the grid datatype. - /// - public const string GridAlias = "Umbraco.Grid"; - - - /// - /// Guid for the Image Cropper datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string ImageCropper = "7A2D436C-34C2-410F-898F-4A23B3D79F54"; - - ///// - ///// Alias for the Image Cropper datatype. - ///// - public const string ImageCropperAlias = "Umbraco.ImageCropper"; - - /// - /// Guid for the Integer datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string Integer = "1413AFCB-D19A-4173-8E9A-68288D2A73B8"; - - /// - /// Alias for the Integer datatype. - /// - public const string IntegerAlias = "Umbraco.Integer"; - - /// - /// Alias for the Decimal datatype. - /// - public const string DecimalAlias = "Umbraco.Decimal"; - - /// - /// Alias for the listview datatype. - /// - public const string ListViewAlias = "Umbraco.ListView"; - - /// - /// Guid for the list view datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string ListView = "474FCFF8-9D2D-12DE-ABC6-AD7A56D89593"; - - - /// - /// Guid for the Macro Container datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string MacroContainer = "474FCFF8-9D2D-11DE-ABC6-AD7A56D89593"; - - /// - /// Alias for the Macro Container datatype. - /// - public const string MacroContainerAlias = "Umbraco.MacroContainer"; - - /// - /// Guid for the Media Picker datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string MediaPicker = "EAD69342-F06D-4253-83AC-28000225583B"; - - [Obsolete("This is an obsoleted picker, use MediaPicker2Alias instead")] - public const string MediaPickerAlias = "Umbraco.MediaPicker"; - - /// - /// Alias for the Media Picker datatype. - /// - public const string MediaPicker2Alias = "Umbraco.MediaPicker2"; - - [Obsolete("This is an obsoleted picker, use MediaPicker2Alias instead")] - public const string MultipleMediaPickerAlias = "Umbraco.MultipleMediaPicker"; - - /// - /// Guid for the Member Picker datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string MemberPicker = "39F533E4-0551-4505-A64B-E0425C5CE775"; - - [Obsolete("This is an obsoleted picker, use MemberPicker2Alias instead")] - public const string MemberPickerAlias = "Umbraco.MemberPicker"; - - /// - /// Alias for the Member Picker datatype. - /// - public const string MemberPicker2Alias = "Umbraco.MemberPicker2"; - - /// - /// Alias for the Member Group Picker datatype. - /// - public const string MemberGroupPickerAlias = "Umbraco.MemberGroupPicker"; - - /// - /// Guid for the Multi-Node Tree Picker datatype - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string MultiNodeTreePicker = "7E062C13-7C41-4AD9-B389-41D88AEEF87C"; - - [Obsolete("This is an obsoleted picker, use MultiNodeTreePicker2Alias instead")] - public const string MultiNodeTreePickerAlias = "Umbraco.MultiNodeTreePicker"; - - /// - /// Alias for the Multi-Node Tree Picker datatype - /// - public const string MultiNodeTreePicker2Alias = "Umbraco.MultiNodeTreePicker2"; - - /// - /// Guid for the Multiple Textstring datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string MultipleTextstring = "5359AD0B-06CC-4182-92BD-0A9117448D3F"; - - /// - /// Alias for the Multiple Textstring datatype. - /// - public const string MultipleTextstringAlias = "Umbraco.MultipleTextstring"; - - /// - /// Guid for the No edit datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string NoEdit = "6C738306-4C17-4D88-B9BD-6546F3771597"; - - /// - /// Alias for the No edit datatype. - /// - public const string NoEditAlias = "Umbraco.NoEdit"; - - /// - /// Guid for the Picker Relations datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string PickerRelations = "83396FF2-2E39-4A90-9066-17F5F3989374"; - - /// - /// Alias for the Picker Relations datatype. - /// - public const string PickerRelationsAlias = "Umbraco.PickerRelations"; - - /// - /// Guid for the Radiobutton list datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string RadioButtonList = "A52C7C1C-C330-476E-8605-D63D3B84B6A6"; - - /// - /// Alias for the Radiobutton list datatype. - /// - public const string RadioButtonListAlias = "Umbraco.RadioButtonList"; - - /// - /// Guid for the Related Links datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string RelatedLinks = "71B8AD1A-8DC2-425C-B6B8-FAA158075E63"; - - [Obsolete("This is an obsoleted picker, use RelatedLinks2Alias instead")] - public const string RelatedLinksAlias = "Umbraco.RelatedLinks"; - - /// - /// Alias for the Related Links property editor. - /// - public const string RelatedLinks2Alias = "Umbraco.RelatedLinks2"; - - /// - /// Guid for the Slider datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string Slider = "29E790E6-26B3-438A-B21F-908663A0B19E"; - - /// - /// Alias for the Slider datatype. - /// - public const string SliderAlias = "Umbraco.Slider"; - - /// - /// Guid for the Tags datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string Tags = "4023E540-92F5-11DD-AD8B-0800200C9A66"; - - /// - /// Alias for the Tags datatype. - /// - public const string TagsAlias = "Umbraco.Tags"; - - /// - /// Guid for the Textbox datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string Textbox = "EC15C1E5-9D90-422A-AA52-4F7622C63BEA"; - - /// - /// Alias for the Textbox datatype. - /// - public const string TextboxAlias = "Umbraco.Textbox"; - - /// - /// Guid for the Textarea datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string TextboxMultiple = "67DB8357-EF57-493E-91AC-936D305E0F2A"; - - /// - /// Alias for the Textarea datatype. - /// - public const string TextboxMultipleAlias = "Umbraco.TextboxMultiple"; - - /// - /// Guid for the TinyMCE v3 wysiwyg datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string TinyMCEv3 = "5E9B75AE-FACE-41C8-B47E-5F4B0FD82F83"; - - /// - /// Alias for the TinyMCE wysiwyg datatype. - /// - public const string TinyMCEAlias = "Umbraco.TinyMCEv3"; - - /// - /// Guid for the True/False (Ja/Nej) datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string TrueFalse = "38B352C1-E9F8-4FD8-9324-9A2EAB06D97A"; - - /// - /// Alias for the True/False (Ja/Nej) datatype. - /// - public const string TrueFalseAlias = "Umbraco.TrueFalse"; - public const string BooleanAlias = TrueFalseAlias; - - /// - /// Guid for the Ultimate Picker datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string UltimatePicker = "CDBF0B5D-5CB2-445F-BC12-FCAAEC07CF2C"; - - /// - /// Guid for the UltraSimpleEditor datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string UltraSimpleEditor = "60B7DABF-99CD-41EB-B8E9-4D2E669BBDE9"; - - /// - /// Alias for the MarkdownEditor datatype. - /// - public const string MarkdownEditorAlias = "Umbraco.MarkdownEditor"; - - /// - /// Guid for the Umbraco Usercontrol Wrapper datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string UmbracoUserControlWrapper = "D15E1281-E456-4B24-AA86-1DDA3E4299D5"; - - /// - /// Guid for the Upload field datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string UploadField = "5032A6E6-69E3-491D-BB28-CD31CD11086C"; - - /// - /// Alias for the User picker datatype. - /// - public const string UserPickerAlias = "Umbraco.UserPicker"; - - /// - /// Guid for the User picker datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string UserPicker = "e66af4a0-e8b4-11de-8a39-0800200c9a66"; - - /// - /// Alias for the Upload field datatype. - /// - public const string UploadFieldAlias = "Umbraco.UploadField"; - - - /// - /// Guid for the XPath CheckBoxList datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string XPathCheckBoxList = "34451D92-D270-49BA-8C7F-EE55BFEEE1CB"; - - /// - /// Alias for the XPath CheckBoxList datatype. - /// - public const string XPathCheckBoxListAlias = "Umbraco.XPathCheckBoxList"; - - /// - /// Guid for the XPath DropDownList datatype. - /// - [Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")] - public const string XPathDropDownList = "173A96AE-00ED-4A7C-9F76-4B53D4A0A1B9"; - - /// - /// Alias for the XPath DropDownList datatype. - /// - public const string XPathDropDownListAlias = "Umbraco.XPathDropDownList"; - - /// - /// Alias for the email address property editor - /// - public const string EmailAddressAlias = "Umbraco.EmailAddress"; - - /// - /// Alias for the nested content property editor. - /// - public const string NestedContentAlias = "Umbraco.NestedContent"; - - public static class PreValueKeys + public static class Aliases { /// - /// Pre-value name used to indicate a field that can be used to override the database field to which data for the associated - /// property is saved + /// CheckBox List. + /// + public const string CheckBoxList = "Umbraco.CheckBoxList"; + + /// + /// Color Picker. + /// + public const string ColorPicker = "Umbraco.ColorPickerAlias"; + + /// + /// Content Picker. + /// + public const string ContentPicker2Alias = "Umbraco.ContentPicker2"; // fixme + + /// + /// Date. + /// + public const string Date = "Umbraco.Date"; + + /// + /// DateTime. + /// + public const string DateTime = "Umbraco.DateTime"; + + /// + /// DropDown List. + /// + public const string DropDownList = "Umbraco.DropDown"; + + /// + /// DropDown List, Publish Keys. + /// + public const string DropdownlistPublishKeys = "Umbraco.DropdownlistPublishingKeys"; + + /// + /// DropDown List Multiple. + /// + public const string DropDownListMultiple = "Umbraco.DropDownMultiple"; + + /// + /// DropDown List Multiple, Publish Keys. + /// + public const string DropdownlistMultiplePublishKeys = "Umbraco.DropdownlistMultiplePublishKeys"; + + /// + /// Folder Browser. + /// + public const string FolderBrowser = "Umbraco.FolderBrowser"; + + /// + /// Grid. + /// + public const string Grid = "Umbraco.Grid"; + + /// + /// Image Cropper. + /// + public const string ImageCropper = "Umbraco.ImageCropper"; + + /// + /// Integer. + /// + public const string Integer = "Umbraco.Integer"; + + /// + /// Decimal. + /// + public const string Decimal = "Umbraco.Decimal"; + + /// + /// ListView. + /// + public const string ListView = "Umbraco.ListView"; + + /// + /// Macro Container. + /// + public const string MacroContainer = "Umbraco.MacroContainer"; + + /// + /// Media Picker. + /// + public const string MediaPicker2 = "Umbraco.MediaPicker2"; // fixme + + /// + /// Member Picker. + /// + public const string MemberPicker2 = "Umbraco.MemberPicker2"; // fixme + + /// + /// Member Group Picker. + /// + public const string MemberGroupPicker = "Umbraco.MemberGroupPicker"; + + /// + /// MultiNode Tree Picker. + /// + public const string MultiNodeTreePicker2 = "Umbraco.MultiNodeTreePicker2"; // fixme + + /// + /// Multiple TextString. + /// + public const string MultipleTextstring = "Umbraco.MultipleTextstring"; + + /// + /// NoEdit. + /// + public const string NoEdit = "Umbraco.NoEdit"; + + /// + /// Picker Relations. + /// + public const string PickerRelations = "Umbraco.PickerRelations"; + + /// + /// RadioButton list. + /// + public const string RadioButtonList = "Umbraco.RadioButtonList"; + + /// + /// Related Links. + /// + public const string RelatedLinks2 = "Umbraco.RelatedLinks2"; // fixme + + /// + /// Slider. + /// + public const string Slider = "Umbraco.Slider"; + + /// + /// Tags. + /// + public const string Tags = "Umbraco.Tags"; + + /// + /// Textbox. + /// + public const string Textbox = "Umbraco.Textbox"; + + /// + /// Textbox Multiple. + /// + public const string TextboxMultiple = "Umbraco.TextboxMultiple"; // fixme TextArea? + + /// + /// TinyMCE + /// + public const string TinyMce = "Umbraco.TinyMCEv3"; + + /// + /// Boolean. + /// + public const string Boolean = "Umbraco.TrueFalse"; + + /// + /// Markdown Editor. + /// + public const string MarkdownEditor = "Umbraco.MarkdownEditor"; + + /// + /// User Picker. + /// + public const string UserPicker = "Umbraco.UserPicker"; + + /// + /// Upload Field. + /// + public const string UploadField = "Umbraco.UploadField"; + + /// + /// XPatch Checkbox List. + /// + public const string XPathCheckBoxList = "Umbraco.XPathCheckBoxList"; + + /// + /// XPath DropDown List. + /// + public const string XPathDropDownList = "Umbraco.XPathDropDownList"; + + /// + /// Email Address. + /// + public const string EmailAddress = "Umbraco.EmailAddress"; + + /// + /// Nested Content. + /// + public const string NestedContent = "Umbraco.NestedContent"; + } + + /// + /// Defines Umbraco build-in datatype configuration keys. + /// + public static class ConfigurationKeys + { + /// + /// The value type of property data (i.e., string, etc) + /// fixme - values? /// public const string DataValueType = "umbracoDataValueType"; } diff --git a/src/Umbraco.Core/IO/IOHelper.cs b/src/Umbraco.Core/IO/IOHelper.cs index 2e5f758107..94d2ccfe7c 100644 --- a/src/Umbraco.Core/IO/IOHelper.cs +++ b/src/Umbraco.Core/IO/IOHelper.cs @@ -111,6 +111,11 @@ namespace Umbraco.Core.IO return MapPath(path, true); } + public static string MapPathIfVirtual(string path) + { + return path.StartsWith("~/") ? MapPath(path) : path; + } + //use a tilde character instead of the complete path internal static string ReturnPath(string settingsKey, string standardPath, bool useTilde) { diff --git a/src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs b/src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs index dc1da2b00e..41aef6b7bd 100644 --- a/src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs +++ b/src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs @@ -226,37 +226,37 @@ namespace Umbraco.Core.Migrations.Install const string layouts = "[" + cardLayout + "," + listLayout + "]"; //TODO Check which of the DataTypeIds below doesn't exist in umbracoNode, which results in a foreign key constraint errors. - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -49, EditorAlias = Constants.PropertyEditors.TrueFalseAlias, DbType = "Integer" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -51, EditorAlias = Constants.PropertyEditors.IntegerAlias, DbType = "Integer" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -87, EditorAlias = Constants.PropertyEditors.TinyMCEAlias, DbType = "Ntext", + _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -49, EditorAlias = Constants.PropertyEditors.Aliases.Boolean, DbType = "Integer" }); + _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -51, EditorAlias = Constants.PropertyEditors.Aliases.Integer, DbType = "Integer" }); + _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -87, EditorAlias = Constants.PropertyEditors.Aliases.TinyMce, DbType = "Ntext", Configuration = "{\"value\":\",code,undo,redo,cut,copy,mcepasteword,stylepicker,bold,italic,bullist,numlist,outdent,indent,mcelink,unlink,mceinsertanchor,mceimage,umbracomacro,mceinserttable,umbracoembed,mcecharmap,|1|1,2,3,|0|500,400|1049,|true|\"}" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -88, EditorAlias = Constants.PropertyEditors.TextboxAlias, DbType = "Nvarchar" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -89, EditorAlias = Constants.PropertyEditors.TextboxMultipleAlias, DbType = "Ntext" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -90, EditorAlias = Constants.PropertyEditors.UploadFieldAlias, DbType = "Nvarchar" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -92, EditorAlias = Constants.PropertyEditors.NoEditAlias, DbType = "Nvarchar" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -36, EditorAlias = Constants.PropertyEditors.DateTimeAlias, DbType = "Date" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -37, EditorAlias = Constants.PropertyEditors.ColorPickerAlias, DbType = "Nvarchar" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -39, EditorAlias = Constants.PropertyEditors.DropDownListMultipleAlias, DbType = "Nvarchar" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -40, EditorAlias = Constants.PropertyEditors.RadioButtonListAlias, DbType = "Nvarchar" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -41, EditorAlias = Constants.PropertyEditors.DateAlias, DbType = "Date" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -42, EditorAlias = Constants.PropertyEditors.DropDownListAlias, DbType = "Integer" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -43, EditorAlias = Constants.PropertyEditors.CheckBoxListAlias, DbType = "Nvarchar" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1041, EditorAlias = Constants.PropertyEditors.TagsAlias, DbType = "Ntext", + _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -88, EditorAlias = Constants.PropertyEditors.Aliases.Textbox, DbType = "Nvarchar" }); + _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -89, EditorAlias = Constants.PropertyEditors.Aliases.TextboxMultiple, DbType = "Ntext" }); + _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -90, EditorAlias = Constants.PropertyEditors.Aliases.UploadField, DbType = "Nvarchar" }); + _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -92, EditorAlias = Constants.PropertyEditors.Aliases.NoEdit, DbType = "Nvarchar" }); + _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -36, EditorAlias = Constants.PropertyEditors.Aliases.DateTime, DbType = "Date" }); + _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -37, EditorAlias = Constants.PropertyEditors.Aliases.ColorPicker, DbType = "Nvarchar" }); + _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -39, EditorAlias = Constants.PropertyEditors.Aliases.DropDownListMultiple, DbType = "Nvarchar" }); + _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 = -42, EditorAlias = Constants.PropertyEditors.Aliases.DropDownList, DbType = "Integer" }); + _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", Configuration = "{\"group\":\"default\"}" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1043, EditorAlias = Constants.PropertyEditors.ImageCropperAlias, DbType = "Ntext" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = Constants.DataTypes.DefaultContentListView, EditorAlias = Constants.PropertyEditors.ListViewAlias, DbType = "Nvarchar" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = Constants.DataTypes.DefaultMediaListView, EditorAlias = Constants.PropertyEditors.ListViewAlias, DbType = "Nvarchar", + _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1043, EditorAlias = Constants.PropertyEditors.Aliases.ImageCropper, DbType = "Ntext" }); + _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = Constants.DataTypes.DefaultContentListView, EditorAlias = Constants.PropertyEditors.Aliases.ListView, DbType = "Nvarchar" }); + _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = Constants.DataTypes.DefaultMediaListView, EditorAlias = Constants.PropertyEditors.Aliases.ListView, DbType = "Nvarchar", Configuration = "{\"pageSize\":100, \"orderBy\":\"updateDate\", \"orderDirection\":\"desc\", \"layouts\":" + layouts + ", \"includeProperties\":[{\"alias\":\"updateDate\",\"header\":\"Last edited\",\"isSystem\":1},{\"alias\":\"owner\",\"header\":\"Updated by\",\"isSystem\":1}]}" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = Constants.DataTypes.DefaultMembersListView, EditorAlias = Constants.PropertyEditors.ListViewAlias, DbType = "Nvarchar", + _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = Constants.DataTypes.DefaultMembersListView, EditorAlias = Constants.PropertyEditors.Aliases.ListView, DbType = "Nvarchar", Configuration = "{\"pageSize\":10, \"orderBy\":\"username\", \"orderDirection\":\"asc\", \"includeProperties\":[{\"alias\":\"username\",\"isSystem\":1},{\"alias\":\"email\",\"isSystem\":1},{\"alias\":\"updateDate\",\"header\":\"Last edited\",\"isSystem\":1}]}" }); //New UDI pickers with newer Ids - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1046, EditorAlias = Constants.PropertyEditors.ContentPicker2Alias, DbType = "Nvarchar" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1047, EditorAlias = Constants.PropertyEditors.MemberPicker2Alias, DbType = "Nvarchar" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1048, EditorAlias = Constants.PropertyEditors.MediaPicker2Alias, DbType = "Ntext" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1049, EditorAlias = Constants.PropertyEditors.MediaPicker2Alias, DbType = "Ntext", + _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1046, EditorAlias = Constants.PropertyEditors.Aliases.ContentPicker2Alias, DbType = "Nvarchar" }); + _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1047, EditorAlias = Constants.PropertyEditors.Aliases.MemberPicker2, DbType = "Nvarchar" }); + _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1048, EditorAlias = Constants.PropertyEditors.Aliases.MediaPicker2, DbType = "Ntext" }); + _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1049, EditorAlias = Constants.PropertyEditors.Aliases.MediaPicker2, DbType = "Ntext", Configuration = "{\"multiPicker\":1}" }); - _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1050, EditorAlias = Constants.PropertyEditors.RelatedLinks2Alias, DbType = "Ntext" }); + _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1050, EditorAlias = Constants.PropertyEditors.Aliases.RelatedLinks2, DbType = "Ntext" }); //TODO: We're not creating these for 7.0 //_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { DataTypeId = 1038, PropertyEditorAlias = Constants.PropertyEditors.MarkdownEditorAlias, DbType = "Ntext" }); diff --git a/src/Umbraco.Core/Models/DataTypeExtensions.cs b/src/Umbraco.Core/Models/DataTypeExtensions.cs new file mode 100644 index 0000000000..c7ae29c4bc --- /dev/null +++ b/src/Umbraco.Core/Models/DataTypeExtensions.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Umbraco.Core.Models +{ + /// + /// Provides extensions methods for . + /// + public static class DataTypeExtensions + { + /// + /// Gets the configuration object. + /// + /// The expected type of the configuration object. + /// This datatype. + /// When the datatype configuration is not of the expected type. + public static T ConfigurationAs(this IDataType dataType) + where T : class + { + var configuration = dataType.Configuration; + + switch (configuration) + { + case null: + return null; + case T configurationAsT: + return configurationAsT; + } + + throw new InvalidCastException($"Cannot cast dataType {dataType.GetType().Name} configuration, of type {configuration.GetType().Name}, to {typeof(T).Name}."); + } + } +} diff --git a/src/Umbraco.Core/Models/Editors/ContentPropertyData.cs b/src/Umbraco.Core/Models/Editors/ContentPropertyData.cs index dbe53f06a1..ee4955cda3 100644 --- a/src/Umbraco.Core/Models/Editors/ContentPropertyData.cs +++ b/src/Umbraco.Core/Models/Editors/ContentPropertyData.cs @@ -11,10 +11,10 @@ namespace Umbraco.Core.Models.Editors /// public class ContentPropertyData { - public ContentPropertyData(object value, PreValueCollection preValues) + public ContentPropertyData(object value, object dataTypeConfiguration) { Value = value; - PreValues = preValues; + DataTypeConfiguration = dataTypeConfiguration; } /// @@ -23,9 +23,9 @@ namespace Umbraco.Core.Models.Editors public object Value { get; } /// - /// The pre-value collection for the content property + /// The data type configuration for the property. /// - public PreValueCollection PreValues { get; } + public object DataTypeConfiguration { get; } /// /// Gets or sets the unique identifier of the content owning the property. diff --git a/src/Umbraco.Core/Models/MediaExtensions.cs b/src/Umbraco.Core/Models/MediaExtensions.cs index 72150c8955..2267843120 100644 --- a/src/Umbraco.Core/Models/MediaExtensions.cs +++ b/src/Umbraco.Core/Models/MediaExtensions.cs @@ -24,10 +24,10 @@ namespace Umbraco.Core.Models var jsonString = val.GetValue() as string; if (jsonString == null) return string.Empty; - if (propertyType.PropertyEditorAlias == Constants.PropertyEditors.UploadFieldAlias) + if (propertyType.PropertyEditorAlias == Constants.PropertyEditors.Aliases.UploadField) return jsonString; - if (propertyType.PropertyEditorAlias == Constants.PropertyEditors.ImageCropperAlias) + if (propertyType.PropertyEditorAlias == Constants.PropertyEditors.Aliases.ImageCropper) { if (jsonString.DetectIsJson() == false) return jsonString; diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs index 3645835170..28ad945267 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs @@ -88,16 +88,16 @@ namespace Umbraco.Core.Models.PublishedContent // fixme - this list somehow also exists in constants, see memberTypeRepository => remove duplicate! private static readonly Dictionary BuiltinMemberProperties = new Dictionary { - { "Email", (Constants.DataTypes.Textbox, Constants.PropertyEditors.TextboxAlias) }, - { "Username", (Constants.DataTypes.Textbox, Constants.PropertyEditors.TextboxAlias) }, - { "PasswordQuestion", (Constants.DataTypes.Textbox, Constants.PropertyEditors.TextboxAlias) }, - { "Comments", (Constants.DataTypes.Textbox, Constants.PropertyEditors.TextboxAlias) }, - { "IsApproved", (Constants.DataTypes.Boolean, Constants.PropertyEditors.BooleanAlias) }, - { "IsLockedOut", (Constants.DataTypes.Boolean, Constants.PropertyEditors.BooleanAlias) }, - { "LastLockoutDate", (Constants.DataTypes.Datetime, Constants.PropertyEditors.DateTimeAlias) }, - { "CreateDate", (Constants.DataTypes.Datetime, Constants.PropertyEditors.DateTimeAlias) }, - { "LastLoginDate", (Constants.DataTypes.Datetime, Constants.PropertyEditors.DateTimeAlias) }, - { "LastPasswordChangeDate", (Constants.DataTypes.Datetime, Constants.PropertyEditors.DateTimeAlias) }, + { "Email", (Constants.DataTypes.Textbox, Constants.PropertyEditors.Aliases.Textbox) }, + { "Username", (Constants.DataTypes.Textbox, Constants.PropertyEditors.Aliases.Textbox) }, + { "PasswordQuestion", (Constants.DataTypes.Textbox, Constants.PropertyEditors.Aliases.Textbox) }, + { "Comments", (Constants.DataTypes.Textbox, Constants.PropertyEditors.Aliases.Textbox) }, + { "IsApproved", (Constants.DataTypes.Boolean, Constants.PropertyEditors.Aliases.Boolean) }, + { "IsLockedOut", (Constants.DataTypes.Boolean, Constants.PropertyEditors.Aliases.Boolean) }, + { "LastLockoutDate", (Constants.DataTypes.Datetime, Constants.PropertyEditors.Aliases.DateTime) }, + { "CreateDate", (Constants.DataTypes.Datetime, Constants.PropertyEditors.Aliases.DateTime) }, + { "LastLoginDate", (Constants.DataTypes.Datetime, Constants.PropertyEditors.Aliases.DateTime) }, + { "LastPasswordChangeDate", (Constants.DataTypes.Datetime, Constants.PropertyEditors.Aliases.DateTime) }, }; #region Content type diff --git a/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs b/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs index 1ffd194c1f..849d189f28 100644 --- a/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs +++ b/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs @@ -53,7 +53,7 @@ namespace Umbraco.Core.Persistence.Factories if (property.DataTypeDatabaseType == DataTypeDatabaseType.Integer) { - if (value is bool || property.PropertyType.PropertyEditorAlias == Constants.PropertyEditors.TrueFalseAlias) + if (value is bool || property.PropertyType.PropertyEditorAlias == Constants.PropertyEditors.Aliases.Boolean) { dto.IntegerValue = value != null && string.IsNullOrEmpty(value.ToString()) ? 0 : Convert.ToInt32(value); } diff --git a/src/Umbraco.Core/PropertyEditors/DataTypeConfigurationEditor.cs b/src/Umbraco.Core/PropertyEditors/DataTypeConfigurationEditor.cs new file mode 100644 index 0000000000..bb677bf887 --- /dev/null +++ b/src/Umbraco.Core/PropertyEditors/DataTypeConfigurationEditor.cs @@ -0,0 +1,130 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Newtonsoft.Json; +using Umbraco.Core.Composing; +using Umbraco.Core.IO; +using Umbraco.Core.Logging; +using Umbraco.Core.Models; + +namespace Umbraco.Core.PropertyEditors +{ + /// + /// Represents a data type configuration editor. + /// + public class DataTypeConfigurationEditor + { + // a configuration editor is made up of multiple configuration fields + // each field is identified by a key, each field has its own editor + // the json serialization attribute is required for manifest property editors to work (fixme - datamember?) + + /// + /// Initializes a new instance of the class. + /// + public DataTypeConfigurationEditor() + { + Fields = DiscoverFields(); + } + + // fixme + // do we need to support discovering fields? + // bearing in mind that attribute.PreValueFieldType is *never* used + // we probably can achieve the same with explicit code everywhere + + private List DiscoverFields() + { + var fields = new List(); + + // discover fields that are properties marked with the field attribute + var props = TypeHelper.CachedDiscoverableProperties(GetType()).Where(x => x.Name != "Fields"); + + foreach (var prop in props) + { + var attribute = prop.GetCustomAttribute(false); + if (attribute == null) continue; + + DataTypeConfigurationField field; + + // if the field does not have its own type, use the base type + if (attribute.PreValueFieldType == null) + { + field = new DataTypeConfigurationField + { + // if the key is empty then use the property name + Key = string.IsNullOrWhiteSpace(attribute.Key) ? prop.Name : attribute.Key, + Name = attribute.Name, + Description = attribute.Description, + HideLabel = attribute.HideLabel, + View = attribute.View.StartsWith("~/") ? IOHelper.ResolveUrl(attribute.View) : attribute.View // fixme why cant it remain unchagned? + }; + + fields.Add(field); + continue; + } + + // if the field has its own type, instanciate it + try + { + field = (DataTypeConfigurationField) Activator.CreateInstance(attribute.PreValueFieldType); + } + catch (Exception ex) + { + Current.Logger.Warn(ex, $"Could not create an instance of type \"{attribute.PreValueFieldType}\"."); + continue; + } + + // then add it, and overwrite values if they are assigned in the attribute + fields.Add(field); + + if (!string.IsNullOrWhiteSpace(attribute.Key)) + field.Key = attribute.Key; + + // if the key is empty then use the property name + if (string.IsNullOrWhiteSpace(field.Key)) + field.Key = prop.Name; + + if (!string.IsNullOrWhiteSpace(attribute.Name)) + field.Name = attribute.Name; + + if (!string.IsNullOrWhiteSpace(attribute.View)) + field.View = attribute.View; + + if (!string.IsNullOrWhiteSpace(attribute.Description)) + field.Description = attribute.Description; + + if (attribute.HideLabel) + field.HideLabel = attribute.HideLabel; + } + + return fields; + } + + /// + /// Gets the fields. + /// + [JsonProperty("fields")] + public List Fields { get; private set; } + + /// + /// Converts the values posted by the editor to configuration values. + /// + /// The values posted by the editor. + /// The current configuration. + /// + public virtual IDictionary ConvertEditorToDb(IDictionary editorValues, object configuration) + { + // fixme by default, just converting to PreValue + //convert to a string based value to be saved in the db + return editorValues.ToDictionary(x => x.Key, x => new PreValue(x.Value?.ToString())); + } + + /// + /// Converts configuration values to values for the editor. + /// + /// The default configuration. + /// The configuration. + public virtual IDictionary ConvertDbToEditor(object defaultConfiguration, object configuration) + {} + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/PropertyEditors/DataTypeConfigurationField.cs b/src/Umbraco.Core/PropertyEditors/DataTypeConfigurationField.cs new file mode 100644 index 0000000000..4a6ac92c7d --- /dev/null +++ b/src/Umbraco.Core/PropertyEditors/DataTypeConfigurationField.cs @@ -0,0 +1,92 @@ +using System.Collections.Generic; +using System.Linq; +using Newtonsoft.Json; +using Umbraco.Core.Manifest; + +namespace Umbraco.Core.PropertyEditors +{ + /// + /// Represents a datatype configuration field for editing. + /// + public class DataTypeConfigurationField + { + /// + /// Initializes a new instance of the class. + /// + public DataTypeConfigurationField() + : this(new List()) + { } + + /// + /// Initializes a new instance of the class. + /// + public DataTypeConfigurationField(params IPropertyValidator[] validators) + : this(validators.ToList()) + { } + + /// + /// Initializes a new instance of the class. + /// + private DataTypeConfigurationField(List validators) + { + Validators = validators; + Config = new Dictionary(); + + // fill details from attribute, if any + var attribute = GetType().GetCustomAttribute(false); + if (attribute == null) return; + + Name = attribute.Name; + Description = attribute.Description; + HideLabel = attribute.HideLabel; + Key = attribute.Key; + View = attribute.View; + } + + /// + /// Gets or sets the name of the field. + /// + [JsonProperty("label", Required = Required.Always)] + public string Name { get; set; } + + /// + /// Gets or sets the description of the field. + /// + [JsonProperty("description")] + public string Description { get; set; } + + /// + /// Gets or sets a value indicating whether to hide the label of the field. + /// + [JsonProperty("hideLabel")] + public bool HideLabel { get; set; } + + /// + /// Gets or sets the key of the field. + /// + [JsonProperty("key", Required = Required.Always)] + public string Key { get; set; } + + /// + /// Gets or sets the view to used in the editor. + /// + /// + /// Can be the full virtual path, or the relative path to the Umbraco folder, + /// or a simple view name which will map to ~/Views/PreValueEditors/{view}.html. + /// + [JsonProperty("view", Required = Required.Always)] + public string View { get; set; } + + /// + /// Gets the validators of the field. + /// + [JsonProperty("validation", ItemConverterType = typeof(ManifestValidatorConverter))] + public List Validators { get; private set; } + + /// + /// Gets or sets extra configuration properties for the editor. + /// + [JsonProperty("config")] + public IDictionary Config { get; set; } + } +} diff --git a/src/Umbraco.Core/PropertyEditors/DataTypeConfigurationFieldAttribute.cs b/src/Umbraco.Core/PropertyEditors/DataTypeConfigurationFieldAttribute.cs new file mode 100644 index 0000000000..76bf2b4631 --- /dev/null +++ b/src/Umbraco.Core/PropertyEditors/DataTypeConfigurationFieldAttribute.cs @@ -0,0 +1,70 @@ +using System; + +namespace Umbraco.Core.PropertyEditors +{ + /// + /// Marks a custom DataTypeConfigurationEditor property as a configuration field. + /// + [AttributeUsage(AttributeTargets.Property)] + public class DataTypeConfigurationFieldAttribute : Attribute + { + /// + /// Initializes a new instance of the class. + /// + public DataTypeConfigurationFieldAttribute(Type preValueFieldType) + { + PreValueFieldType = preValueFieldType; + } + + /// + /// Initializes a new instance of the class. + /// + public DataTypeConfigurationFieldAttribute(string key, string name, string view) + { + Key = key; + Name = name; + View = view; + } + + /// + /// Initializes a new instance of the class. + /// + public DataTypeConfigurationFieldAttribute(string name, string view) + { + Name = name; + View = view; + } + + /// + /// Gets or sets the name of the field. + /// + public string Name { get; } + + /// + /// Gets or sets the description of the field. + /// + public string Description { get; set; } + + /// + /// Gets or sets a value indicating whether to hide the label of the field. + /// + public bool HideLabel { get; set; } + + /// + /// Gets or sets the key of the field. + /// + /// Defaults to the field property name if not specified. + public string Key { get; } + + /// + /// Gets or sets the view to used in the editor. + /// + public string View { get; } + + /// + /// Gets or sets the Clr type of the . Properties + /// from this type are used as defaults, unless explicitely specified in this attribute. + /// + public Type PreValueFieldType { get; set; } + } +} diff --git a/src/Umbraco.Core/PropertyEditors/IDataTypeConfiguration.cs b/src/Umbraco.Core/PropertyEditors/IDataTypeConfiguration.cs new file mode 100644 index 0000000000..635d724d2b --- /dev/null +++ b/src/Umbraco.Core/PropertyEditors/IDataTypeConfiguration.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Umbraco.Core.PropertyEditors +{ + public interface IDataTypeConfiguration + { + IDictionary ToDictionary(); + } +} diff --git a/src/Umbraco.Core/PropertyEditors/IParameterEditor.cs b/src/Umbraco.Core/PropertyEditors/IParameterEditor.cs index ae27c7227d..30f4be9b5f 100644 --- a/src/Umbraco.Core/PropertyEditors/IParameterEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/IParameterEditor.cs @@ -6,17 +6,17 @@ namespace Umbraco.Core.PropertyEditors public interface IParameterEditor : IDiscoverable { /// - /// The id of the property editor + /// Gets the unique identifier of the editor. /// string Alias { get; } /// - /// The name of the property editor + /// Gets the name of the editor. /// string Name { get; } /// - /// Allows a parameter editor to be re-used based on the configuration specified. + /// Allows a parameter editor to be re-used based on the configuration specified. FIXME WTF?! /// IDictionary Configuration { get; } diff --git a/src/Umbraco.Core/PropertyEditors/IValueEditor.cs b/src/Umbraco.Core/PropertyEditors/IValueEditor.cs index fea4c452ca..b16672dec8 100644 --- a/src/Umbraco.Core/PropertyEditors/IValueEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/IValueEditor.cs @@ -1,7 +1,7 @@ namespace Umbraco.Core.PropertyEditors { /// - /// Represents an editor for values. + /// Represents an editor for editing values. /// public interface IValueEditor { diff --git a/src/Umbraco.Core/PropertyEditors/ImageCropperEditorConfiguration.cs b/src/Umbraco.Core/PropertyEditors/ImageCropperEditorConfiguration.cs new file mode 100644 index 0000000000..f6f8149502 --- /dev/null +++ b/src/Umbraco.Core/PropertyEditors/ImageCropperEditorConfiguration.cs @@ -0,0 +1,22 @@ +using Newtonsoft.Json; + +namespace Umbraco.Core.PropertyEditors +{ + public class ImageCropperEditorConfiguration + { + [JsonProperty("crops")] + public Crop[] Crops { get; set; } + + public class Crop + { + [JsonProperty("alias")] + public string Alias { get; set; } + + [JsonProperty("width")] + public int Width { get; set; } + + [JsonProperty("height")] + public int Height { get; set; } + } + } +} diff --git a/src/Umbraco.Core/PropertyEditors/LegacyParameterEditorAliasConverter.cs b/src/Umbraco.Core/PropertyEditors/LegacyParameterEditorAliasConverter.cs index 63f52f7741..4d835f4012 100644 --- a/src/Umbraco.Core/PropertyEditors/LegacyParameterEditorAliasConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/LegacyParameterEditorAliasConverter.cs @@ -91,13 +91,13 @@ namespace Umbraco.Core.PropertyEditors CreateMap("contentTree", Constants.PropertyEditors.ContentPickerAlias); CreateMap("contentAll", Constants.PropertyEditors.ContentPickerAlias); - CreateMap("textMultiLine", Constants.PropertyEditors.TextboxMultipleAlias); - CreateMap("text", Constants.PropertyEditors.TextboxAlias); - CreateMap("bool", Constants.PropertyEditors.TrueFalseAlias); + CreateMap("textMultiLine", Constants.PropertyEditors.Aliases.TextboxMultiple); + CreateMap("text", Constants.PropertyEditors.Aliases.Textbox); + CreateMap("bool", Constants.PropertyEditors.Aliases.Boolean); CreateMap("mediaCurrent", Constants.PropertyEditors.MediaPickerAlias); - CreateMap("number", Constants.PropertyEditors.IntegerAlias); + CreateMap("number", Constants.PropertyEditors.Aliases.Integer); } } } diff --git a/src/Umbraco.Core/PropertyEditors/LegacyPropertyEditorIdToAliasConverter.cs b/src/Umbraco.Core/PropertyEditors/LegacyPropertyEditorIdToAliasConverter.cs index de6a263aaa..4669dcf18f 100644 --- a/src/Umbraco.Core/PropertyEditors/LegacyPropertyEditorIdToAliasConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/LegacyPropertyEditorIdToAliasConverter.cs @@ -105,47 +105,47 @@ namespace Umbraco.Core.PropertyEditors /// internal static void CreateMappingsForCoreEditors() { - CreateMap(Guid.Parse(Constants.PropertyEditors.CheckBoxList), Constants.PropertyEditors.CheckBoxListAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.ColorPicker), Constants.PropertyEditors.ColorPickerAlias); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.CheckBoxList), Constants.PropertyEditors.Aliases.CheckBoxList); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.ColorPicker), Constants.PropertyEditors.Aliases.ColorPicker); CreateMap(Guid.Parse(Constants.PropertyEditors.ContentPicker), Constants.PropertyEditors.ContentPickerAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.Date), Constants.PropertyEditors.DateAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.DateTime), Constants.PropertyEditors.DateTimeAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.DropDownList), Constants.PropertyEditors.DropDownListAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.DropDownListMultiple), Constants.PropertyEditors.DropDownListMultipleAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.DropdownlistMultiplePublishKeys), Constants.PropertyEditors.DropdownlistMultiplePublishKeysAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.DropdownlistPublishingKeys), Constants.PropertyEditors.DropdownlistPublishingKeysAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.FolderBrowser), Constants.PropertyEditors.FolderBrowserAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.Integer), Constants.PropertyEditors.IntegerAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.ListView), Constants.PropertyEditors.ListViewAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.MacroContainer), Constants.PropertyEditors.MacroContainerAlias); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.Date), Constants.PropertyEditors.Aliases.Date); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.DateTime), Constants.PropertyEditors.Aliases.DateTime); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.DropDownList), Constants.PropertyEditors.Aliases.DropDownList); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.DropDownListMultiple), Constants.PropertyEditors.Aliases.DropDownListMultiple); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.DropdownlistMultiplePublishKeys), Constants.PropertyEditors.Aliases.DropdownlistMultiplePublishKeys); + CreateMap(Guid.Parse(Constants.PropertyEditors.DropdownlistPublishingKeys), Constants.PropertyEditors.Aliases.DropdownlistPublishKeys); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.FolderBrowser), Constants.PropertyEditors.Aliases.FolderBrowser); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.Integer), Constants.PropertyEditors.Aliases.Integer); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.ListView), Constants.PropertyEditors.Aliases.ListView); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.MacroContainer), Constants.PropertyEditors.Aliases.MacroContainer); CreateMap(Guid.Parse(Constants.PropertyEditors.MediaPicker), Constants.PropertyEditors.MediaPickerAlias); CreateMap(Guid.Parse(Constants.PropertyEditors.MemberPicker), Constants.PropertyEditors.MemberPickerAlias); CreateMap(Guid.Parse(Constants.PropertyEditors.MultiNodeTreePicker), Constants.PropertyEditors.MultiNodeTreePickerAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.MultipleTextstring), Constants.PropertyEditors.MultipleTextstringAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.NoEdit), Constants.PropertyEditors.NoEditAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.RadioButtonList), Constants.PropertyEditors.RadioButtonListAlias); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.MultipleTextstring), Constants.PropertyEditors.Aliases.MultipleTextstring); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.NoEdit), Constants.PropertyEditors.Aliases.NoEdit); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.RadioButtonList), Constants.PropertyEditors.Aliases.RadioButtonList); CreateMap(Guid.Parse(Constants.PropertyEditors.RelatedLinks), Constants.PropertyEditors.RelatedLinksAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.Slider), Constants.PropertyEditors.SliderAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.Tags), Constants.PropertyEditors.TagsAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.Textbox), Constants.PropertyEditors.TextboxAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.TextboxMultiple), Constants.PropertyEditors.TextboxMultipleAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.TinyMCEv3), Constants.PropertyEditors.TinyMCEAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.TrueFalse), Constants.PropertyEditors.TrueFalseAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.UserPicker), Constants.PropertyEditors.UserPickerAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.UploadField), Constants.PropertyEditors.UploadFieldAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.XPathCheckBoxList), Constants.PropertyEditors.XPathCheckBoxListAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.XPathDropDownList), Constants.PropertyEditors.XPathDropDownListAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.ImageCropper), Constants.PropertyEditors.ImageCropperAlias); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.Slider), Constants.PropertyEditors.Aliases.Slider); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.Tags), Constants.PropertyEditors.Aliases.Tags); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.Textbox), Constants.PropertyEditors.Aliases.Textbox); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.TextboxMultiple), Constants.PropertyEditors.Aliases.TextboxMultiple); + CreateMap(Guid.Parse(Constants.PropertyEditors.TinyMCEv3), Constants.PropertyEditors.Aliases.TinyMce); + CreateMap(Guid.Parse(Constants.PropertyEditors.TrueFalse), Constants.PropertyEditors.Aliases.Boolean); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.UserPicker), Constants.PropertyEditors.Aliases.UserPicker); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.UploadField), Constants.PropertyEditors.Aliases.UploadField); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.XPathCheckBoxList), Constants.PropertyEditors.Aliases.XPathCheckBoxList); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.XPathDropDownList), Constants.PropertyEditors.Aliases.XPathDropDownList); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.ImageCropper), Constants.PropertyEditors.Aliases.ImageCropper); //Being mapped to different editors //TODO: Map this somewhere! - CreateMap(Guid.Parse(Constants.PropertyEditors.PickerRelations), Constants.PropertyEditors.PickerRelationsAlias); + CreateMap(Guid.Parse(Constants.PropertyEditors.Aliases.PickerRelations), Constants.PropertyEditors.Aliases.PickerRelations); CreateMap(Guid.Parse(Constants.PropertyEditors.UltimatePicker), Constants.PropertyEditors.ContentPickerAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.UltraSimpleEditor), Constants.PropertyEditors.MarkdownEditorAlias); + CreateMap(Guid.Parse(Constants.PropertyEditors.UltraSimpleEditor), Constants.PropertyEditors.Aliases.MarkdownEditor); //Not being converted - convert to label - CreateMap(Guid.Parse(Constants.PropertyEditors.DictionaryPicker), Constants.PropertyEditors.NoEditAlias); - CreateMap(Guid.Parse(Constants.PropertyEditors.UmbracoUserControlWrapper), Constants.PropertyEditors.NoEditAlias); + CreateMap(Guid.Parse(Constants.PropertyEditors.DictionaryPicker), Constants.PropertyEditors.Aliases.NoEdit); + CreateMap(Guid.Parse(Constants.PropertyEditors.UmbracoUserControlWrapper), Constants.PropertyEditors.Aliases.NoEdit); } diff --git a/src/Umbraco.Core/PropertyEditors/PreValueEditor.cs b/src/Umbraco.Core/PropertyEditors/PreValueEditor.cs index 01c654553a..c8d5a76685 100644 --- a/src/Umbraco.Core/PropertyEditors/PreValueEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/PreValueEditor.cs @@ -23,13 +23,13 @@ namespace Umbraco.Core.PropertyEditors { public PreValueEditor() { - var fields = new List(); + var fields = new List(); //the ctor checks if we have PreValueFieldAttributes applied and if so we construct our fields from them var props = TypeHelper.CachedDiscoverableProperties(GetType()).Where(x => x.Name != "Fields"); foreach (var p in props) { - var att = p.GetCustomAttributes(typeof (PreValueFieldAttribute), false).OfType().SingleOrDefault(); + var att = p.GetCustomAttributes(typeof (DataTypeConfigurationFieldAttribute), false).OfType().SingleOrDefault(); if (att == null) continue; if (att.PreValueFieldType != null) @@ -38,7 +38,7 @@ namespace Umbraco.Core.PropertyEditors try { // instanciate and add custom field - var instance = (PreValueField) Activator.CreateInstance(att.PreValueFieldType); + var instance = (DataTypeConfigurationField) Activator.CreateInstance(att.PreValueFieldType); fields.Add(instance); // overwrite values if they are assigned @@ -75,9 +75,9 @@ namespace Umbraco.Core.PropertyEditors Fields = fields; } - private static PreValueField MapAttributeToField(PreValueFieldAttribute att, PropertyInfo prop) + private static DataTypeConfigurationField MapAttributeToField(DataTypeConfigurationFieldAttribute att, PropertyInfo prop) { - return new PreValueField + return new DataTypeConfigurationField { //set the key to the property name if it is empty Key = att.Key.IsNullOrWhiteSpace() ? prop.Name : att.Key, @@ -95,7 +95,7 @@ namespace Umbraco.Core.PropertyEditors /// If fields are specified then the master View and Validators will be ignored /// [JsonProperty("fields")] - public List Fields { get; internal set; } + public List Fields { get; internal set; } /// /// A method to format the posted values from the editor to the values to be persisted diff --git a/src/Umbraco.Core/PropertyEditors/PreValueField.cs b/src/Umbraco.Core/PropertyEditors/PreValueField.cs deleted file mode 100644 index ea21677f52..0000000000 --- a/src/Umbraco.Core/PropertyEditors/PreValueField.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System.Collections.Generic; -using Newtonsoft.Json; -using Umbraco.Core.IO; -using Umbraco.Core.Manifest; - -namespace Umbraco.Core.PropertyEditors -{ - /// - /// Defines a pre value editable field - /// - public class PreValueField - { - private string _view; - - /// - /// Standard constructor - /// - public PreValueField() - { - Validators = new List(); - Config = new Dictionary(); - - //check for an attribute and fill the values - var att = GetType().GetCustomAttribute(false); - if (att != null) - { - Name = att.Name; - Description = att.Description; - HideLabel = att.HideLabel; - Key = att.Key; - View = att.View; - } - } - - /// - /// Constructor used to set validators instead of adding them later - /// - /// - public PreValueField(params IPropertyValidator[] validators) - : this() - { - foreach (var v in validators) - { - Validators.Add(v); - } - } - - /// - /// The name to display for this pre-value field - /// - [JsonProperty("label", Required = Required.Always)] - public string Name { get; set; } - - /// - /// The description to display for this pre-value field - /// - [JsonProperty("description")] - public string Description { get; set; } - - /// - /// Specifies whether to hide the label for the pre-value - /// - [JsonProperty("hideLabel")] - public bool HideLabel { get; set; } - - /// - /// The key to store the pre-value against - /// - [JsonProperty("key", Required = Required.Always)] - public string Key { get; set; } - - /// - /// Defines the view to use for the editor, this can be one of 3 things: - /// * the full virtual path or - /// * the relative path to the current Umbraco folder - /// * a simple view name which will map to the views/prevalueeditors/{view}.html - /// - [JsonProperty("view", Required = Required.Always)] - public string View - { - get => _view; - set => _view = IOHelper.ResolveVirtualUrl(value); - } - - /// - /// A collection of validators for the pre value field - /// - [JsonProperty("validation", ItemConverterType = typeof(ManifestValidatorConverter))] - public List Validators { get; private set; } - - /// - /// This allows for custom configuration to be injected into the pre-value editor - /// - [JsonProperty("config")] - public IDictionary Config { get; set; } - } -} diff --git a/src/Umbraco.Core/PropertyEditors/PreValueFieldAttribute.cs b/src/Umbraco.Core/PropertyEditors/PreValueFieldAttribute.cs deleted file mode 100644 index 4e77caabb1..0000000000 --- a/src/Umbraco.Core/PropertyEditors/PreValueFieldAttribute.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; - -namespace Umbraco.Core.PropertyEditors -{ - /// - /// Allows for specifying an attribute on a property of a custm PreValueEditor to be included in the field list. OTherwise it can be attributed - /// on a custom implemention of a PreValueField to have the properties auto-filled. - /// - [AttributeUsage(AttributeTargets.Property | AttributeTargets.Class, AllowMultiple = false)] - public class PreValueFieldAttribute : Attribute - { - /// - /// Used when specifying a PreValueFieldType - /// - public PreValueFieldAttribute(Type preValueFieldType) - { - PreValueFieldType = preValueFieldType; - } - - public PreValueFieldAttribute(string key, string name, string view) - { - Key = key; - Name = name; - View = view; - } - - public PreValueFieldAttribute(string name, string view) - { - Name = name; - View = view; - } - - /// - /// The description to display for the pre-value field - /// - public string Description { get; set; } - - /// - /// The key to store the pre-value against in the databaes - /// - /// - /// If this is not specified and the attribute is being used at the property level then the property name will become the key - /// - public string Key { get; private set; } - - /// - /// The name (label) of the pre-value field - /// - public string Name { get; private set; } - - /// - /// The view to use to render the pre-value field - /// - public string View { get; private set; } - - /// - /// Whether or not to hide the label for the pre-value field - /// - public bool HideLabel { get; set; } - - /// - /// This can be used when assigned to a property which will attempt to create the type - /// of PreValueField declared and assign it to the fields. Any property declared on this - /// attribute will get overwritten on the class that is instantiated. - /// - public Type PreValueFieldType { get; set; } - } -} diff --git a/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs b/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs index 14508e6aa4..e9c30810b8 100644 --- a/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs @@ -147,7 +147,7 @@ namespace Umbraco.Core.PropertyEditors /// /// Creates a configuration editor instance. /// - protected virtual PreValueEditor CreatePreValueEditor() + protected virtual PreValueEditor CreateConfigurationEditor() { // handle assigned editor if (_preValueEditorAssigned != null) @@ -189,7 +189,7 @@ namespace Umbraco.Core.PropertyEditors /// /// Maps configuration to a strongly typed object. /// - public virtual object DeserializeConfiguration(string json) + public virtual object DeserializeConfiguration(string json) // fixme { return JsonConvert.DeserializeObject>(json); } diff --git a/src/Umbraco.Core/PropertyEditors/PropertyValueEditor.cs b/src/Umbraco.Core/PropertyEditors/PropertyValueEditor.cs index fda3d7d77f..1b90454522 100644 --- a/src/Umbraco.Core/PropertyEditors/PropertyValueEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/PropertyValueEditor.cs @@ -8,6 +8,7 @@ using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; +using Umbraco.Core.PropertyEditors.Validators; using Umbraco.Core.Services; namespace Umbraco.Core.PropertyEditors diff --git a/src/Umbraco.Core/PropertyEditors/SliderPropertyEditorConfiguration.cs b/src/Umbraco.Core/PropertyEditors/SliderPropertyEditorConfiguration.cs new file mode 100644 index 0000000000..974f9bfab0 --- /dev/null +++ b/src/Umbraco.Core/PropertyEditors/SliderPropertyEditorConfiguration.cs @@ -0,0 +1,10 @@ +using Newtonsoft.Json; + +namespace Umbraco.Core.PropertyEditors +{ + public class SliderPropertyEditorConfiguration + { + [JsonProperty("enableRange")] + public bool EnableRange { get; set; } + } +} diff --git a/src/Umbraco.Core/PropertyEditors/TagPropertyDefinition.cs b/src/Umbraco.Core/PropertyEditors/TagPropertyDefinition.cs index 4d9bc0e3d4..2c11ca387c 100644 --- a/src/Umbraco.Core/PropertyEditors/TagPropertyDefinition.cs +++ b/src/Umbraco.Core/PropertyEditors/TagPropertyDefinition.cs @@ -1,4 +1,5 @@ -using Umbraco.Core.Models; +using System; +using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; namespace Umbraco.Core.PropertyEditors @@ -32,15 +33,15 @@ namespace Umbraco.Core.PropertyEditors ReplaceTags = tagsAttribute.ReplaceTags; TagGroup = tagsAttribute.TagGroup; - var preValues = propertySaving.PreValues.PreValuesAsDictionary; - StorageType = preValues.ContainsKey("storageType") && preValues["storageType"].Value == TagCacheStorageType.Json.ToString() ? - TagCacheStorageType.Json : TagCacheStorageType.Csv; + if (!(propertySaving.DataTypeConfiguration is TagsPropertyEditorConfiguration configuration)) + throw new InvalidCastException($"Cannot cast configuration of type {propertySaving.DataTypeConfiguration.GetType().Name} to {typeof(TagsPropertyEditorConfiguration).Name}."); + StorageType = configuration.StorageType; } /// /// Defines how to store the tags in cache (CSV or Json) /// - public virtual TagCacheStorageType StorageType { get; private set; } + public virtual TagCacheStorageType StorageType { get; } /// /// Defines a custom delimiter, the default is a comma diff --git a/src/Umbraco.Core/PropertyEditors/TagsPropertyEditorConfiguration.cs b/src/Umbraco.Core/PropertyEditors/TagsPropertyEditorConfiguration.cs new file mode 100644 index 0000000000..7597306f14 --- /dev/null +++ b/src/Umbraco.Core/PropertyEditors/TagsPropertyEditorConfiguration.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Umbraco.Core.Models; + +namespace Umbraco.Core.PropertyEditors +{ + public class TagsPropertyEditorConfiguration + { + public string Group { get; set; } = "default"; + + public TagCacheStorageType StorageType { get; set; } = TagCacheStorageType.Csv; + } +} diff --git a/src/Umbraco.Core/PropertyEditors/DecimalValidator.cs b/src/Umbraco.Core/PropertyEditors/Validators/DecimalValidator.cs similarity index 94% rename from src/Umbraco.Core/PropertyEditors/DecimalValidator.cs rename to src/Umbraco.Core/PropertyEditors/Validators/DecimalValidator.cs index 58a2bf0dfb..919cecbd8e 100644 --- a/src/Umbraco.Core/PropertyEditors/DecimalValidator.cs +++ b/src/Umbraco.Core/PropertyEditors/Validators/DecimalValidator.cs @@ -1,8 +1,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using Umbraco.Core.Models; -namespace Umbraco.Core.PropertyEditors +namespace Umbraco.Core.PropertyEditors.Validators { /// /// A validator that validates that the value is a valid decimal diff --git a/src/Umbraco.Core/PropertyEditors/DelimitedManifestValueValidator.cs b/src/Umbraco.Core/PropertyEditors/Validators/DelimitedManifestValueValidator.cs similarity index 94% rename from src/Umbraco.Core/PropertyEditors/DelimitedManifestValueValidator.cs rename to src/Umbraco.Core/PropertyEditors/Validators/DelimitedManifestValueValidator.cs index 4954b495d8..179628bea0 100644 --- a/src/Umbraco.Core/PropertyEditors/DelimitedManifestValueValidator.cs +++ b/src/Umbraco.Core/PropertyEditors/Validators/DelimitedManifestValueValidator.cs @@ -1,62 +1,61 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Umbraco.Core.Models; - -namespace Umbraco.Core.PropertyEditors -{ - /// - /// A validator that validates a delimited set of values against a common regex - /// - [ValueValidator("Delimited")] - internal sealed class DelimitedManifestValueValidator : ManifestValueValidator - { - /// - public override IEnumerable Validate(object value, string validatorConfiguration, object dataTypeConfiguration, PropertyEditor editor) - { - //TODO: localize these! - if (value != null) - { - var delimiter = ","; - Regex regex = null; - if (validatorConfiguration.IsNullOrWhiteSpace() == false) - { - var json = JsonConvert.DeserializeObject(validatorConfiguration); - if (json["delimiter"] != null) - { - delimiter = json["delimiter"].ToString(); - } - if (json["pattern"] != null) - { - var regexPattern = json["pattern"].ToString(); - regex = new Regex(regexPattern); - } - } - - var stringVal = value.ToString(); - var split = stringVal.Split(new[] { delimiter }, StringSplitOptions.RemoveEmptyEntries); - for (var i = 0; i < split.Length; i++) - { - var s = split[i]; - //next if we have a regex statement validate with that - if (regex != null) - { - if (regex.IsMatch(s) == false) - { - yield return new ValidationResult("The item at index " + i + " did not match the expression " + regex, - new[] - { - //make the field name called 'value0' where 0 is the index - "value" + i - }); - } - } - } - } - - } - } -} +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Umbraco.Core.PropertyEditors.Validators +{ + /// + /// A validator that validates a delimited set of values against a common regex + /// + [ValueValidator("Delimited")] + internal sealed class DelimitedManifestValueValidator : ManifestValueValidator + { + /// + public override IEnumerable Validate(object value, string validatorConfiguration, object dataTypeConfiguration, PropertyEditor editor) + { + //TODO: localize these! + if (value != null) + { + var delimiter = ","; + Regex regex = null; + if (validatorConfiguration.IsNullOrWhiteSpace() == false) + { + var json = JsonConvert.DeserializeObject(validatorConfiguration); + if (json["delimiter"] != null) + { + delimiter = json["delimiter"].ToString(); + } + if (json["pattern"] != null) + { + var regexPattern = json["pattern"].ToString(); + regex = new Regex(regexPattern); + } + } + + var stringVal = value.ToString(); + var split = stringVal.Split(new[] { delimiter }, StringSplitOptions.RemoveEmptyEntries); + for (var i = 0; i < split.Length; i++) + { + var s = split[i]; + //next if we have a regex statement validate with that + if (regex != null) + { + if (regex.IsMatch(s) == false) + { + yield return new ValidationResult("The item at index " + i + " did not match the expression " + regex, + new[] + { + //make the field name called 'value0' where 0 is the index + "value" + i + }); + } + } + } + } + + } + } +} diff --git a/src/Umbraco.Core/PropertyEditors/EmailValidator.cs b/src/Umbraco.Core/PropertyEditors/Validators/EmailValidator.cs similarity index 91% rename from src/Umbraco.Core/PropertyEditors/EmailValidator.cs rename to src/Umbraco.Core/PropertyEditors/Validators/EmailValidator.cs index 3041585187..43cb982b31 100644 --- a/src/Umbraco.Core/PropertyEditors/EmailValidator.cs +++ b/src/Umbraco.Core/PropertyEditors/Validators/EmailValidator.cs @@ -1,33 +1,32 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using Umbraco.Core.Models; - -namespace Umbraco.Core.PropertyEditors -{ - /// - /// A validator that validates an email address - /// - [ValueValidator("Email")] - internal sealed class EmailValidator : ManifestValueValidator, IPropertyValidator - { - /// - public override IEnumerable Validate(object value, string validatorConfiguration, object dataTypeConfiguration, PropertyEditor editor) - { - var asString = value.ToString(); - - var emailVal = new EmailAddressAttribute(); - - if (asString != string.Empty && emailVal.IsValid(asString) == false) - { - // TODO: localize these! - yield return new ValidationResult("Email is invalid", new[] { "value" }); - } - } - - /// - public IEnumerable Validate(object value, object dataTypeConfiguration, PropertyEditor editor) - { - return this.Validate(value, null, dataTypeConfiguration, editor); - } - } -} +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace Umbraco.Core.PropertyEditors.Validators +{ + /// + /// A validator that validates an email address + /// + [ValueValidator("Email")] + internal sealed class EmailValidator : ManifestValueValidator, IPropertyValidator + { + /// + public override IEnumerable Validate(object value, string validatorConfiguration, object dataTypeConfiguration, PropertyEditor editor) + { + var asString = value.ToString(); + + var emailVal = new EmailAddressAttribute(); + + if (asString != string.Empty && emailVal.IsValid(asString) == false) + { + // TODO: localize these! + yield return new ValidationResult("Email is invalid", new[] { "value" }); + } + } + + /// + public IEnumerable Validate(object value, object dataTypeConfiguration, PropertyEditor editor) + { + return this.Validate(value, null, dataTypeConfiguration, editor); + } + } +} diff --git a/src/Umbraco.Core/PropertyEditors/IntegerValidator.cs b/src/Umbraco.Core/PropertyEditors/Validators/IntegerValidator.cs similarity index 91% rename from src/Umbraco.Core/PropertyEditors/IntegerValidator.cs rename to src/Umbraco.Core/PropertyEditors/Validators/IntegerValidator.cs index b8d94f09e1..3a7c4b1a7f 100644 --- a/src/Umbraco.Core/PropertyEditors/IntegerValidator.cs +++ b/src/Umbraco.Core/PropertyEditors/Validators/IntegerValidator.cs @@ -1,30 +1,29 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using Umbraco.Core.Models; - -namespace Umbraco.Core.PropertyEditors -{ - /// - /// A validator that validates that the value is a valid integer - /// - [ValueValidator("Integer")] - internal sealed class IntegerValidator : ManifestValueValidator, IPropertyValidator - { - public override IEnumerable Validate(object value, string validatorConfiguration, object dataTypeConfiguration, PropertyEditor editor) - { - if (value != null && value.ToString() != string.Empty) - { - var result = value.TryConvertTo(); - if (result.Success == false) - { - yield return new ValidationResult("The value " + value + " is not a valid integer", new[] { "value" }); - } - } - } - - public IEnumerable Validate(object value, object dataTypeConfiguration, PropertyEditor editor) - { - return Validate(value, "", dataTypeConfiguration, editor); - } - } -} +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace Umbraco.Core.PropertyEditors.Validators +{ + /// + /// A validator that validates that the value is a valid integer + /// + [ValueValidator("Integer")] + internal sealed class IntegerValidator : ManifestValueValidator, IPropertyValidator + { + public override IEnumerable Validate(object value, string validatorConfiguration, object dataTypeConfiguration, PropertyEditor editor) + { + if (value != null && value.ToString() != string.Empty) + { + var result = value.TryConvertTo(); + if (result.Success == false) + { + yield return new ValidationResult("The value " + value + " is not a valid integer", new[] { "value" }); + } + } + } + + public IEnumerable Validate(object value, object dataTypeConfiguration, PropertyEditor editor) + { + return Validate(value, "", dataTypeConfiguration, editor); + } + } +} diff --git a/src/Umbraco.Core/PropertyEditors/RegexValidator.cs b/src/Umbraco.Core/PropertyEditors/Validators/RegexValidator.cs similarity index 94% rename from src/Umbraco.Core/PropertyEditors/RegexValidator.cs rename to src/Umbraco.Core/PropertyEditors/Validators/RegexValidator.cs index c35cb00344..c457466cd0 100644 --- a/src/Umbraco.Core/PropertyEditors/RegexValidator.cs +++ b/src/Umbraco.Core/PropertyEditors/Validators/RegexValidator.cs @@ -1,66 +1,65 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Text.RegularExpressions; -using Umbraco.Core.Models; - -namespace Umbraco.Core.PropertyEditors -{ - /// - /// A validator that validates that the value against a Regex expression - /// - [ValueValidator("Regex")] - internal sealed class RegexValidator : ManifestValueValidator, IPropertyValidator - { - private readonly string _regex; - - /// - /// Normally used when configured as a ManifestValueValidator - /// - public RegexValidator() - { - } - - /// - /// Normally used when configured as an IPropertyValidator - /// - /// - public RegexValidator(string regex) - { - _regex = regex ?? throw new ArgumentNullException(nameof(regex)); - } - - public override IEnumerable Validate(object value, string validatorConfiguration, object dataTypeConfiguration, PropertyEditor editor) - { - //TODO: localize these! - if (validatorConfiguration.IsNullOrWhiteSpace() == false && value != null) - { - var asString = value.ToString(); - - var regex = new Regex(validatorConfiguration); - - if (regex.IsMatch(asString) == false) - { - yield return new ValidationResult("Value is invalid, it does not match the correct pattern", new[] { "value" }); - } - } - - } - - /// - /// Used when configured as an IPropertyValidator - /// - /// - /// - /// - /// - public IEnumerable Validate(object value, object dataTypeConfiguration, PropertyEditor editor) - { - if (_regex == null) - { - throw new InvalidOperationException("This validator is not configured as a " + typeof(IPropertyValidator)); - } - return Validate(value, _regex, dataTypeConfiguration, editor); - } - } -} +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Text.RegularExpressions; + +namespace Umbraco.Core.PropertyEditors.Validators +{ + /// + /// A validator that validates that the value against a Regex expression + /// + [ValueValidator("Regex")] + internal sealed class RegexValidator : ManifestValueValidator, IPropertyValidator + { + private readonly string _regex; + + /// + /// Normally used when configured as a ManifestValueValidator + /// + public RegexValidator() + { + } + + /// + /// Normally used when configured as an IPropertyValidator + /// + /// + public RegexValidator(string regex) + { + _regex = regex ?? throw new ArgumentNullException(nameof(regex)); + } + + public override IEnumerable Validate(object value, string validatorConfiguration, object dataTypeConfiguration, PropertyEditor editor) + { + //TODO: localize these! + if (validatorConfiguration.IsNullOrWhiteSpace() == false && value != null) + { + var asString = value.ToString(); + + var regex = new Regex(validatorConfiguration); + + if (regex.IsMatch(asString) == false) + { + yield return new ValidationResult("Value is invalid, it does not match the correct pattern", new[] { "value" }); + } + } + + } + + /// + /// Used when configured as an IPropertyValidator + /// + /// + /// + /// + /// + public IEnumerable Validate(object value, object dataTypeConfiguration, PropertyEditor editor) + { + if (_regex == null) + { + throw new InvalidOperationException("This validator is not configured as a " + typeof(IPropertyValidator)); + } + return Validate(value, _regex, dataTypeConfiguration, editor); + } + } +} diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/CheckboxListValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/CheckboxListValueConverter.cs index 5dd16ed69e..4062ed7311 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/CheckboxListValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/CheckboxListValueConverter.cs @@ -11,7 +11,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters private static readonly char[] Comma = { ',' }; public override bool IsConverter(PublishedPropertyType propertyType) - => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.CheckBoxListAlias); + => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.CheckBoxList); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (IEnumerable); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs index fa21b83a0f..9e0ec37f5b 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs @@ -7,7 +7,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public class ColorPickerValueConverter : PropertyValueConverterBase { public override bool IsConverter(PublishedPropertyType propertyType) - => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.ColorPickerAlias); + => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.ColorPicker); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (string); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs index 6ffe57151e..fc8b6bf7ee 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs @@ -10,8 +10,8 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters { private static readonly string[] PropertyEditorAliases = { - Constants.PropertyEditors.DateTimeAlias, - Constants.PropertyEditors.DateAlias + Constants.PropertyEditors.Aliases.DateTime, + Constants.PropertyEditors.Aliases.Date }; public override bool IsConverter(PublishedPropertyType propertyType) diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DecimalValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DecimalValueConverter.cs index b42f1e785d..a20694770c 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DecimalValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DecimalValueConverter.cs @@ -8,7 +8,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public class DecimalValueConverter : PropertyValueConverterBase { public override bool IsConverter(PublishedPropertyType propertyType) - => Constants.PropertyEditors.DecimalAlias.Equals(propertyType.EditorAlias); + => Constants.PropertyEditors.Aliases.Decimal.Equals(propertyType.EditorAlias); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (decimal); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleValueConverter.cs index 3815e00e01..d91f45292c 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleValueConverter.cs @@ -9,7 +9,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public class DropdownListMultipleValueConverter : PropertyValueConverterBase { public override bool IsConverter(PublishedPropertyType propertyType) - => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.DropDownListMultipleAlias); + => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.DropDownListMultiple); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (IEnumerable); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleWithKeysValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleWithKeysValueConverter.cs index b20261de60..bceebc232b 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleWithKeysValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleWithKeysValueConverter.cs @@ -9,7 +9,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public class DropdownListMultipleWithKeysValueConverter : PropertyValueConverterBase { public override bool IsConverter(PublishedPropertyType propertyType) - => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.DropdownlistMultiplePublishKeysAlias); + => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.DropdownlistMultiplePublishKeys); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (IEnumerable); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListValueConverter.cs index 5134bd3ab8..5fe1967f32 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListValueConverter.cs @@ -7,7 +7,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public class DropdownListValueConverter : PropertyValueConverterBase { public override bool IsConverter(PublishedPropertyType propertyType) - => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.DropDownListAlias); + => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.DropDownList); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (string); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListWithKeysValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListWithKeysValueConverter.cs index 7bda5332fe..960cd4afa6 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListWithKeysValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListWithKeysValueConverter.cs @@ -7,7 +7,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public class DropdownListWithKeysValueConverter : PropertyValueConverterBase { public override bool IsConverter(PublishedPropertyType propertyType) - => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.DropdownlistPublishingKeysAlias); + => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.DropdownlistPublishKeys); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (int); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/EmailAddressValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/EmailAddressValueConverter.cs index 6458c294e4..e4ef3a50a3 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/EmailAddressValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/EmailAddressValueConverter.cs @@ -7,7 +7,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public class EmailAddressValueConverter : PropertyValueConverterBase { public override bool IsConverter(PublishedPropertyType propertyType) - => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.EmailAddressAlias); + => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.EmailAddress); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (string); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs index 4cc93d67a8..2350c73567 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs @@ -20,7 +20,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public class GridValueConverter : JsonValueConverter { public override bool IsConverter(PublishedPropertyType propertyType) - => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.GridAlias); + => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.Grid); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (JToken); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs index 2a845bf127..3931975f69 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs @@ -5,6 +5,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Umbraco.Core.Composing; using Umbraco.Core.Logging; +using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.Services; @@ -13,13 +14,13 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters /// /// This ensures that the cropper config (pre-values/crops) are merged in with the front-end value. /// - [DefaultPropertyValueConverter(typeof (JsonValueConverter))] //this shadows the JsonValueConverter - public class ImageCropperValueConverter : JsonValueConverter + [DefaultPropertyValueConverter] + public class ImageCropperValueConverter : PropertyValueConverterBase { private readonly IDataTypeService _dataTypeService; public override bool IsConverter(PublishedPropertyType propertyType) - => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.ImageCropperAlias); + => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.ImageCropper); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (JToken); @@ -37,60 +38,37 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters _dataTypeService = dataTypeService ?? throw new ArgumentNullException(nameof(dataTypeService)); } - internal static void MergePreValues(JObject currentValue, IDataTypeService dataTypeService, int dataTypeId) + // represents the editor value (the one that is serialized to Json) + internal class ImageCropperValue : ImageCropperEditorConfiguration { - //need to lookup the pre-values for this data type - //TODO: Change all singleton access to use ctor injection in v8!!! - var dt = dataTypeService.GetPreValuesCollectionByDataTypeId(dataTypeId); + [JsonProperty("src")] + public string Src { get; set; } + } - if (dt != null && dt.IsDictionaryBased && dt.PreValuesAsDictionary.ContainsKey("crops")) + internal static void MergeConfiguration(ImageCropperValue value, IDataTypeService dataTypeService, int dataTypeId) + { + // merge the crop values - the alias + width + height comes from + // configuration, but each crop can store its own coordinates + + var configuration = dataTypeService.GetDataType(dataTypeId).ConfigurationAs(); + var configuredCrops = configuration.Crops; + var crops = value.Crops.ToList(); + + foreach (var configuredCrop in configuredCrops) { - var cropsString = dt.PreValuesAsDictionary["crops"].Value; - JArray preValueCrops; - try + var crop = crops.FirstOrDefault(x => x.Alias == configuredCrop.Alias); + if (crop != null) { - preValueCrops = JsonConvert.DeserializeObject(cropsString); - } - catch (Exception ex) - { - Current.Logger.Error("Could not parse the string " + cropsString + " to a json object", ex); - return; - } - - //now we need to merge the crop values - the alias + width + height comes from pre-configured pre-values, - // however, each crop can store it's own coordinates - - JArray existingCropsArray; - if (currentValue["crops"] != null) - { - existingCropsArray = (JArray)currentValue["crops"]; + crop.Width = configuredCrop.Width; + crop.Height = configuredCrop.Height; } else { - currentValue["crops"] = existingCropsArray = new JArray(); - } - - foreach (var preValueCrop in preValueCrops.Where(x => x.HasValues)) - { - var found = existingCropsArray.FirstOrDefault(x => - { - if (x.HasValues && x["alias"] != null) - { - return x["alias"].Value() == preValueCrop["alias"].Value(); - } - return false; - }); - if (found != null) - { - found["width"] = preValueCrop["width"]; - found["height"] = preValueCrop["height"]; - } - else - { - existingCropsArray.Add(preValueCrop); - } + crops.Add(configuredCrop); } } + + value.Crops = crops.ToArray(); } public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) @@ -98,30 +76,28 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters if (source == null) return null; var sourceString = source.ToString(); - if (sourceString.DetectIsJson()) + // not json, just return the string + // fixme how can that even work? + if (!sourceString.DetectIsJson()) + return sourceString; + + ImageCropperValue value; + try { - JObject obj; - try + value = JsonConvert.DeserializeObject(sourceString, new JsonSerializerSettings { - obj = JsonConvert.DeserializeObject(sourceString, new JsonSerializerSettings - { - Culture = CultureInfo.InvariantCulture, - FloatParseHandling = FloatParseHandling.Decimal - }); - } - catch (Exception ex) - { - Current.Logger.Error("Could not parse the string " + sourceString + " to a json object", ex); - return sourceString; - } - - MergePreValues(obj, _dataTypeService, propertyType.DataType.Id); - - return obj; + Culture = CultureInfo.InvariantCulture, + FloatParseHandling = FloatParseHandling.Decimal + }); + } + catch (Exception ex) + { + Current.Logger.Error($"Could not deserialize string \"{sourceString}\" into an image cropper value.", ex); + return sourceString; } - //it's not json, just return the string - return sourceString; + MergeConfiguration(value, _dataTypeService, propertyType.DataType.Id); + return value; } } } diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs index c663214608..c0933d8605 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs @@ -7,7 +7,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public class IntegerValueConverter : PropertyValueConverterBase { public override bool IsConverter(PublishedPropertyType propertyType) - => Constants.PropertyEditors.IntegerAlias.Equals(propertyType.EditorAlias); + => Constants.PropertyEditors.Aliases.Integer.Equals(propertyType.EditorAlias); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (int); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs index 63faf19375..039c1e34b2 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs @@ -16,7 +16,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public class LabelValueConverter : PropertyValueConverterBase { public override bool IsConverter(PublishedPropertyType propertyType) - => Constants.PropertyEditors.NoEditAlias.Equals(propertyType.EditorAlias); + => Constants.PropertyEditors.Aliases.NoEdit.Equals(propertyType.EditorAlias); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (string); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs index 8b6870ba46..b2c53e93e6 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs @@ -8,7 +8,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public class MarkdownEditorValueConverter : PropertyValueConverterBase { public override bool IsConverter(PublishedPropertyType propertyType) - => Constants.PropertyEditors.MarkdownEditorAlias.Equals(propertyType.EditorAlias); + => Constants.PropertyEditors.Aliases.MarkdownEditor.Equals(propertyType.EditorAlias); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (IHtmlString); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberGroupPickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberGroupPickerValueConverter.cs index 4b3965522e..bdd09ea33b 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberGroupPickerValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberGroupPickerValueConverter.cs @@ -7,7 +7,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public class MemberGroupPickerValueConverter : PropertyValueConverterBase { public override bool IsConverter(PublishedPropertyType propertyType) - => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.MemberGroupPickerAlias); + => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.MemberGroupPicker); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (string); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs index f581a68dea..db199eed05 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs @@ -10,7 +10,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public class MultipleTextStringValueConverter : PropertyValueConverterBase { public override bool IsConverter(PublishedPropertyType propertyType) - => Constants.PropertyEditors.MultipleTextstringAlias.Equals(propertyType.EditorAlias); + => Constants.PropertyEditors.Aliases.MultipleTextstring.Equals(propertyType.EditorAlias); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (IEnumerable); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/RadioButtonListValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/RadioButtonListValueConverter.cs index d71d72c980..362c88d08c 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/RadioButtonListValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/RadioButtonListValueConverter.cs @@ -7,7 +7,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public class RadioButtonListValueConverter : PropertyValueConverterBase { public override bool IsConverter(PublishedPropertyType propertyType) - => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.RadioButtonListAlias); + => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.RadioButtonList); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (int); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/SliderValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/SliderValueConverter.cs index 3bbd268de8..8e79e2273c 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/SliderValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/SliderValueConverter.cs @@ -19,7 +19,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters } public override bool IsConverter(PublishedPropertyType propertyType) - => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.SliderAlias); + => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.Slider); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => IsRangeDataType(propertyType.DataType.Id) ? typeof (Range) : typeof (decimal); @@ -72,14 +72,8 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters return Storages.GetOrAdd(dataTypeId, id => { var dataType = _dataTypeService.GetDataType(id); - var configuration = dataType.Configuration as SliderPropertyEditor.Configuration; // fixme - why is the converter in Core if the editor is in Web? - return configuration.IsRange; - var preValue = _dataTypeService.GetPreValuesCollectionByDataTypeId(id) - .PreValuesAsDictionary - .FirstOrDefault(x => string.Equals(x.Key, "enableRange", StringComparison.InvariantCultureIgnoreCase)) - .Value; - - return preValue != null && preValue.Value.TryConvertTo().Result; + var configuration = dataType.ConfigurationAs(); + return configuration.EnableRange; }); } diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/TagsValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/TagsValueConverter.cs index 4963aaf606..f9f3416154 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/TagsValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/TagsValueConverter.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.Services; @@ -20,7 +21,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters } public override bool IsConverter(PublishedPropertyType propertyType) - => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.TagsAlias); + => propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.Tags); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (IEnumerable); @@ -61,18 +62,15 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters /// private bool JsonStorageType(int dataTypeId) { + // fixme // GetPreValuesCollectionByDataTypeId is cached at repository level; // still, the collection is deep-cloned so this is kinda expensive, // better to cache here + trigger refresh in DataTypeCacheRefresher return Storages.GetOrAdd(dataTypeId, id => { - var preValue = _dataTypeService.GetPreValuesCollectionByDataTypeId(id) - .PreValuesAsDictionary - .FirstOrDefault(x => string.Equals(x.Key, "storageType", StringComparison.InvariantCultureIgnoreCase)) - .Value; - - return preValue != null && preValue.Value.InvariantEquals("json"); + var configuration = _dataTypeService.GetDataType(id).ConfigurationAs(); + return configuration.StorageType == TagCacheStorageType.Json; }); } diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/TextStringValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/TextStringValueConverter.cs index 5ec9ef2f3c..47b20326b4 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/TextStringValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/TextStringValueConverter.cs @@ -9,8 +9,8 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters { private static readonly string[] PropertyTypeAliases = { - Constants.PropertyEditors.TextboxAlias, - Constants.PropertyEditors.TextboxMultipleAlias + Constants.PropertyEditors.Aliases.Textbox, + Constants.PropertyEditors.Aliases.TextboxMultiple }; public override bool IsConverter(PublishedPropertyType propertyType) diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs index bb1f0ed78a..be7f4b07a2 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs @@ -11,7 +11,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public class TinyMceValueConverter : PropertyValueConverterBase { public override bool IsConverter(PublishedPropertyType propertyType) - => propertyType.EditorAlias == Constants.PropertyEditors.TinyMCEAlias; + => propertyType.EditorAlias == Constants.PropertyEditors.Aliases.TinyMce; public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (IHtmlString); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/UploadPropertyConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/UploadPropertyConverter.cs index 8ecdedad33..cfa247edaa 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/UploadPropertyConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/UploadPropertyConverter.cs @@ -10,7 +10,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public class UploadPropertyConverter : PropertyValueConverterBase { public override bool IsConverter(PublishedPropertyType propertyType) - => propertyType.EditorAlias.Equals(Constants.PropertyEditors.UploadFieldAlias); + => propertyType.EditorAlias.Equals(Constants.PropertyEditors.Aliases.UploadField); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (string); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs index 795d4e4abb..abb66dfa50 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs @@ -7,7 +7,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters public class YesNoValueConverter : PropertyValueConverterBase { public override bool IsConverter(PublishedPropertyType propertyType) - => propertyType.EditorAlias == Constants.PropertyEditors.TrueFalseAlias; + => propertyType.EditorAlias == Constants.PropertyEditors.Aliases.Boolean; public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (bool); diff --git a/src/Umbraco.Core/Runtime/CoreRuntimeComponent.cs b/src/Umbraco.Core/Runtime/CoreRuntimeComponent.cs index 4fa204a581..31fd21417f 100644 --- a/src/Umbraco.Core/Runtime/CoreRuntimeComponent.cs +++ b/src/Umbraco.Core/Runtime/CoreRuntimeComponent.cs @@ -18,12 +18,13 @@ using Umbraco.Core.Migrations.Install; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.Persistence; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.PropertyEditors.Validators; using Umbraco.Core.Scoping; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Core.Sync; using Umbraco.Core._Legacy.PackageActions; -using IntegerValidator = Umbraco.Core.PropertyEditors.IntegerValidator; +using IntegerValidator = Umbraco.Core.PropertyEditors.Validators.IntegerValidator; namespace Umbraco.Core.Runtime { @@ -54,7 +55,7 @@ namespace Umbraco.Core.Runtime composition.Container.RegisterSingleton(factory => factory.GetInstance().MvcViewsFileSystem, Constants.Composing.FileSystems.ViewFileSystem); composition.Container.RegisterSingleton(factory => factory.GetInstance().XsltFileSystem, Constants.Composing.FileSystems.XsltFileSystem); - // register manifest builder, will be injected in eg PropertyEditorCollectionBuilder + // register manifest parser, will be injected in collection builders where needed composition.Container.RegisterSingleton(); composition.Container.RegisterCollectionBuilder() diff --git a/src/Umbraco.Core/Serialization/JsonReadConverter.cs b/src/Umbraco.Core/Serialization/JsonReadConverter.cs index 18e93d4a14..b578a29bc0 100644 --- a/src/Umbraco.Core/Serialization/JsonReadConverter.cs +++ b/src/Umbraco.Core/Serialization/JsonReadConverter.cs @@ -1,10 +1,14 @@ using System; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Umbraco.Core.Exceptions; namespace Umbraco.Core.Serialization { - + /// + /// Provides a base class for custom implementations. + /// + /// The type of the converted object. internal abstract class JsonReadConverter : JsonConverter { /// @@ -15,11 +19,13 @@ namespace Umbraco.Core.Serialization /// protected abstract T Create(Type objectType, JObject jObject); + /// public override bool CanConvert(Type objectType) { - return typeof(T).IsAssignableFrom(objectType); + return typeof (T).IsAssignableFrom(objectType); } + /// public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { // Load JObject from stream @@ -39,9 +45,10 @@ namespace Umbraco.Core.Serialization serializer.Populate(jobject.CreateReader(), target); } + /// public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { - throw new NotSupportedException(); + throw new NotSupportedException("JsonReadConverter instances do not support writing."); } } } diff --git a/src/Umbraco.Core/Services/EntityXmlSerializer.cs b/src/Umbraco.Core/Services/EntityXmlSerializer.cs index 7c0de0b1eb..d06dd3675c 100644 --- a/src/Umbraco.Core/Services/EntityXmlSerializer.cs +++ b/src/Umbraco.Core/Services/EntityXmlSerializer.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.Linq; using System.Web; using System.Xml.Linq; +using Newtonsoft.Json; using Umbraco.Core.Composing; using Umbraco.Core.Models; using Umbraco.Core.Strings; @@ -135,28 +136,13 @@ namespace Umbraco.Core.Services public XElement Serialize(IDataTypeService dataTypeService, IDataType dataType) { - var prevalues = new XElement("PreValues"); - var prevalueList = dataTypeService.GetPreValuesCollectionByDataTypeId(dataType.Id) - .FormatAsDictionary(); - - var sort = 0; - foreach (var pv in prevalueList) - { - var prevalue = new XElement("PreValue"); - prevalue.Add(new XAttribute("Id", pv.Value.Id)); - prevalue.Add(new XAttribute("Value", pv.Value.Value ?? "")); - prevalue.Add(new XAttribute("Alias", pv.Key)); - prevalue.Add(new XAttribute("SortOrder", sort)); - prevalues.Add(prevalue); - sort++; - } - - var xml = new XElement("DataType", prevalues); + var xml = new XElement("DataType"); xml.Add(new XAttribute("Name", dataType.Name)); //The 'ID' when exporting is actually the property editor alias (in pre v7 it was the IDataType GUID id) xml.Add(new XAttribute("Id", dataType.EditorAlias)); xml.Add(new XAttribute("Definition", dataType.Key)); xml.Add(new XAttribute("DatabaseType", dataType.DatabaseType.ToString())); + xml.Add(new XAttribute("Configuration", JsonConvert.SerializeObject(dataType.Configuration))); var folderNames = string.Empty; if (dataType.Level != 1) diff --git a/src/Umbraco.Core/Services/Implement/MemberService.cs b/src/Umbraco.Core/Services/Implement/MemberService.cs index e976c8c430..71e454bf8f 100644 --- a/src/Umbraco.Core/Services/Implement/MemberService.cs +++ b/src/Umbraco.Core/Services/Implement/MemberService.cs @@ -1162,42 +1162,42 @@ namespace Umbraco.Core.Services.Implement Name = "Membership", Id = --identity }; - propGroup.PropertyTypes.Add(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, Constants.Conventions.Member.Comments) + propGroup.PropertyTypes.Add(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, Constants.Conventions.Member.Comments) { Name = Constants.Conventions.Member.CommentsLabel, SortOrder = 0, Id = --identity, Key = identity.ToGuid() }); - propGroup.PropertyTypes.Add(new PropertyType(Constants.PropertyEditors.TrueFalseAlias, DataTypeDatabaseType.Integer, Constants.Conventions.Member.IsApproved) + propGroup.PropertyTypes.Add(new PropertyType(Constants.PropertyEditors.Aliases.Boolean, DataTypeDatabaseType.Integer, Constants.Conventions.Member.IsApproved) { Name = Constants.Conventions.Member.IsApprovedLabel, SortOrder = 3, Id = --identity, Key = identity.ToGuid() }); - propGroup.PropertyTypes.Add(new PropertyType(Constants.PropertyEditors.TrueFalseAlias, DataTypeDatabaseType.Integer, Constants.Conventions.Member.IsLockedOut) + propGroup.PropertyTypes.Add(new PropertyType(Constants.PropertyEditors.Aliases.Boolean, DataTypeDatabaseType.Integer, Constants.Conventions.Member.IsLockedOut) { Name = Constants.Conventions.Member.IsLockedOutLabel, SortOrder = 4, Id = --identity, Key = identity.ToGuid() }); - propGroup.PropertyTypes.Add(new PropertyType(Constants.PropertyEditors.NoEditAlias, DataTypeDatabaseType.Date, Constants.Conventions.Member.LastLockoutDate) + propGroup.PropertyTypes.Add(new PropertyType(Constants.PropertyEditors.Aliases.NoEdit, DataTypeDatabaseType.Date, Constants.Conventions.Member.LastLockoutDate) { Name = Constants.Conventions.Member.LastLockoutDateLabel, SortOrder = 5, Id = --identity, Key = identity.ToGuid() }); - propGroup.PropertyTypes.Add(new PropertyType(Constants.PropertyEditors.NoEditAlias, DataTypeDatabaseType.Date, Constants.Conventions.Member.LastLoginDate) + propGroup.PropertyTypes.Add(new PropertyType(Constants.PropertyEditors.Aliases.NoEdit, DataTypeDatabaseType.Date, Constants.Conventions.Member.LastLoginDate) { Name = Constants.Conventions.Member.LastLoginDateLabel, SortOrder = 6, Id = --identity, Key = identity.ToGuid() }); - propGroup.PropertyTypes.Add(new PropertyType(Constants.PropertyEditors.NoEditAlias, DataTypeDatabaseType.Date, Constants.Conventions.Member.LastPasswordChangeDate) + propGroup.PropertyTypes.Add(new PropertyType(Constants.PropertyEditors.Aliases.NoEdit, DataTypeDatabaseType.Date, Constants.Conventions.Member.LastPasswordChangeDate) { Name = Constants.Conventions.Member.LastPasswordChangeDateLabel, SortOrder = 7, diff --git a/src/Umbraco.Core/Services/Implement/NotificationService.cs b/src/Umbraco.Core/Services/Implement/NotificationService.cs index ccc9e10bd4..0b57958724 100644 --- a/src/Umbraco.Core/Services/Implement/NotificationService.cs +++ b/src/Umbraco.Core/Services/Implement/NotificationService.cs @@ -385,7 +385,7 @@ namespace Umbraco.Core.Services.Implement // make sure to only highlight changes done using TinyMCE editor... other changes will be displayed using default summary // TODO: We should probably allow more than just tinymce?? - if ((p.PropertyType.PropertyEditorAlias == Constants.PropertyEditors.TinyMCEAlias) + if ((p.PropertyType.PropertyEditorAlias == Constants.PropertyEditors.Aliases.TinyMce) && string.CompareOrdinal(oldText, newText) != 0) { summary.Append(""); diff --git a/src/Umbraco.Core/Services/Implement/PackagingService.cs b/src/Umbraco.Core/Services/Implement/PackagingService.cs index 5263f3197e..e609cbce6a 100644 --- a/src/Umbraco.Core/Services/Implement/PackagingService.cs +++ b/src/Umbraco.Core/Services/Implement/PackagingService.cs @@ -21,6 +21,7 @@ using Umbraco.Core.Packaging.Models; using Umbraco.Core.Persistence.Dtos; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.Repositories; +using Umbraco.Core.PropertyEditors; using Umbraco.Core.Scoping; using Umbraco.Core.Strings; using Content = Umbraco.Core.Models.Content; @@ -49,6 +50,7 @@ namespace Umbraco.Core.Services.Implement private readonly IUserService _userService; private readonly IAuditRepository _auditRepository; private readonly IContentTypeRepository _contentTypeRepository; + private readonly PropertyEditorCollection _propertyEditors; public PackagingService( ILogger logger, @@ -63,7 +65,8 @@ namespace Umbraco.Core.Services.Implement IUserService userService, IScopeProvider scopeProvider, IEnumerable urlSegmentProviders, - IAuditRepository auditRepository, IContentTypeRepository contentTypeRepository) + IAuditRepository auditRepository, IContentTypeRepository contentTypeRepository + , PropertyEditorCollection propertyEditors) { _logger = logger; _contentService = contentService; @@ -78,6 +81,7 @@ namespace Umbraco.Core.Services.Implement _urlSegmentProviders = urlSegmentProviders; _auditRepository = auditRepository; _contentTypeRepository = contentTypeRepository; + _propertyEditors = propertyEditors; _userService = userService; _importedContentTypes = new Dictionary(); } @@ -270,7 +274,7 @@ namespace Umbraco.Core.Services.Implement if (propertyType != null) { - if (propertyType.PropertyEditorAlias == Constants.PropertyEditors.CheckBoxListAlias) + if (propertyType.PropertyEditorAlias == Constants.PropertyEditors.Aliases.CheckBoxList) { //TODO: We need to refactor this so the packager isn't making direct db calls for an 'edge' case @@ -724,7 +728,7 @@ namespace Umbraco.Core.Services.Implement property.Element("Type").Value.Trim())); //convert to a label! - dataTypeDefinition = _dataTypeService.GetByEditorAlias(Constants.PropertyEditors.NoEditAlias).FirstOrDefault(); + dataTypeDefinition = _dataTypeService.GetByEditorAlias(Constants.PropertyEditors.Aliases.NoEdit).FirstOrDefault(); //if for some odd reason this isn't there then ignore if (dataTypeDefinition == null) continue; } @@ -992,33 +996,31 @@ namespace Umbraco.Core.Services.Implement { foreach (var dataTypeElement in dataTypeElements) { - var prevaluesElement = dataTypeElement.Element("PreValues"); - if (prevaluesElement == null) continue; + var configurationAttribute = dataTypeElement.Attribute("Configuration"); + if (string.IsNullOrWhiteSpace(configurationAttribute?.Value)) continue; + + var dataTypeName = dataTypeElement.Attribute("Name")?.Value; + var dataType = dataTypes.FirstOrDefault(x => x.Name == dataTypeName); - var dataTypeDefinitionName = dataTypeElement.Attribute("Name").Value; - var dataTypeDefinition = dataTypes.FirstOrDefault(x => x.Name == dataTypeDefinitionName); - - if (dataTypeDefinition != null) + if (dataType == null) { - var valuesWithoutKeys = prevaluesElement.Elements("PreValue") - .Where(x => ((string) x.Attribute("Alias")).IsNullOrWhiteSpace()) - .Select(x => x.Attribute("Value").Value); - - var valuesWithKeys = prevaluesElement.Elements("PreValue") - .Where(x => ((string) x.Attribute("Alias")).IsNullOrWhiteSpace() == false) - .ToDictionary( - key => (string) key.Attribute("Alias"), - val => new PreValue((string) val.Attribute("Value"))); - - //save the values with keys - _dataTypeService.SavePreValues(dataTypeDefinition, valuesWithKeys); - - //save the values without keys (this is legacy) - _dataTypeService.SavePreValues(dataTypeDefinition.Id, valuesWithoutKeys); + _logger.Warn($"No data type found with name \"{dataTypeName}\", configuration will not be saved."); + continue; } - else + + if (!_propertyEditors.TryGet(dataType.EditorAlias, out var editor)) { - _logger.Warn("No data type found with name " + dataTypeDefinitionName + " data type pre-values will not be saved"); + _logger.Warn($"Failed to find an editor with alias \"{dataType.EditorAlias}\", configuration will not be saved."); + continue; + } + + try + { + dataType.Configuration = editor.DeserializeConfiguration(configurationAttribute.Value); + } + catch (Exception ex) + { + _logger.Warn($"Failed to deserialize string \"{configurationAttribute.Value}\" as configuration for editor of type \"{editor.GetType().Name}\".", ex); } } } diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 1f34df8be6..5fc9c5f740 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -316,6 +316,7 @@ + @@ -327,6 +328,11 @@ + + + + + @@ -1167,12 +1173,12 @@ - + - - + + - + @@ -1187,8 +1193,8 @@ - - + + @@ -1199,7 +1205,7 @@ - + diff --git a/src/Umbraco.Tests/Models/Mapping/ContentTypeModelMappingTests.cs b/src/Umbraco.Tests/Models/Mapping/ContentTypeModelMappingTests.cs index 5b1c83951a..458b889a56 100644 --- a/src/Umbraco.Tests/Models/Mapping/ContentTypeModelMappingTests.cs +++ b/src/Umbraco.Tests/Models/Mapping/ContentTypeModelMappingTests.cs @@ -733,7 +733,7 @@ namespace Umbraco.Tests.Models.Mapping var ctMain = MockedContentTypes.CreateSimpleMediaType("parent", "Parent"); //not assigned to tab - ctMain.AddPropertyType(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) + ctMain.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) { Alias = "umbracoUrlName", Name = "Slug", @@ -744,7 +744,7 @@ namespace Umbraco.Tests.Models.Mapping }); MockedContentTypes.EnsureAllIds(ctMain, 8888); var ctChild1 = MockedContentTypes.CreateSimpleMediaType("child1", "Child 1", ctMain, true); - ctChild1.AddPropertyType(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) + ctChild1.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) { Alias = "someProperty", Name = "Some Property", @@ -756,7 +756,7 @@ namespace Umbraco.Tests.Models.Mapping MockedContentTypes.EnsureAllIds(ctChild1, 7777); var contentType = MockedContentTypes.CreateSimpleMediaType("child2", "Child 2", ctChild1, true, "CustomGroup"); //not assigned to tab - contentType.AddPropertyType(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) + contentType.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) { Alias = "umbracoUrlAlias", Name = "AltUrl", @@ -829,13 +829,13 @@ namespace Umbraco.Tests.Models.Mapping var ctMain = MockedContentTypes.CreateSimpleContentType(); //not assigned to tab - ctMain.AddPropertyType(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) + ctMain.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) { Alias = "umbracoUrlName", Name = "Slug", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); MockedContentTypes.EnsureAllIds(ctMain, 8888); var ctChild1 = MockedContentTypes.CreateSimpleContentType("child1", "Child 1", ctMain, true); - ctChild1.AddPropertyType(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) + ctChild1.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) { Alias = "someProperty", Name = "Some Property", @@ -847,7 +847,7 @@ namespace Umbraco.Tests.Models.Mapping MockedContentTypes.EnsureAllIds(ctChild1, 7777); var contentType = MockedContentTypes.CreateSimpleContentType("child2", "Child 2", ctChild1, true, "CustomGroup"); //not assigned to tab - contentType.AddPropertyType(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) + contentType.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) { Alias = "umbracoUrlAlias", Name = "AltUrl", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); diff --git a/src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs b/src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs index 11f6b684b9..a54c00ad1e 100644 --- a/src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs +++ b/src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs @@ -125,8 +125,8 @@ namespace Umbraco.Tests.Models.Mapping var idSeed = 1; var contentType = MockedContentTypes.CreateSimpleContentType(); //add non-grouped properties - contentType.AddPropertyType(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "nonGrouped1") { Name = "Non Grouped 1", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); - contentType.AddPropertyType(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "nonGrouped2") { Name = "Non Grouped 2", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); + contentType.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "nonGrouped1") { Name = "Non Grouped 1", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); + contentType.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "nonGrouped2") { Name = "Non Grouped 2", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); //set ids or it wont work contentType.Id = idSeed; foreach (var p in contentType.PropertyTypes) diff --git a/src/Umbraco.Tests/Persistence/Querying/ContentTypeSqlMappingTests.cs b/src/Umbraco.Tests/Persistence/Querying/ContentTypeSqlMappingTests.cs index 795b2e6f7e..8cc5218263 100644 --- a/src/Umbraco.Tests/Persistence/Querying/ContentTypeSqlMappingTests.cs +++ b/src/Umbraco.Tests/Persistence/Querying/ContentTypeSqlMappingTests.cs @@ -149,7 +149,7 @@ namespace Umbraco.Tests.Persistence.Querying scope.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("umbracoNode")))); scope.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName(Constants.DatabaseSchema.Tables.DataType)))); - scope.Database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { PrimaryKey = 44444, NodeId = 55555, EditorAlias = Constants.PropertyEditors.TextboxAlias, DbType = "Nvarchar" }); + scope.Database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { PrimaryKey = 44444, NodeId = 55555, EditorAlias = Constants.PropertyEditors.Aliases.Textbox, DbType = "Nvarchar" }); scope.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName(Constants.DatabaseSchema.Tables.DataType)))); scope.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("cmsContentType")))); diff --git a/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs index f23ac16795..99d3505972 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs @@ -345,7 +345,7 @@ namespace Umbraco.Tests.Persistence.Repositories { var repository = CreateRepository((IScopeAccessor) provider, out var contentTypeRepository, out DataTypeRepository dataTypeDefinitionRepository); - var dtd = new DataType(-1, Constants.PropertyEditors.DecimalAlias) { Name = "test", DatabaseType = DataTypeDatabaseType.Decimal }; + var dtd = new DataType(-1, Constants.PropertyEditors.Aliases.Decimal) { Name = "test", DatabaseType = DataTypeDatabaseType.Decimal }; dataTypeDefinitionRepository.Save(dtd); const string decimalPropertyAlias = "decimalProperty"; diff --git a/src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs index 2348111aef..81ed363597 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs @@ -83,14 +83,14 @@ namespace Umbraco.Tests.Persistence.Repositories var container2 = new EntityContainer(Constants.ObjectTypes.DataType) { Name = "blah2", ParentId = container1.Id }; containerRepository.Save(container2); - var dataType = (IDataType)new DataType(container2.Id, Constants.PropertyEditors.RadioButtonListAlias) + var dataType = (IDataType)new DataType(container2.Id, Constants.PropertyEditors.Aliases.RadioButtonList) { Name = "dt1" }; repository.Save(dataType); //create a - var dataType2 = (IDataType)new DataType(dataType.Id, Constants.PropertyEditors.RadioButtonListAlias) + var dataType2 = (IDataType)new DataType(dataType.Id, Constants.PropertyEditors.Aliases.RadioButtonList) { Name = "dt2" }; @@ -162,7 +162,7 @@ namespace Umbraco.Tests.Persistence.Repositories var container = new EntityContainer(Constants.ObjectTypes.DataType) { Name = "blah" }; containerRepository.Save(container); - var dataTypeDefinition = new DataType(container.Id, Constants.PropertyEditors.RadioButtonListAlias) { Name = "test" }; + var dataTypeDefinition = new DataType(container.Id, Constants.PropertyEditors.Aliases.RadioButtonList) { Name = "test" }; repository.Save(dataTypeDefinition); Assert.AreEqual(container.Id, dataTypeDefinition.ParentId); @@ -182,7 +182,7 @@ namespace Umbraco.Tests.Persistence.Repositories var container = new EntityContainer(Constants.ObjectTypes.DataType) { Name = "blah" }; containerRepository.Save(container); - IDataType dataType = new DataType(container.Id, Constants.PropertyEditors.RadioButtonListAlias) { Name = "test" }; + IDataType dataType = new DataType(container.Id, Constants.PropertyEditors.Aliases.RadioButtonList) { Name = "test" }; repository.Save(dataType); // Act @@ -206,7 +206,7 @@ namespace Umbraco.Tests.Persistence.Repositories using (var scope = provider.CreateScope()) { var repository = CreateRepository(); - IDataType dataType = new DataType(-1, Constants.PropertyEditors.RadioButtonListAlias) {Name = "test"}; + IDataType dataType = new DataType(-1, Constants.PropertyEditors.Aliases.RadioButtonList) {Name = "test"}; repository.Save(dataType); @@ -295,7 +295,7 @@ namespace Umbraco.Tests.Persistence.Repositories var repository = CreateRepository(); // Act - var query = scope.SqlContext.Query().Where(x => x.EditorAlias == Constants.PropertyEditors.RadioButtonListAlias); + var query = scope.SqlContext.Query().Where(x => x.EditorAlias == Constants.PropertyEditors.Aliases.RadioButtonList); var result = repository.Get(query); // Assert @@ -447,7 +447,7 @@ namespace Umbraco.Tests.Persistence.Repositories using (var scope = provider.CreateScope()) { var repository = CreateRepository(); - var dataTypeDefinition = new DataType(-1, Constants.PropertyEditors.RadioButtonListAlias) { Name = "test" }; + var dataTypeDefinition = new DataType(-1, Constants.PropertyEditors.Aliases.RadioButtonList) { Name = "test" }; repository.Save(dataTypeDefinition); var dtid = dataTypeDefinition.Id; @@ -469,7 +469,7 @@ namespace Umbraco.Tests.Persistence.Repositories using (var scope = provider.CreateScope()) { var repository = CreateRepository(); - var dataTypeDefinition = new DataType(-1, Constants.PropertyEditors.RadioButtonListAlias) { Name = "test" }; + var dataTypeDefinition = new DataType(-1, Constants.PropertyEditors.Aliases.RadioButtonList) { Name = "test" }; repository.Save(dataTypeDefinition); var dtid = dataTypeDefinition.Id; @@ -493,7 +493,7 @@ namespace Umbraco.Tests.Persistence.Repositories using (var scope = provider.CreateScope()) { var repository = Container.GetInstance(); - dtd = new DataType(-1, Constants.PropertyEditors.RadioButtonListAlias) { Name = "test" }; + dtd = new DataType(-1, Constants.PropertyEditors.Aliases.RadioButtonList) { Name = "test" }; repository.Save(dtd); scope.Database.Insert(new DataTypePreValueDto { DataTypeNodeId = dtd.Id, SortOrder = 0, Value = "test1" }); @@ -526,7 +526,7 @@ namespace Umbraco.Tests.Persistence.Repositories using (var scope = provider.CreateScope()) { var repository = Container.GetInstance(); - dtd = new DataType(-1, Constants.PropertyEditors.RadioButtonListAlias) { Name = "test" }; + dtd = new DataType(-1, Constants.PropertyEditors.Aliases.RadioButtonList) { Name = "test" }; repository.Save(dtd); id = scope.Database.Insert(new DataTypePreValueDto() { DataTypeNodeId = dtd.Id, SortOrder = 0, Value = "test1" }); diff --git a/src/Umbraco.Tests/Published/NestedContentTests.cs b/src/Umbraco.Tests/Published/NestedContentTests.cs index 6e52ba4f3d..33c38d78b8 100644 --- a/src/Umbraco.Tests/Published/NestedContentTests.cs +++ b/src/Umbraco.Tests/Published/NestedContentTests.cs @@ -116,9 +116,9 @@ namespace Umbraco.Tests.Published var source = new DataTypeConfigurationSource(dataTypeService.Object, editors); var factory = new PublishedContentTypeFactory(publishedModelFactory.Object, converters, source); - var propertyType1 = factory.CreatePropertyType("property1", 1, Constants.PropertyEditors.NestedContentAlias); - var propertyType2 = factory.CreatePropertyType("property2", 2, Constants.PropertyEditors.NestedContentAlias); - var propertyTypeN1 = factory.CreatePropertyType("propertyN1", 0, Constants.PropertyEditors.TextboxAlias); + var propertyType1 = factory.CreatePropertyType("property1", 1, Constants.PropertyEditors.Aliases.NestedContent); + var propertyType2 = factory.CreatePropertyType("property2", 2, Constants.PropertyEditors.Aliases.NestedContent); + var propertyTypeN1 = factory.CreatePropertyType("propertyN1", 0, Constants.PropertyEditors.Aliases.Textbox); var contentType1 = factory.CreateContentType(1, "content1", new[] { propertyType1 }); var contentType2 = factory.CreateContentType(2, "content2", new[] { propertyType2 }); diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs index 9682450016..b0fe0bcda4 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs @@ -41,7 +41,7 @@ namespace Umbraco.Tests.PublishedContent var propertyTypes = new[] { // AutoPublishedContentType will auto-generate other properties - publishedContentTypeFactory.CreatePropertyType("content", 0, Constants.PropertyEditors.TinyMCEAlias), + publishedContentTypeFactory.CreatePropertyType("content", 0, Constants.PropertyEditors.Aliases.TinyMce), }; var type = new AutoPublishedContentType(0, "anything", propertyTypes); ContentTypesCache.GetPublishedContentTypeByAlias = alias => type; diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs index 3de7c4f32f..0dfee8d725 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs @@ -43,10 +43,10 @@ namespace Umbraco.Tests.PublishedContent var propertyTypes = new[] { // AutoPublishedContentType will auto-generate other properties - factory.CreatePropertyType("umbracoNaviHide", 0, Constants.PropertyEditors.TrueFalseAlias), + factory.CreatePropertyType("umbracoNaviHide", 0, Constants.PropertyEditors.Aliases.Boolean), factory.CreatePropertyType("selectedNodes", 0, "?"), factory.CreatePropertyType("umbracoUrlAlias", 0, "?"), - factory.CreatePropertyType("content", 0, Constants.PropertyEditors.TinyMCEAlias), + factory.CreatePropertyType("content", 0, Constants.PropertyEditors.Aliases.TinyMce), factory.CreatePropertyType("testRecursive", 0, "?"), }; var compositionAliases = new[] { "MyCompositionAlias" }; @@ -553,7 +553,7 @@ namespace Umbraco.Tests.PublishedContent { var factory = Container.GetInstance() as PublishedContentTypeFactory; - var pt = factory.CreatePropertyType("detached", 0, Constants.PropertyEditors.IntegerAlias); + var pt = factory.CreatePropertyType("detached", 0, Constants.PropertyEditors.Aliases.Integer); var ct = factory.CreateContentType(0, "alias", new[] { pt }); var prop = new PublishedElementPropertyBase(pt, null, false, PropertyCacheLevel.None, 5548); Assert.IsInstanceOf(prop.GetValue()); @@ -572,9 +572,9 @@ namespace Umbraco.Tests.PublishedContent { var factory = Container.GetInstance() as PublishedContentTypeFactory; - var pt1 = factory.CreatePropertyType("legend", 0, Constants.PropertyEditors.TextboxAlias); + var pt1 = factory.CreatePropertyType("legend", 0, Constants.PropertyEditors.Aliases.Textbox); var pt2 = factory.CreatePropertyType("image", 0, Constants.PropertyEditors.MediaPickerAlias); - var pt3 = factory.CreatePropertyType("size", 0, Constants.PropertyEditors.IntegerAlias); + var pt3 = factory.CreatePropertyType("size", 0, Constants.PropertyEditors.Aliases.Integer); const string val1 = "boom bam"; const int val2 = 0; const int val3 = 666; diff --git a/src/Umbraco.Tests/Services/ContentTypeServiceExtensionsTests.cs b/src/Umbraco.Tests/Services/ContentTypeServiceExtensionsTests.cs index 3b85814888..aafe37f304 100644 --- a/src/Umbraco.Tests/Services/ContentTypeServiceExtensionsTests.cs +++ b/src/Umbraco.Tests/Services/ContentTypeServiceExtensionsTests.cs @@ -21,7 +21,7 @@ namespace Umbraco.Tests.Services { var contentCollection = new PropertyTypeCollection(true) { - new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) {Alias = alias, Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88} + new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) {Alias = alias, Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88} }; var pg = new PropertyGroup(contentCollection) { Name = "test", SortOrder = 1 }; ct.PropertyGroups.Add(pg); @@ -61,7 +61,7 @@ namespace Umbraco.Tests.Services { var contentCollection = new PropertyTypeCollection(true) { - new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) {Alias = "title", Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88} + new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) {Alias = "title", Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88} }; var pg = new PropertyGroup(contentCollection) { Name = "test", SortOrder = 1 }; ct.PropertyGroups.Add(pg); @@ -98,7 +98,7 @@ namespace Umbraco.Tests.Services { var contentCollection = new PropertyTypeCollection(true) { - new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) {Alias = "title", Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88} + new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) {Alias = "title", Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88} }; var pg = new PropertyGroup(contentCollection) { Name = "test", SortOrder = 1 }; ct.PropertyGroups.Add(pg); diff --git a/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs b/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs index dbfc5cd0bb..f39132f6eb 100644 --- a/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs +++ b/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs @@ -521,9 +521,9 @@ namespace Umbraco.Tests.Services Trashed = false }; - contentType.AddPropertyType(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "title") { Name = "Title", Description = "", Mandatory = false, DataTypeDefinitionId = -88 }); - contentType.AddPropertyType(new PropertyType(Constants.PropertyEditors.TinyMCEAlias, DataTypeDatabaseType.Ntext, "bodyText") { Name = "Body Text", Description = "", Mandatory = false, DataTypeDefinitionId = -87 }); - contentType.AddPropertyType(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "author") { Name = "Author", Description = "Name of the author", Mandatory = false, DataTypeDefinitionId = -88 }); + contentType.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "title") { Name = "Title", Description = "", Mandatory = false, DataTypeDefinitionId = -88 }); + contentType.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.TinyMce, DataTypeDatabaseType.Ntext, "bodyText") { Name = "Body Text", Description = "", Mandatory = false, DataTypeDefinitionId = -87 }); + contentType.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "author") { Name = "Author", Description = "Name of the author", Mandatory = false, DataTypeDefinitionId = -88 }); service.Save(contentType); @@ -912,7 +912,7 @@ namespace Umbraco.Tests.Services service.Save(child); // Act - var duplicatePropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "title") + var duplicatePropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "title") { Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; @@ -948,7 +948,7 @@ namespace Umbraco.Tests.Services service.Save(advancedPage); // Act - var duplicatePropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "title") + var duplicatePropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "title") { Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; @@ -1002,14 +1002,14 @@ namespace Umbraco.Tests.Services service.Save(contentMetaComposition); // Act - var bodyTextPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "bodyText") + var bodyTextPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "bodyText") { Name = "Body Text", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; var bodyTextAdded = basePage.AddPropertyType(bodyTextPropertyType, "Content"); service.Save(basePage); - var authorPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "author") + var authorPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "author") { Name = "Author", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; @@ -1020,7 +1020,7 @@ namespace Umbraco.Tests.Services service.Save(advancedPage); //NOTE: It should not be possible to Save 'BasePage' with the Title PropertyType added - var titlePropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "title") + var titlePropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "title") { Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; @@ -1077,28 +1077,28 @@ namespace Umbraco.Tests.Services service.Save(metaComposition); // Act - var bodyTextPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "bodyText") + var bodyTextPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "bodyText") { Name = "Body Text", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; var bodyTextAdded = basePage.AddPropertyType(bodyTextPropertyType, "Content"); service.Save(basePage); - var authorPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "author") + var authorPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "author") { Name = "Author", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; var authorAdded = contentPage.AddPropertyType(authorPropertyType, "Content"); service.Save(contentPage); - var subtitlePropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "subtitle") + var subtitlePropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "subtitle") { Name = "Subtitle", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; var subtitleAdded = advancedPage.AddPropertyType(subtitlePropertyType, "Content"); service.Save(advancedPage); - var titlePropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "title") + var titlePropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "title") { Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; @@ -1157,28 +1157,28 @@ namespace Umbraco.Tests.Services service.Save(metaComposition); // Act - var bodyTextPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "bodyText") + var bodyTextPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "bodyText") { Name = "Body Text", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; var bodyTextAdded = basePage.AddPropertyType(bodyTextPropertyType, "Content"); service.Save(basePage); - var authorPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "author") + var authorPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "author") { Name = "Author", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; var authorAdded = contentPage.AddPropertyType(authorPropertyType, "Content"); service.Save(contentPage); - var subtitlePropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "subtitle") + var subtitlePropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "subtitle") { Name = "Subtitle", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; var subtitleAdded = advancedPage.AddPropertyType(subtitlePropertyType, "Content"); service.Save(advancedPage); - var titlePropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "title") + var titlePropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "title") { Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; @@ -1198,7 +1198,7 @@ namespace Umbraco.Tests.Services Assert.That(seoCompositionAdded, Is.True); Assert.That(metaCompositionAdded, Is.True); - var testPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "test") + var testPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "test") { Name = "Test", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; @@ -1228,11 +1228,11 @@ namespace Umbraco.Tests.Services service.Save(contentMetaComposition); // Act - var subtitlePropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "subtitle") + var subtitlePropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "subtitle") { Name = "Subtitle", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; - var authorPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "author") + var authorPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "author") { Name = "Author", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; @@ -1274,22 +1274,22 @@ namespace Umbraco.Tests.Services service.Save(advancedPage); // Act - var titlePropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "title") + var titlePropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "title") { Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; var titleAdded = basePage.AddPropertyType(titlePropertyType, "Content"); - var bodyTextPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "bodyText") + var bodyTextPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "bodyText") { Name = "Body Text", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; var bodyTextAdded = contentPage.AddPropertyType(bodyTextPropertyType, "Content"); - var subtitlePropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "subtitle") + var subtitlePropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "subtitle") { Name = "Subtitle", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; var subtitleAdded = contentPage.AddPropertyType(subtitlePropertyType, "Content"); - var authorPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "author") + var authorPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "author") { Name = "Author", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; @@ -1347,7 +1347,7 @@ namespace Umbraco.Tests.Services service.Save(contentMetaComposition); // Act - var propertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "title") + var propertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "title") { Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; @@ -1381,12 +1381,12 @@ namespace Umbraco.Tests.Services service.Save(contentPage); // Act - var propertyTypeOne = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "testTextbox") + var propertyTypeOne = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "testTextbox") { Name = "Test Textbox", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; var firstOneAdded = contentPage.AddPropertyType(propertyTypeOne, "Content_"); - var propertyTypeTwo = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "anotherTextbox") + var propertyTypeTwo = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "anotherTextbox") { Name = "Another Test Textbox", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; @@ -1434,11 +1434,11 @@ namespace Umbraco.Tests.Services service.Save(contentPage); // Act - var bodyTextPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "bodyText") + var bodyTextPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "bodyText") { Name = "Body Text", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; - var subtitlePropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "subtitle") + var subtitlePropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "subtitle") { Name = "Subtitle", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; @@ -1446,15 +1446,15 @@ namespace Umbraco.Tests.Services var subtitleAdded = contentPage.AddPropertyType(subtitlePropertyType, "Content");//Will be added to the "Content Meta" composition service.Save(contentPage); - var authorPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "author") + var authorPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "author") { Name = "Author", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; - var descriptionPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "description") + var descriptionPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "description") { Name = "Description", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; - var keywordsPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "keywords") + var keywordsPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "keywords") { Name = "Keywords", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; @@ -1503,15 +1503,15 @@ namespace Umbraco.Tests.Services service.Save(contentMetaComposition); // Act - var bodyTextPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "bodyText") + var bodyTextPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "bodyText") { Name = "Body Text", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; - var subtitlePropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "subtitle") + var subtitlePropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "subtitle") { Name = "Subtitle", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; - var authorPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "author") + var authorPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "author") { Name = "Author", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; @@ -1556,14 +1556,14 @@ namespace Umbraco.Tests.Services service.Save(contentMetaComposition); // Act - var bodyTextPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "bodyText") + var bodyTextPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "bodyText") { Name = "Body Text", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; var bodyTextAdded = basePage.AddPropertyType(bodyTextPropertyType, "Content"); service.Save(basePage); - var authorPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "author") + var authorPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "author") { Name = "Author", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; @@ -1598,7 +1598,7 @@ namespace Umbraco.Tests.Services basePage.AddPropertyGroup("Meta"); service.Save(basePage); - var authorPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "author") + var authorPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "author") { Name = "Author", Description = "", @@ -1608,7 +1608,7 @@ namespace Umbraco.Tests.Services }; Assert.IsTrue(basePage.AddPropertyType(authorPropertyType, "Content")); - var titlePropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "title") + var titlePropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "title") { Name = "Title", Description = "", @@ -1657,14 +1657,14 @@ namespace Umbraco.Tests.Services service.Save(contentMetaComposition); // Act - var authorPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "author") + var authorPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "author") { Name = "Author", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; var authorAdded = contentPage.AddPropertyType(authorPropertyType, "Content"); service.Save(contentPage); - var bodyTextPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext, "bodyText") + var bodyTextPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext, "bodyText") { Name = "Body Text", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }; @@ -1690,7 +1690,7 @@ namespace Umbraco.Tests.Services //Ensure that adding a new PropertyType to the "Content"-tab also adds it to the right group - var descriptionPropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) + var descriptionPropertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) { Alias = "description", Name = "Description", Description = "", Mandatory = false, SortOrder = 1,DataTypeDefinitionId = -88 }; diff --git a/src/Umbraco.Tests/Services/DataTypeServiceTests.cs b/src/Umbraco.Tests/Services/DataTypeServiceTests.cs index cfb00fa9e2..6697bd7b70 100644 --- a/src/Umbraco.Tests/Services/DataTypeServiceTests.cs +++ b/src/Umbraco.Tests/Services/DataTypeServiceTests.cs @@ -64,7 +64,7 @@ namespace Umbraco.Tests.Services { // Arrange var dataTypeService = ServiceContext.DataTypeService; - var textBoxAlias = Constants.PropertyEditors.TextboxAlias; + var textBoxAlias = Constants.PropertyEditors.Aliases.Textbox; // Act IDataType dataType = new DataType(-1, textBoxAlias) { Name = "Testing prevals", DatabaseType = DataTypeDatabaseType.Ntext }; @@ -94,7 +94,7 @@ namespace Umbraco.Tests.Services { // Arrange var dataTypeService = ServiceContext.DataTypeService; - var textBoxAlias = Constants.PropertyEditors.TextboxAlias; + var textBoxAlias = Constants.PropertyEditors.Aliases.Textbox; // Act IDataType dataType = new DataType(-1, textBoxAlias) { Name = "Testing prevals", DatabaseType = DataTypeDatabaseType.Ntext }; @@ -123,7 +123,7 @@ namespace Umbraco.Tests.Services { // Arrange var dataTypeService = ServiceContext.DataTypeService; - var textBoxAlias = Constants.PropertyEditors.TextboxAlias; + var textBoxAlias = Constants.PropertyEditors.Aliases.Textbox; // Act IDataType dataType = new DataType(-1, textBoxAlias) { Name = "Testing prevals", DatabaseType = DataTypeDatabaseType.Ntext }; @@ -160,7 +160,7 @@ namespace Umbraco.Tests.Services { // Arrange var dataTypeService = ServiceContext.DataTypeService; - var textBoxAlias = Constants.PropertyEditors.TextboxAlias; + var textBoxAlias = Constants.PropertyEditors.Aliases.Textbox; // Act IDataType dataType = new DataType(-1, textBoxAlias) { Name = "Testing prevals", DatabaseType = DataTypeDatabaseType.Ntext }; @@ -194,7 +194,7 @@ namespace Umbraco.Tests.Services { // Arrange var dataTypeService = ServiceContext.DataTypeService; - var textBoxAlias = Constants.PropertyEditors.TextboxAlias; + var textBoxAlias = Constants.PropertyEditors.Aliases.Textbox; // Act IDataType dataType = new DataType(-1, textBoxAlias) { Name = "Testing prevals", DatabaseType = DataTypeDatabaseType.Ntext }; diff --git a/src/Umbraco.Tests/Services/EntityServiceTests.cs b/src/Umbraco.Tests/Services/EntityServiceTests.cs index d6e9f605dc..6c465c0522 100644 --- a/src/Umbraco.Tests/Services/EntityServiceTests.cs +++ b/src/Umbraco.Tests/Services/EntityServiceTests.cs @@ -516,7 +516,7 @@ namespace Umbraco.Tests.Services } Assert.That(entities.Any(x => - x.AdditionalData.Any(y => y.Value is EntitySlim.PropertySlim && ((EntitySlim.PropertySlim) y.Value).PropertyEditorAlias == Constants.PropertyEditors.UploadFieldAlias)), Is.True); + x.AdditionalData.Any(y => y.Value is EntitySlim.PropertySlim && ((EntitySlim.PropertySlim) y.Value).PropertyEditorAlias == Constants.PropertyEditors.Aliases.UploadField)), Is.True); } [Test] diff --git a/src/Umbraco.Tests/Services/Importing/PackageImportTests.cs b/src/Umbraco.Tests/Services/Importing/PackageImportTests.cs index af5dbf6fe9..a3974c6e16 100644 --- a/src/Umbraco.Tests/Services/Importing/PackageImportTests.cs +++ b/src/Umbraco.Tests/Services/Importing/PackageImportTests.cs @@ -320,7 +320,7 @@ namespace Umbraco.Tests.Services.Importing // Assert Assert.That(dataTypeDefinitions, Is.Not.Null); Assert.That(dataTypeDefinitions.Any(), Is.True); - Assert.AreEqual(Constants.PropertyEditors.CheckBoxListAlias, dataTypeDefinitions.First().EditorAlias); + Assert.AreEqual(Constants.PropertyEditors.Aliases.CheckBoxList, dataTypeDefinitions.First().EditorAlias); Assert.That(contents, Is.Not.Null); Assert.That(contentTypes.Any(), Is.True); Assert.That(contents.Any(), Is.True); diff --git a/src/Umbraco.Tests/Services/MemberServiceTests.cs b/src/Umbraco.Tests/Services/MemberServiceTests.cs index e0e894294a..afcc30deaf 100644 --- a/src/Umbraco.Tests/Services/MemberServiceTests.cs +++ b/src/Umbraco.Tests/Services/MemberServiceTests.cs @@ -796,7 +796,7 @@ namespace Umbraco.Tests.Services public void Get_By_Property_Int_Value_Exact() { IMemberType memberType = MockedContentTypes.CreateSimpleMemberType(); - memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.IntegerAlias, DataTypeDatabaseType.Integer, "number") + memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Integer, DataTypeDatabaseType.Integer, "number") { Name = "Number", //NOTE: This is what really determines the db type - the above definition doesn't really do anything @@ -820,7 +820,7 @@ namespace Umbraco.Tests.Services public void Get_By_Property_Int_Value_Greater_Than() { IMemberType memberType = MockedContentTypes.CreateSimpleMemberType(); - memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.IntegerAlias, DataTypeDatabaseType.Integer, "number") + memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Integer, DataTypeDatabaseType.Integer, "number") { Name = "Number", //NOTE: This is what really determines the db type - the above definition doesn't really do anything @@ -844,7 +844,7 @@ namespace Umbraco.Tests.Services public void Get_By_Property_Int_Value_Greater_Than_Equal_To() { IMemberType memberType = MockedContentTypes.CreateSimpleMemberType(); - memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.IntegerAlias, DataTypeDatabaseType.Integer, "number") + memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Integer, DataTypeDatabaseType.Integer, "number") { Name = "Number", //NOTE: This is what really determines the db type - the above definition doesn't really do anything @@ -868,7 +868,7 @@ namespace Umbraco.Tests.Services public void Get_By_Property_Int_Value_Less_Than() { IMemberType memberType = MockedContentTypes.CreateSimpleMemberType(); - memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.DateAlias, DataTypeDatabaseType.Date, "number") + memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Date, DataTypeDatabaseType.Date, "number") { Name = "Number", //NOTE: This is what really determines the db type - the above definition doesn't really do anything @@ -892,7 +892,7 @@ namespace Umbraco.Tests.Services public void Get_By_Property_Int_Value_Less_Than_Or_Equal() { IMemberType memberType = MockedContentTypes.CreateSimpleMemberType(); - memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.IntegerAlias, DataTypeDatabaseType.Integer, "number") + memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Integer, DataTypeDatabaseType.Integer, "number") { Name = "Number", //NOTE: This is what really determines the db type - the above definition doesn't really do anything @@ -916,7 +916,7 @@ namespace Umbraco.Tests.Services public void Get_By_Property_Date_Value_Exact() { IMemberType memberType = MockedContentTypes.CreateSimpleMemberType(); - memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.IntegerAlias, DataTypeDatabaseType.Integer, "date") + memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Integer, DataTypeDatabaseType.Integer, "date") { Name = "Date", //NOTE: This is what really determines the db type - the above definition doesn't really do anything @@ -940,7 +940,7 @@ namespace Umbraco.Tests.Services public void Get_By_Property_Date_Value_Greater_Than() { IMemberType memberType = MockedContentTypes.CreateSimpleMemberType(); - memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.IntegerAlias, DataTypeDatabaseType.Integer, "date") + memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Integer, DataTypeDatabaseType.Integer, "date") { Name = "Date", //NOTE: This is what really determines the db type - the above definition doesn't really do anything @@ -964,7 +964,7 @@ namespace Umbraco.Tests.Services public void Get_By_Property_Date_Value_Greater_Than_Equal_To() { IMemberType memberType = MockedContentTypes.CreateSimpleMemberType(); - memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.IntegerAlias, DataTypeDatabaseType.Integer, "date") + memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Integer, DataTypeDatabaseType.Integer, "date") { Name = "Date", //NOTE: This is what really determines the db type - the above definition doesn't really do anything @@ -988,7 +988,7 @@ namespace Umbraco.Tests.Services public void Get_By_Property_Date_Value_Less_Than() { IMemberType memberType = MockedContentTypes.CreateSimpleMemberType(); - memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.IntegerAlias, DataTypeDatabaseType.Integer, "date") + memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Integer, DataTypeDatabaseType.Integer, "date") { Name = "Date", //NOTE: This is what really determines the db type - the above definition doesn't really do anything @@ -1012,7 +1012,7 @@ namespace Umbraco.Tests.Services public void Get_By_Property_Date_Value_Less_Than_Or_Equal() { IMemberType memberType = MockedContentTypes.CreateSimpleMemberType(); - memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.IntegerAlias, DataTypeDatabaseType.Integer, "date") + memberType.AddPropertyType(new PropertyType(Constants.PropertyEditors.Aliases.Integer, DataTypeDatabaseType.Integer, "date") { Name = "Date", //NOTE: This is what really determines the db type - the above definition doesn't really do anything diff --git a/src/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs b/src/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs index a475a99a92..03edbc57ff 100644 --- a/src/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs +++ b/src/Umbraco.Tests/TestHelpers/Entities/MockedContentTypes.cs @@ -151,9 +151,9 @@ namespace Umbraco.Tests.TestHelpers.Entities }; var contentCollection = new PropertyTypeCollection(true); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) { Alias = "title", Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) { Alias = "bodyText", Name = "Body Text", Description = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -87 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) { Alias = "author", Name = "Author", Description = "Name of the author", Mandatory = false, SortOrder = 3, DataTypeDefinitionId = -88 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) { Alias = "title", Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) { Alias = "bodyText", Name = "Body Text", Description = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -87 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) { Alias = "author", Name = "Author", Description = "Name of the author", Mandatory = false, SortOrder = 3, DataTypeDefinitionId = -88 }); contentType.PropertyGroups.Add(new PropertyGroup(contentCollection) { Name = "Content", SortOrder = 1 }); @@ -167,7 +167,7 @@ namespace Umbraco.Tests.TestHelpers.Entities { var contentType = CreateSimpleContentType(alias, name, parent, randomizeAliases, propertyGroupName); - var propertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) + var propertyType = new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) { Alias = RandomAlias("gen", randomizeAliases), Name = "Gen", @@ -195,9 +195,9 @@ namespace Umbraco.Tests.TestHelpers.Entities contentType.Trashed = false; var contentCollection = new PropertyTypeCollection(true); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) { Alias = RandomAlias("title", randomizeAliases), Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.TinyMCEAlias, DataTypeDatabaseType.Ntext) { Alias = RandomAlias("bodyText", randomizeAliases), Name = "Body Text", Description = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -87 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) { Alias = RandomAlias("author", randomizeAliases) , Name = "Author", Description = "Name of the author", Mandatory = false, SortOrder = 3, DataTypeDefinitionId = -88 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) { Alias = RandomAlias("title", randomizeAliases), Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.TinyMce, DataTypeDatabaseType.Ntext) { Alias = RandomAlias("bodyText", randomizeAliases), Name = "Body Text", Description = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -87 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) { Alias = RandomAlias("author", randomizeAliases) , Name = "Author", Description = "Name of the author", Mandatory = false, SortOrder = 3, DataTypeDefinitionId = -88 }); var pg = new PropertyGroup(contentCollection) {Name = propertyGroupName, SortOrder = 1}; contentType.PropertyGroups.Add(pg); @@ -224,9 +224,9 @@ namespace Umbraco.Tests.TestHelpers.Entities contentType.Trashed = false; var contentCollection = new PropertyTypeCollection(false); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) { Alias = RandomAlias("title", randomizeAliases), Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.TinyMCEAlias, DataTypeDatabaseType.Ntext) { Alias = RandomAlias("bodyText", randomizeAliases), Name = "Body Text", Description = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -87 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) { Alias = RandomAlias("author", randomizeAliases), Name = "Author", Description = "Name of the author", Mandatory = false, SortOrder = 3, DataTypeDefinitionId = -88 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) { Alias = RandomAlias("title", randomizeAliases), Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.TinyMce, DataTypeDatabaseType.Ntext) { Alias = RandomAlias("bodyText", randomizeAliases), Name = "Body Text", Description = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -87 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) { Alias = RandomAlias("author", randomizeAliases), Name = "Author", Description = "Name of the author", Mandatory = false, SortOrder = 3, DataTypeDefinitionId = -88 }); var pg = new PropertyGroup(contentCollection) { Name = propertyGroupName, SortOrder = 1 }; contentType.PropertyGroups.Add(pg); @@ -335,27 +335,27 @@ namespace Umbraco.Tests.TestHelpers.Entities }; var contentCollection = new PropertyTypeCollection(true); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.TrueFalseAlias, DataTypeDatabaseType.Integer) { Alias = "isTrue", Name = "Is True or False", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -49 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.IntegerAlias, DataTypeDatabaseType.Integer) { Alias = "number", Name = "Number", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -51 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.TinyMCEAlias, DataTypeDatabaseType.Ntext) { Alias = "bodyText", Name = "Body Text", Mandatory = false, SortOrder = 3, DataTypeDefinitionId = -87 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Nvarchar) { Alias = "singleLineText", Name = "Text String", Mandatory = false, SortOrder = 4, DataTypeDefinitionId = -88 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.TextboxMultipleAlias, DataTypeDatabaseType.Ntext) { Alias = "multilineText", Name = "Multiple Text Strings", Mandatory = false, SortOrder = 5, DataTypeDefinitionId = -89 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.UploadFieldAlias, DataTypeDatabaseType.Nvarchar) { Alias = "upload", Name = "Upload Field", Mandatory = false, SortOrder = 6, DataTypeDefinitionId = -90 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.NoEditAlias, DataTypeDatabaseType.Nvarchar) { Alias = "label", Name = "Label", Mandatory = false, SortOrder = 7, DataTypeDefinitionId = -92 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.DateTimeAlias, DataTypeDatabaseType.Date) { Alias = "dateTime", Name = "Date Time", Mandatory = false, SortOrder = 8, DataTypeDefinitionId = -36 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.ColorPickerAlias, DataTypeDatabaseType.Nvarchar) { Alias = "colorPicker", Name = "Color Picker", Mandatory = false, SortOrder = 9, DataTypeDefinitionId = -37 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Boolean, DataTypeDatabaseType.Integer) { Alias = "isTrue", Name = "Is True or False", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -49 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Integer, DataTypeDatabaseType.Integer) { Alias = "number", Name = "Number", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -51 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.TinyMce, DataTypeDatabaseType.Ntext) { Alias = "bodyText", Name = "Body Text", Mandatory = false, SortOrder = 3, DataTypeDefinitionId = -87 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Nvarchar) { Alias = "singleLineText", Name = "Text String", Mandatory = false, SortOrder = 4, DataTypeDefinitionId = -88 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.TextboxMultiple, DataTypeDatabaseType.Ntext) { Alias = "multilineText", Name = "Multiple Text Strings", Mandatory = false, SortOrder = 5, DataTypeDefinitionId = -89 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.UploadField, DataTypeDatabaseType.Nvarchar) { Alias = "upload", Name = "Upload Field", Mandatory = false, SortOrder = 6, DataTypeDefinitionId = -90 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.NoEdit, DataTypeDatabaseType.Nvarchar) { Alias = "label", Name = "Label", Mandatory = false, SortOrder = 7, DataTypeDefinitionId = -92 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.DateTime, DataTypeDatabaseType.Date) { Alias = "dateTime", Name = "Date Time", Mandatory = false, SortOrder = 8, DataTypeDefinitionId = -36 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.ColorPicker, DataTypeDatabaseType.Nvarchar) { Alias = "colorPicker", Name = "Color Picker", Mandatory = false, SortOrder = 9, DataTypeDefinitionId = -37 }); //that one is gone in 7.4 //contentCollection.Add(new PropertyType(Constants.PropertyEditors.FolderBrowserAlias, DataTypeDatabaseType.Nvarchar) { Alias = "folderBrowser", Name = "Folder Browser", Mandatory = false, SortOrder = 10, DataTypeDefinitionId = -38 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.DropDownListMultipleAlias, DataTypeDatabaseType.Nvarchar) { Alias = "ddlMultiple", Name = "Dropdown List Multiple", Mandatory = false, SortOrder = 11, DataTypeDefinitionId = -39 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.RadioButtonListAlias, DataTypeDatabaseType.Nvarchar) { Alias = "rbList", Name = "Radio Button List", Mandatory = false, SortOrder = 12, DataTypeDefinitionId = -40 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.DateAlias, DataTypeDatabaseType.Date) { Alias = "date", Name = "Date", Mandatory = false, SortOrder = 13, DataTypeDefinitionId = -41 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.DropDownListAlias, DataTypeDatabaseType.Integer) { Alias = "ddl", Name = "Dropdown List", Mandatory = false, SortOrder = 14, DataTypeDefinitionId = -42 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.CheckBoxListAlias, DataTypeDatabaseType.Nvarchar) { Alias = "chklist", Name = "Checkbox List", Mandatory = false, SortOrder = 15, DataTypeDefinitionId = -43 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.ContentPicker2Alias, DataTypeDatabaseType.Integer) { Alias = "contentPicker", Name = "Content Picker", Mandatory = false, SortOrder = 16, DataTypeDefinitionId = 1046 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.MediaPicker2Alias, DataTypeDatabaseType.Integer) { Alias = "mediaPicker", Name = "Media Picker", Mandatory = false, SortOrder = 17, DataTypeDefinitionId = 1048 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.MemberPicker2Alias, DataTypeDatabaseType.Integer) { Alias = "memberPicker", Name = "Member Picker", Mandatory = false, SortOrder = 18, DataTypeDefinitionId = 1047 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.RelatedLinks2Alias, DataTypeDatabaseType.Ntext) { Alias = "relatedLinks", Name = "Related Links", Mandatory = false, SortOrder = 21, DataTypeDefinitionId = 1050 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.TagsAlias, DataTypeDatabaseType.Ntext) { Alias = "tags", Name = "Tags", Mandatory = false, SortOrder = 22, DataTypeDefinitionId = 1041 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.DropDownListMultiple, DataTypeDatabaseType.Nvarchar) { Alias = "ddlMultiple", Name = "Dropdown List Multiple", Mandatory = false, SortOrder = 11, DataTypeDefinitionId = -39 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.RadioButtonList, DataTypeDatabaseType.Nvarchar) { Alias = "rbList", Name = "Radio Button List", Mandatory = false, SortOrder = 12, DataTypeDefinitionId = -40 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Date, DataTypeDatabaseType.Date) { Alias = "date", Name = "Date", Mandatory = false, SortOrder = 13, DataTypeDefinitionId = -41 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.DropDownList, DataTypeDatabaseType.Integer) { Alias = "ddl", Name = "Dropdown List", Mandatory = false, SortOrder = 14, DataTypeDefinitionId = -42 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.CheckBoxList, DataTypeDatabaseType.Nvarchar) { Alias = "chklist", Name = "Checkbox List", Mandatory = false, SortOrder = 15, DataTypeDefinitionId = -43 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.ContentPicker2Alias, DataTypeDatabaseType.Integer) { Alias = "contentPicker", Name = "Content Picker", Mandatory = false, SortOrder = 16, DataTypeDefinitionId = 1046 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.MediaPicker2, DataTypeDatabaseType.Integer) { Alias = "mediaPicker", Name = "Media Picker", Mandatory = false, SortOrder = 17, DataTypeDefinitionId = 1048 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.MemberPicker2, DataTypeDatabaseType.Integer) { Alias = "memberPicker", Name = "Member Picker", Mandatory = false, SortOrder = 18, DataTypeDefinitionId = 1047 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.RelatedLinks2, DataTypeDatabaseType.Ntext) { Alias = "relatedLinks", Name = "Related Links", Mandatory = false, SortOrder = 21, DataTypeDefinitionId = 1050 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Tags, DataTypeDatabaseType.Ntext) { Alias = "tags", Name = "Tags", Mandatory = false, SortOrder = 22, DataTypeDefinitionId = 1041 }); //contentCollection.Add(new PropertyType(Constants.PropertyEditors.UltraSimpleEditorAlias, DataTypeDatabaseType.Ntext) { Alias = "simpleEditor", Name = "Ultra Simple Editor", Mandatory = false, SortOrder = 19, DataTypeDefinitionId = 1038 }); //contentCollection.Add(new PropertyType(Constants.PropertyEditors.UltimatePickerAlias, DataTypeDatabaseType.Ntext) { Alias = "ultimatePicker", Name = "Ultimate Picker", Mandatory = false, SortOrder = 20, DataTypeDefinitionId = 1039 }); @@ -408,11 +408,11 @@ namespace Umbraco.Tests.TestHelpers.Entities }; var contentCollection = new PropertyTypeCollection(false); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.UploadFieldAlias, DataTypeDatabaseType.Nvarchar) { Alias = Constants.Conventions.Media.File, Name = "File", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -90 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.NoEditAlias, DataTypeDatabaseType.Integer) { Alias = Constants.Conventions.Media.Width, Name = "Width", Description = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -90 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.NoEditAlias, DataTypeDatabaseType.Integer) { Alias = Constants.Conventions.Media.Height, Name = "Height", Description = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -90 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.NoEditAlias, DataTypeDatabaseType.Integer) { Alias = Constants.Conventions.Media.Bytes, Name = "Bytes", Description = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -90 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.NoEditAlias, DataTypeDatabaseType.Nvarchar) { Alias = Constants.Conventions.Media.Extension, Name = "File Extension", Description = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -90 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.UploadField, DataTypeDatabaseType.Nvarchar) { Alias = Constants.Conventions.Media.File, Name = "File", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -90 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.NoEdit, DataTypeDatabaseType.Integer) { Alias = Constants.Conventions.Media.Width, Name = "Width", Description = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -90 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.NoEdit, DataTypeDatabaseType.Integer) { Alias = Constants.Conventions.Media.Height, Name = "Height", Description = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -90 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.NoEdit, DataTypeDatabaseType.Integer) { Alias = Constants.Conventions.Media.Bytes, Name = "Bytes", Description = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -90 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.NoEdit, DataTypeDatabaseType.Nvarchar) { Alias = Constants.Conventions.Media.Extension, Name = "File Extension", Description = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -90 }); mediaType.PropertyGroups.Add(new PropertyGroup(contentCollection) { Name = "Media", SortOrder = 1 }); @@ -437,9 +437,9 @@ namespace Umbraco.Tests.TestHelpers.Entities }; var contentCollection = new PropertyTypeCollection(false); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) { Alias = "title", Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) { Alias = "bodyText", Name = "Body Text", Description = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -87 }); - contentCollection.Add(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) { Alias = "author", Name = "Author", Description = "Name of the author", Mandatory = false, SortOrder = 3, DataTypeDefinitionId = -88 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) { Alias = "title", Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) { Alias = "bodyText", Name = "Body Text", Description = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -87 }); + contentCollection.Add(new PropertyType(Constants.PropertyEditors.Aliases.Textbox, DataTypeDatabaseType.Ntext) { Alias = "author", Name = "Author", Description = "Name of the author", Mandatory = false, SortOrder = 3, DataTypeDefinitionId = -88 }); contentType.PropertyGroups.Add(new PropertyGroup(contentCollection) { Name = "Content", SortOrder = 1 }); diff --git a/src/Umbraco.Web/Editors/BackOfficeController.cs b/src/Umbraco.Web/Editors/BackOfficeController.cs index 761058d633..d1c3009792 100644 --- a/src/Umbraco.Web/Editors/BackOfficeController.cs +++ b/src/Umbraco.Web/Editors/BackOfficeController.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using System.Web; using System.Web.Mvc; using System.Web.UI; +using LightInject; using Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity.Owin; using Microsoft.Owin.Security; @@ -185,9 +186,8 @@ namespace Umbraco.Web.Editors [OutputCache(Order = 1, VaryByParam = "none", Location = OutputCacheLocation.Server, Duration = 5000)] public JavaScriptResult Application() { - var parser = _manifestParser; - var initJs = new JsInitialization(parser); - var initCss = new CssInitialization(parser); + var initJs = new JsInitialization(_manifestParser); + var initCss = new CssInitialization(_manifestParser); //get the legacy ActionJs file references to append as well var legacyActionJsRef = GetLegacyActionJs(LegacyJsActionType.JsUrl); @@ -208,9 +208,8 @@ namespace Umbraco.Web.Editors { JArray GetAssetList() { - var parser = _manifestParser; - var initJs = new JsInitialization(parser); - var initCss = new CssInitialization(parser); + var initJs = new JsInitialization(_manifestParser); + var initCss = new CssInitialization(_manifestParser); var assets = new List(); assets.AddRange(initJs.GetScriptFiles(HttpContext, Enumerable.Empty())); assets.AddRange(initCss.GetStylesheetFiles(HttpContext)); diff --git a/src/Umbraco.Web/Editors/ContentTypeController.cs b/src/Umbraco.Web/Editors/ContentTypeController.cs index ae684814ba..36837a6f96 100644 --- a/src/Umbraco.Web/Editors/ContentTypeController.cs +++ b/src/Umbraco.Web/Editors/ContentTypeController.cs @@ -124,7 +124,7 @@ namespace Umbraco.Web.Editors throw new HttpResponseException(HttpStatusCode.NotFound); } - var preVals = Current.Services.DataTypeService.GetPreValuesCollectionByDataTypeId(id); + var configuration = Current.Services.DataTypeService.GetDataType(id).Configuration; var editor = Current.PropertyEditors[dataTypeDiff.EditorAlias]; return new ContentPropertyDisplay() @@ -132,7 +132,7 @@ namespace Umbraco.Web.Editors Editor = dataTypeDiff.EditorAlias, Validation = new PropertyTypeValidation() { }, View = editor.ValueEditor.View, - Config = editor.PreValueEditor.ConvertDbToEditor(editor.DefaultPreValues, preVals) + Config = editor.PreValueEditor.ConvertDbToEditor(editor.DefaultPreValues, configuration) }; } diff --git a/src/Umbraco.Web/Editors/DataTypeController.cs b/src/Umbraco.Web/Editors/DataTypeController.cs index 5290dd98d5..2ed2cf0452 100644 --- a/src/Umbraco.Web/Editors/DataTypeController.cs +++ b/src/Umbraco.Web/Editors/DataTypeController.cs @@ -113,7 +113,7 @@ namespace Umbraco.Web.Editors //if it doesnt exist yet, we will create it. if (dt == null) { - dt = new DataType(Constants.PropertyEditors.ListViewAlias); + dt = new DataType(Constants.PropertyEditors.Aliases.ListView); dt.Name = Constants.Conventions.DataTypes.ListViewPrefix + contentTypeAlias; Services.DataTypeService.Save(dt); } @@ -127,7 +127,7 @@ namespace Umbraco.Web.Editors /// /// The data type id for the pre-values, -1 if it is a new data type /// - public IEnumerable GetPreValues(string editorAlias, int dataTypeId = -1) + public IEnumerable GetPreValues(string editorAlias, int dataTypeId = -1) { var propEd = Current.PropertyEditors[editorAlias]; if (propEd == null) @@ -138,7 +138,7 @@ namespace Umbraco.Web.Editors if (dataTypeId == -1) { //this is a new data type, so just return the field editors with default values - return Mapper.Map>(propEd); + return Mapper.Map>(propEd); } //we have a data type associated @@ -154,11 +154,11 @@ namespace Umbraco.Web.Editors if (dataType.EditorAlias == editorAlias) { //this is the currently assigned pre-value editor, return with values. - return Mapper.Map>(dataType); + return Mapper.Map>(dataType); } //these are new pre-values, so just return the field editors with default values - return Mapper.Map>(propEd); + return Mapper.Map>(propEd); } /// @@ -194,25 +194,21 @@ namespace Umbraco.Web.Editors { //If we've made it here, then everything has been wired up and validated by the attribute - //finally we need to save the data type and it's pre-vals - var dtService = Services.DataTypeService; - //TODO: Check if the property editor has changed, if it has ensure we don't pass the // existing values to the new property editor! //get the prevalues, current and new - var preValDictionary = dataType.PreValues.ToDictionary(x => x.Key, x => x.Value); - var currVal = Services.DataTypeService.GetPreValuesCollectionByDataTypeId(dataType.PersistedDataType.Id); + var preValDictionary = dataType.ConfigurationFields.ToDictionary(x => x.Key, x => x.Value); + var currentConfiguration = dataType.PersistedDataType.Configuration; //we need to allow for the property editor to deserialize the prevalues - var formattedVal = dataType.PropertyEditor.PreValueEditor.ConvertEditorToDb( - preValDictionary, - currVal); + var formattedVal = dataType.PropertyEditor.PreValueEditor.ConvertEditorToDb(preValDictionary, currentConfiguration); + // fixme and then re-assign to datatype? try { //save the data type - dtService.SaveDataTypeAndPreValues(dataType.PersistedDataType, formattedVal, (int)Security.CurrentUser.Id); + Services.DataTypeService.Save(dataType.PersistedDataType, Security.CurrentUser.Id); } catch (DuplicateNameException ex) { diff --git a/src/Umbraco.Web/Editors/DataTypeValidateAttribute.cs b/src/Umbraco.Web/Editors/DataTypeValidateAttribute.cs index 918780f6aa..46b7c20b63 100644 --- a/src/Umbraco.Web/Editors/DataTypeValidateAttribute.cs +++ b/src/Umbraco.Web/Editors/DataTypeValidateAttribute.cs @@ -46,10 +46,10 @@ namespace Umbraco.Web.Editors dataType.Alias = dataType.Alias == null ? dataType.Name : dataType.Alias.CleanForXss('[', ']', '(', ')', ':'); //Validate that the property editor exists - var propertyEditor = Current.PropertyEditors[dataType.SelectedEditor]; + var propertyEditor = Current.PropertyEditors[dataType.EditorAlias]; if (propertyEditor == null) { - var message = string.Format("Property editor with id: {0} was not found", dataType.SelectedEditor); + var message = string.Format("Property editor with id: {0} was not found", dataType.EditorAlias); actionContext.Response = actionContext.Request.CreateErrorResponse(HttpStatusCode.NotFound, message); return; } @@ -86,7 +86,7 @@ namespace Umbraco.Web.Editors dataType.PersistedDataType = persisted; //Validate each field - foreach (var preVal in dataType.PreValues) + foreach (var preVal in dataType.ConfigurationFields) { var postedValue = preVal.Value; diff --git a/src/Umbraco.Web/Migrations/EnsureListViewDataTypeIsCreated.cs b/src/Umbraco.Web/Migrations/EnsureListViewDataTypeIsCreated.cs index 18285b70a7..9e91fcf7ba 100644 --- a/src/Umbraco.Web/Migrations/EnsureListViewDataTypeIsCreated.cs +++ b/src/Umbraco.Web/Migrations/EnsureListViewDataTypeIsCreated.cs @@ -54,9 +54,9 @@ namespace Umbraco.Web.Migrations if (syntax.SupportsIdentityInsert()) scope.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", syntax.GetQuotedTableName(Constants.DatabaseSchema.Tables.DataType)))); - scope.Database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { PrimaryKey = -26, NodeId = Constants.DataTypes.DefaultContentListView, EditorAlias = Constants.PropertyEditors.ListViewAlias, DbType = "Nvarchar" }); - scope.Database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { PrimaryKey = -27, NodeId = Constants.DataTypes.DefaultMediaListView, EditorAlias = Constants.PropertyEditors.ListViewAlias, DbType = "Nvarchar" }); - scope.Database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { PrimaryKey = -28, NodeId = Constants.DataTypes.DefaultMembersListView, EditorAlias = Constants.PropertyEditors.ListViewAlias, DbType = "Nvarchar" }); + scope.Database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = Constants.DataTypes.DefaultContentListView, EditorAlias = Constants.PropertyEditors.Aliases.ListView, DbType = "Nvarchar" }); + scope.Database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = Constants.DataTypes.DefaultMediaListView, EditorAlias = Constants.PropertyEditors.Aliases.ListView, DbType = "Nvarchar" }); + scope.Database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = Constants.DataTypes.DefaultMembersListView, EditorAlias = Constants.PropertyEditors.Aliases.ListView, DbType = "Nvarchar" }); } finally { diff --git a/src/Umbraco.Web/Models/ContentEditing/ContentPropertyDto.cs b/src/Umbraco.Web/Models/ContentEditing/ContentPropertyDto.cs index 8fe0317159..e80c76eb7b 100644 --- a/src/Umbraco.Web/Models/ContentEditing/ContentPropertyDto.cs +++ b/src/Umbraco.Web/Models/ContentEditing/ContentPropertyDto.cs @@ -15,11 +15,5 @@ namespace Umbraco.Web.Models.ContentEditing public string Description { get; set; } public bool IsRequired { get; set; } public string ValidationRegExp { get; set; } - - /// - /// The current pre-values for this property - /// - [JsonIgnore] - internal PreValueCollection PreValues { get; set; } } } diff --git a/src/Umbraco.Web/Models/ContentEditing/PreValueFieldDisplay.cs b/src/Umbraco.Web/Models/ContentEditing/DataTypeConfigurationFieldDisplay.cs similarity index 88% rename from src/Umbraco.Web/Models/ContentEditing/PreValueFieldDisplay.cs rename to src/Umbraco.Web/Models/ContentEditing/DataTypeConfigurationFieldDisplay.cs index 1276d72a1f..022746c7ec 100644 --- a/src/Umbraco.Web/Models/ContentEditing/PreValueFieldDisplay.cs +++ b/src/Umbraco.Web/Models/ContentEditing/DataTypeConfigurationFieldDisplay.cs @@ -1,44 +1,43 @@ -using System.Collections.Generic; -using System.Runtime.Serialization; - -namespace Umbraco.Web.Models.ContentEditing -{ - /// - /// Defines a pre value editable field for a data type - /// - [DataContract(Name = "preValue", Namespace = "")] - public class PreValueFieldDisplay : PreValueFieldSave - { - - /// - /// The name to display for this pre-value field - /// - [DataMember(Name = "label", IsRequired = true)] - public string Name { get; set; } - - /// - /// The description to display for this pre-value field - /// - [DataMember(Name = "description")] - public string Description { get; set; } - - /// - /// Specifies whether to hide the label for the pre-value - /// - [DataMember(Name = "hideLabel")] - public bool HideLabel { get; set; } - - /// - /// The view to render for the field - /// - [DataMember(Name = "view", IsRequired = true)] - public string View { get; set; } - - /// - /// This allows for custom configuration to be injected into the pre-value editor - /// - [DataMember(Name = "config")] - public IDictionary Config { get; set; } - - } -} +using System.Collections.Generic; +using System.Runtime.Serialization; + +namespace Umbraco.Web.Models.ContentEditing +{ + /// + /// Represents a datatype configuration field model for editing. + /// + [DataContract(Name = "preValue", Namespace = "")] + public class DataTypeConfigurationFieldDisplay : DataTypeConfigurationFieldSave + { + /// + /// The name to display for this pre-value field + /// + [DataMember(Name = "label", IsRequired = true)] + public string Name { get; set; } + + /// + /// The description to display for this pre-value field + /// + [DataMember(Name = "description")] + public string Description { get; set; } + + /// + /// Specifies whether to hide the label for the pre-value + /// + [DataMember(Name = "hideLabel")] + public bool HideLabel { get; set; } + + /// + /// The view to render for the field + /// + [DataMember(Name = "view", IsRequired = true)] + public string View { get; set; } + + /// + /// This allows for custom configuration to be injected into the pre-value editor + /// + [DataMember(Name = "config")] + public IDictionary Config { get; set; } + + } +} diff --git a/src/Umbraco.Web/Models/ContentEditing/PreValueFieldSave.cs b/src/Umbraco.Web/Models/ContentEditing/DataTypeConfigurationFieldSave.cs similarity index 60% rename from src/Umbraco.Web/Models/ContentEditing/PreValueFieldSave.cs rename to src/Umbraco.Web/Models/ContentEditing/DataTypeConfigurationFieldSave.cs index 34bcb75e04..a1887326fe 100644 --- a/src/Umbraco.Web/Models/ContentEditing/PreValueFieldSave.cs +++ b/src/Umbraco.Web/Models/ContentEditing/DataTypeConfigurationFieldSave.cs @@ -1,23 +1,23 @@ -using System.Runtime.Serialization; - -namespace Umbraco.Web.Models.ContentEditing -{ - /// - /// Defines a pre value editable field for a data type - /// - [DataContract(Name = "preValue", Namespace = "")] - public class PreValueFieldSave - { - /// - /// The key to store the pre-value against - /// - [DataMember(Name = "key", IsRequired = true)] - public string Key { get; set; } - - /// - /// The value stored for the pre-value field - /// - [DataMember(Name = "value", IsRequired = true)] - public object Value { get; set; } - } -} +using System.Runtime.Serialization; + +namespace Umbraco.Web.Models.ContentEditing +{ + /// + /// Represents a datatype configuration field model for editing. + /// + [DataContract(Name = "preValue", Namespace = "")] + public class DataTypeConfigurationFieldSave + { + /// + /// Gets the configuration field key. + /// + [DataMember(Name = "key", IsRequired = true)] + public string Key { get; set; } + + /// + /// Gets the configuration field value. + /// + [DataMember(Name = "value", IsRequired = true)] + public object Value { get; set; } // fixme - what's a value? + } +} diff --git a/src/Umbraco.Web/Models/ContentEditing/DataTypeDisplay.cs b/src/Umbraco.Web/Models/ContentEditing/DataTypeDisplay.cs index c61e02d37f..767b7acabf 100644 --- a/src/Umbraco.Web/Models/ContentEditing/DataTypeDisplay.cs +++ b/src/Umbraco.Web/Models/ContentEditing/DataTypeDisplay.cs @@ -27,7 +27,7 @@ namespace Umbraco.Web.Models.ContentEditing public IEnumerable AvailableEditors { get; set; } [DataMember(Name = "preValues")] - public IEnumerable PreValues { get; set; } + public IEnumerable PreValues { get; set; } /// /// This is used to add custom localized messages/strings to the response for the app to use for localized UI purposes. diff --git a/src/Umbraco.Web/Models/ContentEditing/DataTypeSave.cs b/src/Umbraco.Web/Models/ContentEditing/DataTypeSave.cs index 27b7aee1ef..dd671ab77e 100644 --- a/src/Umbraco.Web/Models/ContentEditing/DataTypeSave.cs +++ b/src/Umbraco.Web/Models/ContentEditing/DataTypeSave.cs @@ -8,34 +8,43 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.Models.ContentEditing { + /// + /// Represents a datatype model for editing. + /// [DataContract(Name = "dataType", Namespace = "")] public class DataTypeSave : EntityBasic { /// - /// The action to perform when saving this data type + /// Gets or sets the action to perform. /// /// - /// If either of the Publish actions are specified an exception will be thrown. + /// Some values (publish) are illegal here. /// [DataMember(Name = "action", IsRequired = true)] [Required] public ContentSaveAction Action { get; set; } + /// + /// Gets or sets the datatype editor. + /// [DataMember(Name = "selectedEditor", IsRequired = true)] [Required] - public string SelectedEditor { get; set; } - - [DataMember(Name = "preValues")] - public IEnumerable PreValues { get; set; } + public string EditorAlias { get; set; } /// - /// The real persisted data type + /// Gets or sets the datatype configuration fields. + /// + [DataMember(Name = "preValues")] + public IEnumerable ConfigurationFields { get; set; } + + /// + /// Gets or sets the persisted data type. /// [IgnoreDataMember] internal IDataType PersistedDataType { get; set; } /// - /// The PropertyEditor assigned + /// Gets or sets the property editor. /// [IgnoreDataMember] internal PropertyEditor PropertyEditor { get; set; } diff --git a/src/Umbraco.Web/Models/Mapping/ContentMapperProfile.cs b/src/Umbraco.Web/Models/Mapping/ContentMapperProfile.cs index 0577969799..5ebd5956d4 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentMapperProfile.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentMapperProfile.cs @@ -123,7 +123,7 @@ namespace Umbraco.Web.Models.Mapping Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}doctype", Label = localizedText.Localize("content/documentType"), Value = localizedText.UmbracoDictionaryTranslate(display.ContentTypeName), - View = Current.PropertyEditors[Constants.PropertyEditors.NoEditAlias].ValueEditor.View + View = Current.PropertyEditors[Constants.PropertyEditors.Aliases.NoEdit].ValueEditor.View }, new ContentPropertyDisplay { @@ -131,7 +131,7 @@ namespace Umbraco.Web.Models.Mapping Label = localizedText.Localize("content/releaseDate"), Value = display.ReleaseDate?.ToIsoString(), //Not editible for people without publish permission (U4-287) - View = display.AllowedActions.Contains(ActionPublish.Instance.Letter.ToString(CultureInfo.InvariantCulture)) ? "datepicker" : Current.PropertyEditors[Constants.PropertyEditors.NoEditAlias].ValueEditor.View, + View = display.AllowedActions.Contains(ActionPublish.Instance.Letter.ToString(CultureInfo.InvariantCulture)) ? "datepicker" : Current.PropertyEditors[Constants.PropertyEditors.Aliases.NoEdit].ValueEditor.View, Config = new Dictionary { {"offsetTime", "1"} @@ -144,7 +144,7 @@ namespace Umbraco.Web.Models.Mapping Label = localizedText.Localize("content/unpublishDate"), Value = display.ExpireDate.HasValue ? display.ExpireDate.Value.ToIsoString() : null, //Not editible for people without publish permission (U4-287) - View = display.AllowedActions.Contains(ActionPublish.Instance.Letter.ToString(CultureInfo.InvariantCulture)) ? "datepicker" : Current.PropertyEditors[Constants.PropertyEditors.NoEditAlias].ValueEditor.View, + View = display.AllowedActions.Contains(ActionPublish.Instance.Letter.ToString(CultureInfo.InvariantCulture)) ? "datepicker" : Current.PropertyEditors[Constants.PropertyEditors.Aliases.NoEdit].ValueEditor.View, Config = new Dictionary { {"offsetTime", "1"} diff --git a/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs b/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs index 355188e6fa..6d703c1f6e 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs @@ -35,7 +35,7 @@ namespace Umbraco.Web.Models.Mapping "No property editor found, converting to a Label", new NullReferenceException("The property editor with alias " + property.PropertyType.PropertyEditorAlias + " does not exist")); - editor = Current.PropertyEditors[Constants.PropertyEditors.NoEditAlias]; + editor = Current.PropertyEditors[Constants.PropertyEditors.Aliases.NoEdit]; } var result = new TDestination { diff --git a/src/Umbraco.Web/Models/Mapping/ContentPropertyDisplayConverter.cs b/src/Umbraco.Web/Models/Mapping/ContentPropertyDisplayConverter.cs index f2c55cf71d..7d5f126cb2 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentPropertyDisplayConverter.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentPropertyDisplayConverter.cs @@ -23,11 +23,11 @@ namespace Umbraco.Web.Models.Mapping var display = base.Convert(originalProp, dest, context); var dataTypeService = DataTypeService.Value; - var preVals = dataTypeService.GetPreValuesCollectionByDataTypeId(originalProp.PropertyType.DataTypeDefinitionId); + var config = dataTypeService.GetDataType(originalProp.PropertyType.DataTypeDefinitionId).Configuration; //configure the editor for display with the pre-values var valEditor = display.PropertyEditor.ValueEditor; - valEditor.ConfigureForDisplay(preVals); + valEditor.ConfigureForDisplay(config); //set the display properties after mapping display.Alias = originalProp.Alias; diff --git a/src/Umbraco.Web/Models/Mapping/ContentPropertyDtoConverter.cs b/src/Umbraco.Web/Models/Mapping/ContentPropertyDtoConverter.cs index 5a598eecbf..f6472bfa2c 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentPropertyDtoConverter.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentPropertyDtoConverter.cs @@ -25,10 +25,7 @@ namespace Umbraco.Web.Models.Mapping propertyDto.ValidationRegExp = originalProperty.PropertyType.ValidationRegExp; propertyDto.Description = originalProperty.PropertyType.Description; propertyDto.Label = originalProperty.PropertyType.Name; - - //TODO: We should be able to look both of these up at the same time! propertyDto.DataType = dataTypeService.GetDataType(originalProperty.PropertyType.DataTypeDefinitionId); - propertyDto.PreValues = dataTypeService.GetPreValuesCollectionByDataTypeId(originalProperty.PropertyType.DataTypeDefinitionId); return propertyDto; } diff --git a/src/Umbraco.Web/Models/Mapping/PreValueDisplayResolver.cs b/src/Umbraco.Web/Models/Mapping/DataTypeConfigurationFieldDisplayResolver.cs similarity index 50% rename from src/Umbraco.Web/Models/Mapping/PreValueDisplayResolver.cs rename to src/Umbraco.Web/Models/Mapping/DataTypeConfigurationFieldDisplayResolver.cs index 0abc8598b6..a7ae9eaabd 100644 --- a/src/Umbraco.Web/Models/Mapping/PreValueDisplayResolver.cs +++ b/src/Umbraco.Web/Models/Mapping/DataTypeConfigurationFieldDisplayResolver.cs @@ -1,76 +1,80 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using AutoMapper; -using Umbraco.Core; -using Umbraco.Core.Logging; -using Umbraco.Core.Models; -using Umbraco.Core.PropertyEditors; -using Umbraco.Core.Services; -using Umbraco.Web.Composing; -using Umbraco.Web.Models.ContentEditing; - -namespace Umbraco.Web.Models.Mapping -{ - internal class PreValueDisplayResolver - { - private readonly Lazy _dataTypeService; - - public PreValueDisplayResolver(Lazy dataTypeService) - { - _dataTypeService = dataTypeService; - } - - /// - /// Maps pre-values in the dictionary to the values for the fields - /// - /// - /// - internal static void MapPreValueValuesToPreValueFields(PreValueFieldDisplay[] fields, IDictionary preValues) - { - if (fields == null) throw new ArgumentNullException("fields"); - if (preValues == null) throw new ArgumentNullException("preValues"); - //now we need to wire up the pre-values values with the actual fields defined - foreach (var field in fields) - { - var found = preValues.Any(x => x.Key.InvariantEquals(field.Key)); - if (found == false) - { - Current.Logger.Warn("Could not find persisted pre-value for field " + field.Key); - continue; - } - field.Value = preValues.Single(x => x.Key.InvariantEquals(field.Key)).Value; - } - } - - public IEnumerable Resolve(IDataType source) - { - PropertyEditor propEd = null; - if (source.EditorAlias.IsNullOrWhiteSpace() == false) - { - propEd = Current.PropertyEditors[source.EditorAlias]; - if (propEd == null) - { - throw new InvalidOperationException("Could not find property editor with alias " + source.EditorAlias); - } - } - - //set up the defaults - var dataTypeService = _dataTypeService.Value; - var preVals = dataTypeService.GetPreValuesCollectionByDataTypeId(source.Id); - IDictionary dictionaryVals = preVals.FormatAsDictionary().ToDictionary(x => x.Key, x => (object)x.Value); - var result = Enumerable.Empty().ToArray(); - - //if we have a prop editor, then format the pre-values based on it and create it's fields. - if (propEd != null) - { - result = propEd.PreValueEditor.Fields.Select(Mapper.Map).ToArray(); - dictionaryVals = propEd.PreValueEditor.ConvertDbToEditor(propEd.DefaultPreValues, preVals); - } - - MapPreValueValuesToPreValueFields(result, dictionaryVals); - - return result; - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using AutoMapper; +using Umbraco.Core; +using Umbraco.Core.Logging; +using Umbraco.Core.Models; +using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Services; +using Umbraco.Web.Composing; +using Umbraco.Web.Models.ContentEditing; + +namespace Umbraco.Web.Models.Mapping +{ + internal class DataTypeConfigurationFieldDisplayResolver + { + private readonly IDataTypeService _dataTypeService; + + public DataTypeConfigurationFieldDisplayResolver(IDataTypeService dataTypeService) + { + _dataTypeService = dataTypeService; + } + + /// + /// Maps pre-values in the dictionary to the values for the fields + /// + internal static void MapPreValueValuesToPreValueFields(DataTypeConfigurationFieldDisplay[] fields, IDataTypeConfiguration configuration) + { + if (fields == null) throw new ArgumentNullException(nameof(fields)); + if (configuration == null) throw new ArgumentNullException(nameof(configuration)); + + var preValues = configuration.ToDictionary(); + + //now we need to wire up the pre-values values with the actual fields defined + foreach (var field in fields) + { + // fixme - how can we do this with configuration? + // we need the configuration to be able to be returned as Dictionary in order to be edited! + + var found = preValues.Any(x => x.Key.InvariantEquals(field.Key)); + if (found == false) + { + Current.Logger.Warn("Could not find persisted pre-value for field " + field.Key); + continue; + } + field.Value = preValues.Single(x => x.Key.InvariantEquals(field.Key)).Value; + } + } + + /// + /// Creates a set of configuration fields for a data type. + /// + public IEnumerable Resolve(IDataType dataType) + { + if (string.IsNullOrWhiteSpace(dataType.EditorAlias) || !Current.PropertyEditors.TryGet(dataType.EditorAlias, out var editor)) + throw new InvalidOperationException($"Could not find a property editor with alias \"{dataType.EditorAlias}\"."); + + var configuration = dataType.Configuration; + var fields = editor.PreValueEditor.Fields.Select(Mapper.Map).ToArray(); + var wtf = editor.PreValueEditor.ConvertDbToEditor(editor.DefaultPreValues, configuration); // but wtf? + + //set up the defaults + var dataTypeService = _dataTypeService.Value; + var preVals = dataTypeService.GetPreValuesCollectionByDataTypeId(dataType.Id); + IDictionary dictionaryVals = preVals.FormatAsDictionary().ToDictionary(x => x.Key, x => (object)x.Value); + var result = Enumerable.Empty().ToArray(); + + //if we have a prop editor, then format the pre-values based on it and create it's fields. + if (propEd != null) + { + result = propEd.PreValueEditor.Fields.Select(Mapper.Map).ToArray(); + dictionaryVals = propEd.PreValueEditor.ConvertDbToEditor(propEd.DefaultPreValues, preVals); + } + + MapPreValueValuesToPreValueFields(result, dictionaryVals); + + return result; + } + } +} diff --git a/src/Umbraco.Web/Models/Mapping/DataTypeMapperProfile.cs b/src/Umbraco.Web/Models/Mapping/DataTypeMapperProfile.cs index c7a9749715..65c95021fe 100644 --- a/src/Umbraco.Web/Models/Mapping/DataTypeMapperProfile.cs +++ b/src/Umbraco.Web/Models/Mapping/DataTypeMapperProfile.cs @@ -13,23 +13,21 @@ using Umbraco.Web.Models.ContentEditing; namespace Umbraco.Web.Models.Mapping { /// - /// Configure's model mappings for Data types + /// Configures model mappings for datatypes. /// internal class DataTypeMapperProfile : Profile { public DataTypeMapperProfile(IDataTypeService dataTypeService) { - var lazyDataTypeService = new Lazy(() => dataTypeService); - // create, capture, cache var availablePropertyEditorsResolver = new AvailablePropertyEditorsResolver(UmbracoConfig.For.UmbracoSettings().Content); - var preValueDisplayResolver = new PreValueDisplayResolver(lazyDataTypeService); + var preValueDisplayResolver = new DataTypeConfigurationFieldDisplayResolver(dataTypeService); var databaseTypeResolver = new DatabaseTypeResolver(); CreateMap(); - //just maps the standard properties, does not map the value! - CreateMap() + // map the standard properties, not the values + CreateMap() .ForMember(dest => dest.Value, opt => opt.Ignore()); var systemIds = new[] @@ -59,8 +57,7 @@ namespace Umbraco.Web.Models.Mapping .ForMember(dest => dest.IsSystemDataType, opt => opt.MapFrom(src => systemIds.Contains(src.Id))) .AfterMap((src, dest) => { - var editor = Current.PropertyEditors[src.EditorAlias]; - if (editor != null) + if (Current.PropertyEditors.TryGet(src.EditorAlias, out var editor)) { dest.Alias = editor.Alias; dest.Group = editor.Group; @@ -81,8 +78,7 @@ namespace Umbraco.Web.Models.Mapping .ForMember(dest => dest.IsSystemDataType, opt => opt.MapFrom(src => systemIds.Contains(src.Id))) .AfterMap((src, dest) => { - var editor = Current.PropertyEditors[src.EditorAlias]; - if (editor != null) + if (Current.PropertyEditors.TryGet(src.EditorAlias, out var editor)) { dest.Group = editor.Group; dest.Icon = editor.Icon; @@ -90,33 +86,31 @@ namespace Umbraco.Web.Models.Mapping }); //gets a list of PreValueFieldDisplay objects from the data type definition - CreateMap>() + CreateMap>() .ConvertUsing(src => preValueDisplayResolver.Resolve(src)); CreateMap() - .ConstructUsing(src => new DataType(src.SelectedEditor) {CreateDate = DateTime.Now}) + .ConstructUsing(src => new DataType(src.EditorAlias) {CreateDate = DateTime.Now}) .IgnoreEntityCommonProperties() .ForMember(dest => dest.Id, opt => opt.MapFrom(src => Convert.ToInt32(src.Id))) - //we have to ignore the Key otherwise this will reset the UniqueId field which should never change! - // http://issues.umbraco.org/issue/U4-3911 - .ForMember(dest => dest.Key, opt => opt.Ignore()) + .ForMember(dest => dest.Key, opt => opt.Ignore()) // ignore key, else resets UniqueId - U4-3911 .ForMember(dest => dest.Path, opt => opt.Ignore()) - .ForMember(dest => dest.EditorAlias, opt => opt.MapFrom(src => src.SelectedEditor)) + .ForMember(dest => dest.EditorAlias, opt => opt.MapFrom(src => src.EditorAlias)) .ForMember(dest => dest.DatabaseType, opt => opt.ResolveUsing(src => databaseTypeResolver.Resolve(src))) .ForMember(dest => dest.CreatorId, opt => opt.Ignore()) .ForMember(dest => dest.Level, opt => opt.Ignore()) .ForMember(dest => dest.SortOrder, opt => opt.Ignore()); //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>() + CreateMap>() .ConvertUsing(src => { //this is a new data type, so just return the field editors, there are no values yet var defaultVals = src.DefaultPreValues; - var fields = src.PreValueEditor.Fields.Select(Mapper.Map).ToArray(); + var fields = src.PreValueEditor.Fields.Select(Mapper.Map).ToArray(); if (defaultVals != null) { - PreValueDisplayResolver.MapPreValueValuesToPreValueFields(fields, defaultVals); + DataTypeConfigurationFieldDisplayResolver.MapPreValueValuesToPreValueFields(fields, defaultVals); } return fields; }); diff --git a/src/Umbraco.Web/Models/Mapping/DatabaseTypeResolver.cs b/src/Umbraco.Web/Models/Mapping/DatabaseTypeResolver.cs index d7ab7a912b..aebd82b124 100644 --- a/src/Umbraco.Web/Models/Mapping/DatabaseTypeResolver.cs +++ b/src/Umbraco.Web/Models/Mapping/DatabaseTypeResolver.cs @@ -12,10 +12,10 @@ namespace Umbraco.Web.Models.Mapping { public DataTypeDatabaseType Resolve(DataTypeSave source) { - var propertyEditor = Current.PropertyEditors[source.SelectedEditor]; + var propertyEditor = Current.PropertyEditors[source.EditorAlias]; if (propertyEditor == null) { - throw new InvalidOperationException("Could not find property editor with id " + source.SelectedEditor); + throw new InvalidOperationException("Could not find property editor with id " + source.EditorAlias); } return propertyEditor.ValueEditor.GetDatabaseType(); } diff --git a/src/Umbraco.Web/Models/Mapping/MacroMapperProfile.cs b/src/Umbraco.Web/Models/Mapping/MacroMapperProfile.cs index 4b162be3e2..1d08a8f9d0 100644 --- a/src/Umbraco.Web/Models/Mapping/MacroMapperProfile.cs +++ b/src/Umbraco.Web/Models/Mapping/MacroMapperProfile.cs @@ -40,7 +40,7 @@ namespace Umbraco.Web.Models.Mapping if (paramEditor == null) { //we'll just map this to a text box - paramEditor = Current.ParameterEditors[Constants.PropertyEditors.TextboxAlias]; + paramEditor = Current.ParameterEditors[Constants.PropertyEditors.Aliases.Textbox]; Current.Logger.Warn("Could not resolve a parameter editor with alias " + property.EditorAlias + ", a textbox will be rendered in it's place"); } diff --git a/src/Umbraco.Web/Models/Mapping/MediaMapperProfile.cs b/src/Umbraco.Web/Models/Mapping/MediaMapperProfile.cs index d25299ff43..9360466d76 100644 --- a/src/Umbraco.Web/Models/Mapping/MediaMapperProfile.cs +++ b/src/Umbraco.Web/Models/Mapping/MediaMapperProfile.cs @@ -93,7 +93,7 @@ namespace Umbraco.Web.Models.Mapping Alias = string.Format("{0}doctype", Constants.PropertyEditors.InternalGenericPropertiesPrefix), Label = localizedText.Localize("content/mediatype"), Value = localizedText.UmbracoDictionaryTranslate(display.ContentTypeName), - View = Current.PropertyEditors[Constants.PropertyEditors.NoEditAlias].ValueEditor.View + View = Current.PropertyEditors[Constants.PropertyEditors.Aliases.NoEdit].ValueEditor.View } }; diff --git a/src/Umbraco.Web/Models/Mapping/MemberMapperProfile.cs b/src/Umbraco.Web/Models/Mapping/MemberMapperProfile.cs index e844d97705..8c79ccc97c 100644 --- a/src/Umbraco.Web/Models/Mapping/MemberMapperProfile.cs +++ b/src/Umbraco.Web/Models/Mapping/MemberMapperProfile.cs @@ -179,7 +179,7 @@ namespace Umbraco.Web.Models.Mapping Alias = string.Format("{0}doctype", Constants.PropertyEditors.InternalGenericPropertiesPrefix), Label = localizedText.Localize("content/membertype"), Value = localizedText.UmbracoDictionaryTranslate(display.ContentTypeName), - View = Current.PropertyEditors[Constants.PropertyEditors.NoEditAlias].ValueEditor.View + View = Current.PropertyEditors[Constants.PropertyEditors.Aliases.NoEdit].ValueEditor.View }, GetLoginProperty(memberService, member, display, localizedText), new ContentPropertyDisplay diff --git a/src/Umbraco.Web/Models/Mapping/PropertyTypeGroupResolver.cs b/src/Umbraco.Web/Models/Mapping/PropertyTypeGroupResolver.cs index 47bc936293..e418e8833d 100644 --- a/src/Umbraco.Web/Models/Mapping/PropertyTypeGroupResolver.cs +++ b/src/Umbraco.Web/Models/Mapping/PropertyTypeGroupResolver.cs @@ -199,7 +199,7 @@ namespace Umbraco.Web.Models.Mapping foreach (var p in properties.Where(x => x.DataTypeDefinitionId != 0).OrderBy(x => x.SortOrder)) { var propertyEditor = _propertyEditors[p.PropertyEditorAlias]; - var preValues = _dataTypeService.GetPreValuesCollectionByDataTypeId(p.DataTypeDefinitionId); + var configuration = _dataTypeService.GetDataType(p.DataTypeDefinitionId).Configuration; if (propertyEditor == null) throw new InvalidOperationException("No property editor could be resolved with the alias: " + p.PropertyEditorAlias + ", ensure all packages are installed correctly."); @@ -213,7 +213,7 @@ namespace Umbraco.Web.Models.Mapping Validation = new PropertyTypeValidation {Mandatory = p.Mandatory, Pattern = p.ValidationRegExp}, Label = p.Name, View = propertyEditor.ValueEditor.View, - Config = propertyEditor.PreValueEditor.ConvertDbToEditor(propertyEditor.DefaultPreValues, preValues), + Config = propertyEditor.PreValueEditor.ConvertDbToEditor(propertyEditor.DefaultPreValues, configuration), //Value = "", GroupId = groupId, Inherited = inherited, diff --git a/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs b/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs index 4c18040daa..ac1ed519d3 100644 --- a/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs +++ b/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs @@ -57,7 +57,7 @@ namespace Umbraco.Web.Models.Mapping //store the current props to append to the newly inserted ones var currProps = genericProps.Properties.ToArray(); - var labelEditor = Current.PropertyEditors[Constants.PropertyEditors.NoEditAlias].ValueEditor.View; + var labelEditor = Current.PropertyEditors[Constants.PropertyEditors.Aliases.NoEdit].ValueEditor.View; var contentProps = new List { @@ -148,8 +148,6 @@ namespace Umbraco.Web.Models.Mapping throw new InvalidOperationException("No list view data type was found for this document type, ensure that the default list view data types exists and/or that your custom list view data type exists"); } - var preVals = dataTypeService.GetPreValuesCollectionByDataTypeId(dt.Id); - var editor = Current.PropertyEditors[dt.EditorAlias]; if (editor == null) { @@ -164,7 +162,7 @@ namespace Umbraco.Web.Models.Mapping IsActive = true }; - var listViewConfig = editor.PreValueEditor.ConvertDbToEditor(editor.DefaultPreValues, preVals); + var listViewConfig = editor.PreValueEditor.ConvertDbToEditor(editor.DefaultPreValues, dt.Configuration); //add the entity type to the config listViewConfig["entityType"] = entityType; diff --git a/src/Umbraco.Web/Models/PublishedContentBase.cs b/src/Umbraco.Web/Models/PublishedContentBase.cs index 099367642c..6d805e9914 100644 --- a/src/Umbraco.Web/Models/PublishedContentBase.cs +++ b/src/Umbraco.Web/Models/PublishedContentBase.cs @@ -62,10 +62,10 @@ namespace Umbraco.Web.Models // want to return the normal URL and the cropper stores data as json switch (propType.EditorAlias) { - case Constants.PropertyEditors.UploadFieldAlias: + case Constants.PropertyEditors.Aliases.UploadField: _url = prop.GetValue().ToString(); break; - case Constants.PropertyEditors.ImageCropperAlias: + case Constants.PropertyEditors.Aliases.ImageCropper: //get the url from the json format var stronglyTyped = prop.GetValue() as ImageCropDataSet; diff --git a/src/Umbraco.Web/PropertyEditors/CheckBoxListPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/CheckBoxListPropertyEditor.cs index 0dced99749..4f24949088 100644 --- a/src/Umbraco.Web/PropertyEditors/CheckBoxListPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/CheckBoxListPropertyEditor.cs @@ -13,7 +13,7 @@ namespace Umbraco.Web.PropertyEditors /// as INT and we have logic in here to ensure it is formatted correctly including ensuring that the string value is published /// in cache and not the int ID. /// - [PropertyEditor(Constants.PropertyEditors.CheckBoxListAlias, "Checkbox list", "checkboxlist", Icon="icon-bulleted-list", Group="lists")] + [PropertyEditor(Constants.PropertyEditors.Aliases.CheckBoxList, "Checkbox list", "checkboxlist", Icon="icon-bulleted-list", Group="lists")] public class CheckBoxListPropertyEditor : PropertyEditor { private readonly ILocalizedTextService _textService; @@ -33,7 +33,7 @@ namespace Umbraco.Web.PropertyEditors /// /// We are just going to re-use the ValueListPreValueEditor /// - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new ValueListPreValueEditor(_textService, Logger); } diff --git a/src/Umbraco.Web/PropertyEditors/ColorListPreValueEditor.cs b/src/Umbraco.Web/PropertyEditors/ColorListPreValueEditor.cs index e8bfa3202b..ab1b60d8fa 100644 --- a/src/Umbraco.Web/PropertyEditors/ColorListPreValueEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ColorListPreValueEditor.cs @@ -38,7 +38,7 @@ namespace Umbraco.Web.PropertyEditors internal class ColorListValidator : IPropertyValidator { - public IEnumerable Validate(object value, PreValueCollection preValues, PropertyEditor editor) + public IEnumerable Validate(object value, object dataTypeConfiguration, PropertyEditor editor) { var json = value as JArray; if (json == null) yield break; diff --git a/src/Umbraco.Web/PropertyEditors/ColorPickerPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/ColorPickerPropertyEditor.cs index 6112118968..213ee981ab 100644 --- a/src/Umbraco.Web/PropertyEditors/ColorPickerPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ColorPickerPropertyEditor.cs @@ -5,7 +5,7 @@ using Umbraco.Core.Services; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.ColorPickerAlias, "Color Picker", "colorpicker", Icon="icon-colorpicker", Group="Pickers")] + [PropertyEditor(Constants.PropertyEditors.Aliases.ColorPicker, "Color Picker", "colorpicker", Icon="icon-colorpicker", Group="Pickers")] public class ColorPickerPropertyEditor : PropertyEditor { private readonly ILocalizedTextService _textService; @@ -25,7 +25,7 @@ namespace Umbraco.Web.PropertyEditors /// /// ColorListPreValueEditor uses the ValueListPreValueEditor with a custom view and controller. /// - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new ColorListPreValueEditor(_textService, Logger); } diff --git a/src/Umbraco.Web/PropertyEditors/ContentPicker2PropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/ContentPicker2PropertyEditor.cs index 880df08859..67b47b0594 100644 --- a/src/Umbraco.Web/PropertyEditors/ContentPicker2PropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ContentPicker2PropertyEditor.cs @@ -8,7 +8,7 @@ namespace Umbraco.Web.PropertyEditors /// /// Content property editor that stores UDI /// - [PropertyEditor(Constants.PropertyEditors.ContentPicker2Alias, "Content Picker", PropertyEditorValueTypes.String, "contentpicker", IsParameterEditor = true, Group = "Pickers")] + [PropertyEditor(Constants.PropertyEditors.Aliases.ContentPicker2Alias, "Content Picker", PropertyEditorValueTypes.String, "contentpicker", IsParameterEditor = true, Group = "Pickers")] public class ContentPicker2PropertyEditor : PropertyEditor { public ContentPicker2PropertyEditor(ILogger logger) @@ -32,7 +32,7 @@ namespace Umbraco.Web.PropertyEditors set => InternalPreValues = value; } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new ContentPickerPreValueEditor(); } @@ -42,14 +42,14 @@ namespace Umbraco.Web.PropertyEditors public ContentPickerPreValueEditor() { //create the fields - Fields.Add(new PreValueField() + Fields.Add(new DataTypeConfigurationField() { Key = "showOpenButton", View = "boolean", Name = "Show open button (this feature is in preview!)", Description = "Opens the node in a dialog" }); - Fields.Add(new PreValueField() + Fields.Add(new DataTypeConfigurationField() { Key = "startNodeId", View = "treepicker", diff --git a/src/Umbraco.Web/PropertyEditors/ContentPickerPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/ContentPickerPropertyEditor.cs index bd47f845ef..8e35e9d55f 100644 --- a/src/Umbraco.Web/PropertyEditors/ContentPickerPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ContentPickerPropertyEditor.cs @@ -16,9 +16,9 @@ namespace Umbraco.Web.PropertyEditors InternalPreValues["idType"] = "int"; } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { - var preValEditor = base.CreatePreValueEditor(); + var preValEditor = base.CreateConfigurationEditor(); preValEditor.Fields.Single(x => x.Key == "startNodeId").Config["idType"] = "int"; return preValEditor; } diff --git a/src/Umbraco.Web/PropertyEditors/DateConfigurationEditor.cs b/src/Umbraco.Web/PropertyEditors/DateConfigurationEditor.cs new file mode 100644 index 0000000000..f16c76ead1 --- /dev/null +++ b/src/Umbraco.Web/PropertyEditors/DateConfigurationEditor.cs @@ -0,0 +1,10 @@ +using Umbraco.Core.PropertyEditors; + +namespace Umbraco.Web.PropertyEditors +{ + internal class DateConfigurationEditor : DataTypeConfigurationEditor + { + [DataTypeConfigurationField("format", "Date format", "textstring", Description = "If left empty then the format is YYYY-MM-DD. (see momentjs.com for supported formats)")] + public string DefaultValue { get; set; } + } +} diff --git a/src/Umbraco.Web/PropertyEditors/DatePreValueEditor.cs b/src/Umbraco.Web/PropertyEditors/DatePreValueEditor.cs deleted file mode 100644 index 9200be9f7e..0000000000 --- a/src/Umbraco.Web/PropertyEditors/DatePreValueEditor.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Umbraco.Core.PropertyEditors; - -namespace Umbraco.Web.PropertyEditors -{ - internal class DatePreValueEditor : PreValueEditor - { - [PreValueField("format", "Date format", "textstring", Description = "If left empty then the format is YYYY-MM-DD. (see momentjs.com for supported formats)")] - public string DefaultValue { get; set; } - } -} diff --git a/src/Umbraco.Web/PropertyEditors/DatePropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/DatePropertyEditor.cs index 6f9ed2c036..5094853907 100644 --- a/src/Umbraco.Web/PropertyEditors/DatePropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/DatePropertyEditor.cs @@ -10,7 +10,7 @@ using Umbraco.Core.Services; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.DateAlias, "Date", PropertyEditorValueTypes.Date, "datepicker", Icon="icon-calendar")] + [PropertyEditor(Constants.PropertyEditors.Aliases.Date, "Date", PropertyEditorValueTypes.Date, "datepicker", Icon="icon-calendar")] public class DatePropertyEditor : PropertyEditor { public DatePropertyEditor(ILogger logger): base(logger) @@ -59,9 +59,9 @@ namespace Umbraco.Web.PropertyEditors } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { - return new DatePreValueEditor(); + return new DateConfigurationEditor(); } } } diff --git a/src/Umbraco.Web/PropertyEditors/DateTimePreValueEditor.cs b/src/Umbraco.Web/PropertyEditors/DateTimePreValueEditor.cs index 272f1e58af..de044c88c4 100644 --- a/src/Umbraco.Web/PropertyEditors/DateTimePreValueEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/DateTimePreValueEditor.cs @@ -2,9 +2,9 @@ namespace Umbraco.Web.PropertyEditors { - internal class DateTimePreValueEditor : DatePreValueEditor + internal class DateTimePreValueEditor : DateConfigurationEditor { - [PreValueField("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")] + [DataTypeConfigurationField("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; } } } diff --git a/src/Umbraco.Web/PropertyEditors/DateTimePropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/DateTimePropertyEditor.cs index 82c68e136b..5e398d02a4 100644 --- a/src/Umbraco.Web/PropertyEditors/DateTimePropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/DateTimePropertyEditor.cs @@ -9,7 +9,7 @@ using Umbraco.Core.Services; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.DateTimeAlias, "Date/Time", "datepicker", ValueType = PropertyEditorValueTypes.DateTime, Icon="icon-time")] + [PropertyEditor(Constants.PropertyEditors.Aliases.DateTime, "Date/Time", "datepicker", ValueType = PropertyEditorValueTypes.DateTime, Icon="icon-time")] public class DateTimePropertyEditor : PropertyEditor { public DateTimePropertyEditor(ILogger logger): base(logger) @@ -46,7 +46,7 @@ namespace Umbraco.Web.PropertyEditors return editor; } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new DateTimePreValueEditor(); } diff --git a/src/Umbraco.Web/PropertyEditors/DecimalPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/DecimalPropertyEditor.cs index 50a69ecc80..81bd73e7c9 100644 --- a/src/Umbraco.Web/PropertyEditors/DecimalPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/DecimalPropertyEditor.cs @@ -1,10 +1,11 @@ using Umbraco.Core; using Umbraco.Core.Logging; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.PropertyEditors.Validators; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.DecimalAlias, "Decimal", PropertyEditorValueTypes.Decimal, "decimal", IsParameterEditor = true)] + [PropertyEditor(Constants.PropertyEditors.Aliases.Decimal, "Decimal", PropertyEditorValueTypes.Decimal, "decimal", IsParameterEditor = true)] public class DecimalPropertyEditor : PropertyEditor { /// @@ -25,7 +26,7 @@ namespace Umbraco.Web.PropertyEditors return editor; } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new DecimalPreValueEditor(); } @@ -38,21 +39,21 @@ namespace Umbraco.Web.PropertyEditors public DecimalPreValueEditor() { //create the fields - Fields.Add(new PreValueField(new DecimalValidator()) + Fields.Add(new DataTypeConfigurationField(new DecimalValidator()) { Description = "Enter the minimum amount of number to be entered", Key = "min", View = "decimal", Name = "Minimum" }); - Fields.Add(new PreValueField(new DecimalValidator()) + Fields.Add(new DataTypeConfigurationField(new DecimalValidator()) { Description = "Enter the intervals amount between each step of number to be entered", Key = "step", View = "decimal", Name = "Step Size" }); - Fields.Add(new PreValueField(new DecimalValidator()) + Fields.Add(new DataTypeConfigurationField(new DecimalValidator()) { Description = "Enter the maximum amount of number to be entered", Key = "max", diff --git a/src/Umbraco.Web/PropertyEditors/DropDownMultiplePropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/DropDownMultiplePropertyEditor.cs index ceaa71b2b7..735f3addd4 100644 --- a/src/Umbraco.Web/PropertyEditors/DropDownMultiplePropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/DropDownMultiplePropertyEditor.cs @@ -16,7 +16,7 @@ namespace Umbraco.Web.PropertyEditors [ParameterEditor("propertyTypePickerMultiple", "Name", "textbox")] [ParameterEditor("contentTypeMultiple", "Name", "textbox")] [ParameterEditor("tabPickerMultiple", "Name", "textbox")] - [PropertyEditor(Constants.PropertyEditors.DropDownListMultipleAlias, "Dropdown list multiple", "dropdown", Group = "lists", Icon="icon-bulleted-list")] + [PropertyEditor(Constants.PropertyEditors.Aliases.DropDownListMultiple, "Dropdown list multiple", "dropdown", Group = "lists", Icon="icon-bulleted-list")] public class DropDownMultiplePropertyEditor : DropDownMultipleWithKeysPropertyEditor { /// diff --git a/src/Umbraco.Web/PropertyEditors/DropDownMultipleWithKeysPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/DropDownMultipleWithKeysPropertyEditor.cs index def9b8763e..f697bf7e9b 100644 --- a/src/Umbraco.Web/PropertyEditors/DropDownMultipleWithKeysPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/DropDownMultipleWithKeysPropertyEditor.cs @@ -14,7 +14,7 @@ namespace Umbraco.Web.PropertyEditors /// Due to maintaining backwards compatibility this data type stores the value as a string which is a comma separated value of the /// ids of the individual items so we have logic in here to deal with that. /// - [PropertyEditor(Constants.PropertyEditors.DropdownlistMultiplePublishKeysAlias, "Dropdown list multiple, publish keys", "dropdown", Group = "lists", Icon = "icon-bulleted-list")] + [PropertyEditor(Constants.PropertyEditors.Aliases.DropdownlistMultiplePublishKeys, "Dropdown list multiple, publish keys", "dropdown", Group = "lists", Icon = "icon-bulleted-list")] public class DropDownMultipleWithKeysPropertyEditor : DropDownPropertyEditor { private readonly ILocalizedTextService _textService; @@ -32,7 +32,7 @@ namespace Umbraco.Web.PropertyEditors return new PublishValuesMultipleValueEditor(true, base.CreateValueEditor()); } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new DropDownMultiplePreValueEditor(_textService, Logger); } @@ -50,7 +50,7 @@ namespace Umbraco.Web.PropertyEditors : base(textService, logger) { //add the multiple field, we'll make it hidden so it is not seen in the pre-value editor - Fields.Add(new PreValueField + Fields.Add(new DataTypeConfigurationField { Key = "multiple", Name = "multiple", diff --git a/src/Umbraco.Web/PropertyEditors/DropDownPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/DropDownPropertyEditor.cs index 24b42b5e00..ff0fc1a553 100644 --- a/src/Umbraco.Web/PropertyEditors/DropDownPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/DropDownPropertyEditor.cs @@ -18,7 +18,7 @@ namespace Umbraco.Web.PropertyEditors /// as INT and we have logic in here to ensure it is formatted correctly including ensuring that the string value is published /// in cache and not the int ID. /// - [PropertyEditor(Constants.PropertyEditors.DropDownListAlias, "Dropdown list", "dropdown", ValueType = PropertyEditorValueTypes.String, Group = "lists", Icon = "icon-indent")] + [PropertyEditor(Constants.PropertyEditors.Aliases.DropDownList, "Dropdown list", "dropdown", ValueType = PropertyEditorValueTypes.String, Group = "lists", Icon = "icon-indent")] public class DropDownPropertyEditor : DropDownWithKeysPropertyEditor { /// diff --git a/src/Umbraco.Web/PropertyEditors/DropDownWithKeysPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/DropDownWithKeysPropertyEditor.cs index a1d0d2e46d..e024a60002 100644 --- a/src/Umbraco.Web/PropertyEditors/DropDownWithKeysPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/DropDownWithKeysPropertyEditor.cs @@ -13,7 +13,7 @@ namespace Umbraco.Web.PropertyEditors /// as INT and we have logic in here to ensure it is formatted correctly including ensuring that the INT ID value is published /// in cache and not the string value. /// - [PropertyEditor(Constants.PropertyEditors.DropdownlistPublishingKeysAlias, "Dropdown list, publishing keys", "dropdown", ValueType = PropertyEditorValueTypes.Integer, Group = "lists", Icon = "icon-indent")] + [PropertyEditor(Constants.PropertyEditors.Aliases.DropdownlistPublishKeys, "Dropdown list, publishing keys", "dropdown", ValueType = PropertyEditorValueTypes.Integer, Group = "lists", Icon = "icon-indent")] public class DropDownWithKeysPropertyEditor : PropertyEditor { private readonly ILocalizedTextService _textService; @@ -30,7 +30,7 @@ namespace Umbraco.Web.PropertyEditors /// Return a custom pre-value editor /// /// - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new ValueListPreValueEditor(_textService, Logger); } diff --git a/src/Umbraco.Web/PropertyEditors/EmailAddressPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/EmailAddressPropertyEditor.cs index 57f11ad5e5..b4f293a1cc 100644 --- a/src/Umbraco.Web/PropertyEditors/EmailAddressPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/EmailAddressPropertyEditor.cs @@ -1,10 +1,11 @@ using Umbraco.Core; using Umbraco.Core.Logging; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.PropertyEditors.Validators; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.EmailAddressAlias, "Email address", "email", Icon="icon-message")] + [PropertyEditor(Constants.PropertyEditors.Aliases.EmailAddress, "Email address", "email", Icon="icon-message")] public class EmailAddressPropertyEditor : PropertyEditor { /// @@ -22,7 +23,7 @@ namespace Umbraco.Web.PropertyEditors return editor; } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new EmailAddressePreValueEditor(); } @@ -31,7 +32,7 @@ namespace Umbraco.Web.PropertyEditors { //TODO: This doesn't seem necessary since it can be specified at the property type level - this will however be useful if/when // we support overridden property value pre-value options. - [PreValueField("Required?", "boolean")] + [DataTypeConfigurationField("Required?", "boolean")] public bool IsRequired { get; set; } } diff --git a/src/Umbraco.Web/PropertyEditors/FileUploadPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/FileUploadPropertyEditor.cs index 79824c96d7..4e0527be0a 100644 --- a/src/Umbraco.Web/PropertyEditors/FileUploadPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/FileUploadPropertyEditor.cs @@ -13,7 +13,7 @@ using Umbraco.Core.Services; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.UploadFieldAlias, "File upload", "fileupload", Icon = "icon-download-alt", Group = "media")] + [PropertyEditor(Constants.PropertyEditors.Aliases.UploadField, "File upload", "fileupload", Icon = "icon-download-alt", Group = "media")] public class FileUploadPropertyEditor : PropertyEditor { private readonly MediaFileSystem _mediaFileSystem; @@ -43,7 +43,7 @@ namespace Umbraco.Web.PropertyEditors /// Creates the corresponding preValue editor. /// /// The corresponding preValue editor. - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new FileUploadPreValueEditor(_textService, Logger); } @@ -56,7 +56,7 @@ namespace Umbraco.Web.PropertyEditors /// A value indicating whether a property is an upload field, and (optionaly) has a non-empty value. private static bool IsUploadField(Property property, bool ensureValue) { - if (property.PropertyType.PropertyEditorAlias != Constants.PropertyEditors.UploadFieldAlias) + if (property.PropertyType.PropertyEditorAlias != Constants.PropertyEditors.Aliases.UploadField) return false; if (ensureValue == false) return true; @@ -232,7 +232,7 @@ namespace Umbraco.Web.PropertyEditors internal class ThumbnailListValidator : IPropertyValidator { - public IEnumerable Validate(object value, PreValueCollection preValues, PropertyEditor editor) + public IEnumerable Validate(object value, object dataTypeConfiguration, PropertyEditor editor) { if (!(value is JArray json)) yield break; diff --git a/src/Umbraco.Web/PropertyEditors/FolderBrowserPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/FolderBrowserPropertyEditor.cs index 40cd693380..8cb0875f43 100644 --- a/src/Umbraco.Web/PropertyEditors/FolderBrowserPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/FolderBrowserPropertyEditor.cs @@ -6,7 +6,7 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { [Obsolete("This is no longer used by default, use the ListViewPropertyEditor instead")] - [PropertyEditor(Constants.PropertyEditors.FolderBrowserAlias, "(Obsolete) Folder Browser", "folderbrowser", HideLabel=true, Icon="icon-folder", Group="media", IsDeprecated = true)] + [PropertyEditor(Constants.PropertyEditors.Aliases.FolderBrowser, "(Obsolete) Folder Browser", "folderbrowser", HideLabel=true, Icon="icon-folder", Group="media", IsDeprecated = true)] public class FolderBrowserPropertyEditor : PropertyEditor { /// diff --git a/src/Umbraco.Web/PropertyEditors/GridPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/GridPropertyEditor.cs index 1dafd8c16d..ea29cb662a 100644 --- a/src/Umbraco.Web/PropertyEditors/GridPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/GridPropertyEditor.cs @@ -15,7 +15,7 @@ namespace Umbraco.Web.PropertyEditors { using Examine = global::Examine; - [PropertyEditor(Constants.PropertyEditors.GridAlias, "Grid layout", "grid", HideLabel = true, IsParameterEditor = false, ValueType = PropertyEditorValueTypes.Json, Group="rich content", Icon="icon-layout")] + [PropertyEditor(Constants.PropertyEditors.Aliases.Grid, "Grid layout", "grid", HideLabel = true, IsParameterEditor = false, ValueType = PropertyEditorValueTypes.Json, Group="rich content", Icon="icon-layout")] public class GridPropertyEditor : PropertyEditor { public GridPropertyEditor(ILogger logger) @@ -115,7 +115,7 @@ namespace Umbraco.Web.PropertyEditors return new GridPropertyValueEditor(baseEditor); } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new GridPreValueEditor(); } @@ -131,10 +131,10 @@ namespace Umbraco.Web.PropertyEditors internal class GridPreValueEditor : PreValueEditor { - [PreValueField("items", "Grid", "views/propertyeditors/grid/grid.prevalues.html", Description = "Grid configuration")] + [DataTypeConfigurationField("items", "Grid", "views/propertyeditors/grid/grid.prevalues.html", Description = "Grid configuration")] public string Items { get; set; } - [PreValueField("rte", "Rich text editor", "views/propertyeditors/rte/rte.prevalues.html", Description = "Rich text editor configuration")] + [DataTypeConfigurationField("rte", "Rich text editor", "views/propertyeditors/rte/rte.prevalues.html", Description = "Rich text editor configuration")] public string Rte { get; set; } } } diff --git a/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditor.cs index 167e3d2a0b..4c90eacb9d 100644 --- a/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditor.cs @@ -14,7 +14,7 @@ using Umbraco.Core.Services; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.ImageCropperAlias, "Image Cropper", "imagecropper", ValueType = PropertyEditorValueTypes.Json, HideLabel = false, Group="media", Icon="icon-crop")] + [PropertyEditor(Constants.PropertyEditors.Aliases.ImageCropper, "Image Cropper", "imagecropper", ValueType = PropertyEditorValueTypes.Json, HideLabel = false, Group="media", Icon="icon-crop")] public class ImageCropperPropertyEditor : PropertyEditor { private readonly MediaFileSystem _mediaFileSystem; @@ -61,7 +61,7 @@ namespace Umbraco.Web.PropertyEditors /// Creates the corresponding preValue editor. /// /// The corresponding preValue editor. - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new ImageCropperPreValueEditor(); } @@ -74,7 +74,7 @@ namespace Umbraco.Web.PropertyEditors /// A value indicating whether a property is an image cropper field, and (optionaly) has a non-empty value. private static bool IsCropperField(Property property, bool ensureValue) { - if (property.PropertyType.PropertyEditorAlias != Constants.PropertyEditors.ImageCropperAlias) + if (property.PropertyType.PropertyEditorAlias != Constants.PropertyEditors.Aliases.ImageCropper) return false; if (ensureValue == false) return true; @@ -220,6 +220,8 @@ namespace Umbraco.Web.PropertyEditors continue; } + var v = JsonConvert.DeserializeObject() + var jo = GetJObject(svalue, false); string src; if (jo == null) @@ -250,7 +252,7 @@ namespace Umbraco.Web.PropertyEditors internal class ImageCropperPreValueEditor : PreValueEditor { - [PreValueField("crops", "Crop sizes", "views/propertyeditors/imagecropper/imagecropper.prevalues.html")] + [DataTypeConfigurationField("crops", "Crop sizes", "views/propertyeditors/imagecropper/imagecropper.prevalues.html")] public string Crops { get; set; } } } diff --git a/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyValueEditor.cs b/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyValueEditor.cs index 9bb756297a..3121d28c76 100644 --- a/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyValueEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyValueEditor.cs @@ -42,7 +42,7 @@ namespace Umbraco.Web.PropertyEditors var json = val as JObject; if (json != null) { - ImageCropperValueConverter.MergePreValues(json, dataTypeService, propertyType.DataTypeDefinitionId); + ImageCropperValueConverter.MergeConfiguration(json, dataTypeService, propertyType.DataTypeDefinitionId); return json; } diff --git a/src/Umbraco.Web/PropertyEditors/IntegerPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/IntegerPropertyEditor.cs index da7fdf2b3a..0f9b69d4e2 100644 --- a/src/Umbraco.Web/PropertyEditors/IntegerPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/IntegerPropertyEditor.cs @@ -1,10 +1,11 @@ using Umbraco.Core; using Umbraco.Core.Logging; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.PropertyEditors.Validators; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.IntegerAlias, "Numeric", "integer", IsParameterEditor = true, ValueType = PropertyEditorValueTypes.IntegerAlternative)] + [PropertyEditor(Constants.PropertyEditors.Aliases.Integer, "Numeric", "integer", IsParameterEditor = true, ValueType = PropertyEditorValueTypes.IntegerAlternative)] public class IntegerPropertyEditor : PropertyEditor { /// @@ -25,7 +26,7 @@ namespace Umbraco.Web.PropertyEditors return editor; } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new IntegerPreValueEditor(); } @@ -38,21 +39,21 @@ namespace Umbraco.Web.PropertyEditors public IntegerPreValueEditor() { //create the fields - Fields.Add(new PreValueField(new IntegerValidator()) + Fields.Add(new DataTypeConfigurationField(new IntegerValidator()) { Description = "Enter the minimum amount of number to be entered", Key = "min", View = "number", Name = "Minimum" }); - Fields.Add(new PreValueField(new IntegerValidator()) + Fields.Add(new DataTypeConfigurationField(new IntegerValidator()) { Description = "Enter the intervals amount between each step of number to be entered", Key = "step", View = "number", Name = "Step Size" }); - Fields.Add(new PreValueField(new IntegerValidator()) + Fields.Add(new DataTypeConfigurationField(new IntegerValidator()) { Description = "Enter the maximum amount of number to be entered", Key = "max", diff --git a/src/Umbraco.Web/PropertyEditors/LabelPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/LabelPropertyEditor.cs index f0f8006072..b3fed0c725 100644 --- a/src/Umbraco.Web/PropertyEditors/LabelPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/LabelPropertyEditor.cs @@ -8,61 +8,69 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.NoEditAlias, "Label", "readonlyvalue", Icon = "icon-readonly")] + /// + /// Represents a property editor for label properties. + /// + [PropertyEditor(Constants.PropertyEditors.Aliases.NoEdit, "Label", "readonlyvalue", Icon = "icon-readonly")] public class LabelPropertyEditor : PropertyEditor { /// - /// The constructor will setup the property editor based on the attribute if one is found + /// Initializes a new instance of the class. /// - public LabelPropertyEditor(ILogger logger) : base(logger) - { - } + /// + public LabelPropertyEditor(ILogger logger) + : base(logger) + { } + + /// protected override PropertyValueEditor CreateValueEditor() { return new LabelPropertyValueEditor(base.CreateValueEditor()); } - protected override PreValueEditor CreatePreValueEditor() + /// + protected override PreValueEditor CreateConfigurationEditor() { return new LabelPreValueEditor(); } - /// - /// Custom value editor to mark it as readonly - /// + // provides the property value editor internal class LabelPropertyValueEditor : PropertyValueEditorWrapper { public LabelPropertyValueEditor(PropertyValueEditor wrapped) : base(wrapped) - { - } + { } - /// - /// This editor is for display purposes only, any values bound to it will not be saved back to the database - /// - public override bool IsReadOnly - { - get { return true; } - } + /// + public override bool IsReadOnly => true; } + // provides the datatype configuration editor internal class LabelPreValueEditor : PreValueEditor { - private const string LegacyPropertyEditorValuesKey = "values"; + private const string LegacyPropertyEditorValuesKey = "values"; // fixme wtf is this?! public LabelPreValueEditor() { - Fields.Add(new PreValueField() + //Fields.Add(new DataTypeConfigurationField + //{ + // Key = Constants.PropertyEditors.PreValueKeys.DataValueType, + // Name = "Value type", + // View = "valuetype" + //}); + Fields.Add(new DataTypeConfigurationField { HideLabel = true, View = "readonlykeyvalues", Key = LegacyPropertyEditorValuesKey }); + // fixme what ValueType = PropertyEditorValueTypes.String; } - [PreValueField(Constants.PropertyEditors.PreValueKeys.DataValueType, "Value type", "valuetype")] + // fixme - mixing declarative and code fields, what a mess?! + [DataTypeConfigurationField(Constants.PropertyEditors.ConfigurationKeys.DataValueType, "Value type", "valuetype")] public string ValueType { get; set; } /// @@ -78,19 +86,19 @@ namespace Umbraco.Web.PropertyEditors // Check for a saved value type. If not found set to default string type. var valueType = PropertyEditorValueTypes.String; - if (existing.ContainsKey(Constants.PropertyEditors.PreValueKeys.DataValueType)) + if (existing.ContainsKey(Constants.PropertyEditors.ConfigurationKeys.DataValueType)) { - valueType = (string)existing[Constants.PropertyEditors.PreValueKeys.DataValueType]; + valueType = (string)existing[Constants.PropertyEditors.ConfigurationKeys.DataValueType]; } // Convert any other values from a legacy property editor to a list, easier to enumerate on the editor. // Make sure to exclude values defined on the label property editor itself. var asList = existing .Select(e => new KeyValuePair(e.Key, e.Value)) - .Where(e => e.Key != Constants.PropertyEditors.PreValueKeys.DataValueType) + .Where(e => e.Key != Constants.PropertyEditors.ConfigurationKeys.DataValueType) .ToList(); - var result = new Dictionary { { Constants.PropertyEditors.PreValueKeys.DataValueType, valueType } }; + var result = new Dictionary { { Constants.PropertyEditors.ConfigurationKeys.DataValueType, valueType } }; if (asList.Any()) { result.Add(LegacyPropertyEditorValuesKey, asList); diff --git a/src/Umbraco.Web/PropertyEditors/ListViewPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/ListViewPropertyEditor.cs index 04b362d600..788507fe46 100644 --- a/src/Umbraco.Web/PropertyEditors/ListViewPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ListViewPropertyEditor.cs @@ -5,7 +5,7 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.ListViewAlias, "List view", "listview", HideLabel = true, Group = "lists", Icon = "icon-item-arrangement")] + [PropertyEditor(Constants.PropertyEditors.Aliases.ListView, "List view", "listview", HideLabel = true, Group = "lists", Icon = "icon-item-arrangement")] public class ListViewPropertyEditor : PropertyEditor { /// @@ -15,7 +15,7 @@ namespace Umbraco.Web.PropertyEditors { } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new ListViewPreValueEditor(); } @@ -59,30 +59,30 @@ namespace Umbraco.Web.PropertyEditors internal class ListViewPreValueEditor : PreValueEditor { - [PreValueField("tabName", "Tab Name", "textstring", Description = "The name of the listview tab (default if empty: 'Child Items')")] + [DataTypeConfigurationField("tabName", "Tab Name", "textstring", Description = "The name of the listview tab (default if empty: 'Child Items')")] public int TabName { get; set; } - [PreValueField("displayAtTabNumber", "Display At Tab Number", "number", Description = "Which tab position that the list of child items will be displayed")] + [DataTypeConfigurationField("displayAtTabNumber", "Display At Tab Number", "number", Description = "Which tab position that the list of child items will be displayed")] public int DisplayAtTabNumber { get; set; } - [PreValueField("pageSize", "Page Size", "number", Description = "Number of items per page")] + [DataTypeConfigurationField("pageSize", "Page Size", "number", Description = "Number of items per page")] public int PageSize { get; set; } - [PreValueField("layouts", "Layouts", "views/propertyeditors/listview/layouts.prevalues.html")] + [DataTypeConfigurationField("layouts", "Layouts", "views/propertyeditors/listview/layouts.prevalues.html")] public int Layouts { get; set; } - [PreValueField("includeProperties", "Columns Displayed", "views/propertyeditors/listview/includeproperties.prevalues.html", + [DataTypeConfigurationField("includeProperties", "Columns Displayed", "views/propertyeditors/listview/includeproperties.prevalues.html", Description = "The properties that will be displayed for each column")] public object IncludeProperties { get; set; } - [PreValueField("orderBy", "Order By", "views/propertyeditors/listview/sortby.prevalues.html", + [DataTypeConfigurationField("orderBy", "Order By", "views/propertyeditors/listview/sortby.prevalues.html", Description = "The default sort order for the list")] public int OrderBy { get; set; } - [PreValueField("orderDirection", "Order Direction", "views/propertyeditors/listview/orderdirection.prevalues.html")] + [DataTypeConfigurationField("orderDirection", "Order Direction", "views/propertyeditors/listview/orderdirection.prevalues.html")] public int OrderDirection { get; set; } - [PreValueField("bulkActionPermissions", "Bulk Action Permissions", "views/propertyeditors/listview/bulkactionpermissions.prevalues.html", + [DataTypeConfigurationField("bulkActionPermissions", "Bulk Action Permissions", "views/propertyeditors/listview/bulkactionpermissions.prevalues.html", Description = "The bulk actions that are allowed from the list view")] public BulkActionPermissionSettings BulkActionPermissions { get; set; } diff --git a/src/Umbraco.Web/PropertyEditors/MacroContainerPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/MacroContainerPropertyEditor.cs index 0cc537c939..16624d84e3 100644 --- a/src/Umbraco.Web/PropertyEditors/MacroContainerPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/MacroContainerPropertyEditor.cs @@ -4,7 +4,7 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.MacroContainerAlias, "(Obsolete) Macro Picker", "macrocontainer", ValueType = PropertyEditorValueTypes.Text, Group="rich content", Icon="icon-settings-alt", IsDeprecated = true)] + [PropertyEditor(Constants.PropertyEditors.Aliases.MacroContainer, "(Obsolete) Macro Picker", "macrocontainer", ValueType = PropertyEditorValueTypes.Text, Group="rich content", Icon="icon-settings-alt", IsDeprecated = true)] public class MacroContainerPropertyEditor : PropertyEditor { public MacroContainerPropertyEditor(ILogger logger) @@ -12,17 +12,17 @@ namespace Umbraco.Web.PropertyEditors { } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new MacroContainerPreValueEditor(); } internal class MacroContainerPreValueEditor : PreValueEditor { - [PreValueField("max", "Max items", "number", Description = "The maximum number of macros that are allowed in the container")] + [DataTypeConfigurationField("max", "Max items", "number", Description = "The maximum number of macros that are allowed in the container")] public int MaxItems { get; set; } - [PreValueField("allowed", "Allowed items", "views/propertyeditors/macrocontainer/macrolist.prevalues.html", Description = "The macro types allowed, if none are selected all macros will be allowed")] + [DataTypeConfigurationField("allowed", "Allowed items", "views/propertyeditors/macrocontainer/macrolist.prevalues.html", Description = "The macro types allowed, if none are selected all macros will be allowed")] public object AllowedItems { get; set; } } } diff --git a/src/Umbraco.Web/PropertyEditors/MarkdownPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/MarkdownPropertyEditor.cs index 5ce51aac29..0de0ce500c 100644 --- a/src/Umbraco.Web/PropertyEditors/MarkdownPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/MarkdownPropertyEditor.cs @@ -4,7 +4,7 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.MarkdownEditorAlias, "Markdown editor", "markdowneditor", ValueType = PropertyEditorValueTypes.Text, Icon="icon-code", Group="rich content")] + [PropertyEditor(Constants.PropertyEditors.Aliases.MarkdownEditor, "Markdown editor", "markdowneditor", ValueType = PropertyEditorValueTypes.Text, Icon="icon-code", Group="rich content")] public class MarkdownPropertyEditor : PropertyEditor { /// @@ -14,17 +14,17 @@ namespace Umbraco.Web.PropertyEditors { } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new MarkdownPreValueEditor(); } internal class MarkdownPreValueEditor : PreValueEditor { - [PreValueField("preview", "Preview", "boolean", Description = "Display a live preview")] + [DataTypeConfigurationField("preview", "Preview", "boolean", Description = "Display a live preview")] public bool DisplayLivePreview { get; set; } - [PreValueField("defaultValue", "Default value", "textarea", Description = "If value is blank, the editor will show this")] + [DataTypeConfigurationField("defaultValue", "Default value", "textarea", Description = "If value is blank, the editor will show this")] public string DefaultValue { get; set; } } } diff --git a/src/Umbraco.Web/PropertyEditors/MediaPicker2PropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/MediaPicker2PropertyEditor.cs index ec911bc4d6..adca2d01c3 100644 --- a/src/Umbraco.Web/PropertyEditors/MediaPicker2PropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/MediaPicker2PropertyEditor.cs @@ -8,7 +8,7 @@ namespace Umbraco.Web.PropertyEditors /// /// Media picker property editors that stores UDI /// - [PropertyEditor(Constants.PropertyEditors.MediaPicker2Alias, "Media Picker", PropertyEditorValueTypes.Text, "mediapicker", IsParameterEditor = true, Group = "media", Icon = "icon-picture")] + [PropertyEditor(Constants.PropertyEditors.Aliases.MediaPicker2, "Media Picker", PropertyEditorValueTypes.Text, "mediapicker", IsParameterEditor = true, Group = "media", Icon = "icon-picture")] public class MediaPicker2PropertyEditor : PropertyEditor { public MediaPicker2PropertyEditor(ILogger logger) @@ -28,7 +28,7 @@ namespace Umbraco.Web.PropertyEditors set => InternalPreValues = value; } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new MediaPickerPreValueEditor(); } @@ -38,27 +38,27 @@ namespace Umbraco.Web.PropertyEditors public MediaPickerPreValueEditor() { //create the fields - Fields.Add(new PreValueField + Fields.Add(new DataTypeConfigurationField { Key = "multiPicker", View = "boolean", Name = "Pick multiple items" }); - Fields.Add(new PreValueField + Fields.Add(new DataTypeConfigurationField { Key = "onlyImages", View = "boolean", Name = "Pick only images", Description = "Only let the editor choose images from media." }); - Fields.Add(new PreValueField + Fields.Add(new DataTypeConfigurationField { Key = "disableFolderSelect", View = "boolean", Name = "Disable folder select", Description = "Do not allow folders to be picked." }); - Fields.Add(new PreValueField + Fields.Add(new DataTypeConfigurationField { Key = "startNodeId", View = "mediapicker", diff --git a/src/Umbraco.Web/PropertyEditors/MediaPickerPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/MediaPickerPropertyEditor.cs index 38d7991e45..27ea837976 100644 --- a/src/Umbraco.Web/PropertyEditors/MediaPickerPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/MediaPickerPropertyEditor.cs @@ -25,7 +25,7 @@ namespace Umbraco.Web.PropertyEditors }; } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new SingleMediaPickerPreValueEditor(); } @@ -34,7 +34,7 @@ namespace Umbraco.Web.PropertyEditors { public SingleMediaPickerPreValueEditor() { - Fields.Add(new PreValueField() + Fields.Add(new DataTypeConfigurationField() { Key = "startNodeId", View = "mediapicker", diff --git a/src/Umbraco.Web/PropertyEditors/MemberGroupPickerPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/MemberGroupPickerPropertyEditor.cs index 19233f57db..1bcf96b4bb 100644 --- a/src/Umbraco.Web/PropertyEditors/MemberGroupPickerPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/MemberGroupPickerPropertyEditor.cs @@ -9,7 +9,7 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.MemberGroupPickerAlias, "Member Group Picker", "membergrouppicker", Group="People", Icon="icon-users")] + [PropertyEditor(Constants.PropertyEditors.Aliases.MemberGroupPicker, "Member Group Picker", "membergrouppicker", Group="People", Icon="icon-users")] public class MemberGroupPickerPropertyEditor : PropertyEditor { /// diff --git a/src/Umbraco.Web/PropertyEditors/MemberPicker2PropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/MemberPicker2PropertyEditor.cs index cee1be88f3..c43e7258ba 100644 --- a/src/Umbraco.Web/PropertyEditors/MemberPicker2PropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/MemberPicker2PropertyEditor.cs @@ -5,7 +5,7 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.MemberPicker2Alias, "Member Picker", PropertyEditorValueTypes.String, "memberpicker", Group = "People", Icon = "icon-user")] + [PropertyEditor(Constants.PropertyEditors.Aliases.MemberPicker2, "Member Picker", PropertyEditorValueTypes.String, "memberpicker", Group = "People", Icon = "icon-user")] public class MemberPicker2PropertyEditor : PropertyEditor { public MemberPicker2PropertyEditor(ILogger logger) diff --git a/src/Umbraco.Web/PropertyEditors/MultiNodeTreePicker2PropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/MultiNodeTreePicker2PropertyEditor.cs index 0fb72755b0..c1e86118be 100644 --- a/src/Umbraco.Web/PropertyEditors/MultiNodeTreePicker2PropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/MultiNodeTreePicker2PropertyEditor.cs @@ -6,7 +6,7 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.MultiNodeTreePicker2Alias, "Multinode Treepicker", PropertyEditorValueTypes.Text, "contentpicker", Group = "pickers", Icon = "icon-page-add")] + [PropertyEditor(Constants.PropertyEditors.Aliases.MultiNodeTreePicker2, "Multinode Treepicker", PropertyEditorValueTypes.Text, "contentpicker", Group = "pickers", Icon = "icon-page-add")] public class MultiNodeTreePicker2PropertyEditor : PropertyEditor { public MultiNodeTreePicker2PropertyEditor(ILogger logger) @@ -22,7 +22,7 @@ namespace Umbraco.Web.PropertyEditors }; } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new MultiNodePickerPreValueEditor(); } @@ -40,7 +40,7 @@ namespace Umbraco.Web.PropertyEditors public MultiNodePickerPreValueEditor() { //create the fields - Fields.Add(new PreValueField() + Fields.Add(new DataTypeConfigurationField() { Key = "startNode", View = "treesource", @@ -50,26 +50,26 @@ namespace Umbraco.Web.PropertyEditors {"idType", "udi"} } }); - Fields.Add(new PreValueField() + Fields.Add(new DataTypeConfigurationField() { Key = "filter", View = "textstring", Name = "Allow items of type", Description = "Separate with comma" }); - Fields.Add(new PreValueField() + Fields.Add(new DataTypeConfigurationField() { Key = "minNumber", View = "number", Name = "Minimum number of items" }); - Fields.Add(new PreValueField() + Fields.Add(new DataTypeConfigurationField() { Key = "maxNumber", View = "number", Name = "Maximum number of items" }); - Fields.Add(new PreValueField() + Fields.Add(new DataTypeConfigurationField() { Key = "showOpenButton", View = "boolean", diff --git a/src/Umbraco.Web/PropertyEditors/MultiNodeTreePickerPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/MultiNodeTreePickerPropertyEditor.cs index 8ba2d5df7c..ca50543e78 100644 --- a/src/Umbraco.Web/PropertyEditors/MultiNodeTreePickerPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/MultiNodeTreePickerPropertyEditor.cs @@ -15,9 +15,9 @@ namespace Umbraco.Web.PropertyEditors InternalPreValues["idType"] = "int"; } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { - var preValEditor = base.CreatePreValueEditor(); + var preValEditor = base.CreateConfigurationEditor(); preValEditor.Fields.Single(x => x.Key == "startNode").Config["idType"] = "int"; return preValEditor; } diff --git a/src/Umbraco.Web/PropertyEditors/MultipleMediaPickerPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/MultipleMediaPickerPropertyEditor.cs index a7c8aba17c..2f93290796 100644 --- a/src/Umbraco.Web/PropertyEditors/MultipleMediaPickerPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/MultipleMediaPickerPropertyEditor.cs @@ -17,9 +17,9 @@ namespace Umbraco.Web.PropertyEditors InternalPreValues["idType"] = "int"; } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { - var preValEditor = base.CreatePreValueEditor(); + var preValEditor = base.CreateConfigurationEditor(); preValEditor.Fields.Single(x => x.Key == "startNodeId").Config["idType"] = "int"; return preValEditor; } diff --git a/src/Umbraco.Web/PropertyEditors/MultipleTextStringPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/MultipleTextStringPropertyEditor.cs index dda8dcf857..abcb9b80ad 100644 --- a/src/Umbraco.Web/PropertyEditors/MultipleTextStringPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/MultipleTextStringPropertyEditor.cs @@ -8,11 +8,12 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.PropertyEditors.Validators; using Umbraco.Core.Services; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.MultipleTextstringAlias, "Repeatable textstrings", "multipletextbox", ValueType = PropertyEditorValueTypes.Text, Icon="icon-ordered-list", Group="lists")] + [PropertyEditor(Constants.PropertyEditors.Aliases.MultipleTextstring, "Repeatable textstrings", "multipletextbox", ValueType = PropertyEditorValueTypes.Text, Icon="icon-ordered-list", Group="lists")] public class MultipleTextStringPropertyEditor : PropertyEditor { /// @@ -26,7 +27,7 @@ namespace Umbraco.Web.PropertyEditors return new MultipleTextStringPropertyValueEditor(base.CreateValueEditor()); } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new MultipleTextStringPreValueEditor(Logger); } @@ -42,14 +43,14 @@ namespace Umbraco.Web.PropertyEditors { _logger = logger; //create the fields - Fields.Add(new PreValueField(new IntegerValidator()) + Fields.Add(new DataTypeConfigurationField(new IntegerValidator()) { Description = "Enter the minimum amount of text boxes to be displayed", Key = "min", View = "requiredfield", Name = "Minimum" }); - Fields.Add(new PreValueField(new IntegerValidator()) + Fields.Add(new DataTypeConfigurationField(new IntegerValidator()) { Description = "Enter the maximum amount of text boxes to be displayed, enter 0 for unlimited", Key = "max", diff --git a/src/Umbraco.Web/PropertyEditors/NestedContentPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/NestedContentPropertyEditor.cs index 758bf956f8..7b1d9fd035 100644 --- a/src/Umbraco.Web/PropertyEditors/NestedContentPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/NestedContentPropertyEditor.cs @@ -15,7 +15,7 @@ using Umbraco.Core.Services; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.NestedContentAlias, "Nested Content", "nestedcontent", ValueType = "JSON", Group = "lists", Icon = "icon-thumbnail-list")] + [PropertyEditor(Constants.PropertyEditors.Aliases.NestedContent, "Nested Content", "nestedcontent", ValueType = "JSON", Group = "lists", Icon = "icon-thumbnail-list")] public class NestedContentPropertyEditor : PropertyEditor { private readonly Lazy _propertyEditors; @@ -58,7 +58,7 @@ namespace Umbraco.Web.PropertyEditors #region Pre Value Editor - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new NestedContentPreValueEditor(); } @@ -67,22 +67,22 @@ namespace Umbraco.Web.PropertyEditors { internal const string ContentTypesPreValueKey = "contentTypes"; - [PreValueField(ContentTypesPreValueKey, "Doc Types", "views/propertyeditors/nestedcontent/nestedcontent.doctypepicker.html", Description = "Select the doc types to use as the data blueprint.")] + [DataTypeConfigurationField(ContentTypesPreValueKey, "Doc Types", "views/propertyeditors/nestedcontent/nestedcontent.doctypepicker.html", Description = "Select the doc types to use as the data blueprint.")] public string[] ContentTypes { get; set; } - [PreValueField("minItems", "Min Items", "number", Description = "Set the minimum number of items allowed.")] + [DataTypeConfigurationField("minItems", "Min Items", "number", Description = "Set the minimum number of items allowed.")] public string MinItems { get; set; } - [PreValueField("maxItems", "Max Items", "number", Description = "Set the maximum number of items allowed.")] + [DataTypeConfigurationField("maxItems", "Max Items", "number", Description = "Set the maximum number of items allowed.")] public string MaxItems { get; set; } - [PreValueField("confirmDeletes", "Confirm Deletes", "boolean", Description = "Set whether item deletions should require confirming.")] + [DataTypeConfigurationField("confirmDeletes", "Confirm Deletes", "boolean", Description = "Set whether item deletions should require confirming.")] public string ConfirmDeletes { get; set; } - [PreValueField("showIcons", "Show Icons", "boolean", Description = "Set whether to show the items doc type icon in the list.")] + [DataTypeConfigurationField("showIcons", "Show Icons", "boolean", Description = "Set whether to show the items doc type icon in the list.")] public string ShowIcons { get; set; } - [PreValueField("hideLabel", "Hide Label", "boolean", Description = "Set whether to hide the editor label and have the list take up the full width of the editor window.")] + [DataTypeConfigurationField("hideLabel", "Hide Label", "boolean", Description = "Set whether to hide the editor label and have the list take up the full width of the editor window.")] public string HideLabel { get; set; } } @@ -317,14 +317,13 @@ namespace Umbraco.Web.PropertyEditors else { // Fetch the property types prevalue - var propPreValues = Services.DataTypeService.GetPreValuesCollectionByDataTypeId( - propType.DataTypeDefinitionId); + var propConfiguration = Services.DataTypeService.GetDataType(propType.DataTypeDefinitionId).Configuration; // Lookup the property editor var propEditor = _propertyEditors[propType.PropertyEditorAlias]; // Create a fake content property data object - var contentPropData = new ContentPropertyData(propValues[propKey], propPreValues); + var contentPropData = new ContentPropertyData(propValues[propKey], propConfiguration); // Get the property editor to do it's conversion var newValue = propEditor.ValueEditor.ConvertEditorToDb(contentPropData, propValues[propKey]); @@ -351,7 +350,7 @@ namespace Umbraco.Web.PropertyEditors _propertyEditors = propertyEditors; } - public IEnumerable Validate(object rawValue, PreValueCollection preValues, PropertyEditor editor) + public IEnumerable Validate(object rawValue, object dataTypeConfiguration, PropertyEditor editor) { var value = JsonConvert.DeserializeObject>(rawValue.ToString()); if (value == null) @@ -364,10 +363,7 @@ namespace Umbraco.Web.PropertyEditors var propValues = (JObject) o; var contentType = GetElementType(propValues); - if (contentType == null) - { - continue; - } + if (contentType == null) continue; var propValueKeys = propValues.Properties().Select(x => x.Name).ToArray(); @@ -376,12 +372,12 @@ namespace Umbraco.Web.PropertyEditors var propType = contentType.CompositionPropertyTypes.FirstOrDefault(x => x.Alias == propKey); if (propType != null) { - var propPrevalues = dataTypeService.GetPreValuesCollectionByDataTypeId(propType.DataTypeDefinitionId); - PropertyEditor propertyEditor = _propertyEditors[propType.PropertyEditorAlias]; + var config = dataTypeService.GetDataType(propType.DataTypeDefinitionId).Configuration; + var propertyEditor = _propertyEditors[propType.PropertyEditorAlias]; foreach (var validator in propertyEditor.ValueEditor.Validators) { - foreach (var result in validator.Validate(propValues[propKey], propPrevalues, propertyEditor)) + foreach (var result in validator.Validate(propValues[propKey], config, propertyEditor)) { result.ErrorMessage = "Item " + (i + 1) + " '" + propType.Name + "' " + result.ErrorMessage; yield return result; diff --git a/src/Umbraco.Web/PropertyEditors/RadioButtonsPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/RadioButtonsPropertyEditor.cs index 8adda3616d..d51e8e94fb 100644 --- a/src/Umbraco.Web/PropertyEditors/RadioButtonsPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/RadioButtonsPropertyEditor.cs @@ -13,7 +13,7 @@ namespace Umbraco.Web.PropertyEditors /// as INT and we have logic in here to ensure it is formatted correctly including ensuring that the INT ID value is published /// in cache and not the string value. /// - [PropertyEditor(Constants.PropertyEditors.RadioButtonListAlias, "Radio button list", "radiobuttons", ValueType = PropertyEditorValueTypes.Integer, Group="lists", Icon="icon-target")] + [PropertyEditor(Constants.PropertyEditors.Aliases.RadioButtonList, "Radio button list", "radiobuttons", ValueType = PropertyEditorValueTypes.Integer, Group="lists", Icon="icon-target")] public class RadioButtonsPropertyEditor : DropDownWithKeysPropertyEditor { /// diff --git a/src/Umbraco.Web/PropertyEditors/RelatedLinks2PropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/RelatedLinks2PropertyEditor.cs index e0a1e68ba9..692fd21c90 100644 --- a/src/Umbraco.Web/PropertyEditors/RelatedLinks2PropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/RelatedLinks2PropertyEditor.cs @@ -5,7 +5,7 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.RelatedLinks2Alias, "Related links", "relatedlinks", ValueType = PropertyEditorValueTypes.Json, Icon = "icon-thumbnail-list", Group = "pickers")] + [PropertyEditor(Constants.PropertyEditors.Aliases.RelatedLinks2, "Related links", "relatedlinks", ValueType = PropertyEditorValueTypes.Json, Icon = "icon-thumbnail-list", Group = "pickers")] public class RelatedLinks2PropertyEditor : PropertyEditor { public RelatedLinks2PropertyEditor(ILogger logger) @@ -25,14 +25,14 @@ namespace Umbraco.Web.PropertyEditors set => InternalPreValues = value; } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new RelatedLinksPreValueEditor(); } internal class RelatedLinksPreValueEditor : PreValueEditor { - [PreValueField("max", "Maximum number of links", "number", Description = "Enter the maximum amount of links to be added, enter 0 for unlimited")] + [DataTypeConfigurationField("max", "Maximum number of links", "number", Description = "Enter the maximum amount of links to be added, enter 0 for unlimited")] public int Maximum { get; set; } } } diff --git a/src/Umbraco.Web/PropertyEditors/RichTextPreValueEditor.cs b/src/Umbraco.Web/PropertyEditors/RichTextPreValueEditor.cs index c3a782c050..f2670b35e2 100644 --- a/src/Umbraco.Web/PropertyEditors/RichTextPreValueEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/RichTextPreValueEditor.cs @@ -16,14 +16,14 @@ namespace Umbraco.Web.PropertyEditors // see below for examples. //use a custom editor too - Fields.Add(new PreValueField() + Fields.Add(new DataTypeConfigurationField() { View = "views/propertyeditors/rte/rte.prevalues.html", HideLabel = true, Key = "editor" }); - Fields.Add(new PreValueField() + Fields.Add(new DataTypeConfigurationField() { Name = "Hide Label", View = "boolean", diff --git a/src/Umbraco.Web/PropertyEditors/RichTextPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/RichTextPropertyEditor.cs index 966935dca5..9e98a1b1d1 100644 --- a/src/Umbraco.Web/PropertyEditors/RichTextPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/RichTextPropertyEditor.cs @@ -8,7 +8,7 @@ using Umbraco.Core.Services; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.TinyMCEAlias, "Rich Text Editor", "rte", ValueType = PropertyEditorValueTypes.Text, HideLabel = false, Group="Rich Content", Icon="icon-browser-window")] + [PropertyEditor(Constants.PropertyEditors.Aliases.TinyMce, "Rich Text Editor", "rte", ValueType = PropertyEditorValueTypes.Text, HideLabel = false, Group="Rich Content", Icon="icon-browser-window")] public class RichTextPropertyEditor : PropertyEditor { /// @@ -27,7 +27,7 @@ namespace Umbraco.Web.PropertyEditors return new RichTextPropertyValueEditor(base.CreateValueEditor()); } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new RichTextPreValueEditor(); } diff --git a/src/Umbraco.Web/PropertyEditors/SliderPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/SliderPropertyEditor.cs index 24ea1906b6..9cdf3b0d7d 100644 --- a/src/Umbraco.Web/PropertyEditors/SliderPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/SliderPropertyEditor.cs @@ -4,7 +4,7 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.SliderAlias, "Slider", "slider", Icon="icon-navigation-horizontal")] + [PropertyEditor(Constants.PropertyEditors.Aliases.Slider, "Slider", "slider", Icon="icon-navigation-horizontal")] public class SliderPropertyEditor : PropertyEditor { /// @@ -14,65 +14,65 @@ namespace Umbraco.Web.PropertyEditors { } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new SliderPreValueEditor(); } internal class SliderPreValueEditor : PreValueEditor { - [PreValueField("enableRange", "Enable range", "boolean")] + [DataTypeConfigurationField("enableRange", "Enable range", "boolean")] public string Range { get; set; } - [PreValueField("orientation", "Orientation", "views/propertyeditors/slider/orientation.prevalues.html")] + [DataTypeConfigurationField("orientation", "Orientation", "views/propertyeditors/slider/orientation.prevalues.html")] public string Orientation { get; set; } - [PreValueField("initVal1", "Initial value", "number")] + [DataTypeConfigurationField("initVal1", "Initial value", "number")] public int InitialValue { get; set; } - [PreValueField("initVal2", "Initial value 2", "number", Description = "Used when range is enabled")] + [DataTypeConfigurationField("initVal2", "Initial value 2", "number", Description = "Used when range is enabled")] public int InitialValue2 { get; set; } - [PreValueField("minVal", "Minimum value", "number")] + [DataTypeConfigurationField("minVal", "Minimum value", "number")] public int MinimumValue { get; set; } - [PreValueField("maxVal", "Maximum value", "number")] + [DataTypeConfigurationField("maxVal", "Maximum value", "number")] public int MaximumValue { get; set; } - [PreValueField("step", "Step increments", "number")] + [DataTypeConfigurationField("step", "Step increments", "number")] public int StepIncrements { get; set; } - [PreValueField("precision", "Precision", "number", Description = "The number of digits shown after the decimal. Defaults to the number of digits after the decimal of step value.")] + [DataTypeConfigurationField("precision", "Precision", "number", Description = "The number of digits shown after the decimal. Defaults to the number of digits after the decimal of step value.")] public int Precision { get; set; } - [PreValueField("handle", "Handle", "views/propertyeditors/slider/handle.prevalues.html", Description = "Handle shape. Default is 'round\'")] + [DataTypeConfigurationField("handle", "Handle", "views/propertyeditors/slider/handle.prevalues.html", Description = "Handle shape. Default is 'round\'")] public string Handle { get; set; } - [PreValueField("tooltip", "Tooltip", "views/propertyeditors/slider/tooltip.prevalues.html", Description = "Whether to show the tooltip on drag, hide the tooltip, or always show the tooltip. Accepts: 'show', 'hide', or 'always'")] + [DataTypeConfigurationField("tooltip", "Tooltip", "views/propertyeditors/slider/tooltip.prevalues.html", Description = "Whether to show the tooltip on drag, hide the tooltip, or always show the tooltip. Accepts: 'show', 'hide', or 'always'")] public string Tooltip { get; set; } - [PreValueField("tooltipSplit", "Tooltip split", "boolean", Description = "If false show one tootip if true show two tooltips one for each handler")] + [DataTypeConfigurationField("tooltipSplit", "Tooltip split", "boolean", Description = "If false show one tootip if true show two tooltips one for each handler")] public string TooltipSplit { get; set; } - [PreValueField("tooltipFormat", "Tooltip format", "textstring", Description = "The value wanted to be displayed in the tooltip. Use {0} and {1} for current values - {1} is only for range slider and if not using tooltip split.")] + [DataTypeConfigurationField("tooltipFormat", "Tooltip format", "textstring", Description = "The value wanted to be displayed in the tooltip. Use {0} and {1} for current values - {1} is only for range slider and if not using tooltip split.")] public string TooltipFormat { get; set; } - [PreValueField("tooltipPosition", "Tooltip position", "textstring", Description = "Position of tooltip, relative to slider. Accepts 'top'/'bottom' for horizontal sliders and 'left'/'right' for vertically orientated sliders. Default positions are 'top' for horizontal and 'right' for vertical slider.")] + [DataTypeConfigurationField("tooltipPosition", "Tooltip position", "textstring", Description = "Position of tooltip, relative to slider. Accepts 'top'/'bottom' for horizontal sliders and 'left'/'right' for vertically orientated sliders. Default positions are 'top' for horizontal and 'right' for vertical slider.")] public string TooltipPosition { get; set; } - [PreValueField("reversed", "Reversed", "boolean", Description = "Whether or not the slider should be reversed")] + [DataTypeConfigurationField("reversed", "Reversed", "boolean", Description = "Whether or not the slider should be reversed")] public string Reversed { get; set; } - [PreValueField("ticks", "Ticks", "textstring", Description = "Comma-separated values. Used to define the values of ticks. Tick marks are indicators to denote special values in the range. This option overwrites min and max options.")] + [DataTypeConfigurationField("ticks", "Ticks", "textstring", Description = "Comma-separated values. Used to define the values of ticks. Tick marks are indicators to denote special values in the range. This option overwrites min and max options.")] public string Ticks { get; set; } - [PreValueField("ticksPositions", "Ticks positions", "textstring", Description = "Comma-separated values. Defines the positions of the tick values in percentages. The first value should always be 0, the last value should always be 100 percent.")] + [DataTypeConfigurationField("ticksPositions", "Ticks positions", "textstring", Description = "Comma-separated values. Defines the positions of the tick values in percentages. The first value should always be 0, the last value should always be 100 percent.")] public string TicksPositions { get; set; } - [PreValueField("ticksLabels", "Ticks labels", "textstring", Description = "Comma-separated values. Defines the labels below the tick marks. Accepts HTML input.")] + [DataTypeConfigurationField("ticksLabels", "Ticks labels", "textstring", Description = "Comma-separated values. Defines the labels below the tick marks. Accepts HTML input.")] public string TicksLabels { get; set; } - [PreValueField("ticksSnapBounds", "Ticks snap bounds", "number", Description = "Used to define the snap bounds of a tick. Snaps to the tick if value is within these bounds.")] + [DataTypeConfigurationField("ticksSnapBounds", "Ticks snap bounds", "number", Description = "Used to define the snap bounds of a tick. Snaps to the tick if value is within these bounds.")] public string TicksSnapBounds { get; set; } } } diff --git a/src/Umbraco.Web/PropertyEditors/TagsPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/TagsPropertyEditor.cs index 562fc27778..4184553a82 100644 --- a/src/Umbraco.Web/PropertyEditors/TagsPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/TagsPropertyEditor.cs @@ -11,7 +11,7 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { [SupportTags(typeof(TagPropertyEditorTagDefinition), ValueType = TagValueType.CustomTagList)] - [PropertyEditor(Constants.PropertyEditors.TagsAlias, "Tags", "tags", Icon="icon-tags")] + [PropertyEditor(Constants.PropertyEditors.Aliases.Tags, "Tags", "tags", Icon="icon-tags")] public class TagsPropertyEditor : PropertyEditor { public TagsPropertyEditor(ILogger logger) : base(logger) @@ -39,7 +39,7 @@ namespace Umbraco.Web.PropertyEditors return new TagPropertyValueEditor(base.CreateValueEditor()); } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new TagPreValueEditor(); } @@ -48,19 +48,14 @@ namespace Umbraco.Web.PropertyEditors { public TagPropertyValueEditor(PropertyValueEditor wrapped) : base(wrapped) - { - } + { } - /// - /// This needs to return IEnumerable{string} - /// - /// - /// - /// + /// public override object ConvertEditorToDb(ContentPropertyData editorValue, object currentValue) { - var json = editorValue.Value as JArray; - return json == null ? null : json.Select(x => x.Value()); + return editorValue.Value is JArray json + ? json.Select(x => x.Value()) + : null; } /// @@ -87,15 +82,8 @@ namespace Umbraco.Web.PropertyEditors [ValueValidator("Required")] private class RequiredTagsValueValidator : ManifestValueValidator { - /// - /// Validates a null value or an empty json value - /// - /// - /// - /// - /// - /// - public override IEnumerable Validate(object value, string config, PreValueCollection preValues, PropertyEditor editor) + /// + public override IEnumerable Validate(object value, string validatorConfiguration, object dataTypeConfiguration, PropertyEditor editor) { if (value == null) { @@ -123,7 +111,7 @@ namespace Umbraco.Web.PropertyEditors { public TagPreValueEditor() { - Fields.Add(new PreValueField(new ManifestPropertyValidator { Type = "Required" }) + Fields.Add(new DataTypeConfigurationField(new ManifestPropertyValidator { Type = "Required" }) { Description = "Define a tag group", Key = "group", @@ -131,7 +119,7 @@ namespace Umbraco.Web.PropertyEditors View = "requiredfield" }); - Fields.Add(new PreValueField(new ManifestPropertyValidator {Type = "Required"}) + Fields.Add(new DataTypeConfigurationField(new ManifestPropertyValidator {Type = "Required"}) { Description = "Select whether to store the tags in cache as CSV (default) or as JSON. The only benefits of storage as JSON is that you are able to have commas in a tag value but this will require parsing the json in your views or using a property value converter", Key = "storageType", diff --git a/src/Umbraco.Web/PropertyEditors/TextAreaPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/TextAreaPropertyEditor.cs index d74e30fb06..ce7b54e244 100644 --- a/src/Umbraco.Web/PropertyEditors/TextAreaPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/TextAreaPropertyEditor.cs @@ -4,7 +4,7 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.TextboxMultipleAlias, "Textarea", "textarea", IsParameterEditor = true, ValueType = PropertyEditorValueTypes.Text, Icon="icon-application-window-alt")] + [PropertyEditor(Constants.PropertyEditors.Aliases.TextboxMultiple, "Textarea", "textarea", IsParameterEditor = true, ValueType = PropertyEditorValueTypes.Text, Icon="icon-application-window-alt")] public class TextAreaPropertyEditor : PropertyEditor { /// @@ -19,14 +19,14 @@ namespace Umbraco.Web.PropertyEditors return new TextOnlyValueEditor(base.CreateValueEditor()); } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new TextAreaPreValueEditor(); } internal class TextAreaPreValueEditor : PreValueEditor { - [PreValueField("maxChars", "Maximum allowed characters", "number", Description = "If empty - no character limit")] + [DataTypeConfigurationField("maxChars", "Maximum allowed characters", "number", Description = "If empty - no character limit")] public bool MaxChars { get; set; } } } diff --git a/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs index 036fbff847..ecf4367f34 100644 --- a/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs @@ -10,7 +10,7 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.TextboxAlias, "Textbox", "textbox", IsParameterEditor = true, Group = "Common")] + [PropertyEditor(Constants.PropertyEditors.Aliases.Textbox, "Textbox", "textbox", IsParameterEditor = true, Group = "Common")] public class TextboxPropertyEditor : PropertyEditor { /// @@ -25,14 +25,14 @@ namespace Umbraco.Web.PropertyEditors return new TextOnlyValueEditor(base.CreateValueEditor()); } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new TextboxPreValueEditor(); } internal class TextboxPreValueEditor : PreValueEditor { - [PreValueField("maxChars", "Maximum allowed characters", "number", Description = "If empty - no character limit")] + [DataTypeConfigurationField("maxChars", "Maximum allowed characters", "number", Description = "If empty - no character limit")] public bool MaxChars { get; set; } } } diff --git a/src/Umbraco.Web/PropertyEditors/TrueFalsePropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/TrueFalsePropertyEditor.cs index f7fb7d963e..e3f6bf94e2 100644 --- a/src/Umbraco.Web/PropertyEditors/TrueFalsePropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/TrueFalsePropertyEditor.cs @@ -4,7 +4,7 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.TrueFalseAlias, "True/False", PropertyEditorValueTypes.Integer, "boolean", IsParameterEditor = true, Group = "Common", Icon="icon-checkbox")] + [PropertyEditor(Constants.PropertyEditors.Aliases.Boolean, "True/False", PropertyEditorValueTypes.Integer, "boolean", IsParameterEditor = true, Group = "Common", Icon="icon-checkbox")] public class TrueFalsePropertyEditor : PropertyEditor { /// @@ -13,14 +13,14 @@ namespace Umbraco.Web.PropertyEditors public TrueFalsePropertyEditor(ILogger logger) : base(logger) { } - protected override PreValueEditor CreatePreValueEditor() + protected override PreValueEditor CreateConfigurationEditor() { return new TrueFalsePreValueEditor(); } internal class TrueFalsePreValueEditor : PreValueEditor { - [PreValueField("default", "Default Value", "boolean")] + [DataTypeConfigurationField("default", "Default Value", "boolean")] public string Default { get; set; } } } diff --git a/src/Umbraco.Web/PropertyEditors/UserPickerPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/UserPickerPropertyEditor.cs index 714fab572a..007d1be699 100644 --- a/src/Umbraco.Web/PropertyEditors/UserPickerPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/UserPickerPropertyEditor.cs @@ -7,7 +7,7 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.UserPickerAlias, "User picker", PropertyEditorValueTypes.Integer, "entitypicker", Group="People", Icon="icon-user")] + [PropertyEditor(Constants.PropertyEditors.Aliases.UserPicker, "User picker", PropertyEditorValueTypes.Integer, "entitypicker", Group="People", Icon="icon-user")] public class UserPickerPropertyEditor : PropertyEditor { private IDictionary _defaultPreValues; diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/ContentPickerValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/ContentPickerValueConverter.cs index cb34dc7455..a2965e44ed 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/ContentPickerValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/ContentPickerValueConverter.cs @@ -25,7 +25,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters public override bool IsConverter(PublishedPropertyType propertyType) => propertyType.EditorAlias.Equals(Constants.PropertyEditors.ContentPickerAlias) - || propertyType.EditorAlias.Equals(Constants.PropertyEditors.ContentPicker2Alias); + || propertyType.EditorAlias.Equals(Constants.PropertyEditors.Aliases.ContentPicker2Alias); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (IPublishedContent); diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs index 5f7494cfb1..e6d44c0a8f 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs @@ -30,7 +30,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters } public override bool IsConverter(PublishedPropertyType propertyType) - => propertyType.EditorAlias == Constants.PropertyEditors.MacroContainerAlias; + => propertyType.EditorAlias == Constants.PropertyEditors.Aliases.MacroContainer; public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (IHtmlString); diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs index 66d3ec0639..3b165dc9f0 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs @@ -12,7 +12,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters public class MarkdownEditorValueConverter : PropertyValueConverterBase { public override bool IsConverter(PublishedPropertyType propertyType) - => Constants.PropertyEditors.MarkdownEditorAlias == propertyType.EditorAlias; + => Constants.PropertyEditors.Aliases.MarkdownEditor == propertyType.EditorAlias; public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (IHtmlString); diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs index e5c978373e..6f4da1ea65 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs @@ -29,7 +29,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters public override bool IsConverter(PublishedPropertyType propertyType) { - return propertyType.EditorAlias.Equals(Constants.PropertyEditors.MediaPicker2Alias); + return propertyType.EditorAlias.Equals(Constants.PropertyEditors.Aliases.MediaPicker2); } public override Type GetPropertyValueType(PublishedPropertyType propertyType) diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs index 5336b5bbb0..6a64fc4884 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs @@ -20,7 +20,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters public override bool IsConverter(PublishedPropertyType propertyType) { return propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.MemberPickerAlias) - || propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.MemberPicker2Alias); + || propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.MemberPicker2); } public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/MultiNodeTreePickerValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/MultiNodeTreePickerValueConverter.cs index f71a6e2a7b..90109e1cab 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MultiNodeTreePickerValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MultiNodeTreePickerValueConverter.cs @@ -36,7 +36,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters public override bool IsConverter(PublishedPropertyType propertyType) { return propertyType.EditorAlias.Equals(Constants.PropertyEditors.MultiNodeTreePickerAlias) - || propertyType.EditorAlias.Equals(Constants.PropertyEditors.MultiNodeTreePicker2Alias); + || propertyType.EditorAlias.Equals(Constants.PropertyEditors.Aliases.MultiNodeTreePicker2); } public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) @@ -55,7 +55,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters .ToArray(); return nodeIds; } - if (propertyType.EditorAlias.Equals(Constants.PropertyEditors.MultiNodeTreePicker2Alias)) + if (propertyType.EditorAlias.Equals(Constants.PropertyEditors.Aliases.MultiNodeTreePicker2)) { var nodeIds = source.ToString() .Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries) @@ -106,7 +106,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters return nodeIds.FirstOrDefault(); } - if (propertyType.EditorAlias.Equals(Constants.PropertyEditors.MultiNodeTreePicker2Alias)) + if (propertyType.EditorAlias.Equals(Constants.PropertyEditors.Aliases.MultiNodeTreePicker2)) { var udis = (Udi[])source; diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs index fb28e534a0..ae95b3e752 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs @@ -22,7 +22,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters public static bool IsNested(PublishedPropertyType publishedProperty) { - return publishedProperty.EditorAlias.InvariantEquals(Constants.PropertyEditors.NestedContentAlias); + return publishedProperty.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.NestedContent); } public static bool IsNestedSingle(PublishedPropertyType publishedProperty) diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksLegacyValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksLegacyValueConverter.cs index c0bc4c41ad..aa65c58ca3 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksLegacyValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksLegacyValueConverter.cs @@ -19,7 +19,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters { private static readonly string[] MatchingEditors = { Constants.PropertyEditors.RelatedLinksAlias, - Constants.PropertyEditors.RelatedLinks2Alias + Constants.PropertyEditors.Aliases.RelatedLinks2 }; private readonly IUmbracoContextAccessor _umbracoContextAccessor; @@ -72,7 +72,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters var intLink = helper.NiceUrl(intLinkId); a["link"] = intLink; break; - case Constants.PropertyEditors.RelatedLinks2Alias: + case Constants.PropertyEditors.Aliases.RelatedLinks2: var strLinkId = a.Value("link"); var udiAttempt = strLinkId.TryConvertTo(); if (udiAttempt) diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksValueConverter.cs index 9fbd9e3677..ee29019bf8 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksValueConverter.cs @@ -41,7 +41,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters /// public override bool IsConverter(PublishedPropertyType propertyType) => propertyType.EditorAlias.Equals(Constants.PropertyEditors.RelatedLinksAlias) - || propertyType.EditorAlias.Equals(Constants.PropertyEditors.RelatedLinks2Alias); + || propertyType.EditorAlias.Equals(Constants.PropertyEditors.Aliases.RelatedLinks2); public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (JArray); diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/TextStringValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/TextStringValueConverter.cs index 45ce7ed1db..f6082a45b8 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/TextStringValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/TextStringValueConverter.cs @@ -12,8 +12,8 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters { private static readonly string[] PropertyTypeAliases = { - Constants.PropertyEditors.TextboxAlias, - Constants.PropertyEditors.TextboxMultipleAlias + Constants.PropertyEditors.Aliases.Textbox, + Constants.PropertyEditors.Aliases.TextboxMultiple }; public override bool IsConverter(PublishedPropertyType propertyType) diff --git a/src/Umbraco.Web/PropertyEditors/ValueListPreValueEditor.cs b/src/Umbraco.Web/PropertyEditors/ValueListPreValueEditor.cs index 0cfc667835..030477d96e 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueListPreValueEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueListPreValueEditor.cs @@ -36,11 +36,11 @@ namespace Umbraco.Web.PropertyEditors /// Creates the pre-value fields /// /// - protected List CreatePreValueFields() + protected List CreatePreValueFields() { - return new List + return new List { - new PreValueField(new EnsureUniqueValuesValidator()) + new DataTypeConfigurationField(new EnsureUniqueValuesValidator()) { Description = "Add and remove values for the list", //we're going to call this 'items' because we are going to override the @@ -140,7 +140,7 @@ namespace Umbraco.Web.PropertyEditors /// internal class EnsureUniqueValuesValidator : IPropertyValidator { - public IEnumerable Validate(object value, PreValueCollection preValues, PropertyEditor editor) + public IEnumerable Validate(object value, object dataTypeConfiguration, PropertyEditor editor) { var json = value as JArray; if (json == null) yield break; diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 3e4c260ef3..931166aca3 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -429,7 +429,7 @@ - + @@ -650,14 +650,14 @@ - - + + - + diff --git a/src/Umbraco.Web/UmbracoHelper.cs b/src/Umbraco.Web/UmbracoHelper.cs index 551589583b..9d5f2a12ae 100644 --- a/src/Umbraco.Web/UmbracoHelper.cs +++ b/src/Umbraco.Web/UmbracoHelper.cs @@ -1052,15 +1052,6 @@ namespace Umbraco.Web #endregion - #region Prevalues - - public string GetPreValueAsString(int id) - { - return DataTypeService.GetPreValueAsString(id); - } - - #endregion - #region canvasdesigner [Obsolete("Use EnableCanvasDesigner on the HtmlHelper extensions instead")] diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Macros/assemblyBrowser.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Macros/assemblyBrowser.aspx.cs index 6309b1a5cd..aefdedfa83 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Macros/assemblyBrowser.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Macros/assemblyBrowser.aspx.cs @@ -186,16 +186,16 @@ namespace umbraco.developer switch (baseTypeName) { case "Int32": - return Constants.PropertyEditors.IntegerAlias; + return Constants.PropertyEditors.Aliases.Integer; case "Decimal": //we previously only had an integer editor too! - this would of course // fail if someone enters a real long number - return Constants.PropertyEditors.IntegerAlias; + return Constants.PropertyEditors.Aliases.Integer; case "Boolean": - return Constants.PropertyEditors.TrueFalseAlias; + return Constants.PropertyEditors.Aliases.Boolean; case "String": default: - return Constants.PropertyEditors.TextboxAlias; + return Constants.PropertyEditors.Aliases.Textbox; } }