From 2b2cf48fdb35e53d36f23aa5f76e5104e4a9fd43 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 9 Oct 2013 16:06:07 +1100 Subject: [PATCH] Implements HideLabel for property editor value editors for both c# and manifest declarations. --- .../PropertyEditors/IParameterEditor.cs | 24 +++++++++++++++++++ .../PropertyEditors/ParameterEditor.cs | 20 ---------------- .../PropertyEditors/PropertyEditor.cs | 1 + .../PropertyEditorAttribute.cs | 5 ++++ .../PropertyEditors/PropertyValueEditor.cs | 6 +++++ src/Umbraco.Core/Umbraco.Core.csproj | 1 + .../Manifest/ManifestParserTests.cs | 8 +++++-- .../ContentPropertyDisplayConverter.cs | 1 + .../PropertyEditors/ListViewPropertyEditor.cs | 2 +- .../PropertyValueEditorWrapper.cs | 1 + .../PropertyEditors/RichTextPropertyEditor.cs | 2 +- 11 files changed, 47 insertions(+), 24 deletions(-) create mode 100644 src/Umbraco.Core/PropertyEditors/IParameterEditor.cs diff --git a/src/Umbraco.Core/PropertyEditors/IParameterEditor.cs b/src/Umbraco.Core/PropertyEditors/IParameterEditor.cs new file mode 100644 index 0000000000..cfa7174aae --- /dev/null +++ b/src/Umbraco.Core/PropertyEditors/IParameterEditor.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; + +namespace Umbraco.Core.PropertyEditors +{ + public interface IParameterEditor + { + /// + /// The id of the property editor + /// + string Alias { get; } + + /// + /// The name of the property editor + /// + string Name { get; } + + /// + /// Allows a parameter editor to be re-used based on the configuration specified. + /// + IDictionary Configuration { get; } + + IValueEditor ValueEditor { get; } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/PropertyEditors/ParameterEditor.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditor.cs index 189fd59b8a..be98218808 100644 --- a/src/Umbraco.Core/PropertyEditors/ParameterEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/ParameterEditor.cs @@ -5,26 +5,6 @@ using Umbraco.Core.IO; namespace Umbraco.Core.PropertyEditors { - public interface IParameterEditor - { - /// - /// The id of the property editor - /// - string Alias { get; } - - /// - /// The name of the property editor - /// - string Name { get; } - - /// - /// Allows a parameter editor to be re-used based on the configuration specified. - /// - IDictionary Configuration { get; } - - IValueEditor ValueEditor { get; } - } - /// /// Basic definition of a macro parameter editor /// diff --git a/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs b/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs index 611f180758..cdc38f7cc2 100644 --- a/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/PropertyEditor.cs @@ -116,6 +116,7 @@ namespace Umbraco.Core.PropertyEditors editor.View = _attribute.EditorView; editor.ValueType = _attribute.ValueType; + editor.HideLabel = _attribute.HideLabel; return editor; } diff --git a/src/Umbraco.Core/PropertyEditors/PropertyEditorAttribute.cs b/src/Umbraco.Core/PropertyEditors/PropertyEditorAttribute.cs index 50dfd1d062..714ff31abd 100644 --- a/src/Umbraco.Core/PropertyEditors/PropertyEditorAttribute.cs +++ b/src/Umbraco.Core/PropertyEditors/PropertyEditorAttribute.cs @@ -52,5 +52,10 @@ namespace Umbraco.Core.PropertyEditors public string EditorView { get; private set; } public string ValueType { get; set; } public bool IsParameterEditor { get; set; } + + /// + /// If this is is true than the editor will be displayed full width without a label + /// + public bool HideLabel { get; set; } } } \ No newline at end of file diff --git a/src/Umbraco.Core/PropertyEditors/PropertyValueEditor.cs b/src/Umbraco.Core/PropertyEditors/PropertyValueEditor.cs index 0649a03d40..ec4cd52284 100644 --- a/src/Umbraco.Core/PropertyEditors/PropertyValueEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/PropertyValueEditor.cs @@ -123,6 +123,12 @@ namespace Umbraco.Core.PropertyEditors } } + /// + /// If this is is true than the editor will be displayed full width without a label + /// + [JsonProperty("hideLabel")] + public bool HideLabel { get; set; } + /// /// Set this to true if the property editor is for display purposes only /// diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 6df2573f01..e59e6d7303 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -450,6 +450,7 @@ + diff --git a/src/Umbraco.Tests/Manifest/ManifestParserTests.cs b/src/Umbraco.Tests/Manifest/ManifestParserTests.cs index 154b4a5b5a..7c44649c08 100644 --- a/src/Umbraco.Tests/Manifest/ManifestParserTests.cs +++ b/src/Umbraco.Tests/Manifest/ManifestParserTests.cs @@ -82,16 +82,19 @@ namespace Umbraco.Tests.Manifest }, { alias: 'Test.Test2', - name: 'Test 2', + name: 'Test 2', defaultConfig: { key1: 'some default pre val' }, editor: { - view: '~/App_Plugins/MyPackage/PropertyEditors/CsvEditor.html' + view: '~/App_Plugins/MyPackage/PropertyEditors/CsvEditor.html', + hideLabel: true } } ]"); var parser = ManifestParser.GetPropertyEditors(a); Assert.AreEqual(2, parser.Count()); + + Assert.AreEqual(false, parser.ElementAt(0).ValueEditor.HideLabel); Assert.AreEqual("Test.Test1", parser.ElementAt(0).Alias); Assert.AreEqual("Test 1", parser.ElementAt(0).Name); Assert.AreEqual("/App_Plugins/MyPackage/PropertyEditors/MyEditor.html", parser.ElementAt(0).ValueEditor.View); @@ -104,6 +107,7 @@ namespace Umbraco.Tests.Manifest Assert.IsNotNull(manifestValidator2); Assert.AreEqual("regex", manifestValidator2.Type); + Assert.AreEqual(true, parser.ElementAt(1).ValueEditor.HideLabel); Assert.AreEqual("Test.Test2", parser.ElementAt(1).Alias); Assert.AreEqual("Test 2", parser.ElementAt(1).Name); Assert.IsTrue(parser.ElementAt(1).DefaultPreValues.ContainsKey("key1")); diff --git a/src/Umbraco.Web/Models/Mapping/ContentPropertyDisplayConverter.cs b/src/Umbraco.Web/Models/Mapping/ContentPropertyDisplayConverter.cs index b424751715..b5d68fed21 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentPropertyDisplayConverter.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentPropertyDisplayConverter.cs @@ -28,6 +28,7 @@ namespace Umbraco.Web.Models.Mapping display.Alias = originalProp.Alias; display.Description = originalProp.PropertyType.Description; display.Label = originalProp.PropertyType.Name; + display.HideLabel = display.PropertyEditor.ValueEditor.HideLabel; var dataTypeService = _dataTypeService.Value; diff --git a/src/Umbraco.Web/PropertyEditors/ListViewPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/ListViewPropertyEditor.cs index 74e47c749c..04a52041cc 100644 --- a/src/Umbraco.Web/PropertyEditors/ListViewPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ListViewPropertyEditor.cs @@ -8,7 +8,7 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.ListViewAlias, "List view", "listview")] + [PropertyEditor(Constants.PropertyEditors.ListViewAlias, "List view", "listview", HideLabel = true)] public class ListViewPropertyEditor : PropertyEditor { diff --git a/src/Umbraco.Web/PropertyEditors/PropertyValueEditorWrapper.cs b/src/Umbraco.Web/PropertyEditors/PropertyValueEditorWrapper.cs index bb0a1dd903..3f55eb1c99 100644 --- a/src/Umbraco.Web/PropertyEditors/PropertyValueEditorWrapper.cs +++ b/src/Umbraco.Web/PropertyEditors/PropertyValueEditorWrapper.cs @@ -10,6 +10,7 @@ namespace Umbraco.Web.PropertyEditors { public PropertyValueEditorWrapper(PropertyValueEditor wrapped) { + this.HideLabel = wrapped.HideLabel; this.View = wrapped.View; this.ValueType = wrapped.ValueType; foreach (var v in wrapped.Validators) diff --git a/src/Umbraco.Web/PropertyEditors/RichTextPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/RichTextPropertyEditor.cs index 274e35d202..412148ce8d 100644 --- a/src/Umbraco.Web/PropertyEditors/RichTextPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/RichTextPropertyEditor.cs @@ -5,7 +5,7 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.TinyMCEv3Alias, "Rich Text Editor", "rte")] + [PropertyEditor(Constants.PropertyEditors.TinyMCEv3Alias, "Rich Text Editor", "rte", HideLabel = true)] public class RichTextPropertyEditor : PropertyEditor { ///