Inheritance: System.Web.UI.WebControls.CheckBoxList, IRockControl
        /// <summary>
        /// Creates the HTML controls required to configure this type of field
        /// </summary>
        /// <returns></returns>
        public override List<Control> ConfigurationControls()
        {
            List<Control> controls = new List<Control>();

            var clbSlidingDateRangeTypes = new RockCheckBoxList();
            clbSlidingDateRangeTypes.Label = "Enabled Sliding Date Range Types";
            clbSlidingDateRangeTypes.Help = "Select specific types or leave all blank to use all of them";
            controls.Add( clbSlidingDateRangeTypes );
            var typesList = Enum.GetValues( typeof( SlidingDateRangePicker.SlidingDateRangeType ) ).Cast<SlidingDateRangePicker.SlidingDateRangeType>();
            foreach ( var type in typesList )
            {
                clbSlidingDateRangeTypes.Items.Add( new ListItem( type.ConvertToString(), type.ConvertToInt().ToString() ) );
            }

            var clbSlidingDateRangeUnits = new RockCheckBoxList();
            clbSlidingDateRangeUnits.Label = "Enabled Sliding Date Range Units";
            clbSlidingDateRangeUnits.Help = "Select specific units or leave all blank to use all of them";
            controls.Add( clbSlidingDateRangeUnits );
            var unitsList = Enum.GetValues( typeof( SlidingDateRangePicker.TimeUnitType ) ).Cast<SlidingDateRangePicker.TimeUnitType>();
            foreach ( var type in unitsList )
            {
                clbSlidingDateRangeUnits.Items.Add( new ListItem( type.ConvertToString(), type.ConvertToInt().ToString() ) );
            }

            return controls;
        }
示例#2
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 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 Rock.Web.UI.Controls.RockCheckBoxList {
                    ID = id
                };
                editControl.AddCssClass("checkboxlist-group");
            }
            else
            {
                editControl = new Rock.Web.UI.Controls.RockDropDownList {
                    ID = id
                };
                editControl.Items.Add(new ListItem());
            }

            if (configurationValues != null && configurationValues.ContainsKey(DEFINED_TYPE_KEY))
            {
                int definedTypeId = 0;
                if (Int32.TryParse(configurationValues[DEFINED_TYPE_KEY].Value, out definedTypeId))
                {
                    Rock.Model.DefinedValueService definedValueService = new Model.DefinedValueService();
                    foreach (var definedValue in definedValueService.GetByDefinedTypeId(definedTypeId))
                    {
                        editControl.Items.Add(new ListItem(definedValue.Name, definedValue.Id.ToString()));
                    }
                }
            }

            return(editControl);
        }
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            if (this.Required)
            {
                this.RequiredFieldValidator                 = new RequiredFieldValidator();
                this.RequiredFieldValidator.ID              = this.ID + "_rfv";
                this.RequiredFieldValidator.Display         = ValidatorDisplay.Dynamic;
                this.RequiredFieldValidator.CssClass        = "validation-error help-inline";
                this.RequiredFieldValidator.Enabled         = true;
                this.RequiredFieldValidator.ValidationGroup = this.ValidationGroup;
                Controls.Add(this.RequiredFieldValidator);
            }

            if (EnhanceForLongLists)
            {
                _lboxDefinedValues    = new RockListBox();
                _lboxDefinedValues.ID = this.ID + "_lboxDefinedValues";
                _lboxDefinedValues.Style.Add("width", "85%");
                _lboxDefinedValues.AutoPostBack          = true;
                _lboxDefinedValues.SelectedIndexChanged += lboxDefinedValues_SelectedIndexChanged;
                Controls.Add(_lboxDefinedValues);

                if (this.Required)
                {
                    this.RequiredFieldValidator.ControlToValidate = _lboxDefinedValues.ID;
                }
            }
            else
            {
                _cblDefinedValues    = new RockCheckBoxList();
                _cblDefinedValues.ID = this.ID + "_cblDefinedValues";
                _cblDefinedValues.Style.Add("width", "85%");
                _cblDefinedValues.RepeatColumns         = this.RepeatColumns;
                _cblDefinedValues.RepeatDirection       = this.RepeatDirection;
                _cblDefinedValues.AutoPostBack          = true;
                _cblDefinedValues.SelectedIndexChanged += cblDefinedValues_SelectedIndexChanged;
                Controls.Add(_cblDefinedValues);

                if (this.Required)
                {
                    this.RequiredFieldValidator.ControlToValidate = _cblDefinedValues.ID;
                }
            }

            LinkButtonAddDefinedValue               = new LinkButton();
            LinkButtonAddDefinedValue.ID            = this.ID + "_lbAddDefinedValue";
            LinkButtonAddDefinedValue.Text          = "Add Item";
            LinkButtonAddDefinedValue.CssClass      = "btn btn-default btn-link js-button-add-defined-value";
            LinkButtonAddDefinedValue.OnClientClick = $"javascript:$('.{this.ClientID}-js-defined-value-selector').fadeToggle(400, 'swing', function() {{ $('#{DefinedValueEditorControl.ClientID}').fadeToggle(); }});  return false;";
            Controls.Add(LinkButtonAddDefinedValue);

            DefinedValueEditorControl.IsMultiSelection = true;

            LoadDefinedValues();
        }
示例#4
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 )
        {
            RockCheckBoxList editControl = new RockCheckBoxList { ID = id };
            editControl.RepeatDirection = RepeatDirection.Horizontal;

            foreach ( var item in ListSource )
            {
                ListItem listItem = new ListItem( item.Value, item.Key );
                editControl.Items.Add( listItem );
            }

            return editControl;
        }
示例#5
0
        /// <summary>
        /// Renders the controls necessary for prompting user for a new value and adds them to the parentControl
        /// </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 )
        {
            var editControl = new RockCheckBoxList { ID = id };
            editControl.RepeatDirection = RepeatDirection.Horizontal;

            editControl.Items.Add( "All" );

            foreach(var command in Rock.Lava.LavaHelper.GetLavaCommands() )
            {
                editControl.Items.Add( command );
            }

            return editControl;
        }
