Completes: U4-3261 Ensure label/readonly displays pre-values
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<div ng-show="model.value.length > 0">
|
||||
<ul>
|
||||
<li ng-repeat="preVal in model.value">
|
||||
<i>{{preVal.Key}}</i> : <strong>{{preVal.Value}}</strong>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -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"
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="defaultPreVals"></param>
|
||||
/// <param name="persistedPreVals"></param>
|
||||
/// <returns></returns>
|
||||
public override IDictionary<string, object> ConvertDbToEditor(IDictionary<string, object> 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<string, object>(e.Key, e.Value)).ToList();
|
||||
var result = new Dictionary<string, object> { { "values", asList } };
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user