2019-12-11 08:13:51 +01:00
|
|
|
using System.Collections.Generic;
|
2019-10-28 13:25:05 +01:00
|
|
|
using Umbraco.Core;
|
2019-12-09 09:00:00 +01:00
|
|
|
using Umbraco.Core.Composing;
|
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;
|
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-10 12:37:52 +01:00
|
|
|
private readonly IDataTypeService _dataTypeService;
|
|
|
|
|
private readonly ILocalizationService _localizationService;
|
2019-12-04 14:03:39 +01:00
|
|
|
private readonly IIOHelper _ioHelper;
|
|
|
|
|
|
2019-12-11 08:13:51 +01:00
|
|
|
public MultiNodeTreePickerPropertyEditor(ILogger logger, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper)
|
|
|
|
|
: base(logger, Current.Services.DataTypeService, Current.Services.LocalizationService,Current.Services.TextService, Current.ShortStringHelper)
|
2019-12-04 14:03:39 +01:00
|
|
|
{
|
2019-12-10 12:37:52 +01:00
|
|
|
_dataTypeService = dataTypeService;
|
|
|
|
|
_localizationService = localizationService;
|
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
|
|
|
|
2019-12-10 12:37:52 +01:00
|
|
|
protected override IDataValueEditor CreateValueEditor() => new MultiNodeTreePickerPropertyValueEditor(_dataTypeService, _localizationService, 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
|
|
|
{
|
2019-12-11 08:13:51 +01:00
|
|
|
public MultiNodeTreePickerPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, DataEditorAttribute attribute): base(dataTypeService, localizationService, Current.Services.TextService, Current.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
|
|
|
}
|