Пример #1
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();
        }
        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();
        }
Пример #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");
        }
        public RenderMacroConfigurationEditor()
            : base()
        {
            Fields.Add(
                Macro,
                nameof(Macro),
                "Select and configure the macro to be displayed.",
                IOHelper.ResolveUrl(MacroPickerDataEditor.DataEditorViewPath),
                new Dictionary <string, object>
            {
                { MaxItemsConfigurationField.MaxItems, 1 }
            });

            Fields.AddHideLabel();
        }
Пример #5
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();
        }
        public DropdownListConfigurationEditor()
            : base()
        {
            var listFields = new[]
            {
                new ConfigurationField
                {
                    Key  = "name",
                    Name = "Name",
                    View = "textbox"
                },
                new ConfigurationField
                {
                    Key  = "value",
                    Name = "Value",
                    View = "textbox"
                },
                //new ConfigurationField
                //{
                //    Key = "enabled",
                //    Name = "Enabled",
                //    View = "boolean",
                //    Config = new Dictionary<string, object> { { "default", Constants.Values.True } }
                //},
            };

            Fields.Add(
                Items,
                "Options",
                "Configure the option items for the dropdown list.",
                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 AllowEmptyConfigurationField());
            Fields.AddHideLabel();
        }
Пример #7
0
        public NotesConfigurationEditor()
            : base()
        {
            var editor = new
            {
                maxImageSize = 500,
                mode         = "classic",
                stylesheets  = false,
                toolbar      = new[]
                {
                    "ace",
                    "undo",
                    "redo",
                    "cut",
                    "styleselect",
                    "removeformat",
                    "bold",
                    "italic",
                    "alignleft",
                    "aligncenter",
                    "alignright",
                    "bullist",
                    "numlist",
                    "link",
                    "umbmediapicker",
                    "umbmacro",
                    "umbembeddialog"
                },
            };

            Fields.Add(
                Notes,
                nameof(Notes),
                "Enter the notes to be displayed for the content editor.",
                IOHelper.ResolveUrl("~/umbraco/views/propertyeditors/rte/rte.html"),
                new Dictionary <string, object> {
                { "editor", editor }
            });

            Fields.AddHideLabel();
        }
