2021-02-15 10:42:35 +01:00
|
|
|
|
// Copyright (c) Umbraco.
|
|
|
|
|
|
// See LICENSE for more details.
|
|
|
|
|
|
|
2022-04-29 11:52:58 +02:00
|
|
|
|
using System;
|
2022-04-29 15:02:36 +02:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2021-02-09 10:22:42 +01:00
|
|
|
|
using Umbraco.Cms.Core.IO;
|
|
|
|
|
|
using Umbraco.Cms.Core.Models;
|
|
|
|
|
|
using Umbraco.Cms.Core.Serialization;
|
|
|
|
|
|
using Umbraco.Cms.Core.Services;
|
|
|
|
|
|
using Umbraco.Cms.Core.Strings;
|
2022-04-29 15:02:36 +02:00
|
|
|
|
using Umbraco.Cms.Web.Common.DependencyInjection;
|
2018-06-03 13:30:50 +02:00
|
|
|
|
|
2021-02-15 10:42:35 +01:00
|
|
|
|
namespace Umbraco.Cms.Core.PropertyEditors
|
2018-06-03 13:30:50 +02:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represents a property editor for label properties.
|
|
|
|
|
|
/// </summary>
|
2019-06-07 17:59:38 +01:00
|
|
|
|
[DataEditor(
|
2021-02-09 10:22:42 +01:00
|
|
|
|
Cms.Core.Constants.PropertyEditors.Aliases.Label,
|
2019-06-07 17:59:38 +01:00
|
|
|
|
"Label",
|
|
|
|
|
|
"readonlyvalue",
|
|
|
|
|
|
Icon = "icon-readonly")]
|
2018-06-03 13:30:50 +02:00
|
|
|
|
public class LabelPropertyEditor : DataEditor
|
|
|
|
|
|
{
|
2019-12-04 14:03:39 +01:00
|
|
|
|
private readonly IIOHelper _ioHelper;
|
2022-04-29 11:52:58 +02:00
|
|
|
|
private readonly IEditorConfigurationParser _editorConfigurationParser;
|
2020-01-07 13:08:21 +01:00
|
|
|
|
|
2022-04-29 11:52:58 +02:00
|
|
|
|
// Scheduled for removal in v12
|
|
|
|
|
|
[Obsolete("Please use constructor that takes an IEditorConfigurationParser instead")]
|
|
|
|
|
|
public LabelPropertyEditor(IDataValueEditorFactory dataValueEditorFactory,
|
|
|
|
|
|
IIOHelper ioHelper)
|
2022-04-29 15:02:36 +02:00
|
|
|
|
: this(dataValueEditorFactory, ioHelper, StaticServiceProvider.Instance.GetRequiredService<IEditorConfigurationParser>())
|
2022-04-29 11:52:58 +02:00
|
|
|
|
{
|
|
|
|
|
|
}
|
2019-12-04 14:03:39 +01:00
|
|
|
|
|
2018-06-03 13:30:50 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Initializes a new instance of the <see cref="LabelPropertyEditor"/> class.
|
|
|
|
|
|
/// </summary>
|
2021-05-18 12:40:24 +02:00
|
|
|
|
public LabelPropertyEditor(IDataValueEditorFactory dataValueEditorFactory,
|
2022-04-29 11:52:58 +02:00
|
|
|
|
IIOHelper ioHelper,
|
|
|
|
|
|
IEditorConfigurationParser editorConfigurationParser)
|
2021-05-18 12:40:24 +02:00
|
|
|
|
: base(dataValueEditorFactory)
|
2019-12-04 14:03:39 +01:00
|
|
|
|
{
|
|
|
|
|
|
_ioHelper = ioHelper;
|
2022-04-29 11:52:58 +02:00
|
|
|
|
_editorConfigurationParser = editorConfigurationParser;
|
2019-12-04 14:03:39 +01:00
|
|
|
|
}
|
2018-06-03 13:30:50 +02:00
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2022-02-28 14:37:15 +01:00
|
|
|
|
protected override IDataValueEditor CreateValueEditor() => DataValueEditorFactory.Create<LabelPropertyValueEditor>(Attribute!);
|
2018-06-03 13:30:50 +02:00
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2022-04-29 11:52:58 +02:00
|
|
|
|
protected override IConfigurationEditor CreateConfigurationEditor() => new LabelConfigurationEditor(_ioHelper, _editorConfigurationParser);
|
2018-06-03 13:30:50 +02:00
|
|
|
|
|
|
|
|
|
|
// provides the property value editor
|
|
|
|
|
|
internal class LabelPropertyValueEditor : DataValueEditor
|
|
|
|
|
|
{
|
2021-05-18 12:40:24 +02:00
|
|
|
|
public LabelPropertyValueEditor(
|
|
|
|
|
|
ILocalizedTextService localizedTextService,
|
|
|
|
|
|
IShortStringHelper shortStringHelper,
|
|
|
|
|
|
IJsonSerializer jsonSerializer,
|
|
|
|
|
|
IIOHelper ioHelper,
|
|
|
|
|
|
DataEditorAttribute attribute)
|
|
|
|
|
|
: base(localizedTextService, shortStringHelper, jsonSerializer, ioHelper, attribute)
|
2018-06-03 13:30:50 +02:00
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public override bool IsReadOnly => true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|