예제 #1
0
        /// <summary>
        /// Handles the SelectedIndexChanged event of the groupTypePicker control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        public void groupTypePicker_SelectedIndexChanged(object sender, EventArgs e)
        {
            GroupTypePicker groupTypePicker = sender as GroupTypePicker;
            Panel           pnlGroupAttributeFilterControls = groupTypePicker.Parent as Panel;

            pnlGroupAttributeFilterControls.Controls.Clear();
            pnlGroupAttributeFilterControls.Controls.Add(groupTypePicker);

            // Create the field selection dropdown
            var ddlProperty = new RockDropDownList();

            ddlProperty.ID = string.Format("{0}_ddlProperty", pnlGroupAttributeFilterControls.ID);
            pnlGroupAttributeFilterControls.Controls.Add(ddlProperty);

            // add Empty option first
            ddlProperty.Items.Add(new ListItem());

            foreach (var entityField in GetGroupAttributes(groupTypePicker.SelectedGroupTypeId))
            {
                string controlId = string.Format("{0}_{1}", pnlGroupAttributeFilterControls.ID, entityField.Name);
                var    control   = entityField.FieldType.Field.FilterControl(entityField.FieldConfig, controlId, true);
                if (control != null)
                {
                    // Add the field to the dropdown of availailable fields
                    ddlProperty.Items.Add(new ListItem(entityField.Title, entityField.Name));
                    pnlGroupAttributeFilterControls.Controls.Add(control);
                }
            }
        }
        /// <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 groupTypePicker = new GroupTypePicker();

            groupTypePicker.ID                    = parentControl.ID + "_groupTypePicker";
            groupTypePicker.Label                 = "Group Type";
            groupTypePicker.GroupTypes            = new GroupTypeService(new RockContext()).Queryable().OrderBy(a => a.Order).ThenBy(a => a.Name).ToList();
            groupTypePicker.SelectedIndexChanged += groupTypePicker_SelectedIndexChanged;
            groupTypePicker.AutoPostBack          = true;
            parentControl.Controls.Add(groupTypePicker);

            int?selectedGroupTypeId = parentControl.Page.Request.Params[groupTypePicker.UniqueID].AsIntegerOrNull();

            groupTypePicker.SelectedGroupTypeId = selectedGroupTypeId;

            var cblRole = new RockCheckBoxList();

            cblRole.Label = "with Group Role(s)";
            cblRole.ID    = parentControl.ID + "_cblRole";
            parentControl.Controls.Add(cblRole);

            PopulateGroupRolesCheckList(groupTypePicker.SelectedGroupTypeId ?? 0, cblRole);

            return(new Control[2] {
                groupTypePicker, cblRole
            });
        }
예제 #3
0
        /// <summary>
        /// Creates the child controls.
        /// Implement this version of CreateChildControls if your DataFilterComponent supports different FilterModes
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="filterControl"></param>
        /// <param name="filterMode"></param>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl, FilterMode filterMode)
        {
            var containerControl = new DynamicControlsPanel();

            containerControl.ID       = string.Format("{0}_containerControl", filterControl.ID);
            containerControl.CssClass = "js-container-control";
            filterControl.Controls.Add(containerControl);

            GroupTypePicker groupTypePicker = new GroupTypePicker();

            groupTypePicker.ID    = filterControl.ID + "_groupTypePicker";
            groupTypePicker.Label = "Group Type";
            groupTypePicker.AddCssClass("js-group-type-picker");
            groupTypePicker.GroupTypes            = new GroupTypeService(new RockContext()).Queryable().ToList();
            groupTypePicker.SelectedIndexChanged += groupTypePicker_SelectedIndexChanged;
            groupTypePicker.AutoPostBack          = true;
            if (filterMode == FilterMode.SimpleFilter)
            {
                // we still need to render the control in order to get the selected GroupTypeId on postback, so just hide it instead
                groupTypePicker.Style[HtmlTextWriterStyle.Display] = "none";
            }

            containerControl.Controls.Add(groupTypePicker);

            // set the GroupTypePicker selected value now so we can create the other controls the depending on know the groupTypeid
            if (filterControl.Page.IsPostBack)
            {
                // since we just created the GroupTypePicker, we'll have to sniff the GroupTypeId from Request.Params
                int?groupTypeId = filterControl.Page.Request.Params[groupTypePicker.UniqueID].AsIntegerOrNull();
                groupTypePicker.SelectedGroupTypeId = groupTypeId;
                EnsureSelectedGroupTypeControls(groupTypePicker);
            }

            return(new Control[] { containerControl });
        }