示例#6
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 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 Rock.Web.UI.Controls.RockCheckBoxList {
                    ID = id, RepeatDirection = RepeatDirection.Horizontal
                };
                editControl.AddCssClass("checkboxlist-group");
            }
            else
            {
                editControl = new Rock.Web.UI.Controls.RockDropDownList {
                    ID = id
                };
                editControl.Items.Add(new ListItem());
            }

            if (configurationValues != null && configurationValues.ContainsKey(DEFINED_TYPE_KEY))
            {
                int?definedTypeId = configurationValues[DEFINED_TYPE_KEY].Value.AsIntegerOrNull();
                if (definedTypeId.HasValue)
                {
                    Rock.Model.DefinedValueService definedValueService = new Model.DefinedValueService(new RockContext());
                    var definedValues = definedValueService.GetByDefinedTypeId(definedTypeId.Value);
                    if (definedValues.Any())
                    {
                        bool useDescription = configurationValues.ContainsKey(DISPLAY_DESCRIPTION) && configurationValues[DISPLAY_DESCRIPTION].Value.AsBoolean();

                        foreach (var definedValue in definedValues)
                        {
                            editControl.Items.Add(new ListItem(useDescription ? definedValue.Description : definedValue.Value, definedValue.Id.ToString()));
                        }
                    }

                    return(editControl);
                }
            }

            return(null);
        }
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            if (EnhanceForLongLists)
            {
                _lboxDefinedValues    = new RockListBox();
                _lboxDefinedValues.ID = this.ID + "_lboxDefinedValues";
                _lboxDefinedValues.Style.Add("width", "85%");
                _lboxDefinedValues.AutoPostBack          = true;
                _lboxDefinedValues.SelectedIndexChanged += lboxDefinedValues_SelectedIndexChanged;
                Controls.Add(_lboxDefinedValues);
            }
            else
            {
                _cblDefinedValues    = new RockCheckBoxList();
                _cblDefinedValues.ID = this.ID + "_cblDefinedValues";
                _cblDefinedValues.Style.Add("width", "85%");
                _cblDefinedValues.RepeatColumns         = this.RepeatColumns;
                _cblDefinedValues.RepeatDirection       = this.RepeatDirection;
                _cblDefinedValues.AutoPostBack          = true;
                _cblDefinedValues.SelectedIndexChanged += cblDefinedValues_SelectedIndexChanged;
                Controls.Add(_cblDefinedValues);
            }

            LinkButtonAddDefinedValue               = new LinkButton();
            LinkButtonAddDefinedValue.ID            = this.ID + "_lbAddDefinedValue";
            LinkButtonAddDefinedValue.Text          = "Add Item";
            LinkButtonAddDefinedValue.CssClass      = "btn btn-default btn-link js-button-add-defined-value";
            LinkButtonAddDefinedValue.OnClientClick = $"javascript:$('.{this.ClientID}-js-defined-value-selector').fadeToggle(400, 'swing', function() {{ $('#{DefinedValueEditorControl.ClientID}').fadeToggle(); }});  return false;";
            Controls.Add(LinkButtonAddDefinedValue);

            DefinedValueEditorControl.IsMultiSelection = true;

            LoadDefinedValues();
        }
        /// <summary>
        /// Finds all approved prayer requests for the given selected categories and orders them by least prayed-for.
        /// Also updates the prayer count for the first item in the list.
        /// </summary>
        /// <param name="categoriesList"></param>
        private void SetAndDisplayPrayerRequests( RockCheckBoxList categoriesList )
        {
            RockContext rockContext = new RockContext();
            PrayerRequestService service = new PrayerRequestService( rockContext );
            var prayerRequests = service.GetByCategoryIds( categoriesList.SelectedValuesAsInt ).OrderByDescending( p => p.IsUrgent ).ThenBy( p => p.PrayerCount );
            List<int> list = prayerRequests.Select( p => p.Id ).ToList<int>();

            Session[_sessionKey] = list;
            if ( list.Count > 0 )
            {
                UpdateSessionCountLabel( 1, list.Count );
                hfPrayerIndex.Value = "0";
                PrayerRequest request = prayerRequests.First();
                ShowPrayerRequest( request, rockContext );
            }
        }
示例#9
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 Control EditControl( Dictionary<string, ConfigurationValue> configurationValues, string id )
        {
            int entityTypeId = 0;
            string entityTypeName = string.Empty;
            string qualifierColumn = string.Empty;
            string qualifierValue = string.Empty;

            if ( configurationValues != null )
            {
                if ( configurationValues.ContainsKey( ENTITY_TYPE_NAME_KEY ) )
                {
                    entityTypeName = configurationValues[ENTITY_TYPE_NAME_KEY].Value;
                    if ( !string.IsNullOrWhiteSpace( entityTypeName ) && entityTypeName != None.IdValue )
                    {
                        var entityType = EntityTypeCache.Read( entityTypeName );
                        if ( entityType != null )
                        {
                            entityTypeId = entityType.Id;
                        }
                    }
                }
                if ( configurationValues.ContainsKey( QUALIFIER_COLUMN_KEY ) )
                {
                    qualifierColumn = configurationValues[QUALIFIER_COLUMN_KEY].Value;
                }

                if ( configurationValues.ContainsKey( QUALIFIER_VALUE_KEY ) )
                {
                    qualifierValue = configurationValues[QUALIFIER_VALUE_KEY].Value;
                }
            }

            RockCheckBoxList editControl = new RockCheckBoxList { ID = id };
            editControl.RepeatDirection = RepeatDirection.Horizontal;

            using ( var rockContext = new RockContext() )
            {
                if ( string.IsNullOrWhiteSpace( entityTypeName ) )
                {
                    foreach ( var noteType in new NoteTypeService( rockContext )
                        .Queryable()
                        .OrderBy( n => n.EntityType.Name )
                        .ThenBy( n => n.Name ) )
                    {
                        editControl.Items.Add( new ListItem( string.Format( "{0}: {1}", noteType.EntityType.FriendlyName, noteType.Name ), noteType.Guid.ToString().ToUpper() ) );
                    }
                }
                else
                {
                    foreach ( var noteType in new NoteTypeService( rockContext )
                        .Get( entityTypeId, qualifierColumn, qualifierValue )
                        .OrderBy( n => n.Name ) )
                    {
                        editControl.Items.Add( new ListItem( noteType.Name, noteType.Guid.ToString().ToUpper() ) );
                    }
                }
            }

            return editControl;
        }
