From be8320bb4b26d61db54b6083dc2b89e0339a6062 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 25 Mar 2014 14:14:09 +1100 Subject: [PATCH] fixes some compatibility issues with PR for sortable pre-vals --- .../src/views/prevalueeditors/multivalues.controller.js | 2 +- src/Umbraco.Web/PropertyEditors/ColorListPreValueEditor.cs | 7 +++++++ src/Umbraco.Web/PropertyEditors/ValueListPreValueEditor.cs | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/multivalues.controller.js b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/multivalues.controller.js index 02b8831306..a55a40d5ec 100644 --- a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/multivalues.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/multivalues.controller.js @@ -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 diff --git a/src/Umbraco.Web/PropertyEditors/ColorListPreValueEditor.cs b/src/Umbraco.Web/PropertyEditors/ColorListPreValueEditor.cs index 17dbb14fdf..e7750c4c65 100644 --- a/src/Umbraco.Web/PropertyEditors/ColorListPreValueEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ColorListPreValueEditor.cs @@ -26,6 +26,13 @@ namespace Umbraco.Web.PropertyEditors field.Validators.Add(new ColorListValidator()); } + public override IDictionary ConvertDbToEditor(IDictionary defaultPreVals, PreValueCollection persistedPreVals) + { + var dictionary = persistedPreVals.FormatAsDictionary(); + var arrayOfVals = dictionary.Select(item => item.Value).ToList(); + return new Dictionary { { "items", arrayOfVals.ToDictionary(x => x.Id, x => x.Value) } }; + } + internal class ColorListValidator : IPropertyValidator { public IEnumerable Validate(object value, PreValueCollection preValues, PropertyEditor editor) diff --git a/src/Umbraco.Web/PropertyEditors/ValueListPreValueEditor.cs b/src/Umbraco.Web/PropertyEditors/ValueListPreValueEditor.cs index 8185a3059c..6f81c9362a 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueListPreValueEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueListPreValueEditor.cs @@ -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 { { "items", arrayOfVals.ToDictionary(x => x.Id, x => PreValueAsDictionary(x)) } }; + + return new Dictionary {{"items", arrayOfVals.ToDictionary(x => x.Id, PreValueAsDictionary)}}; } ///