예제 #4
0
        /// <summary>
        /// Sets the selection.
        /// </summary>
        /// <param name="controls">The controls.</param>
        /// <param name="selection">The selection.</param>
        public override void SetSelection(System.Web.UI.Control[] controls, string selection)
        {
            string[] selectionValues = selection.Split('|');
            if (selectionValues.Length >= 1)
            {
                RockRadioButtonList rblShowAsLinkType    = controls[0] as RockRadioButtonList;
                GroupTypePicker     groupTypePicker      = controls[1] as GroupTypePicker;
                RockCheckBoxList    cblRole              = controls[2] as RockCheckBoxList;
                RockDropDownList    ddlGroupMemberStatus = controls[3] as RockDropDownList;

                rblShowAsLinkType.SelectedValue = selectionValues[0].ConvertToEnum <ShowAsLinkType>(ShowAsLinkType.NameOnly).ConvertToInt().ToString();

                if (selectionValues.Length >= 3)
                {
                    Guid groupTypeGuid = selectionValues[1].AsGuid();
                    var  groupTypeId   = new GroupTypeService(new RockContext()).GetId(groupTypeGuid);
                    if (groupTypeId.HasValue)
                    {
                        groupTypePicker.SetValue(groupTypeId.Value);
                    }

                    groupTypePicker_SelectedIndexChanged(groupTypePicker, new EventArgs());

                    string[] selectedRoleGuids = selectionValues[2].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                    foreach (var item in cblRole.Items.OfType <ListItem>())
                    {
                        item.Selected = selectedRoleGuids.Contains(item.Value);
                    }

                    ddlGroupMemberStatus.SetValue(selectionValues[3]);
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Sets the selection.
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="controls">The controls.</param>
        /// <param name="selection">The selection.</param>
        public override void SetSelection(Type entityType, Control[] controls, string selection)
        {
            if (!string.IsNullOrWhiteSpace(selection))
            {
                var values = JsonConvert.DeserializeObject <List <string> >(selection);
                if (controls.Length > 0 && values.Count > 0)
                {
                    var groupType = GroupTypeCache.Read(values[0].AsGuid());
                    if (groupType != null)
                    {
                        var containerControl = controls[0] as DynamicControlsPanel;
                        if (containerControl.Controls.Count > 0)
                        {
                            GroupTypePicker groupTypePicker = containerControl.Controls[0] as GroupTypePicker;
                            groupTypePicker.SelectedGroupTypeId = groupType.Id;
                            groupTypePicker_SelectedIndexChanged(groupTypePicker, new EventArgs());
                        }

                        if (containerControl.Controls.Count > 1 && values.Count > 1)
                        {
                            DropDownList ddlProperty  = containerControl.Controls[1] as DropDownList;
                            var          entityFields = GetGroupAttributes(groupType.Id);

                            var panelControls = new List <Control>();
                            panelControls.AddRange(containerControl.Controls.OfType <Control>());
                            SetEntityFieldSelection(entityFields, ddlProperty, values.Skip(1).ToList(), panelControls);
                        }
                    }
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Creates the child controls.
        /// Implement this version of CreateChildControls if your DataFilterComponent supports different FilterModes
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="filterControl"></param>
        /// <param name="filterMode"></param>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl, FilterMode filterMode)
        {
            var containerControl = new DynamicControlsPanel();

            containerControl.ID       = string.Format("{0}_containerControl", filterControl.ID);
            containerControl.CssClass = "js-container-control";
            filterControl.Controls.Add(containerControl);

            GroupTypePicker groupTypePicker = new GroupTypePicker();

            groupTypePicker.ID                    = filterControl.ID + "_groupTypePicker";
            groupTypePicker.Label                 = "Group Type";
            groupTypePicker.GroupTypes            = new GroupTypeService(new RockContext()).Queryable().OrderBy(a => a.Order).ThenBy(a => a.Name).ToList();
            groupTypePicker.SelectedIndexChanged += groupTypePicker_SelectedIndexChanged;
            groupTypePicker.AutoPostBack          = true;
            groupTypePicker.Visible               = filterMode == FilterMode.AdvancedFilter;
            containerControl.Controls.Add(groupTypePicker);

            // set the GroupTypePicker selected value now so we can create the other controls the depending on know the groupTypeid
            int?groupTypeId = filterControl.Page.Request.Params[groupTypePicker.UniqueID].AsIntegerOrNull();

            groupTypePicker.SelectedGroupTypeId = groupTypeId;
            groupTypePicker_SelectedIndexChanged(groupTypePicker, new EventArgs());

            return(new Control[] { containerControl });
        }
예제 #7
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            int?selectedGroupTypeId = null;

            if (groupTypePicker != null)
            {
                selectedGroupTypeId = groupTypePicker.SelectedGroupTypeId;
            }

            groupTypePicker                       = new GroupTypePicker();
            groupTypePicker.ID                    = filterControl.ID + "_groupTypePicker";
            groupTypePicker.Label                 = "Group Type";
            groupTypePicker.GroupTypes            = new GroupTypeService(new RockContext()).Queryable().OrderBy(a => a.Order).ThenBy(a => a.Name).ToList();
            groupTypePicker.SelectedIndexChanged += groupTypePicker_SelectedIndexChanged;
            groupTypePicker.AutoPostBack          = true;
            groupTypePicker.SelectedGroupTypeId   = selectedGroupTypeId;
            filterControl.Controls.Add(groupTypePicker);

            cblRole       = new RockCheckBoxList();
            cblRole.Label = "with Group Role(s)";
            cblRole.ID    = filterControl.ID + "_cblRole";
            filterControl.Controls.Add(cblRole);

            PopulateGroupRolesCheckList(groupTypePicker.SelectedGroupTypeId ?? 0);

            return(new Control[2] {
                groupTypePicker, cblRole
            });
        }
예제 #8
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            Panel pnlGroupAttributeFilterControls = new Panel();

            pnlGroupAttributeFilterControls.ViewStateMode = ViewStateMode.Disabled;
            pnlGroupAttributeFilterControls.ID            = filterControl.ID + "_pnlGroupAttributeFilterControls";
            filterControl.Controls.Add(pnlGroupAttributeFilterControls);

            GroupTypePicker groupTypePicker = new GroupTypePicker();

            groupTypePicker.ID                    = filterControl.ID + "_groupTypePicker";
            groupTypePicker.Label                 = "Group Type";
            groupTypePicker.GroupTypes            = new GroupTypeService(new RockContext()).Queryable().OrderBy(a => a.Order).ThenBy(a => a.Name).ToList();
            groupTypePicker.SelectedIndexChanged += groupTypePicker_SelectedIndexChanged;
            groupTypePicker.AutoPostBack          = true;
            pnlGroupAttributeFilterControls.Controls.Add(groupTypePicker);

            // set the GroupTypePicker selected value now so we can create the other controls the depending on know the groupTypeid
            int?groupTypeId = filterControl.Page.Request.Params[groupTypePicker.UniqueID].AsIntegerOrNull();

            groupTypePicker.SelectedGroupTypeId = groupTypeId;
            groupTypePicker_SelectedIndexChanged(groupTypePicker, new EventArgs());

            return(new Control[] { pnlGroupAttributeFilterControls });
        }
예제 #9
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            var gtpGroupType = new GroupTypePicker();

            gtpGroupType.ID = filterControl.ID + "_0";
            gtpGroupType.AddCssClass("js-group-type");
            filterControl.Controls.Add(gtpGroupType);

            gtpGroupType.UseGuidAsValue = true;
            gtpGroupType.IsSortedByName = true;
            gtpGroupType.GroupTypes     = new GroupTypeService(new RockContext()).Queryable().ToList();

            var cbChildGroupTypes = new RockCheckBox();

            cbChildGroupTypes.ID = filterControl.ID + "_cbChildGroupTypes";
            cbChildGroupTypes.AddCssClass("js-child-group-types");
            cbChildGroupTypes.Text = "Include Child Group Types(s)";
            filterControl.Controls.Add(cbChildGroupTypes);

            var ddlIntegerCompare = ComparisonHelper.ComparisonControl(ComparisonHelper.NumericFilterComparisonTypes);

            ddlIntegerCompare.Label = "Attendance Count";
            ddlIntegerCompare.ID    = filterControl.ID + "_ddlIntegerCompare";
            ddlIntegerCompare.AddCssClass("js-filter-compare");
            filterControl.Controls.Add(ddlIntegerCompare);

            var tbAttendedCount = new RockTextBox();

            tbAttendedCount.ID    = filterControl.ID + "_2";
            tbAttendedCount.Label = "&nbsp;"; // give it whitespace label so it lines up nicely
            tbAttendedCount.AddCssClass("js-attended-count");
            filterControl.Controls.Add(tbAttendedCount);

            var slidingDateRangePicker = new SlidingDateRangePicker();

            slidingDateRangePicker.Label = "Date Range";
            slidingDateRangePicker.ID    = filterControl.ID + "_slidingDateRangePicker";
            slidingDateRangePicker.AddCssClass("js-sliding-date-range");
            filterControl.Controls.Add(slidingDateRangePicker);

            var controls = new Control[5] {
                gtpGroupType, cbChildGroupTypes, ddlIntegerCompare, tbAttendedCount, slidingDateRangePicker
            };

            // convert pipe to comma delimited
            var defaultDelimitedValues = slidingDateRangePicker.DelimitedValues.Replace("|", ",");
            var defaultCount           = 4;

            // set the default values in case this is a newly added filter
            SetSelection(
                entityType,
                controls,
                string.Format("{0}|{1}|{2}|{3}|false", gtpGroupType.Items.Count > 0 ? gtpGroupType.Items[0].Value : "0", ComparisonType.GreaterThanOrEqualTo.ConvertToInt().ToString(), defaultCount, defaultDelimitedValues));

            return(controls);
        }
예제 #10
0
        /// <summary>
        /// Creates the control(s) neccessary 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)
        {
            var editControl = new GroupTypePicker {
                ID = id
            };

            editControl.GroupTypes = new GroupTypeService().Queryable()
                                     .OrderBy(a => a.Name).ToList();
            return(editControl);
        }
예제 #11
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            GroupTypePicker groupTypePicker = new GroupTypePicker();

            groupTypePicker.ID         = filterControl.ID + "_groupTypePicker";
            groupTypePicker.Label      = "Group Type";
            groupTypePicker.GroupTypes = new GroupTypeService(new RockContext()).Queryable().OrderBy(a => a.Order).ThenBy(a => a.Name).ToList();
            filterControl.Controls.Add(groupTypePicker);

            return(new Control[] { groupTypePicker });
        }
        /// <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 groupTypePicker = new GroupTypePicker();

            groupTypePicker.ID         = parentControl.ID + "_0";
            groupTypePicker.Label      = "Group Type";
            groupTypePicker.GroupTypes = new GroupTypeService(new RockContext()).Queryable().OrderBy(a => a.Order).ThenBy(a => a.Name).ToList();
            parentControl.Controls.Add(groupTypePicker);

            return(new Control[1] {
                groupTypePicker
            });
        }
예제 #13
0
        /// <summary>
        /// Ensures that the controls that are created based on the GroupType have been created
        /// </summary>
        /// <param name="groupTypePicker">The group type picker.</param>
        private void EnsureSelectedGroupTypeControls(GroupTypePicker groupTypePicker)
        {
            DynamicControlsPanel containerControl = groupTypePicker.Parent as DynamicControlsPanel;
            FilterField          filterControl    = containerControl.FirstParentControlOfType <FilterField>();

            var entityFields = GetGroupMemberAttributes(groupTypePicker.SelectedGroupTypeId);

            // Create the field selection dropdown
            string           propertyControlId = string.Format("{0}_ddlProperty", containerControl.ID);
            RockDropDownList ddlProperty       = containerControl.Controls.OfType <RockDropDownList>().FirstOrDefault(a => a.ID == propertyControlId);

            if (ddlProperty == null)
            {
                ddlProperty                       = new RockDropDownList();
                ddlProperty.ID                    = propertyControlId;
                ddlProperty.AutoPostBack          = true;
                ddlProperty.SelectedIndexChanged += ddlProperty_SelectedIndexChanged;
                ddlProperty.AddCssClass("js-property-dropdown");
                containerControl.Controls.Add(ddlProperty);
            }

            // update the list of items just in case the GroupType changed
            ddlProperty.Items.Clear();

            // add Empty option first
            ddlProperty.Items.Add(new ListItem());
            foreach (var entityField in entityFields)
            {
                // Add the field to the dropdown of available fields
                ddlProperty.Items.Add(new ListItem(entityField.TitleWithoutQualifier, entityField.UniqueName));
            }

            if (groupTypePicker.Page.IsPostBack)
            {
                ddlProperty.SetValue(groupTypePicker.Page.Request.Params[ddlProperty.UniqueID]);
            }

            foreach (var entityField in entityFields)
            {
                string controlId = string.Format("{0}_{1}", containerControl.ID, entityField.UniqueName);
                if (!containerControl.Controls.OfType <Control>().Any(a => a.ID == controlId))
                {
                    var control = entityField.FieldType.Field.FilterControl(entityField.FieldConfig, controlId, true, filterControl.FilterMode);
                    if (control != null)
                    {
                        containerControl.Controls.Add(control);
                    }
                }
            }
        }
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            int?selectedGroupTypeId = null;

            if (groupTypePicker != null)
            {
                selectedGroupTypeId = groupTypePicker.SelectedGroupTypeId;
            }

            groupTypePicker                       = new GroupTypePicker();
            groupTypePicker.ID                    = filterControl.ID + "_groupTypePicker";
            groupTypePicker.Label                 = "Group Type";
            groupTypePicker.GroupTypes            = new GroupTypeService(new RockContext()).Queryable().OrderBy(a => a.Order).ThenBy(a => a.Name).ToList();
            groupTypePicker.SelectedIndexChanged += groupTypePicker_SelectedIndexChanged;
            groupTypePicker.AutoPostBack          = true;
            groupTypePicker.SelectedGroupTypeId   = selectedGroupTypeId;
            filterControl.Controls.Add(groupTypePicker);

            cblRole       = new RockCheckBoxList();
            cblRole.Label = "with Group Role(s)";
            cblRole.ID    = filterControl.ID + "_cblRole";
            filterControl.Controls.Add(cblRole);

            PopulateGroupRolesCheckList(groupTypePicker.SelectedGroupTypeId ?? 0);

            RockDropDownList ddlGroupMemberStatus = new RockDropDownList();

            ddlGroupMemberStatus.CssClass = "js-group-member-status";
            ddlGroupMemberStatus.ID       = filterControl.ID + "_ddlGroupMemberStatus";
            ddlGroupMemberStatus.Label    = "with Group Member Status";
            ddlGroupMemberStatus.Help     = "Select a specific group member status to only include group members with that status. Leaving this blank will return all members.";
            ddlGroupMemberStatus.BindToEnum <GroupMemberStatus>(true);
            ddlGroupMemberStatus.SetValue(GroupMemberStatus.Active.ConvertToInt());
            filterControl.Controls.Add(ddlGroupMemberStatus);

            RockDropDownList ddlGroupStatus = new RockDropDownList();

            ddlGroupStatus.CssClass = "js-group-status";
            ddlGroupStatus.ID       = filterControl.ID + "_ddlGroupStatus";
            ddlGroupStatus.Label    = "with Group Status";
            ddlGroupStatus.Items.Insert(0, new ListItem("[All]", ""));
            ddlGroupStatus.Items.Insert(1, new ListItem("Active", "True"));
            ddlGroupStatus.Items.Insert(2, new ListItem("Inactive", "False"));
            ddlGroupStatus.SetValue(true.ToString());
            filterControl.Controls.Add(ddlGroupStatus);

            return(new Control[4] {
                groupTypePicker, cblRole, ddlGroupStatus, ddlGroupMemberStatus
            });
        }