示例#10
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls( Type entityType, FilterField filterControl )
        {
            gp = new GroupPicker();
            gp.ID = filterControl.ID + "_gp";
            gp.Label = "Group(s)";
            gp.SelectItem += gp_SelectItem;
            gp.CssClass = "js-group-picker";
            gp.AllowMultiSelect = true;
            filterControl.Controls.Add( gp );

            cbChildGroups = new RockCheckBox();
            cbChildGroups.ID = filterControl.ID + "_cbChildsGroups";
            cbChildGroups.Text = "Include Child Group(s)";
            cbChildGroups.CssClass = "js-include-child-groups";
            cbChildGroups.AutoPostBack = true;
            cbChildGroups.CheckedChanged += gp_SelectItem;
            filterControl.Controls.Add( cbChildGroups );

            cbIncludeSelectedGroup = new RockCheckBox();
            cbIncludeSelectedGroup.ID = filterControl.ID + "_cbIncludeSelectedGroup";
            cbIncludeSelectedGroup.Text = "Include Selected Group(s)";
            cbIncludeSelectedGroup.CssClass = "js-include-selected-groups";
            cbIncludeSelectedGroup.AutoPostBack = true;
            cbIncludeSelectedGroup.CheckedChanged += gp_SelectItem;
            filterControl.Controls.Add( cbIncludeSelectedGroup );

            cbChildGroupsPlusDescendants = new RockCheckBox();
            cbChildGroupsPlusDescendants.ID = filterControl.ID + "_cbChildGroupsPlusDescendants";
            cbChildGroupsPlusDescendants.Text = "Include All Descendants(s)";
            cbChildGroupsPlusDescendants.CssClass = "js-include-child-groups-descendants";
            cbChildGroupsPlusDescendants.AutoPostBack = true;
            cbChildGroupsPlusDescendants.CheckedChanged += gp_SelectItem;
            filterControl.Controls.Add( cbChildGroupsPlusDescendants );

            cbIncludeInactiveGroups = new RockCheckBox();
            cbIncludeInactiveGroups.ID = filterControl.ID + "_cbIncludeInactiveGroups";
            cbIncludeInactiveGroups.Text = "Include Inactive Groups";
            cbIncludeInactiveGroups.CssClass = "js-include-inactive-groups";
            cbIncludeInactiveGroups.AutoPostBack = true;
            cbIncludeInactiveGroups.CheckedChanged += gp_SelectItem;
            filterControl.Controls.Add( cbIncludeInactiveGroups );

            cblRole = new RockCheckBoxList();
            cblRole.Label = "with Group Member Role(s) (optional)";
            cblRole.ID = filterControl.ID + "_cblRole";
            cblRole.CssClass = "js-roles";
            cblRole.Visible = false;
            filterControl.Controls.Add( cblRole );

            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 );

            PanelWidget pwAdvanced = new PanelWidget();
            filterControl.Controls.Add( pwAdvanced );
            pwAdvanced.ID = filterControl.ID + "_pwAttributes";
            pwAdvanced.Title = "Advanced Filters";
            pwAdvanced.CssClass = "advanced-panel";

            SlidingDateRangePicker addedOnDateRangePicker = new SlidingDateRangePicker();
            addedOnDateRangePicker.ID = pwAdvanced.ID + "_addedOnDateRangePicker";
            addedOnDateRangePicker.AddCssClass( "js-sliding-date-range" );
            addedOnDateRangePicker.Label = "Date Added:";
            addedOnDateRangePicker.Help = "Select the date range that the person was added to the group. Leaving this blank will not restrict results to a date range.";
            pwAdvanced.Controls.Add( addedOnDateRangePicker );

            return new Control[9] { gp, cbChildGroups, cbIncludeSelectedGroup, cbChildGroupsPlusDescendants, cblRole, ddlGroupMemberStatus, cbIncludeInactiveGroups, addedOnDateRangePicker, pwAdvanced };
        }
        /// <summary>
        /// Adds the group type controls.
        /// </summary>
        /// <param name="groupType">Type of the group.</param>
        /// <param name="pnlGroupTypes">The PNL group types.</param>
        private void AddGroupTypeControls( GroupType groupType, HtmlGenericContainer liGroupTypeItem )
        {
            if ( !_addedGroupTypeIds.Contains( groupType.Id ) )
            {
                _addedGroupTypeIds.Add( groupType.Id );

                if ( groupType.Groups.Any() )
                {
                    bool showGroupAncestry = GetAttributeValue( "ShowGroupAncestry" ).AsBoolean( true );

                    var groupService = new GroupService( _rockContext );

                    var cblGroupTypeGroups = new RockCheckBoxList { ID = "cblGroupTypeGroups" + groupType.Id };

                    cblGroupTypeGroups.Label = groupType.Name;
                    cblGroupTypeGroups.Items.Clear();

                    foreach ( var group in groupType.Groups
                        .Where( g => !g.ParentGroupId.HasValue )
                        .OrderBy( a => a.Order )
                        .ThenBy( a => a.Name )
                        .ToList() )
                    {
                        AddGroupControls( group, cblGroupTypeGroups, groupService, showGroupAncestry );
                    }

                    liGroupTypeItem.Controls.Add( cblGroupTypeGroups );
                }
                else
                {
                    if ( groupType.ChildGroupTypes.Any() )
                    {
                        liGroupTypeItem.Controls.Add( new Label { Text = groupType.Name, ID = "lbl" + groupType.Name } );
                    }
                }

                if ( groupType.ChildGroupTypes.Any() )
                {
                    var ulGroupTypeList = new HtmlGenericContainer( "ul", "rocktree-children" );

                    liGroupTypeItem.Controls.Add( ulGroupTypeList );
                    foreach ( var childGroupType in groupType.ChildGroupTypes.OrderBy( a => a.Order ).ThenBy( a => a.Name ) )
                    {
                        var liChildGroupTypeItem = new HtmlGenericContainer( "li", "rocktree-item rocktree-folder" );
                        liChildGroupTypeItem.ID = "liGroupTypeItem" + childGroupType.Id;
                        ulGroupTypeList.Controls.Add( liChildGroupTypeItem );
                        AddGroupTypeControls( childGroupType, liChildGroupTypeItem );
                    }
                }
            }
        }
        /// <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.SelectedIndexChanged += groupTypePicker_SelectedIndexChanged;
            groupTypePicker.AutoPostBack = true;
            groupTypePicker.SelectedGroupTypeId = selectedGroupTypeId;
            parentControl.Controls.Add( groupTypePicker );

            cblRole = new RockCheckBoxList();
            cblRole.Label = "with Group Role(s)";
            cblRole.ID = parentControl.ID + "_1";
            PopulateGroupRolesCheckList( groupTypePicker.SelectedGroupTypeId ?? 0 );

            parentControl.Controls.Add( cblRole );

            return new Control[2] { groupTypePicker, cblRole };
        }
        /// <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 RockCheckBoxList { ID = id };
                editControl.AddCssClass( "checkboxlist-group" );
            }
            else
            {
                editControl = new RockDropDownList { ID = id };
                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.Read( entityTypeGuid.Value );
                    if ( entityType != null )
                    {
                        Rock.Model.AttributeService attributeService = new Model.AttributeService( new RockContext() );
                        var attributes = attributeService.GetByEntityTypeId( entityType.Id );
                        if ( attributes.Any() )
                        {
                            foreach ( var attribute in attributes.OrderBy( a => a.Name ) )
                            {
                                editControl.Items.Add( new ListItem( attribute.Name, attribute.Id.ToString() ) );
                            }
                        }
                        return editControl;
                    }
                }
            }

            return null;
        }
