Example #1
0
        /// <summary>
        /// Populates the tag list.
        /// </summary>
        private void PopulateTagList(FilterField filterField)
        {
            int entityTypePersonId = EntityTypeCache.GetId(typeof(Rock.Model.Person)) ?? 0;
            var tagQry             = new TagService(new RockContext()).Queryable("OwnerPersonAlias").Where(a => a.EntityTypeId == entityTypePersonId);

            var      rblTagType = filterField.ControlsOfTypeRecursive <RockRadioButtonList>().FirstOrDefault(a => a.HasCssClass("js-tag-type"));
            var      ddlTagList = filterField.ControlsOfTypeRecursive <RockDropDownList>().FirstOrDefault(a => a.HasCssClass("js-tag-filter-list"));
            RockPage rockPage   = rblTagType.Page as RockPage;

            if (rblTagType.SelectedValueAsInt() == 1)
            {
                // Personal tags - tags where the ownerid is the current person id
                tagQry = tagQry.Where(a => a.OwnerPersonAlias.PersonId == rockPage.CurrentPersonId).OrderBy(a => a.Name);
            }
            else
            {
                // Organizational tags - tags where the ownerid is null
                tagQry = tagQry.Where(a => a.OwnerPersonAlias == null).OrderBy(a => a.Name);
            }

            ddlTagList.Items.Clear();
            var tempTagList = tagQry.ToList();

            foreach (var tag in tagQry.Select(a => new { a.Guid, a.Name }))
            {
                ddlTagList.Items.Add(new ListItem(tag.Name, tag.Guid.ToString()));
            }
        }
        /// <summary>
        /// Populates the connection opportunity list.
        /// </summary>
        /// <param name="filterField">The filter field.</param>
        private void PopulateConnectionOpportunityDropdownList(FilterField filterField)
        {
            var connectionTypePicker        = filterField.ControlsOfTypeRecursive <RockDropDownList>().FirstOrDefault(a => a.HasCssClass("js-connectiontype-picker"));
            var connectionOpportunityPicker = filterField.ControlsOfTypeRecursive <RockDropDownList>().FirstOrDefault(a => a.HasCssClass("js-connectionopportunity-picker"));
            var connectionTypeId            = connectionTypePicker.SelectedValueAsId();

            if (connectionTypeId.HasValue)
            {
                connectionOpportunityPicker.Items.Clear();
                var connectionOpportunityList = new ConnectionOpportunityService(new RockContext()).Queryable().Where(a => a.ConnectionTypeId == connectionTypeId.Value && a.IsActive)
                                                .OrderBy(a => a.Order)
                                                .ThenBy(a => a.Name)
                                                .ToList();
                foreach (var connectionOpportunity in connectionOpportunityList)
                {
                    connectionOpportunityPicker.Items.Add(new ListItem(connectionOpportunity.Name, connectionOpportunity.Id.ToString()));
                }

                connectionOpportunityPicker.Visible = connectionOpportunityPicker.Items.Count > 0;
            }
            else
            {
                connectionOpportunityPicker.Visible = false;
            }
        }