Пример #8
0
        public ToggleGroupConfigurationEditor()
            : base()
        {
            var listFields = new[]
            {
                new ConfigurationField
                {
                    Key  = "name",
                    Name = "Name",
                    View = "textbox"
                },
                new ConfigurationField
                {
                    Key  = "description",
                    Name = "Description",
                    View = "textbox"
                },
                new ConfigurationField
                {
                    Key  = "value",
                    Name = "Value",
                    View = "textbox"
                }
            };

            Fields.Add(
                Items,
                "Options",
                "Configure the option items for the checkbox list.",
                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.AddHideLabel();
        }
        public DataListConfigurationEditor()
            : base()
        {
            var defaultConfigEditorConfig = new Dictionary <string, object>
            {
                { MaxItemsConfigurationField.MaxItems, 1 },
                { DisableSortingConfigurationField.DisableSorting, Constants.Values.True },
                { ConfigurationEditorConfigurationEditor.OverlaySize, ConfigurationEditorConfigurationEditor.OverlaySizeConfigurationField.Large },
                { ConfigurationEditorConfigurationEditor.OverlayView, IOHelper.ResolveUrl(ConfigurationEditorDataEditor.DataEditorOverlayViewPath) },
                { ConfigurationEditorConfigurationEditor.EnableDevMode, Constants.Values.False },
            };

            var service     = new ConfigurationEditorService();
            var dataSources = service.GetConfigurationEditors <IDataListSource>();
            var listEditors = service.GetConfigurationEditors <IDataListEditor>();

            Fields.Add(
                DataSource,
                "Data source",
                "Select and configure the data source.",
                IOHelper.ResolveUrl(ConfigurationEditorDataEditor.DataEditorViewPath),
                new Dictionary <string, object>(defaultConfigEditorConfig)
            {
                { ConfigurationEditorConfigurationEditor.Items, dataSources }
            });

            Fields.Add(
                ListEditor,
                "List editor",
                "Select and configure the type of editor for the data list.",
                IOHelper.ResolveUrl(ConfigurationEditorDataEditor.DataEditorViewPath),
                new Dictionary <string, object>(defaultConfigEditorConfig)
            {
                { ConfigurationEditorConfigurationEditor.Items, listEditors }
            });

            Fields.AddHideLabel();
        }
Пример #10
0
 public ContentListPreValueEditor()
     : base()
 {
     Fields.Add("maxItems", "Max Items", "number", "Set the maximum number of items allowed.");
     Fields.AddHideLabel();
 }
Пример #11
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();
        }
        public CodeEditorConfigurationEditor()
            : base()
        {
            Fields.AddNotes(@"<div class=""alert alert-info"">
<p>This property editor makes use of <a href=""https://ace.c9.io/"" target=""_blank""><strong>AWS Cloud 9's Ace editor</strong></a> that is distributed with Umbraco. By default, Umbraco ships a minimal set of programming language modes and themes.</p>
<p>If you would like to add more modes and themes, you can do this by <a href=""https://github.com/ajaxorg/ace-builds/releases"" target=""_blank""><strong>downloading the latest pre-packaged version of the Ace editor</strong></a> and copy whichever <code>mode-*</code> or <code>theme-*</code> files from the <code>src-min-noconflict</code> folder over to the <code>~/umbraco/lib/ace-builds/src-min-noconflict</code> folder in this Umbraco installation.</p>
<p>When you reload this screen, the new programming language modes and themes will appear in the dropdown options below.</p>
</div>");

            var aceEditorPath = IOHelper.MapPath("~/umbraco/lib/ace-builds/src-min-noconflict/");

            if (Directory.Exists(aceEditorPath))
            {
                var aceEditorFiles = Directory.GetFiles(aceEditorPath, "*.js");
                if (aceEditorFiles != null && aceEditorFiles.Length > 0)
                {
                    var modes  = new List <object>();
                    var themes = new List <object>();

                    foreach (var file in aceEditorFiles)
                    {
                        var filename = Path.GetFileNameWithoutExtension(file);
                        if (filename.StartsWith("mode-"))
                        {
                            var mode = filename.Replace("mode-", string.Empty).ToLower();
                            modes.Add(new { name = mode.ToFirstUpper(), value = mode });
                        }

                        if (filename.StartsWith("theme-"))
                        {
                            var theme = filename.Replace("theme-", string.Empty).ToLower();
                            themes.Add(new { name = theme.ToFirstUpper(), value = theme });
                        }
                    }

                    if (modes.Count > 0)
                    {
                        Fields.Add(
                            Mode,
                            "Programming language mode",
                            "Select the programming language mode. By default, 'Razor' mode will be used.",
                            IOHelper.ResolveUrl(DropdownListDataEditor.DataEditorViewPath),
                            new Dictionary <string, object>
                        {
                            { AllowEmptyConfigurationField.AllowEmpty, Constants.Values.False },
                            { DropdownListConfigurationEditor.Items, modes },
                            { DropdownListConfigurationEditor.DefaultValue, "razor" }
                        });
                    }

                    if (themes.Count > 0)
                    {
                        Fields.Add(
                            Theme,
                            nameof(Theme),
                            "Set the theme for the code editor. By default, 'Chrome' will be used.",
                            IOHelper.ResolveUrl(DropdownListDataEditor.DataEditorViewPath),
                            new Dictionary <string, object>
                        {
                            { AllowEmptyConfigurationField.AllowEmpty, Constants.Values.False },
                            { DropdownListConfigurationEditor.Items, themes },
                            { DropdownListConfigurationEditor.DefaultValue, "chrome" }
                        });
                    }
                }
            }

            Fields.Add(FontSize, "Font size", "Set the font size. The value must be a valid CSS font-size. The default value is '14px'.", "textstring");
            Fields.Add(UseWrapMode, "Word wrapping", "Select to enable word wrapping.", "boolean");

            // NOTE: [LK:2019-06-07] Hidden the advanced options (for now), need to review.
            //Fields.Add("showGutter", "Show gutter?", "Select to show the left-hand side gutter in the code editor.", "boolean"); // TODO: Tempted to reverse the logic here, then use ToValueEditor to negate it? [LK]
            //Fields.Add("firstLineNumber", "First Line Number", "[A friendly description]", "number");
            //Fields.Add("showInvisibles", "showInvisibles", "[A friendly description]", "boolean");// showInvisibles: 0,
            //Fields.Add("showIndentGuides", "showIndentGuides", "[A friendly description]", "boolean");// showIndentGuides: 0,
            //Fields.Add("useSoftTabs", "useSoftTabs", "[A friendly description]", "boolean");// useSoftTabs: 1,
            //Fields.Add("showPrintMargin", "showPrintMargin", "[A friendly description]", "boolean");// showPrintMargin: 0,
            //Fields.Add("disableSearch", "disableSearch", "[A friendly description]", "boolean");// disableSearch: 0,
            //Fields.Add("enableSnippets", "enableSnippets", "[A friendly description]", "boolean");// enableSnippets: 0,
            //Fields.Add("enableBasicAutocompletion", "enableBasicAutocompletion", "[A friendly description]", "boolean");// enableBasicAutocompletion: 0,
            //Fields.Add("enableLiveAutocompletion", "enableLiveAutocompletion", "[A friendly description]", "boolean");// enableLiveAutocompletion: 0,

            Fields.AddHideLabel();
        }
Пример #13
0
 public IconPickerConfigurationEditor()
     : base()
 {
     Fields.Add(new DefaultIconConfigurationField());
     Fields.AddHideLabel();
 }