예제 #15
0
        /// <summary>
        /// Sets the value. ( as Guid )
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="value">The value.</param>
        public override void SetEditValue(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues, string value)
        {
            GroupTypePicker groupTypePicker = control as GroupTypePicker;

            if (groupTypePicker != null)
            {
                Guid?          groupTypeGuid = value.AsGuidOrNull();
                GroupTypeCache groupType     = null;
                if (groupTypeGuid.HasValue)
                {
                    groupType = GroupTypeCache.Get(groupTypeGuid.Value);
                }

                groupTypePicker.SelectedGroupTypeId = groupType?.Id;
            }
        }
예제 #16
0
        /// <summary>
        /// Sets the value. ( as Guid )
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="value">The value.</param>
        public override void SetEditValue(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues, string value)
        {
            GroupTypePicker groupTypePicker = control as GroupTypePicker;

            if (groupTypePicker != null && !string.IsNullOrWhiteSpace(value))
            {
                Guid groupTypeGuid = Guid.Empty;
                if (Guid.TryParse(value, out groupTypeGuid))
                {
                    groupTypePicker.SelectedGroupTypeId = new GroupTypeService(new RockContext()).Queryable()
                                                          .Where(g => g.Guid.Equals(groupTypeGuid))
                                                          .Select(g => g.Id)
                                                          .FirstOrDefault();
                }
            }
        }
