2019-12-19 15:53:50 +01:00
|
|
|
|
using System.Collections.Generic;
|
2019-10-28 13:25:05 +01:00
|
|
|
|
using Umbraco.Core;
|
2019-12-04 14:03:39 +01:00
|
|
|
|
using Umbraco.Core.IO;
|
2017-05-12 14:49:44 +02:00
|
|
|
|
using Umbraco.Core.Logging;
|
2019-10-28 13:25:05 +01:00
|
|
|
|
using Umbraco.Core.Models.Editors;
|
2017-05-12 14:49:44 +02:00
|
|
|
|
using Umbraco.Core.PropertyEditors;
|
2019-12-10 12:37:52 +01:00
|
|
|
|
using Umbraco.Core.Services;
|
2019-12-20 17:36:44 +01:00
|
|
|
|
using Umbraco.Core.Strings;
|
2017-05-12 14:49:44 +02:00
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.PropertyEditors
|
|
|
|
|
|
{
|
2019-06-07 17:59:38 +01:00
|
|
|
|
[DataEditor(
|
|
|
|
|
|
Constants.PropertyEditors.Aliases.MultiNodeTreePicker,
|
|
|
|
|
|
"Multinode Treepicker",
|
|
|
|
|
|
"contentpicker",
|
|
|
|
|
|
ValueType = ValueTypes.Text,
|
|
|
|
|
|
Group = Constants.PropertyEditors.Groups.Pickers,
|
|
|
|
|
|
Icon = "icon-page-add")]
|
2018-03-19 18:39:34 +01:00
|
|
|
|
public class MultiNodeTreePickerPropertyEditor : DataEditor
|
2017-05-12 14:49:44 +02:00
|
|
|
|
{
|
2019-12-04 14:03:39 +01:00
|
|
|
|
private readonly IIOHelper _ioHelper;
|
|
|
|
|
|
|
2020-01-07 13:08:21 +01:00
|
|
|
|
public MultiNodeTreePickerPropertyEditor(ILogger logger, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IIOHelper ioHelper, IShortStringHelper shortStringHelper)
|
|
|
|
|
|
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
|
2019-12-04 14:03:39 +01:00
|
|
|
|
{
|
|
|
|
|
|
_ioHelper = ioHelper;
|
|
|
|
|
|
}
|
2017-05-12 14:49:44 +02:00
|
|
|
|
|
2019-12-04 14:03:39 +01:00
|
|
|
|
protected override IConfigurationEditor CreateConfigurationEditor() => new MultiNodePickerConfigurationEditor(_ioHelper);
|
2019-10-28 13:25:05 +01:00
|
|
|
|
|
2020-01-07 13:08:21 +01:00
|
|
|
|
protected override IDataValueEditor CreateValueEditor() => new MultiNodeTreePickerPropertyValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, Attribute);
|
2019-10-28 13:25:05 +01:00
|
|
|
|
|
2019-12-02 15:00:56 +00:00
|
|
|
|
public class MultiNodeTreePickerPropertyValueEditor : DataValueEditor, IDataValueReference
|
2019-10-28 13:25:05 +01:00
|
|
|
|
{
|
2020-01-07 13:08:21 +01:00
|
|
|
|
public MultiNodeTreePickerPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute)
|
|
|
|
|
|
: base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute)
|
2019-10-28 13:25:05 +01:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2019-12-02 15:00:56 +00:00
|
|
|
|
|
|
|
|
|
|
public IEnumerable<UmbracoEntityReference> GetReferences(object value)
|
|
|
|
|
|
{
|
|
|
|
|
|
var asString = value == null ? string.Empty : value is string str ? str : value.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
var udiPaths = asString.Split(',');
|
|
|
|
|
|
foreach (var udiPath in udiPaths)
|
2019-12-10 12:37:52 +01:00
|
|
|
|
if (UdiParser.TryParse(udiPath, out var udi))
|
2019-12-02 15:00:56 +00:00
|
|
|
|
yield return new UmbracoEntityReference(udi);
|
|
|
|
|
|
}
|
2019-10-28 13:25:05 +01:00
|
|
|
|
}
|
2017-05-12 14:49:44 +02:00
|
|
|
|
}
|
2019-10-28 13:25:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
2017-07-20 11:21:28 +02:00
|
|
|
|
}
|