Got Data Type Creation working. Need to look at fixing up the issues with creating content/media tomorrow.

This commit is contained in:
Shannon
2013-08-20 18:10:19 +10:00
parent b901ae3269
commit 7df641cf2b
11 changed files with 57 additions and 29 deletions

View File

@@ -16,9 +16,12 @@ namespace Umbraco.Web.Models.ContentEditing
Notifications = new List<Notification>();
}
/// <summary>
/// This is nullable because when we are creating a new one, it is nothing
/// </summary>
[DataMember(Name = "selectedEditor", IsRequired = true)]
[Required]
public Guid SelectedEditor { get; set; }
public Guid? SelectedEditor { get; set; }
[DataMember(Name = "availableEditors")]
public IEnumerable<PropertyEditorBasic> AvailableEditors { get; set; }

View File

@@ -30,7 +30,8 @@ namespace Umbraco.Web.Models.Mapping
.ForMember(display => display.AvailableEditors, expression => expression.ResolveUsing<AvailablePropertyEditorsResolver>())
.ForMember(display => display.PreValues, expression => expression.ResolveUsing(
new PreValueDisplayResolver(lazyDataTypeService)))
.ForMember(display => display.SelectedEditor, expression => expression.MapFrom(definition => definition.ControlId));
.ForMember(display => display.SelectedEditor, expression => expression.MapFrom(
definition => definition.ControlId == Guid.Empty ? null : (Guid?) definition.ControlId));
config.CreateMap<DataTypeSave, IDataTypeDefinition>()
.ConstructUsing(save => new DataTypeDefinition(-1, save.SelectedEditor) {CreateDate = DateTime.Now})

View File

@@ -22,17 +22,26 @@ namespace Umbraco.Web.Models.Mapping
protected override IEnumerable<PreValueFieldDisplay> ResolveCore(IDataTypeDefinition source)
{
var propEd = PropertyEditorResolver.Current.GetById(source.ControlId);
if (propEd == null)
PropertyEditor propEd = null;
if (source.ControlId != Guid.Empty)
{
throw new InvalidOperationException("Could not find property editor with id " + source.ControlId);
propEd = PropertyEditorResolver.Current.GetById(source.ControlId);
if (propEd == null)
{
throw new InvalidOperationException("Could not find property editor with id " + source.ControlId);
}
}
var dataTypeService = (DataTypeService) _dataTypeService.Value;
var preVals = dataTypeService.GetPreValuesCollectionByDataTypeId(source.Id);
var dictionaryVals = PreValueCollection.AsDictionary(preVals);
var result = propEd.PreValueEditor.Fields.Select(Mapper.Map<PreValueFieldDisplay>).ToArray();
var result = Enumerable.Empty<PreValueFieldDisplay>();
if (propEd != null)
{
result = propEd.PreValueEditor.Fields.Select(Mapper.Map<PreValueFieldDisplay>).ToArray();
}
var currentIndex = 0; //used if the collection is non-dictionary based.
foreach (var field in result)
{