예제 #17
0
        /// <summary>
        /// Gets the selection.
        /// </summary>
        /// <param name="entityType">Type of the entity.</param>
        /// <param name="controls">The controls.</param>
        /// <param name="filterMode"></param>
        /// <returns></returns>
        public override string GetSelection(Type entityType, Control[] controls, FilterMode filterMode)
        {
            var values = new List <string>();

            if (controls.Length > 0)
            {
                var containerControl = controls[0] as DynamicControlsPanel;
                if (containerControl.Controls.Count >= 1)
                {
                    // note: since this datafilter creates additional controls outside of CreateChildControls(), we'll use our _controlsToRender instead of the controls parameter
                    GroupTypePicker groupTypePicker = containerControl.Controls[0] as GroupTypePicker;
                    Guid            groupTypeGuid   = Guid.Empty;
                    var             groupType       = GroupTypeCache.Read(groupTypePicker.SelectedGroupTypeId ?? 0);
                    if (groupType != null)
                    {
                        if (containerControl.Controls.Count == 1)
                        {
                            groupTypePicker_SelectedIndexChanged(groupTypePicker, new EventArgs());
                        }

                        if (containerControl.Controls.Count > 1)
                        {
                            DropDownList ddlProperty = containerControl.Controls[1] as DropDownList;

                            var entityFields = GetGroupAttributes(groupType.Id);
                            var entityField  = entityFields.FirstOrDefault(f => f.Name == ddlProperty.SelectedValue);
                            if (entityField != null)
                            {
                                var panelControls = new List <Control>();
                                panelControls.AddRange(containerControl.Controls.OfType <Control>());

                                var control = panelControls.FirstOrDefault(c => c.ID.EndsWith(entityField.Name));
                                if (control != null)
                                {
                                    values.Add(groupType.Guid.ToString());
                                    values.Add(ddlProperty.SelectedValue);
                                    entityField.FieldType.Field.GetFilterValues(control, entityField.FieldConfig, filterMode).ForEach(v => values.Add(v));
                                }
                            }
                        }
                    }
                }
            }

            return(values.ToJson());
        }