Example #3
0
        /// <summary>
        /// Populates the selection lists for Step Type and Step Status.
        /// </summary>
        /// <param name="filterField">The filter field.</param>
        private void PopulateStepProgramRelatedSelectionLists(FilterField filterField)
        {
            var dataContext = new RockContext();

            var programService = new StepProgramService(dataContext);

            SingleEntityPicker <StepProgram> stepProgramSingleEntityPicker = filterField.ControlsOfTypeRecursive <SingleEntityPicker <StepProgram> >().FirstOrDefault(c => c.HasCssClass("js-step-program-picker"));
            RockCheckBoxList cblStepType    = filterField.ControlsOfTypeRecursive <RockCheckBoxList>().FirstOrDefault(c => c.HasCssClass("js-step-type"));
            RockCheckBoxList _cblStepStatus = filterField.ControlsOfTypeRecursive <RockCheckBoxList>().FirstOrDefault(c => c.HasCssClass("js-step-status"));

            int?stepProgramId = stepProgramSingleEntityPicker.SelectedId;

            StepProgram stepProgram = null;

            if (stepProgramId != null)
            {
                stepProgram = programService.Get(stepProgramId.Value);
            }

            if (stepProgram != null)
            {
                // Step Type list
                cblStepType.Items.Clear();

                var stepTypeService = new StepTypeService(dataContext);

                var stepTypes = stepTypeService.Queryable().Where(x => x.StepProgramId == stepProgramId);

                foreach (var item in stepTypes)
                {
                    cblStepType.Items.Add(new ListItem(item.Name, item.Guid.ToString()));
                }

                cblStepType.Visible = cblStepType.Items.Count > 0;

                // Step Status list
                _cblStepStatus.Items.Clear();

                var stepStatusService = new StepStatusService(dataContext);

                var stepStatuses = stepStatusService.Queryable().Where(x => x.StepProgramId == stepProgramId);

                foreach (var item in stepStatuses)
                {
                    _cblStepStatus.Items.Add(new ListItem(item.Name, item.Guid.ToString()));
                }

                _cblStepStatus.Visible = _cblStepStatus.Items.Count > 0;
            }
            else
            {
                cblStepType.Visible    = false;
                _cblStepStatus.Visible = false;
            }
        }
Example #4
0
        /// <summary>
        /// Handles the SelectedIndexChanged event of the ddlInteractionChannel control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void ddlInteractionChannel_SelectedIndexChanged(object sender, EventArgs e)
        {
            FilterField filterField = (sender as Control).FirstParentControlOfType <FilterField>();

            var ddlInteractionChannel   = filterField.ControlsOfTypeRecursive <RockDropDownList>().FirstOrDefault(a => a.HasCssClass("js-interaction-channel"));
            var ddlInteractionComponent = filterField.ControlsOfTypeRecursive <RockDropDownList>().FirstOrDefault(a => a.HasCssClass("js-interaction-component"));

            int?interactionChannelId = ddlInteractionChannel.SelectedValueAsId();

            PopulateInteractionComponent(interactionChannelId, ddlInteractionComponent);
        }
Example #5
0
        /// <summary>
        /// Handles the SelectedIndexChanged event of the ddlProperty control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void ddlProperty_SelectedIndexChanged(object sender, EventArgs e)
        {
            var         ddlEntityField   = sender as RockDropDownList;
            var         containerControl = ddlEntityField.FirstParentControlOfType <DynamicControlsPanel>();
            FilterField filterControl    = ddlEntityField.FirstParentControlOfType <FilterField>();

            RockDropDownList contentChannelTypePicker = filterControl.ControlsOfTypeRecursive <RockDropDownList>().Where(a => a.HasCssClass("js-content-channel-picker")).FirstOrDefault();

            var entityFields = GetContentChannelItemAttributes(contentChannelTypePicker.SelectedValue.AsIntegerOrNull());
            var entityField  = entityFields.FirstOrDefault(a => a.UniqueName == ddlEntityField.SelectedValue);

            if (entityField != null)
            {
                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)
                    {
                        // Add the filter controls of the selected field
                        containerControl.Controls.Add(control);
                    }
                }
            }
        }
