public DataListConfigurationEditor(ConfigurationEditorUtility utility) : base() { _utility = utility; var configEditorViewPath = IOHelper.ResolveUrl(ConfigurationEditorDataEditor.DataEditorViewPath); var defaultConfigEditorConfig = new Dictionary <string, object> { { MaxItemsConfigurationField.MaxItems, 1 }, { DisableSortingConfigurationField.DisableSorting, Constants.Values.True }, { Constants.Conventions.ConfigurationFieldAliases.OverlayView, IOHelper.ResolveUrl(ConfigurationEditorDataEditor.DataEditorOverlayViewPath) }, { EnableDevModeConfigurationField.EnableDevMode, Constants.Values.True }, }; var dataSources = utility.GetConfigurationEditorModels <IDataListSource>().ToList(); var listEditors = utility.GetConfigurationEditorModels <IDataListEditor>().ToList(); Fields.Add(new ConfigurationField { Key = DataSource, Name = "Data source", Description = "Select and configure a data source.", View = configEditorViewPath, Config = new Dictionary <string, object>(defaultConfigEditorConfig) { { Constants.Conventions.ConfigurationFieldAliases.AddButtonLabelKey, "contentment_configureDataSource" }, { EnableFilterConfigurationField.EnableFilter, dataSources.Count > 10 ? Constants.Values.True : Constants.Values.False }, { Constants.Conventions.ConfigurationFieldAliases.Items, dataSources }, { "help", new { @class = "alert alert-info", title = "Do you need a custom data-source?", notes = $@"<p>If one of the data-sources above does not fit your needs, you can extend Data List with your own custom data source.</p> <p>To do this, read the documentation on <a href=""{Constants.Package.RepositoryUrl}/blob/develop/docs/editors/data-list.md#extending-with-your-own-custom-data-source"" target=""_blank"" rel=""noopener""><strong>extending with your own custom data source</strong></a>.</p>" } }, } }); Fields.Add(new ConfigurationField { Key = ListEditor, Name = "List editor", Description = "Select and configure a list editor.", View = configEditorViewPath, Config = new Dictionary <string, object>(defaultConfigEditorConfig) { { Constants.Conventions.ConfigurationFieldAliases.AddButtonLabelKey, "contentment_configureListEditor" }, { EnableFilterConfigurationField.EnableFilter, dataSources.Count > 10 ? Constants.Values.True : Constants.Values.False }, { Constants.Conventions.ConfigurationFieldAliases.Items, listEditors }, } }); Fields.Add(new ConfigurationField { Key = "preview", Name = "Preview", View = IOHelper.ResolveUrl(DataListDataEditor.DataEditorPreviewViewPath) }); }
public TextInputConfigurationEditor(ConfigurationEditorUtility utility) : base() { _utility = utility; var dataSources = _utility.GetConfigurationEditorModels <IDataListSource>(); Fields.Add(new PlaceholderTextConfigurationField()); Fields.Add(new AutocompleteConfigurationField()); Fields.Add(new MaxCharsConfigurationField()); Fields.Add( Items, "Data list", "<em>(optional)</em> Select and configure the data source to provide a HTML5 <datalist> for this text input.", IOHelper.ResolveUrl(ConfigurationEditorDataEditor.DataEditorViewPath), new Dictionary <string, object>() { { OverlaySizeConfigurationField.OverlaySize, OverlaySizeConfigurationField.Small }, { ConfigurationEditorConfigurationEditor.OverlayView, IOHelper.ResolveUrl(ConfigurationEditorDataEditor.DataEditorOverlayViewPath) }, { ConfigurationEditorConfigurationEditor.Items, dataSources }, { MaxItemsConfigurationField.MaxItems, 1 }, { DisableSortingConfigurationField.DisableSorting, Constants.Values.True }, { EnableDevModeConfigurationField.EnableDevMode, Constants.Values.True }, }); }
public override IDictionary <string, object> ToValueEditor(object configuration) { var config = base.ToValueEditor(configuration); if (config.TryGetValue(Items, out var items) && items is JArray array && array.Count > 0) { var types = new List <Type>(); foreach (var item in array) { var type = TypeFinder.GetTypeByName(item.Value <string>()); if (type != null) { types.Add(type); } } config[Items] = _utility.GetConfigurationEditorModels <IConfigurationEditorItem>(); config[OrderBy] = string.Empty; // Set to empty, so to preserve the selected order. } if (config.ContainsKey(OverlayView) == false) { config.Add(OverlayView, IOHelper.ResolveUrl(ConfigurationEditorDataEditor.DataEditorOverlayViewPath)); } return(config); }
public ConfigurationEditorConfigurationEditor(ConfigurationEditorUtility utility) : base() { _utility = utility; var items = utility .GetConfigurationEditorModels <IConfigurationEditorItem>(ignoreFields: true) .Select(x => new DataListItem { Icon = x.Icon, Name = x.Name, Description = x.Description, Value = x.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) }, { EnableDevModeConfigurationField.EnableDevMode, Constants.Values.False }, }); Fields.Add(new EnableFilterConfigurationField()); Fields.Add(new OverlaySizeConfigurationField()); Fields.Add(new MaxItemsConfigurationField()); Fields.Add(new AllowDuplicatesConfigurationField()); Fields.Add(new DisableSortingConfigurationField()); }
public TextInputConfigurationEditor(ConfigurationEditorUtility utility) : base() { _utility = utility; var dataSources = _utility.GetConfigurationEditorModels <IDataListSource>().ToList(); Fields.Add(new ConfigurationField { Key = "placeholderText", Name = "Placeholder text", Description = "Add placeholder text for the text input.<br>This is to be used as instructional information, not as a default value.", View = "textstring", }); Fields.Add(new ConfigurationField { Key = Constants.Conventions.ConfigurationFieldAliases.Items, Name = "Data list", Description = "<em>(optional)</em> Select and configure a data source to provide a HTML5 <datalist> for this text input.", View = IOHelper.ResolveUrl(ConfigurationEditorDataEditor.DataEditorViewPath), Config = new Dictionary <string, object>() { { Constants.Conventions.ConfigurationFieldAliases.AddButtonLabelKey, "contentment_configureDataSource" }, { MaxItemsConfigurationField.MaxItems, 1 }, { DisableSortingConfigurationField.DisableSorting, Constants.Values.True }, { Constants.Conventions.ConfigurationFieldAliases.OverlayView, IOHelper.ResolveUrl(ConfigurationEditorDataEditor.DataEditorOverlayViewPath) }, { EnableDevModeConfigurationField.EnableDevMode, Constants.Values.True }, { EnableFilterConfigurationField.EnableFilter, dataSources.Count > 10 ? Constants.Values.True : Constants.Values.False }, { Constants.Conventions.ConfigurationFieldAliases.Items, dataSources }, } }); Fields.Add(new ConfigurationField { Name = "Maximum allowed characters", Key = "maxChars", Description = "Enter the maximum number of characters allowed for the text input.<br>The default limit is 500 characters.", View = IOHelper.ResolveUrl(NumberInputDataEditor.DataEditorViewPath), }); Fields.Add(new ConfigurationField { Key = "autocomplete", Name = "Enable autocomplete?", Description = "Select to enable your web-browser's autocomplete functionality on the text input.", View = "boolean", }); Fields.Add(new ConfigurationField { Key = "spellcheck", Name = "Enable spellcheck?", Description = "Select to enable your web-browser's spellcheck functionality on the text input.", View = "boolean", }); }
public DataListConfigurationEditor(ConfigurationEditorUtility utility) : base() { _utility = utility; var configEditorViewPath = IOHelper.ResolveUrl(ConfigurationEditorDataEditor.DataEditorViewPath); var defaultConfigEditorConfig = new Dictionary <string, object> { { MaxItemsConfigurationField.MaxItems, 1 }, { DisableSortingConfigurationField.DisableSorting, Constants.Values.True }, { Constants.Conventions.ConfigurationFieldAliases.OverlayView, IOHelper.ResolveUrl(ConfigurationEditorDataEditor.DataEditorOverlayViewPath) }, { EnableDevModeConfigurationField.EnableDevMode, Constants.Values.True }, }; var dataSources = utility.GetConfigurationEditorModels <IDataListSource>(); var listEditors = utility.GetConfigurationEditorModels <IDataListEditor>(); Fields.Add( DataSource, "Data source", "Select and configure a data source.", configEditorViewPath, new Dictionary <string, object>(defaultConfigEditorConfig) { { Constants.Conventions.ConfigurationFieldAliases.AddButtonLabelKey, "contentment_configureDataSource" }, { Constants.Conventions.ConfigurationFieldAliases.Items, dataSources } }); Fields.Add( ListEditor, "List editor", "Select and configure a list editor.", configEditorViewPath, new Dictionary <string, object>(defaultConfigEditorConfig) { { Constants.Conventions.ConfigurationFieldAliases.AddButtonLabelKey, "contentment_configureListEditor" }, { Constants.Conventions.ConfigurationFieldAliases.Items, listEditors } }); }
public DataListConfigurationEditor(ConfigurationEditorUtility utility) : base() { _utility = utility; var configEditorViewPath = IOHelper.ResolveUrl(ConfigurationEditorDataEditor.DataEditorViewPath); var defaultConfigEditorConfig = new Dictionary <string, object> { { MaxItemsConfigurationField.MaxItems, 1 }, { DisableSortingConfigurationField.DisableSorting, Constants.Values.True }, { OverlaySizeConfigurationField.OverlaySize, OverlaySizeConfigurationField.Small }, { ConfigurationEditorConfigurationEditor.OverlayView, IOHelper.ResolveUrl(ConfigurationEditorDataEditor.DataEditorOverlayViewPath) }, { EnableDevModeConfigurationField.EnableDevMode, Constants.Values.True }, }; var dataSources = utility.GetConfigurationEditorModels <IDataListSource>(); var listEditors = utility.GetConfigurationEditorModels <IDataListEditor>(); Fields.Add( DataSource, "Data source", "Select and configure the data source.", configEditorViewPath, new Dictionary <string, object>(defaultConfigEditorConfig) { { ConfigurationEditorConfigurationEditor.Items, dataSources } }); Fields.Add( ListEditor, "List editor", "Select and configure the type of editor for the data list.", configEditorViewPath, new Dictionary <string, object>(defaultConfigEditorConfig) { { ConfigurationEditorConfigurationEditor.Items, listEditors } }); }
public ContentBlocksConfigurationEditor( IContentService contentService, IContentTypeService contentTypeService, ConfigurationEditorUtility utility) : base() { _utility = utility; // NOTE: Gets all the elementTypes and blueprints upfront, rather than several hits inside the loop. _elementTypes = contentTypeService.GetAllElementTypes().ToDictionary(x => x.Key); _elementBlueprints = new Lazy <ILookup <int, IContent> >(() => contentService.GetBlueprintsForContentTypes(_elementTypes.Values.Select(x => x.Id).ToArray()).ToLookup(x => x.ContentTypeId)); var displayModes = utility.GetConfigurationEditorModels <IContentBlocksDisplayMode>(); // NOTE: Sets the default display mode to be the Blocks. var defaultDisplayMode = displayModes.FirstOrDefault(x => x.Key.InvariantEquals(typeof(BlocksDisplayMode).GetFullNameWithAssembly())); if (defaultDisplayMode != null) { DefaultConfiguration.Add(DisplayMode, new[] { new { key = defaultDisplayMode.Key, value = defaultDisplayMode.DefaultValues } }); } Fields.Add(new ConfigurationField { Key = DisplayMode, Name = "Display mode", Description = "Select and configure how to display the blocks in the editor.", View = IOHelper.ResolveUrl(ConfigurationEditorDataEditor.DataEditorViewPath), Config = new Dictionary <string, object>() { { Constants.Conventions.ConfigurationFieldAliases.AddButtonLabelKey, "contentment_configureDisplayMode" }, { Constants.Conventions.ConfigurationFieldAliases.Items, displayModes }, { MaxItemsConfigurationField.MaxItems, 1 }, { DisableSortingConfigurationField.DisableSorting, Constants.Values.True }, { Constants.Conventions.ConfigurationFieldAliases.OverlayView, IOHelper.ResolveUrl(ConfigurationEditorDataEditor.DataEditorOverlayViewPath) }, { EnableDevModeConfigurationField.EnableDevMode, Constants.Values.True }, } }); Fields.Add(new ContentBlocksTypesConfigurationField(_elementTypes.Values)); Fields.Add(new EnableFilterConfigurationField()); Fields.Add(new MaxItemsConfigurationField()); Fields.Add(new DisableSortingConfigurationField()); Fields.Add(new EnableDevModeConfigurationField()); }