diff --git a/src/Infocaster.Umbraco.IcomoonPicker/App_plugins/Infocaster.Umbraco.IcomoonPicker/package.manifest b/src/Infocaster.Umbraco.IcomoonPicker/App_plugins/Infocaster.Umbraco.IcomoonPicker/package.manifest deleted file mode 100644 index 19b03fc..0000000 --- a/src/Infocaster.Umbraco.IcomoonPicker/App_plugins/Infocaster.Umbraco.IcomoonPicker/package.manifest +++ /dev/null @@ -1,42 +0,0 @@ -{ - "propertyEditors": [ - { - "alias": "Infocaster.IcomoonPicker", - "name": "Icomoon icon picker", - "editor": { - "view": "~/App_Plugins/Infocaster.Umbraco.IcomoonPicker/editor/editor.html", - "isReadOnly": false - }, - "prevalues": { - "fields": [ - { - "label": "Project name", - "description": "The name of the project in icomoon", - "key": "projectName", - "view": "textstring", - "validation": [ - { - "type": "Required" - } - ] - }, - { - "label": "Project code", - "description": "The code that is associated with this project in icomoon", - "key": "projectCode", - "view": "textstring", - "validation": [ - { - "type": "Required" - } - ] - } - ] - } - } - ], - - "javascript": [ - "~/App_Plugins/Infocaster.Umbraco.IcomoonPicker/script.iife.js", - ], -} diff --git a/src/Infocaster.Umbraco.IcomoonPicker/PropertyValueConverters/IcomoonPickerDataType.cs b/src/Infocaster.Umbraco.IcomoonPicker/PropertyValueConverters/IcomoonPickerDataType.cs new file mode 100644 index 0000000..d2bf8b7 --- /dev/null +++ b/src/Infocaster.Umbraco.IcomoonPicker/PropertyValueConverters/IcomoonPickerDataType.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Umbraco.Cms.Core.IO; +using Umbraco.Cms.Core.PropertyEditors; +using Umbraco.Cms.Core.PropertyEditors.Validators; +using Umbraco.Cms.Core.Services; + +namespace Infocaster.Umbraco.IcomoonPicker.PropertyValueConverters +{ + [DataEditor( + alias: "Infocaster.IcomoonPicker", + name: "Icomoon icon picker", + view: "~/App_Plugins/Infocaster.Umbraco.IcomoonPicker/editor/editor.html", + ValueType = ValueTypes.String)] + public class IcomoonPickerDataType : DataEditor + { + private readonly IIOHelper _ioHelper; + private readonly IEditorConfigurationParser _editorConfigurationParser; + private readonly ILocalizedTextService _textService; + + public IcomoonPickerDataType( + IDataValueEditorFactory dataValueEditorFactory, + IIOHelper ioHelper, + IEditorConfigurationParser editorConfigurationParser, + ILocalizedTextService textService) + : base(dataValueEditorFactory) + { + _ioHelper = ioHelper; + _editorConfigurationParser = editorConfigurationParser; + _textService = textService; + } + + protected override IConfigurationEditor CreateConfigurationEditor() + { + return new IcomoonPickerConfigurationEditor(_ioHelper, _editorConfigurationParser, _textService); + } + } + + public class IcomoonPickerConfigurationEditor + : ConfigurationEditor + { + public IcomoonPickerConfigurationEditor(IIOHelper ioHelper, IEditorConfigurationParser editorConfigurationParser, ILocalizedTextService textService) + : base(ioHelper, editorConfigurationParser) + { + Field(nameof(IcomoonPickerConfiguration.ProjectName)).Validators.Add(new RequiredValidator(textService)); + Field(nameof(IcomoonPickerConfiguration.ProjectCode)).Validators.Add(new RequiredValidator(textService)); + } + } + + public class IcomoonPickerConfiguration + { + [ConfigurationField("projectName", "Project name", "requiredfield", Description = "The name of the project in icomoon")] + public string ProjectName { get; set; } + + [ConfigurationField("projectCode", "Project code", "requiredfield", Description = "The code that is associated with this project in icomoon")] + public string ProjectCode { get; set; } + } +} diff --git a/src/Infocaster.Umbraco.IcomoonPicker/frontend/public/package.manifest b/src/Infocaster.Umbraco.IcomoonPicker/frontend/public/package.manifest deleted file mode 100644 index 19b03fc..0000000 --- a/src/Infocaster.Umbraco.IcomoonPicker/frontend/public/package.manifest +++ /dev/null @@ -1,42 +0,0 @@ -{ - "propertyEditors": [ - { - "alias": "Infocaster.IcomoonPicker", - "name": "Icomoon icon picker", - "editor": { - "view": "~/App_Plugins/Infocaster.Umbraco.IcomoonPicker/editor/editor.html", - "isReadOnly": false - }, - "prevalues": { - "fields": [ - { - "label": "Project name", - "description": "The name of the project in icomoon", - "key": "projectName", - "view": "textstring", - "validation": [ - { - "type": "Required" - } - ] - }, - { - "label": "Project code", - "description": "The code that is associated with this project in icomoon", - "key": "projectCode", - "view": "textstring", - "validation": [ - { - "type": "Required" - } - ] - } - ] - } - } - ], - - "javascript": [ - "~/App_Plugins/Infocaster.Umbraco.IcomoonPicker/script.iife.js", - ], -}