示例#14
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <param name="parentControl"></param>
        /// <returns></returns>
        public override Control[] CreateChildControls( Control parentControl )
        {
            // Define Control: Family Relationships Checkbox List
            var cblFamilyRelationships = new RockCheckBoxList();
            cblFamilyRelationships.Label = "Include Family Relationship Types";
            cblFamilyRelationships.Help = "These relationship types apply to members of the same Family.";
            cblFamilyRelationships.ID = parentControl.GetChildControlInstanceName( _CtlFamilyRelationshipType );

            var items = cblFamilyRelationships.Items;

            items.Add( new ListItem( "Parent", FamilyRelationshipParentGuid ) );
            items.Add( new ListItem( "Child", FamilyRelationshipChildGuid ) );
            items.Add( new ListItem( "Sibling", FamilyRelationshipSiblingGuid ) );
            items.Add( new ListItem( "Spouse", FamilyRelationshipSpouseGuid ) );

            parentControl.Controls.Add( cblFamilyRelationships );

            // Define Control: Known Relationships Checkbox List
            var cblKnownRelationships = new RockCheckBoxList();
            cblKnownRelationships.Label = "Include Known Relationship Types";
            cblKnownRelationships.Help = "These relationship types apply to People from another Family.";
            cblKnownRelationships.ID = parentControl.GetChildControlInstanceName( _CtlKnownRelationshipType );
            PopulateRelationshipTypesSelector( cblKnownRelationships, SystemGuid.GroupType.GROUPTYPE_KNOWN_RELATIONSHIPS.AsGuid() );

            parentControl.Controls.Add( cblKnownRelationships );

            // Define Control: Output Format DropDown List
            var ddlFormat = new RockDropDownList();
            ddlFormat.ID = parentControl.GetChildControlInstanceName( _CtlFormat );
            ddlFormat.Label = "Output Format";
            ddlFormat.Help = "Specifies the content and format of the items in this field.";
            ddlFormat.Items.Add( new ListItem( "Person Name and Relationship", ListFormatSpecifier.NameAndRelationship.ToString() ) );
            ddlFormat.Items.Add( new ListItem( "Person Name", ListFormatSpecifier.NameOnly.ToString() ) );
            parentControl.Controls.Add( ddlFormat );

            return new Control[] { cblFamilyRelationships, cblKnownRelationships, ddlFormat };
        }
示例#15
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 Control EditControl( Dictionary<string, ConfigurationValue> configurationValues, string id )
        {
            var editControl = new RockCheckBoxList { ID = id }; 

            editControl.RepeatDirection = RepeatDirection.Horizontal;

            if ( configurationValues != null && configurationValues.ContainsKey( "values" ) )
            {
                string listSource = configurationValues["values"].Value;

                if ( listSource.ToUpper().Contains( "SELECT" ) && listSource.ToUpper().Contains( "FROM" ) )
                {
                    var tableValues = new List<string>();
                    DataTable dataTable = new Rock.Data.Service().GetDataTable( listSource, CommandType.Text, null );
                    if ( dataTable != null && dataTable.Columns.Contains( "Value" ) && dataTable.Columns.Contains( "Text" ) )
                    {
                        foreach ( DataRow row in dataTable.Rows )
                        {
                            editControl.Items.Add( new ListItem( row["text"].ToString(), row["value"].ToString() ) );
                        }
                    }
                }

                else
                {
                    foreach ( string keyvalue in listSource.Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries ) )
                    {
                        var keyValueArray = keyvalue.Split( new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries );
                        if ( keyValueArray.Length > 0 )
                        {
                            ListItem li = new ListItem();
                            li.Value = keyValueArray[0];
                            li.Text = keyValueArray.Length > 1 ? keyValueArray[1] : keyValueArray[0];
                            editControl.Items.Add( li );
                        }
                    }
                }
            }
            return editControl;
        }
        /// <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 && configurationValues.ContainsKey( "values" ) )
            {
                var editControl = new RockCheckBoxList { ID = id };
                editControl.RepeatDirection = RepeatDirection.Horizontal;

                string listSource = configurationValues["values"].Value;

                if ( listSource.ToUpper().Contains( "SELECT" ) && listSource.ToUpper().Contains( "FROM" ) )
                {
                    var tableValues = new List<string>();
                    DataTable dataTable = Rock.Data.DbService.GetDataTable( listSource, CommandType.Text, null );
                    if ( dataTable != null && dataTable.Columns.Contains( "Value" ) && dataTable.Columns.Contains( "Text" ) )
                    {
                        foreach ( DataRow row in dataTable.Rows )
                        {
                            editControl.Items.Add( new ListItem( row["text"].ToString(), row["value"].ToString() ) );
                        }
                    }
                }

                else
                {
                    foreach ( var listItem in listSource.GetListItems() )
                    {
                        editControl.Items.Add( listItem );
                    }
                }

                if ( editControl.Items.Count > 0 )
                {
                    return editControl;
                }
            }

            return null;
        }
示例#17
0
        /// <summary>
        /// Gets the filter value control.
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="filterMode">The filter mode.</param>
        /// <returns></returns>
        public override Control FilterValueControl( Dictionary<string, ConfigurationValue> configurationValues, string id, bool required, FilterMode filterMode )
        {
            var cbList = new RockCheckBoxList();
            cbList.ID = string.Format( "{0}_cbList", id );
            cbList.AddCssClass( "js-filter-control" );
            cbList.RepeatDirection = RepeatDirection.Horizontal;

            var campusList = CampusCache.All();
            if ( campusList.Any() )
            {
                foreach ( var campus in campusList )
                {
                    ListItem listItem = new ListItem( campus.Name, campus.Guid.ToString() );
                    cbList.Items.Add( listItem );
                }

                return cbList;
            }

            return null;
        }
