/// <summary> /// Renders the controls. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="filterControl">The filter control.</param> /// <param name="writer">The writer.</param> /// <param name="controls">The controls.</param> public override void RenderControls(Type entityType, FilterField filterControl, HtmlTextWriter writer, Control[] controls) { if (controls.Count() < 4) { return; } RegistrationTemplatePicker registrationTemplatePicker = controls[0] as RegistrationTemplatePicker; RockCheckBox cbIncludeInactiveRegistrationInstances = controls[1] as RockCheckBox; PanelWidget pwAdvanced = controls[3] as PanelWidget; writer.AddAttribute(HtmlTextWriterAttribute.Class, "row"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.AddAttribute(HtmlTextWriterAttribute.Class, "col-md-6"); writer.RenderBeginTag(HtmlTextWriterTag.Div); registrationTemplatePicker.RenderControl(writer); writer.RenderBeginTag(HtmlTextWriterTag.Div); cbIncludeInactiveRegistrationInstances.ContainerCssClass = "margin-l-md"; cbIncludeInactiveRegistrationInstances.RenderControl(writer); writer.RenderEndTag(); writer.RenderEndTag(); writer.AddAttribute(HtmlTextWriterAttribute.Class, "col-md-6"); writer.RenderBeginTag(HtmlTextWriterTag.Div); pwAdvanced.RenderControl(writer); writer.RenderEndTag(); writer.RenderEndTag(); }
/// <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) { RegistrationTemplatePicker editControl = new RegistrationTemplatePicker { ID = id }; return(editControl); }
/// <summary> /// Creates the HTML controls required to configure this type of field /// </summary> /// <returns></returns> public override List <Control> ConfigurationControls() { var controls = base.ConfigurationControls(); // build a drop down list of defined types (the one that gets selected is // used to build a list of defined values) var rtp = new RegistrationTemplatePicker(); controls.Add(rtp); rtp.SelectItem += OnQualifierUpdated; rtp.Label = "Registration Template"; rtp.Help = "Registration Template to select items from, if left blank any registration template's instance can be selected."; return(controls); }
/// <summary> /// Sets the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="controls">The controls.</param> /// <param name="selection">The selection.</param> public override void SetSelection(Type entityType, Control[] controls, string selection) { if (controls.Count() < 3) { return; } RegistrationTemplatePicker registrationTemplatePicker = controls[0] as RegistrationTemplatePicker; RockCheckBox cbIncludeInactive = controls[1] as RockCheckBox; SlidingDateRangePicker registeredOnDateRangePicker = controls[2] as SlidingDateRangePicker; string[] selectionValues = selection.Split('|'); if (selectionValues.Length >= 1) { List <Guid> registrationTemplateGuids = selectionValues[0].Split(',').AsGuidList(); var registrationTemplates = new RegistrationTemplateService(new RockContext()).GetByGuids(registrationTemplateGuids); if (registrationTemplates != null) { registrationTemplatePicker.SetValues(registrationTemplates); } if (selectionValues.Length >= 2) { cbIncludeInactive.Checked = selectionValues[1].AsBooleanOrNull() ?? false; } else { // if options where saved before this option was added, set to false, even though it would have included inactive before cbIncludeInactive.Checked = false; } if (selectionValues.Length >= 3) { // convert comma delimited to pipe registeredOnDateRangePicker.DelimitedValues = selectionValues[2].Replace(',', '|'); } } }
/// <summary> /// Creates the child controls. /// </summary> /// <returns></returns> public override Control[] CreateChildControls(Type entityType, FilterField filterControl) { var rp = new RegistrationTemplatePicker(); rp.ID = filterControl.ID + "_rp"; rp.Label = "RegistrationTemplate(s)"; rp.CssClass = "js-group-picker"; rp.AllowMultiSelect = true; rp.Help = "Select the registration templates that you want the registrants for. Leaving this blank will not restrict results to a registration template."; filterControl.Controls.Add(rp); var cbIncludeInactiveRegistrationInstances = new RockCheckBox(); cbIncludeInactiveRegistrationInstances.ID = filterControl.ID + "_cbIncludeInactiveRegistrationInstances"; cbIncludeInactiveRegistrationInstances.Text = "Include Inactive Registration Instances"; cbIncludeInactiveRegistrationInstances.CssClass = "js-include-inactive-groups"; cbIncludeInactiveRegistrationInstances.AutoPostBack = true; filterControl.Controls.Add(cbIncludeInactiveRegistrationInstances); PanelWidget pwAdvanced = new PanelWidget(); filterControl.Controls.Add(pwAdvanced); pwAdvanced.ID = filterControl.ID + "_pwAttributes"; pwAdvanced.Title = "Advanced Filters"; pwAdvanced.CssClass = "advanced-panel"; SlidingDateRangePicker registeredOnDateRangePicker = new SlidingDateRangePicker(); registeredOnDateRangePicker.ID = pwAdvanced.ID + "_addedOnDateRangePicker"; registeredOnDateRangePicker.AddCssClass("js-sliding-date-range"); registeredOnDateRangePicker.Label = "Date Registered:"; registeredOnDateRangePicker.Help = "Select the date range that the person was registered. Leaving this blank will not restrict results to a date range."; pwAdvanced.Controls.Add(registeredOnDateRangePicker); return(new Control[4] { rp, cbIncludeInactiveRegistrationInstances, registeredOnDateRangePicker, pwAdvanced }); }
/// <summary> /// Gets the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="controls">The controls.</param> /// <returns></returns> public override string GetSelection(Type entityType, Control[] controls) { if (controls.Count() < 3) { return(null); } RegistrationTemplatePicker registrationTemplatePicker = controls[0] as RegistrationTemplatePicker; RockCheckBox cbInactiveRegistrationInstances = controls[1] as RockCheckBox; SlidingDateRangePicker registeredOnDateRangePicker = controls[2] as SlidingDateRangePicker; List <int> registrationTemplateIdList = registrationTemplatePicker.SelectedValues.AsIntegerList(); var registrationTemplateGuids = new RegistrationTemplateService(new RockContext()).GetByIds(registrationTemplateIdList).Select(a => a.Guid).Distinct().ToList(); // convert pipe to comma delimited var delimitedValues = registeredOnDateRangePicker.DelimitedValues.Replace("|", ","); return(string.Format( "{0}|{1}|{2}", registrationTemplateGuids.AsDelimited(","), cbInactiveRegistrationInstances.Checked.ToString(), delimitedValues)); }