예제 #18
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <param name="parentControl"></param>
        /// <returns></returns>
        public override System.Web.UI.Control[] CreateChildControls(System.Web.UI.Control parentControl)
        {
            RockRadioButtonList rblShowAsLinkType = new RockRadioButtonList();

            rblShowAsLinkType.ID = parentControl.ID + "_rblShowAsLinkType";
            rblShowAsLinkType.Items.Add(new ListItem("Show Name Only", ShowAsLinkType.NameOnly.ConvertToInt().ToString()));
            rblShowAsLinkType.Items.Add(new ListItem("Show as Person Link", ShowAsLinkType.PersonLink.ConvertToInt().ToString()));
            rblShowAsLinkType.Items.Add(new ListItem("Show as Group Member Link", ShowAsLinkType.GroupMemberLink.ConvertToInt().ToString()));
            parentControl.Controls.Add(rblShowAsLinkType);

            var groupTypePicker = new GroupTypePicker();

            groupTypePicker.ID                    = parentControl.ID + "_groupTypePicker";
            groupTypePicker.Label                 = "Group Type";
            groupTypePicker.CssClass              = "js-grouptype-picker";
            groupTypePicker.GroupTypes            = new GroupTypeService(new RockContext()).Queryable().OrderBy(a => a.Order).ThenBy(a => a.Name).ToList();
            groupTypePicker.SelectedIndexChanged += groupTypePicker_SelectedIndexChanged;
            groupTypePicker.AutoPostBack          = true;
            parentControl.Controls.Add(groupTypePicker);

            int?selectedGroupTypeId = parentControl.Page.Request.Params[groupTypePicker.UniqueID].AsIntegerOrNull();

            groupTypePicker.SelectedGroupTypeId = selectedGroupTypeId;

            var cblRole = new RockCheckBoxList();

            cblRole.Label    = "with Group Role(s)";
            cblRole.CssClass = "js-group-role";
            cblRole.ID       = parentControl.ID + "_cblRole";
            parentControl.Controls.Add(cblRole);

            PopulateGroupRolesCheckList(groupTypePicker);

            RockDropDownList ddlGroupMemberStatus = new RockDropDownList();

            ddlGroupMemberStatus.CssClass = "js-group-member-status";
            ddlGroupMemberStatus.ID       = parentControl.ID + "_ddlGroupMemberStatus";
            ddlGroupMemberStatus.Label    = "with Group Member Status";
            ddlGroupMemberStatus.Help     = "Select a specific group member status to only include group members with that status. Leaving this blank will return all members.";
            ddlGroupMemberStatus.BindToEnum <GroupMemberStatus>(true);
            ddlGroupMemberStatus.SetValue(GroupMemberStatus.Active.ConvertToInt());
            parentControl.Controls.Add(ddlGroupMemberStatus);

            return(new System.Web.UI.Control[] { rblShowAsLinkType, groupTypePicker, cblRole, ddlGroupMemberStatus });
        }
