diff --git a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/readonly.html b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/readonly.html new file mode 100644 index 0000000000..a9a55588d4 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/readonly.html @@ -0,0 +1,7 @@ +
+ +
\ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/LabelPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/LabelPropertyEditor.cs index c1bf052406..ef5e2eeb32 100644 --- a/src/Umbraco.Web/PropertyEditors/LabelPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/LabelPropertyEditor.cs @@ -1,6 +1,9 @@ -using System.ComponentModel; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; using System.Web.Mvc; using Umbraco.Core; +using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors @@ -14,5 +17,39 @@ namespace Umbraco.Web.PropertyEditors return new LabelPropertyValueEditor(base.CreateValueEditor()); } + protected override PreValueEditor CreatePreValueEditor() + { + return new LabelPreValueEditor(); + } + + internal class LabelPreValueEditor : PreValueEditor + { + public LabelPreValueEditor() + { + Fields.Add(new PreValueField() + { + HideLabel = true, + View = "readonly", + Key = "values" + }); + } + + /// + /// Chuck all the values into one field so devs can see what is stored there - we want this in case we've converted a legacy proeprty editor over to a label + /// we should still show the pre-values stored for the data type. + /// + /// + /// + /// + public override IDictionary ConvertDbToEditor(IDictionary defaultPreVals, PreValueCollection persistedPreVals) + { + var existing = base.ConvertDbToEditor(defaultPreVals, persistedPreVals); + //convert to a list, easier to enumerate on the editor + var asList = existing.Select(e => new KeyValuePair(e.Key, e.Value)).ToList(); + var result = new Dictionary { { "values", asList } }; + return result; + } + } + } } \ No newline at end of file