From aa614f1e20d924ad1ce20e8c0a786ab61993fb7e Mon Sep 17 00:00:00 2001 From: Stephan Date: Fri, 9 Feb 2018 15:33:44 +0100 Subject: [PATCH] Cleanup --- .../PropertyEditors/TagConfiguration.cs | 2 +- .../ContentEditing/TabbedContentItem.cs | 2 +- .../ContentPickerConfiguration.cs | 13 +++++ .../ContentPickerConfigurationEditor.cs | 51 ++++--------------- .../MediaPickerConfiguration.cs | 3 +- .../MediaPickerConfigurationEditor.cs | 24 ++++----- .../RelatedLinksConfigurationEditor.cs | 9 ++-- .../PropertyEditors/TagConfigurationEditor.cs | 7 --- src/Umbraco.Web/Umbraco.Web.csproj | 1 + 9 files changed, 40 insertions(+), 72 deletions(-) create mode 100644 src/Umbraco.Web/PropertyEditors/ContentPickerConfiguration.cs diff --git a/src/Umbraco.Core/PropertyEditors/TagConfiguration.cs b/src/Umbraco.Core/PropertyEditors/TagConfiguration.cs index 52b079ada8..15bdcb125b 100644 --- a/src/Umbraco.Core/PropertyEditors/TagConfiguration.cs +++ b/src/Umbraco.Core/PropertyEditors/TagConfiguration.cs @@ -9,7 +9,7 @@ namespace Umbraco.Core.PropertyEditors { // no field attribute, all defined in the editor, due to validators - public string Group { get; set; } + public string Group { get; set; } = "default"; public TagsStorageType StorageType { get; set; } = TagsStorageType.Csv; diff --git a/src/Umbraco.Web/Models/ContentEditing/TabbedContentItem.cs b/src/Umbraco.Web/Models/ContentEditing/TabbedContentItem.cs index ab4ec065bc..5447d15e7b 100644 --- a/src/Umbraco.Web/Models/ContentEditing/TabbedContentItem.cs +++ b/src/Umbraco.Web/Models/ContentEditing/TabbedContentItem.cs @@ -40,7 +40,7 @@ namespace Umbraco.Web.Models.ContentEditing /// This property cannot be set /// [IgnoreDataMember] - [JsonIgnore] // fixme - see note on IgnoreDataMember vs JsonIgnore + [JsonIgnore] // see note above on IgnoreDataMember vs JsonIgnore public override IEnumerable Properties { get => Tabs.SelectMany(x => x.Properties); diff --git a/src/Umbraco.Web/PropertyEditors/ContentPickerConfiguration.cs b/src/Umbraco.Web/PropertyEditors/ContentPickerConfiguration.cs new file mode 100644 index 0000000000..fe6ab6a054 --- /dev/null +++ b/src/Umbraco.Web/PropertyEditors/ContentPickerConfiguration.cs @@ -0,0 +1,13 @@ +using Umbraco.Core.PropertyEditors; + +namespace Umbraco.Web.PropertyEditors +{ + public class ContentPickerConfiguration + { + [ConfigurationField("showOpenButton", "Show open button (this feature is in beta!)", "boolean", Description = "Opens the node in a dialog")] + public bool ShowOpenButton { get; set; } + + [ConfigurationField("startNodeId", "Start node", "treepicker")] // + config in configuration editor ctor + public int StartNodeId { get; set; } = -1; // default value is -1 + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/ContentPickerConfigurationEditor.cs b/src/Umbraco.Web/PropertyEditors/ContentPickerConfigurationEditor.cs index 65ce8065d0..9cb5a3fe6b 100644 --- a/src/Umbraco.Web/PropertyEditors/ContentPickerConfigurationEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ContentPickerConfigurationEditor.cs @@ -1,58 +1,25 @@ using System.Collections.Generic; -using System.Linq; using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - - // FIXME obviously the idea is to turn it into a ConfigurationEditor - // but - // before that we have to find a way to have "default configuration" works for base ConfigurationEditors - - public class ContentPickerConfiguration - { - [ConfigurationField("showOpenButton", "Show open button (this feature is in beta!)", "boolean", Description = "Opens the node in a dialog")] - public bool ShowOpenButton { get; set; } - - [ConfigurationField("startNodeId", "Start node", "treepicker")] - public int StartNodeId { get; set; } = -1; // default value is -1 - } - - internal class ContentPickerConfigurationEditor : ConfigurationEditor // + internal class ContentPickerConfigurationEditor : ConfigurationEditor { public ContentPickerConfigurationEditor() { - Fields.Add(new ConfigurationField - { - Key = "showOpenButton", - View = "boolean", - Name = "Show open button (this feature is in preview!)", - Description = "Opens the node in a dialog", - PropertyName = nameof(ContentPickerConfiguration.ShowOpenButton) - }); - Fields.Add(new ConfigurationField - { - Key = "startNodeId", - View = "treepicker", - Name = "Start node", - PropertyName = nameof(ContentPickerConfiguration.StartNodeId) - }); - // configure fields Field(nameof(ContentPickerConfiguration.StartNodeId)) .Config = new Dictionary { { "idType", "udi" } }; } - // fixme - cache this to allocate only once! - // fixme - should derive from the ContentPickerConfiguration class! - // fixme - we have way more stuff in here than pure fields defined above = what does it mean? - public override IDictionary DefaultConfiguration => new Dictionary + public override Dictionary ToValueEditor(object configuration) { - { "startNodeId", -1 }, - { "showOpenButton", 0 }, - { "showEditButton", 0 }, - { "showPathOnHover", 0 }, - { "idType", "udi" } - }; + // these are not configuration fields, but constants required by the value editor + var d = base.ToValueEditor(configuration); + d["showEditButton"] = false; + d["showPathOnHover"] = false; + d["idType"] = "udi"; + return d; + } } } \ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/MediaPickerConfiguration.cs b/src/Umbraco.Web/PropertyEditors/MediaPickerConfiguration.cs index 05c7405285..382db7e414 100644 --- a/src/Umbraco.Web/PropertyEditors/MediaPickerConfiguration.cs +++ b/src/Umbraco.Web/PropertyEditors/MediaPickerConfiguration.cs @@ -16,8 +16,7 @@ namespace Umbraco.Web.PropertyEditors [ConfigurationField("disableFolderSelect", "Disable folder select", "boolean", Description = "Do not allow folders to be picked.")] public bool DisableFolderSelect { get; set; } - // cannot set field.Config through attribute = done in editor ctor - //[ConfigurationField("startNodeId", "Start node", "mediapicker")] + [ConfigurationField("startNodeId", "Start node", "mediapicker")] public int StartNodeId { get; set; } } } \ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/MediaPickerConfigurationEditor.cs b/src/Umbraco.Web/PropertyEditors/MediaPickerConfigurationEditor.cs index 4a5acc5b07..53ae28c4a9 100644 --- a/src/Umbraco.Web/PropertyEditors/MediaPickerConfigurationEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/MediaPickerConfigurationEditor.cs @@ -13,24 +13,18 @@ namespace Umbraco.Web.PropertyEditors /// public MediaPickerConfigurationEditor() { - // must add that one explicitely due to field.Config - Fields.Add(new ConfigurationField - { - Key = "startNodeId", - View = "mediapicker", - Name = "Start node", - PropertyName = nameof(MediaPickerConfiguration.StartNodeId), - Config = new Dictionary + Field(nameof(MediaPickerConfiguration.StartNodeId)) + .Config = new Dictionary { - {"idType", "udi"} - } - }); + { "idType", "udi" } + }; } - // fixme - is this configuration? or field' configuration? WTF?! - public override IDictionary DefaultConfiguration => new Dictionary + public override Dictionary ToValueEditor(object configuration) { - {"idType", "udi"} - }; + var d = base.ToValueEditor(configuration); + d["idType"] = "udi"; + return d; + } } } \ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/RelatedLinksConfigurationEditor.cs b/src/Umbraco.Web/PropertyEditors/RelatedLinksConfigurationEditor.cs index 972da4664a..64d16f8f2a 100644 --- a/src/Umbraco.Web/PropertyEditors/RelatedLinksConfigurationEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/RelatedLinksConfigurationEditor.cs @@ -8,10 +8,11 @@ namespace Umbraco.Web.PropertyEditors /// public class RelatedLinksConfigurationEditor : ConfigurationEditor { - // fixme - this is weird?! - public override IDictionary DefaultConfiguration => new Dictionary + public override Dictionary ToValueEditor(object configuration) { - {"idType", "udi"} - }; + var d = base.ToValueEditor(configuration); + d["idType"] = "udi"; + return d; + } } } \ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/TagConfigurationEditor.cs b/src/Umbraco.Web/PropertyEditors/TagConfigurationEditor.cs index 8de751c49b..aa823ea5a9 100644 --- a/src/Umbraco.Web/PropertyEditors/TagConfigurationEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/TagConfigurationEditor.cs @@ -33,13 +33,6 @@ namespace Umbraco.Web.PropertyEditors }); } - // fixme - public override IDictionary DefaultConfiguration => new Dictionary - { - {"group", "default"}, - {"storageType", TagsStorageType.Csv.ToString()} - }; - public override Dictionary ToConfigurationEditor(TagConfiguration configuration) { var dictionary = base.ToConfigurationEditor(configuration); diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 17d2e6cc7b..bb62d3df50 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -239,6 +239,7 @@ +