예제 #19
0
        /// <summary>
        /// Handles the SelectedIndexChanged event of the groupTypePicker control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        public void groupTypePicker_SelectedIndexChanged(object sender, EventArgs e)
        {
            GroupTypePicker      groupTypePicker  = sender as GroupTypePicker;
            DynamicControlsPanel containerControl = groupTypePicker.Parent as DynamicControlsPanel;
            FilterField          filterControl    = containerControl.FirstParentControlOfType <FilterField>();

            containerControl.Controls.Clear();
            containerControl.Controls.Add(groupTypePicker);

            // Create the field selection dropdown
            var ddlProperty = new RockDropDownList();

            ddlProperty.ID = string.Format("{0}_{1}_ddlProperty", containerControl.ID, groupTypePicker.SelectedGroupTypeId);
            containerControl.Controls.Add(ddlProperty);

            // add Empty option first
            ddlProperty.Items.Add(new ListItem());

            this.entityFields = GetGroupAttributes(groupTypePicker.SelectedGroupTypeId);
            foreach (var entityField in this.entityFields)
            {
                string controlId = string.Format("{0}_{1}", containerControl.ID, entityField.Name);
                var    control   = entityField.FieldType.Field.FilterControl(entityField.FieldConfig, controlId, true, filterControl.FilterMode);
                if (control != null)
                {
                    // Add the field to the dropdown of available fields
                    ddlProperty.Items.Add(new ListItem(entityField.TitleWithoutQualifier, entityField.Name));
                    containerControl.Controls.Add(control);
                }
            }

            ddlProperty.AutoPostBack = true;

            // grab the currently selected value off of the request params since we are creating the controls after the Page Init
            var selectedValue = ddlProperty.Page.Request.Params[ddlProperty.UniqueID];

            if (selectedValue != null)
            {
                ddlProperty.SelectedValue = selectedValue;
                ddlProperty_SelectedIndexChanged(ddlProperty, new EventArgs());
            }

            ddlProperty.SelectedIndexChanged += ddlProperty_SelectedIndexChanged;
        }
예제 #20
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            groupTypePicker                       = new GroupTypePicker();
            groupTypePicker.ID                    = filterControl.ID + "_0";
            groupTypePicker.Label                 = "Group Type";
            groupTypePicker.GroupTypes            = new GroupTypeService().Queryable().OrderBy(a => a.Order).ThenBy(a => a.Name).ToList();
            groupTypePicker.SelectedIndexChanged += groupTypePicker_SelectedIndexChanged;
            groupTypePicker.AutoPostBack          = true;
            filterControl.Controls.Add(groupTypePicker);

            cblRole       = new RockCheckBoxList();
            cblRole.Label = "with Group Role(s)";
            cblRole.ID    = filterControl.ID + "_1";
            filterControl.Controls.Add(cblRole);

            return(new Control[2] {
                groupTypePicker, cblRole
            });
        }
