Fixes up pre-value formatted data so it doesn't include ID in the value since this confuses things.

This commit is contained in:
Shannon
2013-08-28 18:52:00 +10:00
parent 68b337729b
commit 4b4fc037dd
13 changed files with 29 additions and 24 deletions

View File

@@ -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<string, object>
{
{"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;
}

View File

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

View File

@@ -1 +1 @@
<input name="boolean" type="checkbox" ng-model="model.value.value" ng-true-value="1" ng-false-value="0" />
<input name="boolean" type="checkbox" ng-model="model.value" ng-true-value="1" ng-false-value="0" />

View File

@@ -1 +1 @@
<input name="hidden" type="hidden" ng-model="model.value.value" name="{{model.alias}" />
<input name="hidden" type="hidden" ng-model="model.value" name="{{model.alias}" />

View File

@@ -7,4 +7,6 @@
<input type="text" ng-model="item.value" val-server="item_{{$index}}" required />
<button class="btn btn-small btn-danger" ng-click="remove(item, $event)">Remove</button>
</div>
</div>
</div>

View File

@@ -1,6 +1,6 @@
<div>
<input name="requiredfield" type="text" class="umb-textstring span7 textstring"
ng-model="model.value.value"
ng-model="model.value"
required
val-server="value" />

View File

@@ -1 +1 @@
<textarea name="textarea" ng-model="model.value.value" rows="4" class="span8"></textarea>ee
<textarea name="textarea" ng-model="model.value" rows="4" class="span8"></textarea>ee

View File

@@ -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: "" });
}
};

View File

@@ -3,13 +3,13 @@
<div class="control-group" ng-repeat="item in model.value">
<input type="text" name="item_{{$index}}" ng-model="item.value" />
<a prevent-default href="" title="Remove this text box"
ng-show="model.value.length > model.config.min.value"
ng-show="model.value.length > model.config.min"
ng-click="remove($index)">
<i class="icon icon-minus"></i>
</a>
</div>
<a prevent-default href="" title="Add another text box"
ng-show="model.config.max.value <= 0 || model.value.length < model.config.max.value"
ng-show="model.config.max <= 0 || model.value.length < model.config.max"
ng-click="add()">
<i class="icon icon-plus"></i>
</a>

View File

@@ -8,6 +8,12 @@ namespace Umbraco.Web.Models.ContentEditing
[DataContract(Name = "preValue", Namespace = "")]
public class PreValueFieldDisplay : PreValueFieldSave
{
///// <summary>
///// The id of the pre-value field
///// </summary>
//[DataMember(Name = "id", IsRequired = true)]
//public int Id { get; set; }
/// <summary>
/// The name to display for this pre-value field
/// </summary>

View File

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

View File

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

View File

@@ -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<int>() });
returnVal["min"] = json["Minimum"].Value<int>();
}
if (json["Maximum"] != null)
{
returnVal["max"] = JObject.FromObject(new { id = 0, value = json["Maximum"].Value<int>() });
returnVal["max"] = json["Maximum"].Value<int>();
}
}
catch (Exception e)