public MacroPickerConfigurationEditor(IMacroService macroService)
            : base()
        {
            _macroService = macroService;

            var macros = macroService
                         .GetAll()
                         .Select(x => new DataListItem
            {
                Icon        = UmbracoIcons.Macro,
                Name        = x.Name,
                Description = x.Alias,
                Value       = x.GetUdi().ToString()
            });

            Fields.Add(
                AllowedMacros,
                "Allowed macros",
                "Restrict the macros that can be picked.",
                IOHelper.ResolveUrl(ItemPickerDataEditor.DataEditorViewPath),
                new Dictionary <string, object>
            {
                { AllowDuplicatesConfigurationField.AllowDuplicates, Constants.Values.False },
                { ItemPickerConfigurationEditor.Items, macros },
                { ItemPickerTypeConfigurationField.ListType, ItemPickerTypeConfigurationField.List },
                { ItemPickerConfigurationEditor.OverlayView, IOHelper.ResolveUrl(ItemPickerDataEditor.DataEditorOverlayViewPath) },
                { ItemPickerConfigurationEditor.EnableDevMode, Constants.Values.False },
            });

            Fields.AddMaxItems();
            Fields.AddDisableSorting();
            Fields.AddHideLabel();
        }
Пример #2
0
        public DataTableConfigurationEditor()
            : base()
        {
            // NOTE: Excluded these ParameterEditors, as they don't fully support zero-config.
            var exclusions   = new[] { "contentpicker", "mediapicker", "entitypicker" };
            var paramEditors = Current.ParameterEditors
                               .Select(x => new { name = x.Name, value = x.GetValueEditor().View })
                               .Where(x => exclusions.Contains(x.value) == false)
                               .OrderBy(x => x.name)
                               .ToList();

            var listFields = new[]
            {
                new ConfigurationField
                {
                    Key  = "key",
                    Name = "Key",
                    View = "textbox"
                },
                new ConfigurationField
                {
                    Key  = "label",
                    Name = "Name",
                    View = "textbox"
                },
                new ConfigurationField
                {
                    Key    = "view",
                    Name   = "Editor",
                    View   = IOHelper.ResolveUrl(DropdownListDataEditor.DataEditorViewPath),
                    Config = new Dictionary <string, object>
                    {
                        { DropdownListConfigurationEditor.Items, paramEditors }
                    }
                },
            };

            Fields.Add(
                FieldItems,
                nameof(Fields),
                "Configure the editor fields for the data table.",
                IOHelper.ResolveUrl(DataTableDataEditor.DataEditorViewPath),
                new Dictionary <string, object>()
            {
                { FieldItems, listFields },
                { MaxItemsConfigurationField.MaxItems, 0 },
                { DisableSortingConfigurationField.DisableSorting, Constants.Values.False },
                { RestrictWidth, Constants.Values.True },
                { UsePrevalueEditors, Constants.Values.False }
            });

            Fields.AddMaxItems();
            Fields.Add(
                RestrictWidth,
                "Restrict width?",
                "Select to restrict the width of the data table. This will attempt to make the table to be the same width as the 'Add' button.",
                "boolean");
            Fields.AddHideLabel();
            Fields.AddDisableSorting();
        }
Пример #3
0
        public ItemPickerConfigurationEditor()
            : base()
        {
            var listFields = new[]
            {
                new ConfigurationField
                {
                    Key  = "icon",
                    Name = "Icon",
                    View = IOHelper.ResolveUrl(IconPickerDataEditor.DataEditorViewPath)
                },
                new ConfigurationField
                {
                    Key  = "name",
                    Name = "Name",
                    View = "textbox"
                },
                new ConfigurationField
                {
                    Key  = "value",
                    Name = "Value",
                    View = "textbox"
                },
            };

            Fields.Add(
                Items,
                nameof(Items),
                "Configure the items for the item picker.",
                IOHelper.ResolveUrl(DataTableDataEditor.DataEditorViewPath),
                new Dictionary <string, object>()
            {
                { DataTableConfigurationEditor.FieldItems, listFields },
                { MaxItemsConfigurationField.MaxItems, 0 },
                { DisableSortingConfigurationField.DisableSorting, Constants.Values.False },
                { DataTableConfigurationEditor.RestrictWidth, Constants.Values.True },
                { DataTableConfigurationEditor.UsePrevalueEditors, Constants.Values.False }
            });

            Fields.Add(new ItemPickerTypeConfigurationField());

            // TODO: [LK:2019-07-19] Consider if we should have an option for determining the default sort order (of the overlay items).

            Fields.AddMaxItems();
            Fields.Add(new AllowDuplicatesConfigurationField());
            Fields.AddDisableSorting();
            Fields.AddHideLabel();
            Fields.Add(
                EnableDevMode,
                "Enable developer mode?",
                "Select to enable add the ability to edit the raw JSON data for the editor value.",
                "boolean");
        }
