fixes some compatibility issues with PR for sortable pre-vals

This commit is contained in:
Shannon
2014-03-25 14:14:09 +11:00
parent 1d4b6178e5
commit be8320bb4b
3 changed files with 10 additions and 2 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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>