示例#18
0
        /// <summary>
        /// Adds the field type controls.
        /// </summary>
        /// <param name="parentControl">The filter control.</param>
        /// <param name="controls">The controls.</param>
        /// <param name="entityField">The entity field.</param>
        protected void AddFieldTypeControls( Control parentControl, List<Control> controls, EntityField entityField )
        {
            string controlIdPrefix = string.Format( "{0}_{1}", parentControl.ID, entityField.FieldKind == FieldKind.Attribute ? entityField.AttributeGuid.Value.ToString("n") : entityField.Name );
            switch ( entityField.FilterFieldType )
            {
                case SystemGuid.FieldType.DATE:

                    var ddlDateCompare = ComparisonControl( DateFilterComparisonTypes );
                    ddlDateCompare.ID = string.Format( "{0}_ddlDateCompare", controlIdPrefix );
                    ddlDateCompare.AddCssClass( "js-filter-compare" );
                    parentControl.Controls.Add( ddlDateCompare );
                    controls.Add( ddlDateCompare );

                    var datePicker = new DatePicker();
                    datePicker.ID = string.Format( "{0}_dtPicker", controlIdPrefix );
                    datePicker.AddCssClass( "js-filter-control" );
                    parentControl.Controls.Add( datePicker );
                    controls.Add( datePicker );

                    break;

                case SystemGuid.FieldType.TIME:

                    var ddlTimeCompare = ComparisonControl( DateFilterComparisonTypes );
                    ddlTimeCompare.ID = string.Format( "{0}_ddlTimeCompare", controlIdPrefix );
                    ddlTimeCompare.AddCssClass( "js-filter-compare" );
                    parentControl.Controls.Add( ddlTimeCompare );
                    controls.Add( ddlTimeCompare );

                    var timePicker = new TimePicker();
                    timePicker.ID = string.Format( "{0}_timePicker", controlIdPrefix );
                    timePicker.AddCssClass( "js-filter-control" );
                    parentControl.Controls.Add( timePicker );
                    controls.Add( timePicker );

                    break;

                case SystemGuid.FieldType.INTEGER:
                case SystemGuid.FieldType.DECIMAL:

                    var ddlNumberCompare = ComparisonControl( NumericFilterComparisonTypes );
                    ddlNumberCompare.ID = string.Format( "{0}_ddlNumberCompare", controlIdPrefix );
                    ddlNumberCompare.AddCssClass( "js-filter-compare" );
                    parentControl.Controls.Add( ddlNumberCompare );
                    controls.Add( ddlNumberCompare );

                    var numberBox = new NumberBox();
                    numberBox.ID = string.Format( "{0}_numberBox", controlIdPrefix );
                    numberBox.AddCssClass( "js-filter-control" );
                    parentControl.Controls.Add( numberBox );
                    controls.Add( numberBox );

                    numberBox.FieldName = entityField.Title;

                    break;

                case SystemGuid.FieldType.MULTI_SELECT:

                    var cblMultiSelect = new RockCheckBoxList();
                    cblMultiSelect.ID = string.Format( "{0}_cblMultiSelect", controlIdPrefix );
                    parentControl.Controls.Add( cblMultiSelect );
                    cblMultiSelect.RepeatDirection = RepeatDirection.Horizontal;
                    controls.Add( cblMultiSelect );

                    if ( entityField.FieldKind == FieldKind.Property )
                    {
                        if ( entityField.PropertyType.IsEnum )
                        {
                            // Enumeration property
                            foreach ( var value in Enum.GetValues( entityField.PropertyType ) )
                            {
                                cblMultiSelect.Items.Add( new ListItem( Enum.GetName( entityField.PropertyType, value ).SplitCase() ) );
                            }
                        }
                        else if ( entityField.DefinedTypeGuid.HasValue )
                        {
                            // Defined Value Properties
                            var definedType = DefinedTypeCache.Read( entityField.DefinedTypeGuid.Value );
                            if ( definedType != null )
                            {
                                foreach ( var definedValue in definedType.DefinedValues )
                                {
                                    cblMultiSelect.Items.Add( new ListItem( definedValue.Name, definedValue.Guid.ToString() ) );
                                }
                            }
                        }
                    }
                    else
                    {
                        var attribute = AttributeCache.Read( entityField.AttributeGuid.Value );
                        if ( attribute != null )
                        {
                            switch ( attribute.FieldType.Guid.ToString().ToUpper() )
                            {
                                case SystemGuid.FieldType.SINGLE_SELECT:
                                    //TODO get attribute values qualifier to populate cbl
                                    break;
                                case SystemGuid.FieldType.MULTI_SELECT:
                                    //TODO get attribute values qualifier to populate cbl
                                    break;
                            }
                        }
                    }

                    break;

                case SystemGuid.FieldType.SINGLE_SELECT:

                    var ddlSingleSelect = new RockDropDownList();
                    ddlSingleSelect.ID = string.Format( "{0}_ddlSingleSelect", controlIdPrefix );
                    parentControl.Controls.Add( ddlSingleSelect );
                    controls.Add( ddlSingleSelect );

                    if ( entityField.FieldKind == FieldKind.Property )
                    {
                        if ( entityField.PropertyType == typeof( bool ) || entityField.PropertyType == typeof( bool? ) )
                        {
                            ddlSingleSelect.Items.Add( new ListItem( "True", "True" ) );
                            ddlSingleSelect.Items.Add( new ListItem( "False", "False" ) );
                        }
                    }
                    else
                    {
                        var attribute = AttributeCache.Read( entityField.AttributeGuid.Value );
                        if ( attribute != null )
                        {
                            switch ( attribute.FieldType.Guid.ToString().ToUpper() )
                            {
                                case SystemGuid.FieldType.BOOLEAN:
                                    ddlSingleSelect.Items.Add( new ListItem( "True", "True" ) );
                                    ddlSingleSelect.Items.Add( new ListItem( "False", "False" ) );
                                    break;
                            }
                        }
                    }

                    break;

                case SystemGuid.FieldType.DAY_OF_WEEK:
                    var dayOfWeekPicker = new DayOfWeekPicker();
                    dayOfWeekPicker.Label = string.Empty;
                    dayOfWeekPicker.ID = string.Format( "{0}_dayOfWeekPicker", controlIdPrefix );
                    dayOfWeekPicker.AddCssClass( "js-filter-control" );
                    parentControl.Controls.Add( dayOfWeekPicker );
                    controls.Add( dayOfWeekPicker );

                    break;

                case SystemGuid.FieldType.TEXT:

                    var ddlText = ComparisonControl( StringFilterComparisonTypes );
                    ddlText.ID = string.Format( "{0}_ddlText", controlIdPrefix );
                    ddlText.AddCssClass( "js-filter-compare" );
                    parentControl.Controls.Add( ddlText );
                    controls.Add( ddlText );

                    var tbText = new RockTextBox();
                    tbText.ID = string.Format( "{0}_tbText", controlIdPrefix );
                    tbText.AddCssClass( "js-filter-control" );
                    parentControl.Controls.Add( tbText );
                    controls.Add( tbText );

                    break;
            }
        }
