fixes some compatibility issues with PR for sortable pre-vals
This commit is contained in:
@@ -11,7 +11,7 @@ angular.module("umbraco").controller("Umbraco.PrevalueEditors.MultiValuesControl
|
||||
//make an array from the dictionary
|
||||
var items = [];
|
||||
for (var i in $scope.model.value) {
|
||||
items.push({
|
||||
items.push({
|
||||
value: $scope.model.value[i].value,
|
||||
sortOrder: $scope.model.value[i].sortOrder,
|
||||
id: i
|
||||
|
||||
@@ -26,6 +26,13 @@ namespace Umbraco.Web.PropertyEditors
|
||||
field.Validators.Add(new ColorListValidator());
|
||||
}
|
||||
|
||||
public override IDictionary<string, object> ConvertDbToEditor(IDictionary<string, object> defaultPreVals, PreValueCollection persistedPreVals)
|
||||
{
|
||||
var dictionary = persistedPreVals.FormatAsDictionary();
|
||||
var arrayOfVals = dictionary.Select(item => item.Value).ToList();
|
||||
return new Dictionary<string, object> { { "items", arrayOfVals.ToDictionary(x => x.Id, x => x.Value) } };
|
||||
}
|
||||
|
||||
internal class ColorListValidator : IPropertyValidator
|
||||
{
|
||||
public IEnumerable<ValidationResult> Validate(object value, PreValueCollection preValues, PropertyEditor editor)
|
||||
|
||||
@@ -64,7 +64,8 @@ namespace Umbraco.Web.PropertyEditors
|
||||
var arrayOfVals = dictionary.Select(item => item.Value).ToList();
|
||||
|
||||
//the items list will be a dictionary of it's id -> value we need to use the id for persistence for backwards compatibility
|
||||
return new Dictionary<string, object> { { "items", arrayOfVals.ToDictionary(x => x.Id, x => PreValueAsDictionary(x)) } };
|
||||
|
||||
return new Dictionary<string, object> {{"items", arrayOfVals.ToDictionary(x => x.Id, PreValueAsDictionary)}};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user