/// <summary> /// Get a collection of all the (key/label) items for a picker (with optional typeahead) /// </summary> /// <param name="currentId">the current id</param> /// <param name="parentId">the parent id</param> /// <param name="propertyAlias">the property alias</param> /// <param name="dataSource">the datasource</param> /// <param name="customLabelMacro">an optional macro to use for custom labels</param> /// <param name="typeahead">optional typeahead text to filter down on items returned</param> /// <returns>a collection of <see cref="EditorDataItem"/></returns> internal static IEnumerable <EditorDataItem> GetEditorDataItems( int currentId, int parentId, string propertyAlias, IDataSource dataSource, string customLabelMacro, string typeahead = null) { IEnumerable <EditorDataItem> editorDataItems = Enumerable.Empty <EditorDataItem>(); // default return data if (dataSource != null) { editorDataItems = dataSource.GetEditorDataItems(currentId, parentId, typeahead); // both are passed as current id may = 0 (new content) if (!string.IsNullOrWhiteSpace(customLabelMacro)) { editorDataItems = new CustomLabel(customLabelMacro, currentId, propertyAlias).ProcessEditorDataItems(editorDataItems); } // if the datasource didn't handle the typeahead text, then it needs to be done here (post custom label processing ?) if (!dataSource.HandledTypeahead && !string.IsNullOrWhiteSpace(typeahead)) { editorDataItems = new TypeaheadListPicker(typeahead).ProcessEditorDataItems(editorDataItems); } } return(editorDataItems); }
public IEnumerable <EditorDataItem> GetEditorDataItems([FromUri] int contextId, [FromUri] string propertyAlias, [FromBody] dynamic data) { XmlDataSource xmlDataSource = ((JObject)data.config.dataSource).ToObject <XmlDataSource>(); IEnumerable <EditorDataItem> editorDataItems = xmlDataSource.GetEditorDataItems(contextId); CustomLabel customLabel = new CustomLabel((string)data.config.customLabel, contextId, propertyAlias); TypeaheadListPicker typeaheadListPicker = new TypeaheadListPicker((string)data.typeahead); // process the labels and then handle any type ahead text return(typeaheadListPicker.ProcessEditorDataItems(customLabel.ProcessEditorDataItems(editorDataItems))); }
public IEnumerable <EditorDataItem> GetEditorDataItems([FromUri] int contextId, [FromUri] int parentId, [FromUri] string propertyAlias, [FromBody] dynamic data) { DotNetDataSource dotNetDataSource = ((JObject)data.config.dataSource).ToObject <DotNetDataSource>(); dotNetDataSource.Typeahead = (string)data.typeahead; IEnumerable <EditorDataItem> editorDataItems = dotNetDataSource.GetEditorDataItems(contextId, parentId).ToList(); CustomLabel customLabel = new CustomLabel((string)data.config.customLabel, contextId, propertyAlias); editorDataItems = customLabel.ProcessEditorDataItems(editorDataItems); // if the typeahead wasn't handled by the custom data-source, then fallback to default typeahead processing if (!dotNetDataSource.HandledTypeahead) { TypeaheadListPicker typeaheadListPicker = new TypeaheadListPicker((string)data.typeahead); editorDataItems = typeaheadListPicker.ProcessEditorDataItems(editorDataItems); } return(editorDataItems); }