示例#19
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 };
        }
        private void BuildDynamicControls()
        {
            // Get all the accounts grouped by campus
            if ( _campusAccounts == null )
            {
                using ( var rockContext = new RockContext() )
                {
                    _campusAccounts = new Dictionary<int, Dictionary<int, string>>();

                    Guid contributionGuid = Rock.SystemGuid.DefinedValue.TRANSACTION_TYPE_CONTRIBUTION.AsGuid();
                    var contributionAccountIds = new FinancialTransactionDetailService( rockContext )
                        .Queryable().AsNoTracking()
                        .Where( d =>
                            d.Transaction != null &&
                            d.Transaction.TransactionTypeValue != null &&
                            d.Transaction.TransactionTypeValue.Guid.Equals( contributionGuid ) )
                        .Select( d => d.AccountId )
                        .Distinct()
                        .ToList();

                    foreach ( var campusAccounts in new FinancialAccountService( rockContext )
                        .Queryable().AsNoTracking()
                        .Where( a =>
                            a.IsActive &&
                            contributionAccountIds.Contains( a.Id ) )
                        .GroupBy( a => a.CampusId ?? 0 )
                        .Select( c => new
                        {
                            CampusId = c.Key,
                            Accounts = c.OrderBy( a => a.Name ).Select( a => new { a.Id, a.Name } ).ToList()
                        } ) )
                    {
                        _campusAccounts.Add( campusAccounts.CampusId, new Dictionary<int, string>() );
                        foreach ( var account in campusAccounts.Accounts )
                        {
                            _campusAccounts[campusAccounts.CampusId].Add( account.Id, account.Name );
                        }
                    }
                }
            }

            phAccounts.Controls.Clear();

            foreach( var campusId in _campusAccounts )
            {
                var cbList = new RockCheckBoxList();
                cbList.ID = "cblAccounts" + campusId.Key.ToString();

                if ( campusId.Key > 0)
                {
                    var campus = CampusCache.Read( campusId.Key );
                    cbList.Label = campus != null ? campus.Name + " Accounts" : "Campus " + campusId.Key.ToString();
                }
                else
                {
                    cbList.Label = "Accounts";
                }

                cbList.RepeatDirection = RepeatDirection.Vertical;
                cbList.DataValueField = "Key";
                cbList.DataTextField = "Value";
                cbList.DataSource = campusId.Value;
                cbList.DataBind();

                phAccounts.Controls.Add( cbList );
            }
        }
示例#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 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 Rock.Web.UI.Controls.RockCheckBoxList { ID = id, RepeatDirection = RepeatDirection.Horizontal };
                editControl.AddCssClass( "checkboxlist-group" );
            }
            else
            {
                editControl = new Rock.Web.UI.Controls.RockDropDownList { ID = id };
                editControl.Items.Add( new ListItem() );
            }

            if ( configurationValues != null && configurationValues.ContainsKey( DEFINED_TYPE_KEY ) )
            {
                int? definedTypeId = configurationValues[DEFINED_TYPE_KEY].Value.AsIntegerOrNull();
                if ( definedTypeId.HasValue )
                {
                    Rock.Model.DefinedValueService definedValueService = new Model.DefinedValueService( new RockContext() );
                    var definedValues = definedValueService.GetByDefinedTypeId( definedTypeId.Value );
                    if ( definedValues.Any() )
                    {
                        bool useDescription = configurationValues.ContainsKey( DISPLAY_DESCRIPTION ) && configurationValues[DISPLAY_DESCRIPTION].Value.AsBoolean();

                        foreach ( var definedValue in definedValues )
                        {
                            editControl.Items.Add( new ListItem( useDescription ? definedValue.Description : definedValue.Value, definedValue.Id.ToString() ) );
                        }
                    }

                    return editControl;
                }
            }

            return null;
        }
示例#22
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls( Type entityType, FilterField filterControl )
        {
            gp = new GroupPicker();
            gp.ID = filterControl.ID + "_gp";
            gp.Label = "Group";
            gp.SelectItem += gp_SelectItem;
            filterControl.Controls.Add( gp );

            cbChildGroups = new RockCheckBox();
            cbChildGroups.ID = filterControl.ID + "_cbChildsGroups";
            cbChildGroups.Text = "Include Child Group(s)";
            cbChildGroups.AutoPostBack = true;
            cbChildGroups.CheckedChanged += gp_SelectItem;
            filterControl.Controls.Add( cbChildGroups );

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

            return new Control[3] { gp, cbChildGroups, cblRole };
        }
示例#23
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 );

            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 );

            return new Control[3] { groupTypePicker, cblRole, ddlGroupMemberStatus };
        }
示例#24
0
        /// <summary>
        /// Configures the settings.
        /// </summary>
        private void ConfigureSettings()
        {
            // toggle refine search view toggle button
            lbRefineSearch.Visible = GetAttributeValue( "ShowRefinedSearch" ).AsBoolean();

            // model selector
            var enabledModelIds = new List<int>();
            if ( GetAttributeValue( "EnabledModels" ).IsNotNullOrWhitespace() )
            {
                enabledModelIds = GetAttributeValue( "EnabledModels" ).Split( ',' ).Select( int.Parse ).ToList();
            }

            var entities = EntityTypeCache.All();
            var indexableEntities = entities.Where( i => i.IsIndexingSupported == true &&  enabledModelIds.Contains( i.Id )).ToList();

            cblModelFilter.DataTextField = "FriendlyName";
            cblModelFilter.DataValueField = "Id";
            cblModelFilter.DataSource = indexableEntities;
            cblModelFilter.DataBind();

            cblModelFilter.Visible = GetAttributeValue( "ShowFilters" ).AsBoolean();

            // add dynamic filters
            if ( GetAttributeValue( "ShowRefinedSearch" ).AsBoolean() )
            {
                foreach ( var entity in indexableEntities )
                {
                    var entityType = entity.GetEntityType();

                    if ( SupportsIndexFieldFiltering( entityType ) )
                    {
                        var filterOptions = GetIndexFilterConfig( entityType );

                        RockCheckBoxList filterConfig = new RockCheckBoxList();
                        filterConfig.Label = filterOptions.FilterLabel;
                        filterConfig.CssClass = "js-entity-id-" + entity.Id.ToString();
                        filterConfig.RepeatDirection = RepeatDirection.Horizontal;
                        filterConfig.Attributes.Add( "entity-id", entity.Id.ToString() );
                        filterConfig.Attributes.Add( "entity-filter-field", filterOptions.FilterField );
                        filterConfig.DataSource = filterOptions.FilterValues;
                        filterConfig.DataBind();

                        // set any selected values from the query string
                        if(!string.IsNullOrWhiteSpace(PageParameter( filterOptions.FilterField ) ) )
                        {
                            List<string> selectedValues = PageParameter( filterOptions.FilterField ).Split( ',' ).ToList();

                            foreach(ListItem item in filterConfig.Items )
                            {
                                if ( selectedValues.Contains( item.Value ) )
                                {
                                    item.Selected = true;
                                }
                            }
                        }

                        if ( filterOptions.FilterValues.Count > 0 )
                        {
                            HtmlGenericContainer filterWrapper = new HtmlGenericContainer( "div", "col-md-6" );
                            filterWrapper.Controls.Add( filterConfig );
                            phFilters.Controls.Add( filterWrapper );
                        }
                    }
                }
            }

            // if only one model is selected then hide the type checkbox
            if (cblModelFilter.Items.Count == 1 )
            {
                cblModelFilter.Visible = false;
            }

            ddlSearchType.BindToEnum<SearchType>();
            ddlSearchType.SelectedValue = GetAttributeValue( "SearchType" );

            // override the block setting if passed in the query string
            if ( !string.IsNullOrWhiteSpace( PageParameter( "SearchType" ) ) )
            {
                ddlSearchType.SelectedValue = PageParameter( "SearchType" );
            }

            // set setting values from query string
            if ( !string.IsNullOrWhiteSpace( PageParameter( "Models" ) ) )
            {
                var queryStringModels = PageParameter( "Models" ).Split( ',' ).Select( s => s.Trim() ).ToList();

                foreach ( ListItem item in cblModelFilter.Items )
                {
                    if ( queryStringModels.Contains( item.Value ) )
                    {
                        item.Selected = true;
                    }
                    else
                    {
                        item.Selected = false;
                    }
                }
            }

            if ( !string.IsNullOrWhiteSpace( PageParameter( "ItemsPerPage" ) ) )
            {
                _itemsPerPage = PageParameter( "ItemsPerPage" ).AsInteger();
            }

            if ( !string.IsNullOrWhiteSpace( PageParameter( "CurrentPage" ) ) )
            {
                _currentPageNum = PageParameter( "CurrentPage" ).AsInteger();
            }

            if ( !string.IsNullOrWhiteSpace( PageParameter( "RefinedSearch" ) ) )
            {
                pnlRefineSearch.Visible = PageParameter( "RefinedSearch" ).AsBoolean();

                if ( pnlRefineSearch.Visible )
                {
                    lbRefineSearch.Text = "Hide Refined Search";
                }
            }

            _itemsPerPage = GetAttributeValue( "ResultsPerPage" ).AsInteger();
        }
