AB3326 - Made MediaPickerPropertyValueEditor nested and internal and handle null values

This commit is contained in:
Bjarke Berg
2019-10-28 13:58:23 +01:00
parent f2e02ea05e
commit c8b189d53d
2 changed files with 15 additions and 11 deletions

View File

@@ -60,7 +60,7 @@ namespace Umbraco.Web.PropertyEditors
private readonly HtmlImageSourceParser _imageSourceParser;
private readonly RichTextEditorPastedImages _pastedImages;
private readonly RichTextPropertyEditor.RichTextPropertyValueEditor _richTextPropertyValueEditor;
private readonly MediaPickerPropertyValueEditor _mediaPickerPropertyValueEditor;
private readonly MediaPickerPropertyEditor.MediaPickerPropertyValueEditor _mediaPickerPropertyValueEditor;
public GridPropertyValueEditor(DataEditorAttribute attribute,
IUmbracoContextAccessor umbracoContextAccessor,
@@ -73,7 +73,7 @@ namespace Umbraco.Web.PropertyEditors
_imageSourceParser = imageSourceParser;
_pastedImages = pastedImages;
_richTextPropertyValueEditor = new RichTextPropertyEditor.RichTextPropertyValueEditor(attribute, umbracoContextAccessor, imageSourceParser, localLinkParser, pastedImages);
_mediaPickerPropertyValueEditor = new MediaPickerPropertyValueEditor(attribute);
_mediaPickerPropertyValueEditor = new MediaPickerPropertyEditor.MediaPickerPropertyValueEditor(attribute);
}
/// <summary>

View File

@@ -32,19 +32,23 @@ namespace Umbraco.Web.PropertyEditors
protected override IConfigurationEditor CreateConfigurationEditor() => new MediaPickerConfigurationEditor();
protected override IDataValueEditor CreateValueEditor() => new MediaPickerPropertyValueEditor(Attribute);
}
public class MediaPickerPropertyValueEditor : DataValueEditor, IDataValueReference
{
public MediaPickerPropertyValueEditor(DataEditorAttribute attribute) : base(attribute)
internal class MediaPickerPropertyValueEditor : DataValueEditor, IDataValueReference
{
}
public MediaPickerPropertyValueEditor(DataEditorAttribute attribute) : base(attribute)
{
}
public IEnumerable<UmbracoEntityReference> GetReferences(object value)
{
var asString = value == null ? string.Empty : value is string str ? str : value.ToString();
public IEnumerable<UmbracoEntityReference> GetReferences(object value)
{
if (value == null) yield break;
yield return new UmbracoEntityReference(Udi.Parse(asString));
var asString = value is string str ? str : value.ToString();
yield return new UmbracoEntityReference(Udi.Parse(asString));
}
}
}
}