Got Data Type Creation working. Need to look at fixing up the issues with creating content/media tomorrow.
This commit is contained in:
@@ -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; }
|
||||
|
||||
@@ -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})
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user