Example #6
0
        /// <summary>
        /// Handles the SelectedIndexChanged event of the ddlProperty control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void ddlProperty_SelectedIndexChanged(object sender, EventArgs e)
        {
            var         ddlProperty      = sender as RockDropDownList;
            var         containerControl = ddlProperty.FirstParentControlOfType <DynamicControlsPanel>();
            FilterField filterControl    = ddlProperty.FirstParentControlOfType <FilterField>();
            var         groupTypePicker  = filterControl.ControlsOfTypeRecursive <GroupTypePicker>().Where(a => a.HasCssClass("js-group-type-picker")).FirstOrDefault();

            int?entityTypeId = ddlProperty.Attributes["EntityTypeId"]?.AsIntegerOrNull();

            if (!entityTypeId.HasValue)
            {
                // shouldn't happen;
                return;
            }

            var entityType = EntityTypeCache.Get(entityTypeId.Value).GetEntityType();

            var entityFields = GetGroupMemberAttributes(groupTypePicker.SelectedGroupTypeId);

            var entityField = entityFields.FirstOrDefault(a => a.UniqueName == ddlProperty.SelectedValue);

            if (entityField != null)
            {
                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)
                    {
                        // Add the filter controls of the selected field
                        containerControl.Controls.Add(control);
                    }
                }
            }
        }
        /// <summary>
        /// Handles the SelectItem event of the DvpDataView control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void DvpDataView_SelectItem(object sender, EventArgs e)
        {
            // if selecting another dataview, default the cbUsePersisted to True
            Control     control        = sender as Control;
            FilterField filterField    = control.FirstParentControlOfType <FilterField>();
            var         cbUsePersisted = filterField?.ControlsOfTypeRecursive <RockCheckBox>().Where(a => a.HasCssClass("js-usepersisted")).FirstOrDefault();

            if (cbUsePersisted != null)
            {
                cbUsePersisted.Checked = true;
            }
        }
Example #8
0
        /// <summary>
        /// Populates the group roles.
        /// </summary>
        /// <param name="filterField">The filter field.</param>
        private void PopulateGroupRolesCheckList(FilterField filterField)
        {
            var groupTypePicker = filterField.ControlsOfTypeRecursive <GroupTypePicker>().FirstOrDefault(a => a.HasCssClass("js-grouptype-picker"));
            var cblRole         = filterField.ControlsOfTypeRecursive <RockCheckBoxList>().FirstOrDefault(a => a.HasCssClass("js-group-roles"));
            int?groupTypeId     = groupTypePicker.SelectedValueAsId();

            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.Visible = cblRole.Items.Count > 0;
            }
            else
            {
                cblRole.Visible = false;
            }
        }
Example #9
0
        /// <summary>
        /// Populates the registration instance list.
        /// </summary>
        /// <param name="filterField">The filter field.</param>
        private void PopulateRegistrationInstanceList(FilterField filterField)
        {
            var _ddlRegistrationTemplate = filterField.ControlsOfTypeRecursive <RockDropDownList>().FirstOrDefault(a => a.HasCssClass("js-registration-template"));
            var _ddlRegistrationInstance = filterField.ControlsOfTypeRecursive <RockDropDownList>().FirstOrDefault(a => a.HasCssClass("js-registration-instance"));

            var registrationTemplateId = _ddlRegistrationTemplate.SelectedValue.AsInteger();

            if (registrationTemplateId != 0)
            {
                _ddlRegistrationInstance.Items.Clear();
                _ddlRegistrationInstance.Items.Add(new ListItem("- Any -", string.Empty));
                foreach (var item in new RegistrationInstanceService(new RockContext()).Queryable().Where(r => r.RegistrationTemplateId == registrationTemplateId).OrderBy(r => r.Name))
                {
                    _ddlRegistrationInstance.Items.Add(new ListItem(item.Name, item.Guid.ToString()));
                }

                _ddlRegistrationInstance.Visible = _ddlRegistrationInstance.Items.Count > 1;
            }
            else
            {
                _ddlRegistrationInstance.Visible = false;
            }
        }