示例#25
0
        /// <summary>
        ///     Populates the group roles.
        /// </summary>
        /// <param name="checkboxList"></param>
        /// <param name="groupTypeGuid"></param>
        private void PopulateRelationshipTypesSelector( RockCheckBoxList checkboxList, Guid? groupTypeGuid )
        {
            bool showSelector = false;

            checkboxList.Items.Clear();

            var groupType = GroupTypeCache.Read( groupTypeGuid.GetValueOrDefault() );

            if ( groupType != null )
            {
                var selectableRoles = new GroupTypeRoleService( new RockContext() ).GetByGroupTypeId( groupType.Id );

                // Exclude the Owner Role from the list of selectable Roles because a Person cannot be related to themselves.
                var ownerGuid = GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_OWNER.AsGuid();

                selectableRoles = selectableRoles.Where( x => x.Guid != ownerGuid );

                checkboxList.Items.Clear();

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

                showSelector = checkboxList.Items.Count > 0;
            }

            checkboxList.Visible = showSelector;
        }
示例#26
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 );

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

            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;
            groupTypePicker.SelectedGroupTypeId = selectedGroupTypeId;
            parentControl.Controls.Add( groupTypePicker );

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

            PopulateGroupRolesCheckList( groupTypePicker.SelectedGroupTypeId ?? 0 );

            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 };
        }
示例#27
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 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 Rock.Web.UI.Controls.RockCheckBoxList { ID = id }; 
                editControl.AddCssClass( "checkboxlist-group" );
            }
            else
            {
                editControl = new Rock.Web.UI.Controls.RockDropDownList { ID = id }; 
                editControl.Items.Add( new ListItem() );
            }

            if ( configurationValues != null && configurationValues.ContainsKey( DEFINED_TYPE_KEY ) )
            {
                int definedTypeId = 0;
                if ( Int32.TryParse( configurationValues[DEFINED_TYPE_KEY].Value, out definedTypeId ) )
                {
                    Rock.Model.DefinedValueService definedValueService = new Model.DefinedValueService();
                    foreach ( var definedValue in definedValueService.GetByDefinedTypeId( definedTypeId ) )
                    {
                        editControl.Items.Add( new ListItem( definedValue.Name, definedValue.Id.ToString() ) );
                    }
                }
            }
            
            return editControl;
        }
示例#28
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls( Type entityType, FilterField filterControl )
        {
            gp = new GroupPicker();
            gp.ID = filterControl.ID + "_0";
            gp.Label = "Group";
            gp.SelectItem += gp_SelectItem;
            filterControl.Controls.Add( gp );

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

            return new Control[2] { gp, cblRole };
        }
        /// <summary>
        /// Adds the group controls.
        /// </summary>
        /// <param name="group">The group.</param>
        /// <param name="checkBoxList">The check box list.</param>
        /// <param name="service">The service.</param>
        /// <param name="showGroupAncestry">if set to <c>true</c> [show group ancestry].</param>
        private void AddGroupControls( Group group, RockCheckBoxList checkBoxList, GroupService service, bool showGroupAncestry )
        {
            // Only show groups that actually have a schedule
            if ( group != null )
            {
                if ( group.ScheduleId.HasValue || group.GroupLocations.Any( l => l.Schedules.Any() ) )
                {
                    string displayName = showGroupAncestry ? service.GroupAncestorPathName( group.Id ) : group.Name;
                    checkBoxList.Items.Add( new ListItem( displayName, group.Id.ToString() ) );
                }

                if ( group.Groups != null )
                {
                    foreach ( var childGroup in group.Groups
                        .OrderBy( a => a.Order )
                        .ThenBy( a => a.Name )
                        .ToList() )
                    {
                        AddGroupControls( childGroup, checkBoxList, service, showGroupAncestry );
                    }
                }
            }
        }
        /// <summary>
        /// Gets the filter value control.
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="filterMode">The filter mode.</param>
        /// <returns></returns>
        public override Control FilterValueControl( Dictionary<string, ConfigurationValue> configurationValues, string id, bool required, FilterMode filterMode )
        {
            if ( configurationValues != null && configurationValues.ContainsKey( "values" ) )
            {
                var cbList = new RockCheckBoxList();
                cbList.ID = string.Format( "{0}_cbList", id );
                cbList.AddCssClass( "js-filter-control" );
                cbList.RepeatDirection = RepeatDirection.Horizontal;

                foreach ( var keyVal in Helper.GetConfiguredValues( configurationValues ) )
                {
                    cbList.Items.Add( new ListItem( keyVal.Value, keyVal.Key ) );
                }

                if ( cbList.Items.Count > 0 )
                {
                    return cbList;
                }
            }

            return null;
        }
