// Copyright (c) Umbraco. // See LICENSE for more details. using Umbraco.Cms.Core.IO; using Umbraco.Cms.Core.Models; using Umbraco.Cms.Core.Serialization; namespace Umbraco.Cms.Core.PropertyEditors; /// /// A property editor to allow multiple checkbox selection of pre-defined items. /// [DataEditor( Constants.PropertyEditors.Aliases.CheckBoxList, ValueType = ValueTypes.Text, // We use the Text value type to ensure we don't run out of storage space in the database field with large lists with multiple values selected. ValueEditorIsReusable = true)] public class CheckBoxListPropertyEditor : DataEditor { private readonly IIOHelper _ioHelper; private readonly IConfigurationEditorJsonSerializer _configurationEditorJsonSerializer; /// /// The constructor will setup the property editor based on the attribute if one is found /// public CheckBoxListPropertyEditor(IDataValueEditorFactory dataValueEditorFactory, IIOHelper ioHelper, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer) : base(dataValueEditorFactory) { _ioHelper = ioHelper; _configurationEditorJsonSerializer = configurationEditorJsonSerializer; SupportsReadOnly = true; } /// protected override IConfigurationEditor CreateConfigurationEditor() => new ValueListConfigurationEditor(_ioHelper, _configurationEditorJsonSerializer); /// protected override IDataValueEditor CreateValueEditor() => DataValueEditorFactory.Create(Attribute!); }