/// <summary> /// Creates the control(s) necessary for prompting user for a new value /// </summary> /// <param name="configurationValues">The configuration values.</param> /// <param name="id"></param> /// <returns> /// The control /// </returns> public override Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id) { if (configurationValues != null) { ListControl editControl = null; if (configurationValues.ContainsKey(ENHANCED_SELECTION_KEY) && configurationValues[ENHANCED_SELECTION_KEY].Value.AsBoolean()) { editControl = new RockListBox { ID = id }; ((RockListBox)editControl).DisplayDropAsAbsolute = true; } else { editControl = new RockCheckBoxList { ID = id }; ((RockCheckBoxList)editControl).RepeatDirection = RepeatDirection.Horizontal; } foreach (var keyVal in Helper.GetConfiguredValues(configurationValues)) { editControl.Items.Add(new ListItem(keyVal.Value, keyVal.Key)); } if (editControl.Items.Count > 0) { return(editControl); } } return(null); }
/// <summary> /// Creates the child controls. /// </summary> /// <param name="parentControl"></param> /// <returns></returns> public override System.Web.UI.Control[] CreateChildControls(System.Web.UI.Control parentControl) { var cblNoteTypes = new RockListBox(); cblNoteTypes.ID = parentControl.GetChildControlInstanceName(_CtlNoteTypes); cblNoteTypes.Label = "Note Types"; cblNoteTypes.Help = "The type of note to filter by. Leave blank to include all note types."; parentControl.Controls.Add(cblNoteTypes); var noteTypeService = new NoteTypeService(new RockContext()); var entityTypeIdPerson = EntityTypeCache.GetId <Rock.Model.Person>(); var noteTypes = noteTypeService.Queryable() .Where(a => a.EntityTypeId == entityTypeIdPerson) .OrderBy(a => a.Order) .ThenBy(a => a.Name) .Select(a => new { a.Id, a.Name }).ToList(); cblNoteTypes.Items.Clear(); cblNoteTypes.Items.AddRange(noteTypes.Select(a => new ListItem(a.Name, a.Id.ToString())).ToArray()); var slidingDateRangePicker = new SlidingDateRangePicker(); slidingDateRangePicker.ID = parentControl.GetChildControlInstanceName(_CtlSlidingDateRangePicker); slidingDateRangePicker.Label = "Date Range"; slidingDateRangePicker.Help = "The date range that the note was created during."; slidingDateRangePicker.Required = false; parentControl.Controls.Add(slidingDateRangePicker); return(new System.Web.UI.Control[] { cblNoteTypes, slidingDateRangePicker }); }
/// <summary> /// Creates the control(s) necessary for prompting user for a new value /// </summary> /// <param name="configurationValues">The configuration values.</param> /// <param name="id"></param> /// <returns> /// The control /// </returns> public override Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id) { ListControl editControl; if (configurationValues != null && configurationValues.ContainsKey(ALLOW_MULTIPLE_KEY) && configurationValues[ALLOW_MULTIPLE_KEY].Value.AsBoolean()) { editControl = new RockListBox { ID = id }; editControl.AddCssClass("checkboxlist-group"); } else { editControl = new RockDropDownList { ID = id, EnhanceForLongLists = true }; editControl.Items.Add(new ListItem()); } if (configurationValues != null && configurationValues.ContainsKey(ENTITY_TYPE_KEY)) { Guid?entityTypeGuid = configurationValues[ENTITY_TYPE_KEY].Value.AsGuidOrNull(); if (entityTypeGuid.HasValue) { var entityType = EntityTypeCache.Get(entityTypeGuid.Value); if (entityType != null) { Rock.Model.AttributeService attributeService = new Model.AttributeService(new RockContext()); IQueryable <Rock.Model.Attribute> attributeQuery; if (configurationValues.ContainsKey(QUALIFIER_COLUMN_KEY) && configurationValues.ContainsKey(QUALIFIER_VALUE_KEY)) { attributeQuery = attributeService .GetByEntityTypeQualifier(entityType.Id, configurationValues[QUALIFIER_COLUMN_KEY].Value, configurationValues[QUALIFIER_VALUE_KEY].Value, true); } else { attributeQuery = attributeService.GetByEntityTypeId(entityType.Id, true); } List <AttributeCache> attributeList = attributeQuery.ToAttributeCacheList(); if (attributeList.Any()) { foreach (var attribute in attributeList.OrderBy(a => a.Name)) { editControl.Items.Add(new ListItem(attribute.Name, attribute.Id.ToString(), attribute.IsActive)); } } return(editControl); } } } return(null); }
/// <summary> /// Creates the control(s) necessary for prompting user for a new value /// </summary> /// <param name="configurationValues">The configuration values.</param> /// <param name="id"></param> /// <returns> /// The control /// </returns> public override Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id) { ListControl editControl; var values = DocumentTypeCache.All().Select(v => new { v.Id, v.Name }).OrderBy(v => v.Name).ToList(); var allowMultiple = true; if (configurationValues != null && configurationValues.ContainsKey(ALLOW_MULTIPLE_KEY)) { allowMultiple = configurationValues[ALLOW_MULTIPLE_KEY].Value.AsBoolean(true); } if (!allowMultiple) { // Select single member editControl = new RockDropDownList { ID = id }; } else { // Select multiple members editControl = new RockListBox { ID = id, DisplayDropAsAbsolute = true }; } var items = new List <ListItem>(); foreach (var value in values) { items.Add(new ListItem(value.Name, value.Id.ToString())); } if (items.Count > 0) { if (editControl is RockListBox) { (editControl as RockListBox).Items.AddRange(items.ToArray()); } else { (editControl as RockDropDownList).Items.AddRange(items.ToArray()); } return(editControl); } return(null); }
/// <summary> /// Creates the control(s) necessary for prompting user for a new value /// </summary> /// <param name="configurationValues">The configuration values.</param> /// <param name="id"></param> /// <returns> /// The control /// </returns> public override System.Web.UI.Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id) { if (configurationValues == null) { return(null); } ListControl editControl = null; if (configurationValues.ContainsKey(ENHANCED_SELECTION_KEY) && configurationValues[ENHANCED_SELECTION_KEY].Value.AsBoolean()) { editControl = new RockListBox { ID = id }; (( RockListBox )editControl).DisplayDropAsAbsolute = true; } else { editControl = new RockCheckBoxList { ID = id }; var rockCheckBoxList = ( RockCheckBoxList )editControl; rockCheckBoxList.RepeatDirection = RepeatDirection.Horizontal; // Fixed bug preventing what was is stated in the 'Columns' help text: "If blank or 0 then 4 columns..." if (configurationValues.ContainsKey(REPEAT_COLUMNS) && configurationValues[REPEAT_COLUMNS].Value.AsInteger() != 0) { rockCheckBoxList.RepeatColumns = configurationValues[REPEAT_COLUMNS].Value.AsInteger(); } } var listSource = GetListSource(configurationValues); if (listSource.Any()) { foreach (var item in listSource) { ListItem listItem = new ListItem(item.Value, item.Key); editControl.Items.Add(listItem); } return(editControl); } else { return(null); } }
/// <summary> /// Creates the control(s) necessary for prompting user for a new value /// </summary> /// <param name="configurationValues">The configuration values.</param> /// <param name="id"></param> /// <returns> /// The control /// </returns> public override Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id) { if (configurationValues != null) { ListControl editControl = null; if (configurationValues.ContainsKey(ENHANCED_SELECTION_KEY) && configurationValues[ENHANCED_SELECTION_KEY].Value.AsBoolean()) { editControl = new RockListBox { ID = id }; (( RockListBox )editControl).DisplayDropAsAbsolute = true; } else { editControl = new RockCheckBoxList { ID = id }; var rockCheckBoxList = ( RockCheckBoxList )editControl; if (configurationValues.ContainsKey(REPEAT_COLUMNS)) { rockCheckBoxList.RepeatColumns = configurationValues[REPEAT_COLUMNS].Value.AsInteger(); } if (configurationValues.ContainsKey(REPEAT_DIRECTION)) { rockCheckBoxList.RepeatDirection = configurationValues[REPEAT_DIRECTION].Value.ConvertToEnumOrNull <RepeatDirection>() ?? RepeatDirection.Horizontal; } else { rockCheckBoxList.RepeatDirection = RepeatDirection.Horizontal; } } foreach (var keyVal in Helper.GetConfiguredValues(configurationValues)) { editControl.Items.Add(new ListItem(keyVal.Value, keyVal.Key)); } if (editControl.Items.Count > 0) { return(editControl); } } return(null); }
/// <summary> /// Creates the child controls. /// </summary> /// <returns></returns> public override Control[] CreateChildControls(Type entityType, FilterField filterControl) { var cblNoteTypes = new RockListBox(); cblNoteTypes.ID = filterControl.GetChildControlInstanceName(_CtlNoteTypes); cblNoteTypes.CssClass = "js-notetypes"; cblNoteTypes.Label = "Note Types"; cblNoteTypes.Help = "The type of note to filter by. Leave blank to include all note types."; filterControl.Controls.Add(cblNoteTypes); var noteTypeService = new NoteTypeService(new RockContext()); var entityTypeIdPerson = EntityTypeCache.GetId <Rock.Model.Person>(); var noteTypes = noteTypeService.Queryable().Where(a => a.EntityTypeId == entityTypeIdPerson) .OrderBy(a => a.Order) .ThenBy(a => a.Name) .Select(a => new { a.Id, a.Name }).ToList(); cblNoteTypes.Items.Clear(); cblNoteTypes.Items.AddRange(noteTypes.Select(a => new ListItem(a.Name, a.Id.ToString())).ToArray()); var slidingDateRangePicker = new SlidingDateRangePicker(); slidingDateRangePicker.ID = filterControl.GetChildControlInstanceName(_CtlSlidingDateRangePicker); slidingDateRangePicker.AddCssClass("js-sliding-date-range"); slidingDateRangePicker.Label = "Date Range"; slidingDateRangePicker.Help = "The date range that the note was created during."; slidingDateRangePicker.Required = false; filterControl.Controls.Add(slidingDateRangePicker); var nbMinimumCount = new NumberBox(); nbMinimumCount.ID = filterControl.GetChildControlInstanceName(_CtlMinimumCount); nbMinimumCount.NumberType = ValidationDataType.Integer; nbMinimumCount.MinimumValue = "1"; nbMinimumCount.Label = "Minimum Count"; nbMinimumCount.Help = "The minimum number of notes created during the date range to be considered a match."; nbMinimumCount.Required = true; nbMinimumCount.AddCssClass("js-minimum-count"); filterControl.Controls.Add(nbMinimumCount); return(new System.Web.UI.Control[3] { cblNoteTypes, slidingDateRangePicker, nbMinimumCount }); }
/// <summary> /// Creates the control(s) necessary for prompting user for a new value /// </summary> /// <param name="configurationValues">The configuration values.</param> /// <param name="id"></param> /// <returns> /// The control /// </returns> public override Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id) { RockListBox editControl = new RockListBox { ID = id, DisplayDropAsAbsolute = true }; var values = DocumentTypeCache.All().Select(v => new { v.Id, v.Name }).OrderBy(v => v.Name).ToList(); foreach (var value in values) { editControl.Items.Add(new ListItem(value.Name, value.Id.ToString())); } if (editControl.Items.Count > 0) { return(editControl); } return(null); }