From af7df0c6b5c14b92e3df2519b0b8b4e8abcf0d22 Mon Sep 17 00:00:00 2001 From: Stephan Date: Fri, 9 Feb 2018 18:22:59 +0100 Subject: [PATCH] Cleanup --- .../UmbracoSettings/ContentElement.cs | 281 ++++-------------- .../UmbracoSettings/IContentSection.cs | 6 + .../PropertyEditors/PropertyEditor.cs | 8 +- .../PropertyEditors/ValueEditorAttribute.cs | 7 +- src/Umbraco.Core/ReflectionUtilities.cs | 39 +-- .../AvailablePropertyEditorsResolver.cs | 8 +- .../Models/Mapping/DataTypeMapperProfile.cs | 2 - .../FolderBrowserPropertyEditor.cs | 19 -- .../ImageCropperConfigurationEditor.cs | 13 +- .../MacroContainerPropertyEditor.cs | 4 +- .../MultiNodePickerConfiguration.cs | 25 ++ .../MultiNodePickerConfigurationEditor.cs | 85 +----- .../NestedContentConfiguration.cs | 6 +- .../NestedContentConfigurationEditor.cs | 12 +- src/Umbraco.Web/Umbraco.Web.csproj | 2 +- 15 files changed, 129 insertions(+), 388 deletions(-) delete mode 100644 src/Umbraco.Web/PropertyEditors/FolderBrowserPropertyEditor.cs create mode 100644 src/Umbraco.Web/PropertyEditors/MultiNodePickerConfiguration.cs diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs index 79283242e2..b58df9b527 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Configuration; using Umbraco.Core.Macros; @@ -7,303 +6,141 @@ namespace Umbraco.Core.Configuration.UmbracoSettings { internal class ContentElement : UmbracoConfigurationElement, IContentSection { + private const string DefaultPreviewBadge = @"In Preview Mode - click to end"; + [ConfigurationProperty("imaging")] - internal ContentImagingElement Imaging - { - get { return (ContentImagingElement)this["imaging"]; } - } + internal ContentImagingElement Imaging => (ContentImagingElement) this["imaging"]; [ConfigurationProperty("scripteditor")] - internal ContentScriptEditorElement ScriptEditor - { - get { return (ContentScriptEditorElement)this["scripteditor"]; } - } + internal ContentScriptEditorElement ScriptEditor => (ContentScriptEditorElement) this["scripteditor"]; [ConfigurationProperty("ResolveUrlsFromTextString")] - internal InnerTextConfigurationElement ResolveUrlsFromTextString - { - get { return GetOptionalTextElement("ResolveUrlsFromTextString", false); } - } + internal InnerTextConfigurationElement ResolveUrlsFromTextString => GetOptionalTextElement("ResolveUrlsFromTextString", false); [ConfigurationProperty("UploadAllowDirectories")] - internal InnerTextConfigurationElement UploadAllowDirectories - { - get { return GetOptionalTextElement("UploadAllowDirectories", true); } - } + internal InnerTextConfigurationElement UploadAllowDirectories => GetOptionalTextElement("UploadAllowDirectories", true); - public IEnumerable Error404Collection - { - get { return Errors.Error404Collection; } - } + public IEnumerable Error404Collection => Errors.Error404Collection; [ConfigurationProperty("errors", IsRequired = true)] - internal ContentErrorsElement Errors - { - get { return (ContentErrorsElement) base["errors"]; } - } + internal ContentErrorsElement Errors => (ContentErrorsElement) base["errors"]; [ConfigurationProperty("notifications", IsRequired = true)] - internal NotificationsElement Notifications - { - get { return (NotificationsElement)base["notifications"]; } - } + internal NotificationsElement Notifications => (NotificationsElement) base["notifications"]; [ConfigurationProperty("ensureUniqueNaming")] - internal InnerTextConfigurationElement EnsureUniqueNaming - { - get { return GetOptionalTextElement("ensureUniqueNaming", true); } - } + internal InnerTextConfigurationElement EnsureUniqueNaming => GetOptionalTextElement("ensureUniqueNaming", true); [ConfigurationProperty("XmlCacheEnabled")] - internal InnerTextConfigurationElement XmlCacheEnabled - { - get { return GetOptionalTextElement("XmlCacheEnabled", true); } - } + internal InnerTextConfigurationElement XmlCacheEnabled => GetOptionalTextElement("XmlCacheEnabled", true); [ConfigurationProperty("ContinouslyUpdateXmlDiskCache")] - internal InnerTextConfigurationElement ContinouslyUpdateXmlDiskCache - { - get { return GetOptionalTextElement("ContinouslyUpdateXmlDiskCache", true); } - } + internal InnerTextConfigurationElement ContinouslyUpdateXmlDiskCache => GetOptionalTextElement("ContinouslyUpdateXmlDiskCache", true); [ConfigurationProperty("XmlContentCheckForDiskChanges")] - internal InnerTextConfigurationElement XmlContentCheckForDiskChanges - { - get { return GetOptionalTextElement("XmlContentCheckForDiskChanges", false); } - } + internal InnerTextConfigurationElement XmlContentCheckForDiskChanges => GetOptionalTextElement("XmlContentCheckForDiskChanges", false); [ConfigurationProperty("EnableSplashWhileLoading")] - internal InnerTextConfigurationElement EnableSplashWhileLoading - { - get { return GetOptionalTextElement("EnableSplashWhileLoading", false); } - } + internal InnerTextConfigurationElement EnableSplashWhileLoading => GetOptionalTextElement("EnableSplashWhileLoading", false); [ConfigurationProperty("PropertyContextHelpOption")] - internal InnerTextConfigurationElement PropertyContextHelpOption - { - get { return GetOptionalTextElement("PropertyContextHelpOption", "text"); } - } - + internal InnerTextConfigurationElement PropertyContextHelpOption => GetOptionalTextElement("PropertyContextHelpOption", "text"); [ConfigurationProperty("ForceSafeAliases")] - internal InnerTextConfigurationElement ForceSafeAliases - { - get { return GetOptionalTextElement("ForceSafeAliases", true); } - } + internal InnerTextConfigurationElement ForceSafeAliases => GetOptionalTextElement("ForceSafeAliases", true); [ConfigurationProperty("PreviewBadge")] - internal InnerTextConfigurationElement PreviewBadge - { - get - { - return GetOptionalTextElement("PreviewBadge", @"In Preview Mode - click to end"); - } - } + internal InnerTextConfigurationElement PreviewBadge => GetOptionalTextElement("PreviewBadge", DefaultPreviewBadge); [ConfigurationProperty("UmbracoLibraryCacheDuration")] - internal InnerTextConfigurationElement UmbracoLibraryCacheDuration - { - get { return GetOptionalTextElement("UmbracoLibraryCacheDuration", 1800); } - } + internal InnerTextConfigurationElement UmbracoLibraryCacheDuration => GetOptionalTextElement("UmbracoLibraryCacheDuration", 1800); [ConfigurationProperty("MacroErrors")] - internal InnerTextConfigurationElement MacroErrors - { - get { return GetOptionalTextElement("MacroErrors", MacroErrorBehaviour.Inline); } - } + internal InnerTextConfigurationElement MacroErrors => GetOptionalTextElement("MacroErrors", MacroErrorBehaviour.Inline); [ConfigurationProperty("disallowedUploadFiles")] - internal CommaDelimitedConfigurationElement DisallowedUploadFiles - { - get { return GetOptionalDelimitedElement("disallowedUploadFiles", new[] {"ashx", "aspx", "ascx", "config", "cshtml", "vbhtml", "asmx", "air", "axd"}); } - } + internal CommaDelimitedConfigurationElement DisallowedUploadFiles => GetOptionalDelimitedElement("disallowedUploadFiles", new[] {"ashx", "aspx", "ascx", "config", "cshtml", "vbhtml", "asmx", "air", "axd"}); [ConfigurationProperty("allowedUploadFiles")] - internal CommaDelimitedConfigurationElement AllowedUploadFiles - { - get { return GetOptionalDelimitedElement("allowedUploadFiles", new string[0]); } - } + internal CommaDelimitedConfigurationElement AllowedUploadFiles => GetOptionalDelimitedElement("allowedUploadFiles", new string[0]); [ConfigurationProperty("cloneXmlContent")] - internal InnerTextConfigurationElement CloneXmlContent - { - get { return GetOptionalTextElement("cloneXmlContent", true); } - } + internal InnerTextConfigurationElement CloneXmlContent => GetOptionalTextElement("cloneXmlContent", true); [ConfigurationProperty("GlobalPreviewStorageEnabled")] - internal InnerTextConfigurationElement GlobalPreviewStorageEnabled - { - get { return GetOptionalTextElement("GlobalPreviewStorageEnabled", false); } - } + internal InnerTextConfigurationElement GlobalPreviewStorageEnabled => GetOptionalTextElement("GlobalPreviewStorageEnabled", false); [ConfigurationProperty("defaultDocumentTypeProperty")] - internal InnerTextConfigurationElement DefaultDocumentTypeProperty - { - get { return GetOptionalTextElement("defaultDocumentTypeProperty", "Textstring"); } - } + internal InnerTextConfigurationElement DefaultDocumentTypeProperty => GetOptionalTextElement("defaultDocumentTypeProperty", "Textstring"); [ConfigurationProperty("showDeprecatedPropertyEditors")] - internal InnerTextConfigurationElement ShowDeprecatedPropertyEditors - { - get { return GetOptionalTextElement("showDeprecatedPropertyEditors", false); } - } + internal InnerTextConfigurationElement ShowDeprecatedPropertyEditors => GetOptionalTextElement("showDeprecatedPropertyEditors", false); [ConfigurationProperty("EnableInheritedDocumentTypes")] - internal InnerTextConfigurationElement EnableInheritedDocumentTypes - { - get { return GetOptionalTextElement("EnableInheritedDocumentTypes", true); } - } + internal InnerTextConfigurationElement EnableInheritedDocumentTypes => GetOptionalTextElement("EnableInheritedDocumentTypes", true); [ConfigurationProperty("EnableInheritedMediaTypes")] - internal InnerTextConfigurationElement EnableInheritedMediaTypes - { - get { return GetOptionalTextElement("EnableInheritedMediaTypes", true); } - } + internal InnerTextConfigurationElement EnableInheritedMediaTypes => GetOptionalTextElement("EnableInheritedMediaTypes", true); [ConfigurationProperty("loginBackgroundImage")] - internal InnerTextConfigurationElement LoginBackgroundImage - { - get { return GetOptionalTextElement("loginBackgroundImage", string.Empty); } - } + internal InnerTextConfigurationElement LoginBackgroundImage => GetOptionalTextElement("loginBackgroundImage", string.Empty); - string IContentSection.NotificationEmailAddress - { - get { return Notifications.NotificationEmailAddress; } - } + string IContentSection.NotificationEmailAddress => Notifications.NotificationEmailAddress; - bool IContentSection.DisableHtmlEmail - { - get { return Notifications.DisableHtmlEmail; } - } + bool IContentSection.DisableHtmlEmail => Notifications.DisableHtmlEmail; - IEnumerable IContentSection.ImageFileTypes - { - get { return Imaging.ImageFileTypes; } - } + IEnumerable IContentSection.ImageFileTypes => Imaging.ImageFileTypes; - IEnumerable IContentSection.ImageTagAllowedAttributes - { - get { return Imaging.ImageTagAllowedAttributes; } - } + IEnumerable IContentSection.ImageTagAllowedAttributes => Imaging.ImageTagAllowedAttributes; - IEnumerable IContentSection.ImageAutoFillProperties - { - get { return Imaging.ImageAutoFillProperties; } - } + IEnumerable IContentSection.ImageAutoFillProperties => Imaging.ImageAutoFillProperties; - bool IContentSection.ScriptEditorDisable - { - get { return ScriptEditor.ScriptEditorDisable; } - } + bool IContentSection.ScriptEditorDisable => ScriptEditor.ScriptEditorDisable; - string IContentSection.ScriptFolderPath - { - get { return ScriptEditor.ScriptFolderPath; } - } + string IContentSection.ScriptFolderPath => ScriptEditor.ScriptFolderPath; - IEnumerable IContentSection.ScriptFileTypes - { - get { return ScriptEditor.ScriptFileTypes; } - } + IEnumerable IContentSection.ScriptFileTypes => ScriptEditor.ScriptFileTypes; - bool IContentSection.ResolveUrlsFromTextString - { - get { return ResolveUrlsFromTextString; } - } + bool IContentSection.ResolveUrlsFromTextString => ResolveUrlsFromTextString; - bool IContentSection.UploadAllowDirectories - { - get { return UploadAllowDirectories; } - } + bool IContentSection.UploadAllowDirectories => UploadAllowDirectories; - bool IContentSection.EnsureUniqueNaming - { - get { return EnsureUniqueNaming; } - } + bool IContentSection.EnsureUniqueNaming => EnsureUniqueNaming; - bool IContentSection.XmlCacheEnabled - { - get { return XmlCacheEnabled; } - } + bool IContentSection.XmlCacheEnabled => XmlCacheEnabled; - bool IContentSection.ContinouslyUpdateXmlDiskCache - { - get { return ContinouslyUpdateXmlDiskCache; } - } + bool IContentSection.ContinouslyUpdateXmlDiskCache => ContinouslyUpdateXmlDiskCache; - bool IContentSection.XmlContentCheckForDiskChanges - { - get { return XmlContentCheckForDiskChanges; } - } + bool IContentSection.XmlContentCheckForDiskChanges => XmlContentCheckForDiskChanges; - bool IContentSection.EnableSplashWhileLoading - { - get { return EnableSplashWhileLoading; } - } + bool IContentSection.EnableSplashWhileLoading => EnableSplashWhileLoading; - string IContentSection.PropertyContextHelpOption - { - get { return PropertyContextHelpOption; } - } + string IContentSection.PropertyContextHelpOption => PropertyContextHelpOption; - bool IContentSection.ForceSafeAliases - { - get { return ForceSafeAliases; } - } + bool IContentSection.ForceSafeAliases => ForceSafeAliases; - string IContentSection.PreviewBadge - { - get { return PreviewBadge; } - } + string IContentSection.PreviewBadge => PreviewBadge; - int IContentSection.UmbracoLibraryCacheDuration - { - get { return UmbracoLibraryCacheDuration; } - } + int IContentSection.UmbracoLibraryCacheDuration => UmbracoLibraryCacheDuration; - MacroErrorBehaviour IContentSection.MacroErrorBehaviour - { - get { return MacroErrors; } - } + MacroErrorBehaviour IContentSection.MacroErrorBehaviour => MacroErrors; - IEnumerable IContentSection.DisallowedUploadFiles - { - get { return DisallowedUploadFiles; } - } + IEnumerable IContentSection.DisallowedUploadFiles => DisallowedUploadFiles; - IEnumerable IContentSection.AllowedUploadFiles - { - get { return AllowedUploadFiles; } - } + IEnumerable IContentSection.AllowedUploadFiles => AllowedUploadFiles; - bool IContentSection.CloneXmlContent - { - get { return CloneXmlContent; } - } + bool IContentSection.CloneXmlContent => CloneXmlContent; - bool IContentSection.GlobalPreviewStorageEnabled - { - get { return GlobalPreviewStorageEnabled; } - } + bool IContentSection.GlobalPreviewStorageEnabled => GlobalPreviewStorageEnabled; - string IContentSection.DefaultDocumentTypeProperty - { - get { return DefaultDocumentTypeProperty; } - } + string IContentSection.DefaultDocumentTypeProperty => DefaultDocumentTypeProperty; - bool IContentSection.EnableInheritedDocumentTypes - { - get { return EnableInheritedDocumentTypes; } - } + bool IContentSection.ShowDeprecatedPropertyEditors => ShowDeprecatedPropertyEditors; - bool IContentSection.EnableInheritedMediaTypes - { - get { return EnableInheritedMediaTypes; } - } + bool IContentSection.EnableInheritedDocumentTypes => EnableInheritedDocumentTypes; - string IContentSection.LoginBackgroundImage - { - get { return LoginBackgroundImage; } - } + bool IContentSection.EnableInheritedMediaTypes => EnableInheritedMediaTypes; + + string IContentSection.LoginBackgroundImage => LoginBackgroundImage; } } diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/IContentSection.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/IContentSection.cs index babc3811f1..879afd65bf 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/IContentSection.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/IContentSection.cs @@ -57,6 +57,12 @@ namespace Umbraco.Core.Configuration.UmbracoSettings string DefaultDocumentTypeProperty { get; } + /// + /// Gets a value indicating whether to show deprecated property editors in + /// a datatype list of available editors. + /// + bool ShowDeprecatedPropertyEditors { get; } + bool EnableInheritedDocumentTypes { get; } bool EnableInheritedMediaTypes { get; } diff --git a/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs b/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs index 007a9b279c..be73c984e3 100644 --- a/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs @@ -87,14 +87,16 @@ namespace Umbraco.Core.PropertyEditors /// /// Gets or sets a value indicating whether the property editor is deprecated. /// + /// A deprecated editor does not show up in the list of available editors for a datatype, + /// unless it is the current editor for the datatype. [JsonIgnore] - public bool IsDeprecated { get; internal set; } // fixme - kill it all in v8 + public bool IsDeprecated { get; internal set; } /// /// Gets or sets the value editor. /// /// - /// If an instance of a value editor is assigned to the property, + /// If an instance of a value editor is assigned to the property, /// then this instance is returned when getting the property value. Otherwise, a /// new instance is created by CreateValueEditor. /// The instance created by CreateValueEditor is not cached, i.e. @@ -124,7 +126,7 @@ namespace Umbraco.Core.PropertyEditors /// Gets or sets the configuration editor. /// /// - /// If an instance of a configuration editor is assigned to the property, + /// If an instance of a configuration editor is assigned to the property, /// then this instance is returned when getting the property value. Otherwise, a /// new instance is created by CreateConfigurationEditor. /// The instance created by CreateConfigurationEditor is not cached, i.e. diff --git a/src/Umbraco.Core/PropertyEditors/ValueEditorAttribute.cs b/src/Umbraco.Core/PropertyEditors/ValueEditorAttribute.cs index 059aafa818..25afe2d628 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueEditorAttribute.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueEditorAttribute.cs @@ -68,10 +68,11 @@ namespace Umbraco.Core.PropertyEditors public bool IsMacroParameterEditor { get; set; } // => (EditorType & EditorType.MacroParameter) != 0; /// - /// If set to true, this property editor will not show up in the DataType's drop down list - /// if there is not already one of them chosen for a DataType + /// Gets or sets a value indicating whether the value editor is deprecated. /// - public bool IsDeprecated { get; set; } // fixme should just kill in v8 + /// A deprecated editor does not show up in the list of available editors for a datatype, + /// unless it is the current editor for the datatype. + public bool IsDeprecated { get; set; } /// /// Gets or sets a value indicating whether the editor should be displayed without its label. diff --git a/src/Umbraco.Core/ReflectionUtilities.cs b/src/Umbraco.Core/ReflectionUtilities.cs index 4b08f181d4..2187dc363b 100644 --- a/src/Umbraco.Core/ReflectionUtilities.cs +++ b/src/Umbraco.Core/ReflectionUtilities.cs @@ -254,7 +254,7 @@ namespace Umbraco.Core if (lambdaParameters.Length != ctorParameters.Length) ThrowInvalidLambda("ctor", ctorDeclaring, ctorParameters); for (var i = 0; i < lambdaParameters.Length; i++) - if (lambdaParameters[i] != ctorParameters[i]) // fixme cast? relax? + if (lambdaParameters[i] != ctorParameters[i]) // note: relax the constraint with IsAssignableFrom? ThrowInvalidLambda("ctor", ctorDeclaring, ctorParameters); if (!returned.IsAssignableFrom(ctorDeclaring)) ThrowInvalidLambda("ctor", ctorDeclaring, ctorParameters); @@ -596,42 +596,6 @@ namespace Umbraco.Core ilgen.Emit(ldargOpCodes[i]); else ilgen.Emit(OpCodes.Ldarg, i); - - //EmitInputAdapter(ilgen, lambdaArgTypes[i], methodArgTypes[i]); - } - } - - // emits adapter opcodes after each OpCode.Ldarg - private static void EmitInputAdapter(ILGenerator ilgen, Type inputType, Type methodParamType) - { - if (inputType == methodParamType) return; - - if (methodParamType.IsValueType) - { - if (inputType.IsValueType) - { - // both input and parameter are value types - // not supported, use proper input - // (otherwise, would require converting) - throw new NotSupportedException("ValueTypes conversion."); - } - - // parameter is value type, but input is reference type - // unbox the input to the parameter value type - // fixme - conversions? - ilgen.Emit(OpCodes.Unbox_Any, inputType); - } - else - { - // parameter is reference type, but input is value type - // not supported, input should always be less constrained - // (otherwise, would require boxing and converting) - if (inputType.IsValueType) - throw new NotSupportedException("ValueType boxing."); - - // both input and parameter are reference types - // cast the input to the parameter type - ilgen.Emit(OpCodes.Castclass, methodParamType); } } @@ -652,7 +616,6 @@ namespace Umbraco.Core // returned is value type, but output is reference type // box the returned value - // fixme - conversions? ilgen.Emit(OpCodes.Box, methodReturnedType); } else diff --git a/src/Umbraco.Web/Models/Mapping/AvailablePropertyEditorsResolver.cs b/src/Umbraco.Web/Models/Mapping/AvailablePropertyEditorsResolver.cs index 7d1a808171..7b8bdb91c5 100644 --- a/src/Umbraco.Web/Models/Mapping/AvailablePropertyEditorsResolver.cs +++ b/src/Umbraco.Web/Models/Mapping/AvailablePropertyEditorsResolver.cs @@ -20,13 +20,7 @@ namespace Umbraco.Web.Models.Mapping public IEnumerable Resolve(IDataType source) { return Current.PropertyEditors - .Where(x => - { - // fixme should we support deprecating? - //if (_contentSection.ShowDeprecatedPropertyEditors) - // return true; - return source.EditorAlias == x.Alias || x.IsDeprecated == false; - }) + .Where(x => !x.IsDeprecated || _contentSection.ShowDeprecatedPropertyEditors || source.EditorAlias == x.Alias) .OrderBy(x => x.Name) .Select(Mapper.Map); } diff --git a/src/Umbraco.Web/Models/Mapping/DataTypeMapperProfile.cs b/src/Umbraco.Web/Models/Mapping/DataTypeMapperProfile.cs index 995ee06e96..3177a5d355 100644 --- a/src/Umbraco.Web/Models/Mapping/DataTypeMapperProfile.cs +++ b/src/Umbraco.Web/Models/Mapping/DataTypeMapperProfile.cs @@ -111,8 +111,6 @@ namespace Umbraco.Web.Models.Mapping // this is a new data type, so just return the field editors, with default values - there are no values yet var fields = src.ConfigurationEditor.Fields.Select(Mapper.Map).ToArray(); - // fixme for ConfigurationEditor it's a dictionary, for ConfigurationEditor it's a new TConfiguration - // and then what? need to get it back as a dictionary so it can be applied here? var defaultConfiguration = src.DefaultConfiguration; if (defaultConfiguration != null) DataTypeConfigurationFieldDisplayResolver.MapPreValueValuesToPreValueFields(fields, defaultConfiguration); diff --git a/src/Umbraco.Web/PropertyEditors/FolderBrowserPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/FolderBrowserPropertyEditor.cs deleted file mode 100644 index 5742271f37..0000000000 --- a/src/Umbraco.Web/PropertyEditors/FolderBrowserPropertyEditor.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using Umbraco.Core; -using Umbraco.Core.Logging; -using Umbraco.Core.PropertyEditors; - -namespace Umbraco.Web.PropertyEditors -{ - [Obsolete("This is no longer used by default, use the ListViewPropertyEditor instead")] - [ValueEditor(Constants.PropertyEditors.Aliases.FolderBrowser, "(Obsolete) Folder Browser", "folderbrowser", HideLabel=true, Icon="icon-folder", Group="media", IsDeprecated = true)] - public class FolderBrowserPropertyEditor : PropertyEditor - { - /// - /// The constructor will setup the property editor based on the attribute if one is found - /// - public FolderBrowserPropertyEditor(ILogger logger) : base(logger) - { - } - } -} diff --git a/src/Umbraco.Web/PropertyEditors/ImageCropperConfigurationEditor.cs b/src/Umbraco.Web/PropertyEditors/ImageCropperConfigurationEditor.cs index 70d0681406..f2bb4d6a53 100644 --- a/src/Umbraco.Web/PropertyEditors/ImageCropperConfigurationEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ImageCropperConfigurationEditor.cs @@ -8,12 +8,13 @@ namespace Umbraco.Web.PropertyEditors /// internal class ImageCropperConfigurationEditor : ConfigurationEditor { - //fixme - // BUT... focal point and src are NOT part of configuration?! - public override IDictionary DefaultConfiguration => new Dictionary + /// + public override Dictionary ToValueEditor(object configuration) { - {"focalPoint", "{left: 0.5, top: 0.5}"}, - {"src", ""} - }; + var d = base.ToValueEditor(configuration); + if (!d.ContainsKey("focalPoint")) d["focalPoint"] = new { left = 0.5, top = 0.5 }; + if (!d.ContainsKey("src")) d["src"] = ""; + return d; + } } } \ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/MacroContainerPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/MacroContainerPropertyEditor.cs index 679f8f86c7..02b5203aff 100644 --- a/src/Umbraco.Web/PropertyEditors/MacroContainerPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/MacroContainerPropertyEditor.cs @@ -4,13 +4,13 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { + // fixme - if deprecated, what's the alternative? [ValueEditor(Constants.PropertyEditors.Aliases.MacroContainer, "(Obsolete) Macro Picker", "macrocontainer", ValueType = ValueTypes.Text, Group="rich content", Icon="icon-settings-alt", IsDeprecated = true)] public class MacroContainerPropertyEditor : PropertyEditor { public MacroContainerPropertyEditor(ILogger logger) : base(logger) - { - } + { } protected override ConfigurationEditor CreateConfigurationEditor() { diff --git a/src/Umbraco.Web/PropertyEditors/MultiNodePickerConfiguration.cs b/src/Umbraco.Web/PropertyEditors/MultiNodePickerConfiguration.cs new file mode 100644 index 0000000000..0e82a7179b --- /dev/null +++ b/src/Umbraco.Web/PropertyEditors/MultiNodePickerConfiguration.cs @@ -0,0 +1,25 @@ +using Umbraco.Core.PropertyEditors; + +namespace Umbraco.Web.PropertyEditors +{ + /// + /// Represents the configuration for the multinode picker value editor. + /// + public class MultiNodePickerConfiguration + { + [ConfigurationField("startNode", "Node type", "treesource")] + public string TreeSource { get; set; } + + [ConfigurationField("filter", "Allow items of type", "textstring", Description = "Separate with comma")] + public string Filter { get; set; } + + [ConfigurationField("minNumber", "Minimum number of items", "number")] + public int MinNumber { get; set; } + + [ConfigurationField("maxNumber", "Maximum number of items", "number")] + public int MaxNumber { get; set; } + + [ConfigurationField("showOpenButtom", "Show open button (this feature is in preview!)", "boolean", Description = "Opens the node in a dialog")] + public bool ShowOpen { get; set; } + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/MultiNodePickerConfigurationEditor.cs b/src/Umbraco.Web/PropertyEditors/MultiNodePickerConfigurationEditor.cs index c5433f5f2a..eb0849c3c6 100644 --- a/src/Umbraco.Web/PropertyEditors/MultiNodePickerConfigurationEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/MultiNodePickerConfigurationEditor.cs @@ -3,24 +3,6 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - /// - /// Represents the configuration for the multinode picker value editor. - /// - public class MultiNodePickerConfiguration - { - // all fields added in the editor ctor - - public string TreeSource { get; set; } // fixme Udi? - - public string Filter { get; set; } - - public int MinNumber { get; set; } - - public int MaxNumber { get; set; } - - public bool ShowOpen { get; set; } - } - /// /// Represents the configuration for the multinode picker value editor. /// @@ -28,63 +10,13 @@ namespace Umbraco.Web.PropertyEditors { public MultiNodePickerConfigurationEditor() { - Fields.Add(new ConfigurationField() - { - Key = "startNode", - View = "treesource", - Name = "Node type", - PropertyName = nameof(MultiNodePickerConfiguration.TreeSource), - Config = new Dictionary + Field(nameof(MultiNodePickerConfiguration.TreeSource)) + .Config = new Dictionary { { "idType", "udi" } - } - }); - - Fields.Add(new ConfigurationField() - { - Key = "filter", - View = "textstring", - Name = "Allow items of type", - PropertyName = nameof(MultiNodePickerConfiguration.Filter), - Description = "Separate with comma" - }); - - Fields.Add(new ConfigurationField() - { - Key = "minNumber", - View = "number", - Name = "Minimum number of items", - PropertyName = nameof(MultiNodePickerConfiguration.MinNumber) - }); - - Fields.Add(new ConfigurationField() - { - Key = "maxNumber", - View = "number", - Name = "Maximum number of items", - PropertyName = nameof(MultiNodePickerConfiguration.MaxNumber) - }); - - Fields.Add(new ConfigurationField() - { - Key = "showOpenButton", - View = "boolean", - Name = "Show open button (this feature is in preview!)", - PropertyName = nameof(MultiNodePickerConfiguration.ShowOpen), - Description = "Opens the node in a dialog" - }); + }; } - // fixme - public override IDictionary DefaultConfiguration => new Dictionary - { - { "multiPicker", 1 }, - { "showOpenButton", 0 }, - { "showEditButton", 0 }, - { "showPathOnHover", 0 }, - { "idType", "udi" } - }; - /// public override Dictionary ToConfigurationEditor(MultiNodePickerConfiguration configuration) { @@ -95,5 +27,16 @@ namespace Umbraco.Web.PropertyEditors return output; } + + /// + public override Dictionary ToValueEditor(object configuration) + { + var d = base.ToValueEditor(configuration); + d["multiPicker"] = true; + d["showEditButton"] = false; + d["showPathOnHover"] = false; + d["idType"] = "udi"; + return d; + } } } \ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/NestedContentConfiguration.cs b/src/Umbraco.Web/PropertyEditors/NestedContentConfiguration.cs index 1fabe5ee7a..44648ee859 100644 --- a/src/Umbraco.Web/PropertyEditors/NestedContentConfiguration.cs +++ b/src/Umbraco.Web/PropertyEditors/NestedContentConfiguration.cs @@ -18,13 +18,13 @@ namespace Umbraco.Web.PropertyEditors public int? MaxItems { get; set; } [ConfigurationField("confirmDeletes", "Confirm Deletes", "boolean", Description = "Set whether item deletions should require confirming.")] - public string ConfirmDeletes { get; set; } // fixme bool + public bool ConfirmDeletes { get; set; } = true; [ConfigurationField("showIcons", "Show Icons", "boolean", Description = "Set whether to show the items doc type icon in the list.")] - public string ShowIcons { get; set; } // fixme bool + public bool ShowIcons { get; set; } = true; [ConfigurationField("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; } // fixme bool + public bool HideLabel { get; set; } public class ContentType { diff --git a/src/Umbraco.Web/PropertyEditors/NestedContentConfigurationEditor.cs b/src/Umbraco.Web/PropertyEditors/NestedContentConfigurationEditor.cs index 78e704b253..5daed5c0aa 100644 --- a/src/Umbraco.Web/PropertyEditors/NestedContentConfigurationEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/NestedContentConfigurationEditor.cs @@ -7,15 +7,5 @@ namespace Umbraco.Web.PropertyEditors /// Represents the configuration editor for the nested content value editor. /// public class NestedContentConfigurationEditor : ConfigurationEditor - { - // fixme - public override IDictionary DefaultConfiguration => new Dictionary - { - {"contentTypes", ""}, - {"minItems", 0}, - {"maxItems", 0}, - {"confirmDeletes", "1"}, - {"showIcons", "1"} - }; - } + { } } \ No newline at end of file diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index bb62d3df50..813715ba2a 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -265,6 +265,7 @@ + @@ -692,7 +693,6 @@ -