Пример #4
0
        public ConfigurationEditorConfigurationEditor()
            : base()
        {
            _service = new ConfigurationEditorService();

            var configEditors = _service.GetConfigurationEditors <IConfigurationEditorItem>(onlyPublic: true, ignoreFields: true);
            var items         = new List <DataListItem>();

            foreach (var configEditor in configEditors)
            {
                items.Add(new DataListItem
                {
                    Icon        = configEditor.Icon,
                    Name        = configEditor.Name,
                    Description = configEditor.Description,
                    Value       = configEditor.Type
                });
            }

            Fields.Add(
                Items,
                nameof(Items),
                "Select the configuration editors to use.",
                IOHelper.ResolveUrl(ItemPickerDataEditor.DataEditorViewPath),
                new Dictionary <string, object>
            {
                { AllowDuplicatesConfigurationField.AllowDuplicates, Constants.Values.False },
                { ItemPickerConfigurationEditor.Items, items },
                { ItemPickerTypeConfigurationField.ListType, ItemPickerTypeConfigurationField.List },
                { ItemPickerConfigurationEditor.OverlayView, IOHelper.ResolveUrl(ItemPickerDataEditor.DataEditorOverlayViewPath) },
                { ItemPickerConfigurationEditor.EnableDevMode, Constants.Values.False },
            });

            Fields.Add(
                EnableFilter,
                "Enable filter?",
                "Select to enable the search filter in the overlay selection panel.",
                "boolean");

            Fields.Add(new OverlaySizeConfigurationField());
            Fields.AddMaxItems();
            Fields.AddDisableSorting();
            Fields.AddHideLabel();
        }
Пример #5
0
        public ElementsConfigurationEditor()
            : base()
        {
            var defaultFields = new List <ConfigurationField>
            {
                new ConfigurationField
                {
                    Key         = "displayIcon",
                    Name        = "Display icon",
                    Description = "You can choose to select a different icon for this configuration.",
                    View        = IOHelper.ResolveUrl(IconPickerDataEditor.DataEditorViewPath)
                },
                new ConfigurationField
                {
                    Key         = "displayName",
                    Name        = "Display name",
                    Description = "Enter a friendly name for this configuration.",
                    View        = "textstring"
                },
                new ConfigurationField
                {
                    Key         = "nameTemplate",
                    Name        = "Name template",
                    Description = "Enter an AngularJs expression to evaluate against each item for its name.",
                    View        = "textstring"
                },
                new ConfigurationField
                {
                    Key  = "enablePreview",
                    Name = "Enable preview?",
                    View = "boolean"
                }
            };

            // TODO: [LK:2019-07-01] I'm not completely happy with this approach.
            // I'd like to be able to select a doctype, then override it's name/description/icon.
            // The we could have multiple instances of a doctype.
            // Or is that overkill? Should we work like Umbraco, just use the exact names/icons? Don't over-complicate it.

            var items = Current.Services.ContentTypeService
                        .GetAll()
                        .Where(x => x.IsElement)
                        .OrderBy(x => x.Name)
                        .Select(x => new ConfigurationEditorModel
            {
                Description   = x.Description,
                Icon          = x.Icon,
                Name          = x.Name,
                Type          = x.GetUdi().ToString(),
                Fields        = defaultFields,
                DefaultValues = new Dictionary <string, object>
                {
                    { "displayIcon", x.Icon },
                    { "displayName", x.Name },
                    { "nameTemplate", $"{x.Name} #{{{{$index + 1}}}}" },
                },
                NameTemplate = "{{displayName || name}}",
            });

            Fields.Add(
                Items,
                nameof(Items),
                "Select the element types to use.",
                IOHelper.ResolveUrl(ConfigurationEditorDataEditor.DataEditorViewPath),
                new Dictionary <string, object>
            {
                { AllowDuplicatesConfigurationField.AllowDuplicates, Constants.Values.False },
                { ConfigurationEditorConfigurationEditor.Items, items },
                { ConfigurationEditorConfigurationEditor.OverlaySize, ConfigurationEditorConfigurationEditor.OverlaySizeConfigurationField.Large },
                { ConfigurationEditorConfigurationEditor.OverlayView, IOHelper.ResolveUrl(ConfigurationEditorDataEditor.DataEditorOverlayViewPath) },
                { ConfigurationEditorConfigurationEditor.EnableFilter, Constants.Values.True },
                { ConfigurationEditorConfigurationEditor.EnableDevMode, Constants.Values.False },
            });

            Fields.AddMaxItems();
            Fields.AddDisableSorting();
            Fields.AddHideLabel();
        }