Example #10
0
        /// <summary>
        /// Handles the SelectItem event of the gp control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void gp_SelectItem(object sender, EventArgs e)
        {
            FilterField filterField = (sender as Control).FirstParentControlOfType <FilterField>();

            GroupPicker      groupPicker   = filterField.ControlsOfTypeRecursive <GroupPicker>().FirstOrDefault(a => a.HasCssClass("js-group-picker"));
            RockCheckBox     cbChildGroups = filterField.ControlsOfTypeRecursive <RockCheckBox>().FirstOrDefault(a => a.HasCssClass("js-include-child-groups"));
            RockCheckBox     cbChildGroupsPlusDescendants = filterField.ControlsOfTypeRecursive <RockCheckBox>().FirstOrDefault(a => a.HasCssClass("js-include-child-groups-descendants"));
            RockCheckBox     cbIncludeInactiveGroups      = filterField.ControlsOfTypeRecursive <RockCheckBox>().FirstOrDefault(a => a.HasCssClass("js-include-inactive-groups"));
            RockCheckBox     cbIncludeSelectedGroup       = filterField.ControlsOfTypeRecursive <RockCheckBox>().FirstOrDefault(a => a.HasCssClass("js-include-selected-groups"));
            RockCheckBoxList cblRoles = filterField.ControlsOfTypeRecursive <RockCheckBoxList>().FirstOrDefault(a => a.HasCssClass("js-roles"));

            var rockContext = new RockContext();

            var groupIdList  = groupPicker.SelectedValues.AsIntegerList();
            var groupService = new GroupService(rockContext);

            var selectedGroups = groupService.GetByIds(groupIdList).Select(s => new { s.Id, s.GroupTypeId }).ToList();

            if (selectedGroups.Any())
            {
                var        groupTypeRoleService = new GroupTypeRoleService(rockContext);
                var        qryGroupTypeRoles    = groupTypeRoleService.Queryable();
                List <int> selectedGroupTypeIds = selectedGroups.Select(a => a.GroupTypeId).Distinct().ToList();

                if (cbChildGroups.Checked)
                {
                    List <int> childGroupTypeIds = new List <int>();
                    foreach (var groupId in selectedGroups.Select(a => a.Id).ToList())
                    {
                        if (cbChildGroupsPlusDescendants.Checked)
                        {
                            // get all children and descendants of the selected group(s)
                            var descendantGroupTypes = groupService.GetAllDescendentsGroupTypes(groupId, cbIncludeInactiveGroups.Checked);

                            childGroupTypeIds.AddRange(descendantGroupTypes.Select(a => a.Id).ToList());
                        }
                        else
                        {
                            // get only immediate children of the selected group(s)
                            var childGroups = groupService.Queryable().Where(a => a.ParentGroupId == groupId);
                            if (!cbIncludeInactiveGroups.Checked)
                            {
                                childGroups = childGroups.Where(a => a.IsActive == true);
                            }

                            childGroupTypeIds.AddRange(childGroups.Select(a => a.GroupTypeId).Distinct().ToList());
                        }
                    }

                    childGroupTypeIds = childGroupTypeIds.Distinct().ToList();

                    if (cbIncludeSelectedGroup.Checked)
                    {
                        qryGroupTypeRoles = qryGroupTypeRoles.Where(a => a.GroupTypeId.HasValue && (selectedGroupTypeIds.Contains(a.GroupTypeId.Value) || childGroupTypeIds.Contains(a.GroupTypeId.Value)));
                    }
                    else
                    {
                        qryGroupTypeRoles = qryGroupTypeRoles.Where(a => a.GroupTypeId.HasValue && childGroupTypeIds.Contains(a.GroupTypeId.Value));
                    }
                }
                else
                {
                    qryGroupTypeRoles = qryGroupTypeRoles.Where(a => a.GroupTypeId.HasValue && selectedGroupTypeIds.Contains(a.GroupTypeId.Value));
                }

                var list = qryGroupTypeRoles.OrderBy(a => a.GroupType.Order).ThenBy(a => a.GroupType.Name).ThenBy(a => a.Order).ThenBy(a => a.Name).Select(a => new
                {
                    a.Name,
                    GroupTypeName = a.GroupType.Name,
                    a.Guid
                }).ToList();
                cblRoles.Items.Clear();
                foreach (var item in list)
                {
                    cblRoles.Items.Add(new ListItem(string.Format("{0} ({1})", item.Name, item.GroupTypeName), item.Guid.ToString()));
                }

                cblRoles.Visible = list.Count > 0;
            }
            else
            {
                cblRoles.Visible = false;
            }
        }