fixes issue with legacy data types and new-prevalues

This commit is contained in:
Shannon
2013-08-15 13:29:35 +10:00
parent b3defcb007
commit bedd938553
2 changed files with 22 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Umbraco.Core.Models
{
@@ -60,5 +61,22 @@ namespace Umbraco.Core.Models
{
_preValuesAsDictionary = preVals;
}
internal static IDictionary<string, object> AsDictionary(PreValueCollection persistedPreVals)
{
if (persistedPreVals.IsDictionaryBased)
{
return persistedPreVals.PreValuesAsDictionary;
}
//it's an array so need to format it
var result = new Dictionary<string, object>();
var asArray = persistedPreVals.PreValuesAsArray.ToArray();
for (var i = 0; i < asArray.Length; i++)
{
result.Add(i.ToInvariantString(), asArray[i]);
}
return result;
}
}
}

View File

@@ -31,11 +31,11 @@ namespace Umbraco.Web.Models.Mapping
var preVals = dataTypeService.GetPreValuesCollectionByDataTypeId(originalProp.PropertyType.DataTypeDefinitionId);
//let the property editor format the pre-values
display.Config = display.PropertyEditor.FormatPreValues(display.PropertyEditor.DefaultPreValues, preVals);
if (display.PropertyEditor == null)
{
display.Config = PreValueCollection.AsDictionary(preVals);
//if there is no property editor it means that it is a legacy data type
// we cannot support editing with that so we'll just render the readonly value view.
display.View = GlobalSettings.Path.EnsureEndsWith('/') +
@@ -43,6 +43,8 @@ namespace Umbraco.Web.Models.Mapping
}
else
{
//let the property editor format the pre-values
display.Config = display.PropertyEditor.FormatPreValues(display.PropertyEditor.DefaultPreValues, preVals);
display.View = display.PropertyEditor.ValueEditor.View;
}