예제 #21
0
        /// <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)
        {
            var editControl = new GroupTypePicker {
                ID = id
            };
            var qryGroupTypes = new GroupTypeService(new RockContext()).Queryable();

            if (configurationValues.ContainsKey(GROUP_TYPE_PURPOSE_VALUE_GUID))
            {
                var groupTypePurposeValueGuid = (configurationValues[GROUP_TYPE_PURPOSE_VALUE_GUID]).Value.AsGuidOrNull();
                if (groupTypePurposeValueGuid.HasValue)
                {
                    qryGroupTypes = qryGroupTypes.Where(a => a.GroupTypePurposeValue.Guid == groupTypePurposeValueGuid.Value);
                }
            }

            editControl.GroupTypes = qryGroupTypes.OrderBy(a => a.Name).ToList();
            return(editControl);
        }
예제 #22
0
        /// <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>
        /// <param name="filterMode"></param>
        public override void RenderControls(Type entityType, FilterField filterControl, HtmlTextWriter writer, Control[] controls, FilterMode filterMode)
        {
            if (controls.Length > 0)
            {
                var containerControl = controls[0] as DynamicControlsPanel;
                if (containerControl.Controls.Count >= 2)
                {
                    GroupTypePicker groupTypePicker = containerControl.Controls[0] as GroupTypePicker;
                    groupTypePicker.RenderControl(writer);

                    DropDownList ddlEntityField = containerControl.Controls[1] as DropDownList;
                    var          entityFields   = GetGroupAttributes(groupTypePicker.SelectedGroupTypeId);

                    var panelControls = new List <Control>();
                    panelControls.AddRange(containerControl.Controls.OfType <Control>());

                    RenderEntityFieldsControls(entityType, filterControl, writer, entityFields, ddlEntityField, panelControls, containerControl.ID, filterMode);
                }
            }
        }
예제 #23
0
        /// <summary>
        /// Reads new values entered by the user for the field
        /// </summary>
        /// <param name="control">Parent control that controls were added to in the CreateEditControl() method</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <returns></returns>
        public override string GetEditValue(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues)
        {
            List <string> values = new List <string>();

            GroupTypePicker groupTypePicker = control as GroupTypePicker;

            if (groupTypePicker != null)
            {
                if (groupTypePicker.SelectedGroupTypeId.HasValue)
                {
                    var groupType = GroupTypeCache.Read(groupTypePicker.SelectedGroupTypeId.Value);
                    if (groupType != null)
                    {
                        return(groupType.Guid.ToString());
                    }
                }
            }

            return(null);
        }
예제 #24
0
        /// <summary>
        /// Populates the group roles check list.
        /// </summary>
        /// <param name="groupTypePicker">The group type picker.</param>
        private void PopulateGroupRolesCheckList(GroupTypePicker groupTypePicker)
        {
            var groupTypeId          = groupTypePicker.SelectedGroupTypeId;
            RockCheckBoxList cblRole = groupTypePicker.Parent.ControlsOfTypeRecursive <RockCheckBoxList>().FirstOrDefault(a => a.HasCssClass("js-group-role"));

            if (groupTypeId.HasValue)
            {
//                cblRole.Items.Clear();
                foreach (var item in new GroupTypeRoleService(new RockContext()).GetByGroupTypeId(groupTypeId.Value))
                {
                    cblRole.Items.Add(new ListItem(item.Name, item.Guid.ToString()));
                }

                cblRole.Style[HtmlTextWriterStyle.Display] = cblRole.Items.Count > 0 ? "" : "none";
            }
            else
            {
                cblRole.Style[HtmlTextWriterStyle.Display] = "none";
            }
        }
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <param name="parentControl"></param>
        /// <returns></returns>
        public override System.Web.UI.Control[] CreateChildControls(System.Web.UI.Control parentControl)
        {
            int?selectedGroupTypeId = null;

            if (groupTypePicker != null)
            {
                selectedGroupTypeId = groupTypePicker.SelectedGroupTypeId;
            }

            groupTypePicker                     = new GroupTypePicker();
            groupTypePicker.ID                  = parentControl.ID + "_0";
            groupTypePicker.Label               = "Group Type";
            groupTypePicker.GroupTypes          = new GroupTypeService(new RockContext()).Queryable().OrderBy(a => a.Order).ThenBy(a => a.Name).ToList();
            groupTypePicker.AutoPostBack        = true;
            groupTypePicker.SelectedGroupTypeId = selectedGroupTypeId;
            parentControl.Controls.Add(groupTypePicker);

            return(new Control[1] {
                groupTypePicker
            });
        }