示例#31
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 )
        {
            RockCheckBoxList emailPreferenceTypeList = new RockCheckBoxList();
            emailPreferenceTypeList.Items.Clear();
            foreach (var preference in Enum.GetValues(typeof(EmailPreference)))
            {
                emailPreferenceTypeList.Items.Add(new ListItem(preference.ToString().SplitCase(), ((int)preference).ToString()));
            }

            emailPreferenceTypeList.ID = parentControl.ID + "_emailPreferenceList";
            emailPreferenceTypeList.Label = "Email Preference";
            emailPreferenceTypeList.Help = "Only include a parent's email address if their email preference is one of these selected values.";
            parentControl.Controls.Add(emailPreferenceTypeList);

            return new System.Web.UI.Control[] { emailPreferenceTypeList };
        }
示例#32
0
        private void BuildDynamicControls()
        {
            // Get all the accounts grouped by campus
            if ( _campusAccounts == null )
            {
                using ( var rockContext = new RockContext() )
                {
                    _campusAccounts = new Dictionary<int, Dictionary<int, string>>();
                    foreach ( var campusAccounts in new FinancialAccountService( rockContext )
                        .Queryable().AsNoTracking()
                        .Where( a => a.IsActive && a.IsTaxDeductible )
                        .GroupBy( a => a.CampusId ?? 0 )
                        .Select( c => new
                        {
                            CampusId = c.Key,
                            Accounts = c.OrderBy( a => a.Name ).Select( a => new { a.Id, a.Name } ).ToList()
                        } ) )
                    {
                        _campusAccounts.Add( campusAccounts.CampusId, new Dictionary<int, string>() );
                        foreach ( var account in campusAccounts.Accounts )
                        {
                            _campusAccounts[campusAccounts.CampusId].Add( account.Id, account.Name );
                        }
                    }
                }
            }

            phAccounts.Controls.Clear();

            foreach ( var campusId in _campusAccounts )
            {
                var cbList = new RockCheckBoxList();
                cbList.ID = "cblAccounts" + campusId.Key.ToString();

                if ( campusId.Key > 0 )
                {
                    var campus = CampusCache.Read( campusId.Key );
                    cbList.Label = campus != null ? campus.Name + " Accounts" : "Campus " + campusId.Key.ToString();
                }
                else
                {
                    cbList.Label = "Accounts";
                }

                cbList.RepeatDirection = RepeatDirection.Vertical;
                cbList.DataValueField = "Key";
                cbList.DataTextField = "Value";
                cbList.DataSource = campusId.Value;
                cbList.DataBind();

                phAccounts.Controls.Add( cbList );
            }
        }
示例#33
0
        /// <summary>
        /// Adds the group type controls.
        /// </summary>
        /// <param name="groupType">Type of the group.</param>
        /// <param name="pnlGroupTypes">The PNL group types.</param>
        private void AddGroupTypeControls( GroupType groupType, HtmlGenericContainer liGroupTypeItem )
        {
            if ( groupType.Groups.Any() )
            {
                var cblGroupTypeGroups = new RockCheckBoxList { ID = "cblGroupTypeGroups" + groupType.Id };

                cblGroupTypeGroups.Label = groupType.Name;
                cblGroupTypeGroups.Items.Clear();
                foreach ( var group in groupType.Groups.OrderBy( a => a.Order ).ThenBy( a => a.Name ).Select( a => new { a.Id, a.Name } ).ToList() )
                {
                    cblGroupTypeGroups.Items.Add( new ListItem( group.Name, group.Id.ToString() ) );
                }

                liGroupTypeItem.Controls.Add( cblGroupTypeGroups );
            }
            else
            {
                if ( groupType.ChildGroupTypes.Any() )
                {
                    liGroupTypeItem.Controls.Add( new Label { Text = groupType.Name, ID = "lbl" + groupType.Name } );
                }
            }
            
            if ( groupType.ChildGroupTypes.Any() )
            {
                var ulGroupTypeList = new HtmlGenericContainer( "ul", "rocktree-children" );

                liGroupTypeItem.Controls.Add( ulGroupTypeList );
                foreach ( var childGroupType in groupType.ChildGroupTypes.OrderBy( a => a.Order ).ThenBy( a => a.Name ) )
                {
                    var liChildGroupTypeItem = new HtmlGenericContainer( "li", "rocktree-item rocktree-folder" );
                    liChildGroupTypeItem.ID = "liGroupTypeItem" + groupType.Id;
                    ulGroupTypeList.Controls.Add( liChildGroupTypeItem );
                    AddGroupTypeControls( childGroupType, liChildGroupTypeItem );
                }
            }
        }
示例#34
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls( Type entityType, FilterField filterControl )
        {
            gp = new GroupPicker();
            gp.ID = filterControl.ID + "_gp";
            gp.Label = "Group(s)";
            gp.SelectItem += gp_SelectItem;
            gp.CssClass = "js-group-picker";
            gp.AllowMultiSelect = true;
            filterControl.Controls.Add( gp );

            cbChildGroups = new RockCheckBox();
            cbChildGroups.ID = filterControl.ID + "_cbChildsGroups";
            cbChildGroups.Text = "Include Child Group(s)";
            cbChildGroups.CssClass = "js-include-child-groups";
            cbChildGroups.AutoPostBack = true;
            cbChildGroups.CheckedChanged += gp_SelectItem;
            filterControl.Controls.Add( cbChildGroups );

            cbIncludeSelectedGroup = new RockCheckBox();
            cbIncludeSelectedGroup.ID = filterControl.ID + "_cbIncludeSelectedGroup";
            cbIncludeSelectedGroup.Text = "Include Selected Group(s)";
            cbIncludeSelectedGroup.CssClass = "js-include-selected-groups";
            cbIncludeSelectedGroup.AutoPostBack = true;
            cbIncludeSelectedGroup.CheckedChanged += gp_SelectItem;
            filterControl.Controls.Add( cbIncludeSelectedGroup );

            cbChildGroupsPlusDescendants = new RockCheckBox();
            cbChildGroupsPlusDescendants.ID = filterControl.ID + "_cbChildGroupsPlusDescendants";
            cbChildGroupsPlusDescendants.Text = "Include All Descendants(s)";
            cbChildGroupsPlusDescendants.CssClass = "js-include-child-groups-descendants";
            cbChildGroupsPlusDescendants.AutoPostBack = true;
            cbChildGroupsPlusDescendants.CheckedChanged += gp_SelectItem;
            filterControl.Controls.Add( cbChildGroupsPlusDescendants );

            cblRole = new RockCheckBoxList();
            cblRole.Label = "with Group Member Role(s) (optional)";
            cblRole.ID = filterControl.ID + "_cblRole";
            cblRole.CssClass = "js-roles";
            cblRole.Visible = false;
            filterControl.Controls.Add( cblRole );

            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 );

            return new Control[6] { gp, cbChildGroups, cbIncludeSelectedGroup, cbChildGroupsPlusDescendants, cblRole, ddlGroupMemberStatus };
        }