public DataTableConfigurationEditor(ParameterEditorCollection parameterEditors) : base() { // NOTE: Excluded these ParameterEditors, as they don't fully support zero-config. var exclusions = new[] { "contentpicker", "mediapicker", "entitypicker" }; var paramEditors = 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.Add(new MaxItemsConfigurationField()); 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.Add(new DisableSortingConfigurationField()); }
public MacrosController( ParameterEditorCollection parameterEditorCollection, IMacroService macroService, IShortStringHelper shortStringHelper, IBackOfficeSecurityAccessor backofficeSecurityAccessor, ILogger <MacrosController> logger, IHostingEnvironment hostingEnvironment, IUmbracoMapper umbracoMapper) { _parameterEditorCollection = parameterEditorCollection ?? throw new ArgumentNullException(nameof(parameterEditorCollection)); _macroService = macroService ?? throw new ArgumentNullException(nameof(macroService)); _shortStringHelper = shortStringHelper ?? throw new ArgumentNullException(nameof(shortStringHelper)); _backofficeSecurityAccessor = backofficeSecurityAccessor ?? throw new ArgumentNullException(nameof(backofficeSecurityAccessor)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment)); _umbracoMapper = umbracoMapper ?? throw new ArgumentNullException(nameof(umbracoMapper)); }
/// <summary> /// Finds media UDIs in Macro Parameter Values by calling the GetReference method for all the Macro Parameter Editors /// for a particular macro. /// </summary> /// <param name="macroParameters">The parameters for the macro a dictionary of key/value strings</param> /// <param name="macroConfig"> /// The macro configuration for this particular macro - contains the types of editors used for /// each parameter /// </param> /// <param name="parameterEditors"> /// A list of all the registered parameter editors used in the Umbraco implmentation - to /// look up the corresponding property editor for a macro parameter /// </param> /// <returns></returns> private IEnumerable <UmbracoEntityReference> GetUmbracoEntityReferencesFromMacroParameters( Dictionary <string, string> macroParameters, IMacro macroConfig, ParameterEditorCollection parameterEditors) { var foundUmbracoEntityReferences = new List <UmbracoEntityReference>(); foreach (IMacroProperty parameter in macroConfig.Properties) { if (macroParameters.TryGetValue(parameter.Alias, out var parameterValue)) { var parameterEditorAlias = parameter.EditorAlias; // Lookup propertyEditor from the registered ParameterEditors with the implmementation to avoid looking up for each parameter IDataEditor?parameterEditor = parameterEditors.FirstOrDefault(f => string.Equals(f.Alias, parameterEditorAlias, StringComparison.OrdinalIgnoreCase)); if (parameterEditor is not null) { // Get the ParameterValueEditor for this PropertyEditor (where the GetReferences method is implemented) - cast as IDataValueReference to determine if 'it is' implemented for the editor if (parameterEditor.GetValueEditor() is IDataValueReference parameterValueEditor) { foreach (UmbracoEntityReference entityReference in parameterValueEditor.GetReferences( parameterValue)) { foundUmbracoEntityReferences.Add(entityReference); } } else { _logger.LogInformation( "{0} doesn't have a ValueEditor that implements IDataValueReference", parameterEditor.Alias); } } } } return(foundUmbracoEntityReferences); }
public MacroMapDefinition(ParameterEditorCollection parameterEditors, ILogger logger) { _parameterEditors = parameterEditors; _logger = logger; }
public HtmlMacroParameterParser(IMacroService macroService, ILogger <HtmlMacroParameterParser> logger, ParameterEditorCollection parameterEditors) { _macroService = macroService; _logger = logger; _parameterEditors = parameterEditors; }