예제 #26
0
        /// <summary>
        /// Sets the selection.
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="controls">The controls.</param>
        /// <param name="selection">The selection.</param>
        public override void SetSelection(Type entityType, Control[] controls, string selection)
        {
            var settings = new FilterSettings(selection);

            if (!settings.IsValid)
            {
                return;
            }

            if (controls.Length > 0)
            {
                int?groupTypeId = settings.GroupTypeId;

                var containerControl = controls[0] as DynamicControlsPanel;
                if (containerControl.Controls.Count > 0)
                {
                    GroupTypePicker groupTypePicker = containerControl.Controls[0] as GroupTypePicker;
                    groupTypePicker.SelectedGroupTypeId = groupTypeId;
                    EnsureSelectedGroupTypeControls(groupTypePicker);
                }

                if (containerControl.Controls.Count > 1)
                {
                    DropDownList ddlProperty  = containerControl.Controls[1] as DropDownList;
                    var          entityFields = GetGroupMemberAttributes(groupTypeId);

                    var panelControls = new List <Control>();
                    panelControls.AddRange(containerControl.Controls.OfType <Control>());

                    var parameters = new List <string> {
                        settings.AttributeKey
                    };

                    parameters.AddRange(settings.AttributeFilterSettings);

                    SetEntityFieldSelection(entityFields, ddlProperty, parameters, panelControls);
                }
            }
        }
예제 #27
0
        /// <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 groupTypePicker = new GroupTypePicker();

            groupTypePicker.ID                    = parentControl.ID + "_groupTypePicker";
            groupTypePicker.Label                 = "Group Type";
            groupTypePicker.GroupTypes            = new GroupTypeService(new RockContext()).Queryable().ToList();
            groupTypePicker.SelectedIndexChanged += groupTypePicker_SelectedIndexChanged;
            groupTypePicker.AutoPostBack          = true;
            parentControl.Controls.Add(groupTypePicker);

            int?selectedGroupTypeId = parentControl.Page.Request.Params[groupTypePicker.UniqueID].AsIntegerOrNull();

            groupTypePicker.SelectedGroupTypeId = selectedGroupTypeId;

            var cblRole = new RockCheckBoxList();

            cblRole.Label = "with Group Role(s)";
            cblRole.ID    = parentControl.ID + "_cblRole";
            parentControl.Controls.Add(cblRole);

            PopulateGroupRolesCheckList(groupTypePicker.SelectedGroupTypeId ?? 0, cblRole);

            RockDropDownList ddlGroupMemberStatus = new RockDropDownList();

            ddlGroupMemberStatus.CssClass = "js-group-member-status";
            ddlGroupMemberStatus.ID       = parentControl.ID + "_ddlGroupMemberStatus";
            ddlGroupMemberStatus.Label    = "with Group Member Status";
            ddlGroupMemberStatus.Help     = "Select a specific group member status only include to only show true for group members with that status. Leaving this blank will return true for all members.";
            ddlGroupMemberStatus.BindToEnum <GroupMemberStatus>(true);
            ddlGroupMemberStatus.SetValue(GroupMemberStatus.Active.ConvertToInt());
            parentControl.Controls.Add(ddlGroupMemberStatus);

            return(new Control[3] {
                groupTypePicker, cblRole, ddlGroupMemberStatus
            });
        }
예제 #28
0
        /// <summary>
        /// Gets the selection.
        /// </summary>
        /// <param name="entityType">Type of the entity.</param>
        /// <param name="controls">The controls.</param>
        /// <param name="filterMode"></param>
        /// <returns></returns>
        public override string GetSelection(Type entityType, Control[] controls, FilterMode filterMode)
        {
            var settings = new FilterSettings();

            if (controls.Length > 0)
            {
                var containerControl = controls[0] as DynamicControlsPanel;
                if (containerControl.Controls.Count >= 1)
                {
                    // note: since this datafilter creates additional controls outside of CreateChildControls(), we'll use our _controlsToRender instead of the controls parameter
                    GroupTypePicker groupTypePicker = containerControl.Controls[0] as GroupTypePicker;
                    Guid            groupTypeGuid   = Guid.Empty;
                    var             groupTypeId     = groupTypePicker.SelectedGroupTypeId;

                    if (containerControl.Controls.Count > 1)
                    {
                        DropDownList ddlProperty = containerControl.Controls[1] as DropDownList;
                        settings.AttributeKey = ddlProperty.SelectedValue;
                        var entityFields = GetGroupMemberAttributes(groupTypeId);
                        var entityField  = entityFields.FirstOrDefault(f => f.UniqueName == ddlProperty.SelectedValue);
                        if (entityField != null)
                        {
                            var panelControls = new List <Control>();
                            panelControls.AddRange(containerControl.Controls.OfType <Control>());

                            var control = panelControls.FirstOrDefault(c => c.ID.EndsWith(entityField.UniqueName));
                            if (control != null)
                            {
                                entityField.FieldType.Field.GetFilterValues(control, entityField.FieldConfig, filterMode).ForEach(v => settings.AttributeFilterSettings.Add(v));
                            }
                        }
                    }
                }
            }

            return(settings.ToSelectionString());
        }
예제 #29
0
        /// <summary>
        /// Handles the SelectedIndexChanged event of the groupTypePicker control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        public void groupTypePicker_SelectedIndexChanged(object sender, EventArgs e)
        {
            GroupTypePicker groupTypePicker = sender as GroupTypePicker;

            EnsureSelectedGroupTypeControls(groupTypePicker);
        }