From 4b4fc037ddafae6a98254f6bc1b2c26558453355 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 28 Aug 2013 18:52:00 +1000 Subject: [PATCH] Fixes up pre-value formatted data so it doesn't include ID in the value since this confuses things. --- src/Umbraco.Core/PropertyEditors/PreValueEditor.cs | 13 +++++-------- .../src/common/services/util.service.js | 3 ++- .../src/views/prevalueeditors/boolean.html | 2 +- .../src/views/prevalueeditors/hidden.html | 2 +- .../src/views/prevalueeditors/multivalues.html | 4 +++- .../src/views/prevalueeditors/requiredfield.html | 2 +- .../src/views/prevalueeditors/textarea.html | 2 +- .../multipletextbox/multipletextbox.controller.js | 6 +++--- .../multipletextbox/multipletextbox.html | 4 ++-- .../Models/ContentEditing/PreValueFieldDisplay.cs | 6 ++++++ .../PropertyEditors/ColorPickerPropertyEditor.cs | 1 - .../DropDownMultipleWithKeysPropertyEditor.cs | 4 ++-- .../MultipleTextStringPropertyEditor.cs | 4 ++-- 13 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/Umbraco.Core/PropertyEditors/PreValueEditor.cs b/src/Umbraco.Core/PropertyEditors/PreValueEditor.cs index 899b5d7bfd..c99ea744b8 100644 --- a/src/Umbraco.Core/PropertyEditors/PreValueEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/PreValueEditor.cs @@ -135,13 +135,9 @@ namespace Umbraco.Core.PropertyEditors //we just need to merge the dictionaries now, the persisted will replace default. foreach (var item in persistedPreVals.PreValuesAsDictionary) { - //we want the json output to be in camelcase so change the value to a custom dictionary - - defaultPreVals[item.Key] = new Dictionary - { - {"id", item.Value.Id}, - {"value", item.Value.Value} - }; + //The persisted dictionary contains values of type PreValue which contain the ID and the Value, we don't care + // about the Id, just the value so ignore the id. + defaultPreVals[item.Key] = item.Value.Value; } return defaultPreVals; } @@ -151,7 +147,8 @@ namespace Umbraco.Core.PropertyEditors var asArray = persistedPreVals.PreValuesAsArray.ToArray(); for (var i = 0; i < asArray.Length; i++) { - result.Add(i.ToInvariantString(), asArray[i]); + //each item is of type PreValue but we don't want the ID, just the value so ignore the ID + result.Add(i.ToInvariantString(), asArray[i].Value); } return result; } diff --git a/src/Umbraco.Web.UI.Client/src/common/services/util.service.js b/src/Umbraco.Web.UI.Client/src/common/services/util.service.js index 042b2145c1..8cfa220a56 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/util.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/util.service.js @@ -148,9 +148,10 @@ function umbDataFormatter() { preValues: [] }; for (var i = 0; i < preValues.length; i++) { + saveModel.preValues.push({ key: preValues[i].alias, - value: preValues[i].value.value + value: preValues[i].value }); } return saveModel; diff --git a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/boolean.html b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/boolean.html index 128a5a9504..8af17a18ea 100644 --- a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/boolean.html +++ b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/boolean.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/hidden.html b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/hidden.html index e04621b3ed..758ba68fd7 100644 --- a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/hidden.html +++ b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/hidden.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/multivalues.html b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/multivalues.html index d3a267e50c..004b13bc89 100644 --- a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/multivalues.html +++ b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/multivalues.html @@ -7,4 +7,6 @@ - \ No newline at end of file + + + diff --git a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/requiredfield.html b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/requiredfield.html index 80bcb9c0f9..2d1f3dde42 100644 --- a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/requiredfield.html +++ b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/requiredfield.html @@ -1,6 +1,6 @@ 
diff --git a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/textarea.html b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/textarea.html index 0e371c1e2e..f4e10014f4 100644 --- a/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/textarea.html +++ b/src/Umbraco.Web.UI.Client/src/views/prevalueeditors/textarea.html @@ -1 +1 @@ -ee \ No newline at end of file +ee \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multipletextbox/multipletextbox.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multipletextbox/multipletextbox.controller.js index ff06de42a1..1254029920 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multipletextbox/multipletextbox.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multipletextbox/multipletextbox.controller.js @@ -5,8 +5,8 @@ } //add any fields that there isn't values for - if ($scope.model.config.min.value > 0) { - for (var i = 0; i < $scope.model.config.min.value; i++) { + if ($scope.model.config.min > 0) { + for (var i = 0; i < $scope.model.config.min; i++) { if ((i + 1) > $scope.model.value.length) { $scope.model.value.push({ value: "" }); } @@ -14,7 +14,7 @@ } $scope.add = function () { - if ($scope.model.config.max.value <= 0 || $scope.model.value.length < $scope.model.config.max.value) { + if ($scope.model.config.max <= 0 || $scope.model.value.length < $scope.model.config.max) { $scope.model.value.push({ value: "" }); } }; diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multipletextbox/multipletextbox.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multipletextbox/multipletextbox.html index 290e4f06f1..5af11e2c26 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multipletextbox/multipletextbox.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multipletextbox/multipletextbox.html @@ -3,13 +3,13 @@ diff --git a/src/Umbraco.Web/Models/ContentEditing/PreValueFieldDisplay.cs b/src/Umbraco.Web/Models/ContentEditing/PreValueFieldDisplay.cs index 8d779ca23b..d3cefaa745 100644 --- a/src/Umbraco.Web/Models/ContentEditing/PreValueFieldDisplay.cs +++ b/src/Umbraco.Web/Models/ContentEditing/PreValueFieldDisplay.cs @@ -8,6 +8,12 @@ namespace Umbraco.Web.Models.ContentEditing [DataContract(Name = "preValue", Namespace = "")] public class PreValueFieldDisplay : PreValueFieldSave { + ///// + ///// The id of the pre-value field + ///// + //[DataMember(Name = "id", IsRequired = true)] + //public int Id { get; set; } + /// /// The name to display for this pre-value field /// diff --git a/src/Umbraco.Web/PropertyEditors/ColorPickerPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/ColorPickerPropertyEditor.cs index 51c9493c32..93d6044d8b 100644 --- a/src/Umbraco.Web/PropertyEditors/ColorPickerPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ColorPickerPropertyEditor.cs @@ -30,7 +30,6 @@ namespace Umbraco.Web.PropertyEditors { public ColorListPreValueEditor() { - Fields.AddRange(CreatePreValueFields()); //use a custom editor too Fields.First().View = "views/propertyeditors/colorpicker/colorpicker.prevalues.html"; //change the description diff --git a/src/Umbraco.Web/PropertyEditors/DropDownMultipleWithKeysPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/DropDownMultipleWithKeysPropertyEditor.cs index 781880557f..0eb53b2261 100644 --- a/src/Umbraco.Web/PropertyEditors/DropDownMultipleWithKeysPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/DropDownMultipleWithKeysPropertyEditor.cs @@ -36,13 +36,13 @@ namespace Umbraco.Web.PropertyEditors { public DropDownMultiplePreValueEditor() { - Fields.AddRange(CreatePreValueFields()); //add the multiple field, we'll make it hidden so it is not seen in the pre-value editor Fields.Add(new PreValueField { Key = "multiple", Name = "multiple", - View = "hidden" + View = "hidden", + HideLabel = true }); } diff --git a/src/Umbraco.Web/PropertyEditors/MultipleTextStringPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/MultipleTextStringPropertyEditor.cs index 7a5fac1d19..51f43c2fd1 100644 --- a/src/Umbraco.Web/PropertyEditors/MultipleTextStringPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/MultipleTextStringPropertyEditor.cs @@ -86,11 +86,11 @@ namespace Umbraco.Web.PropertyEditors if (json["Minimum"] != null) { //by default pre-values are sent out with an id/value pair - returnVal["min"] = JObject.FromObject(new { id = 0, value = json["Minimum"].Value() }); + returnVal["min"] = json["Minimum"].Value(); } if (json["Maximum"] != null) { - returnVal["max"] = JObject.FromObject(new { id = 0, value = json["Maximum"].Value() }); + returnVal["max"] = json["Maximum"].Value(); } } catch (Exception e)