コード例 #1
0
ファイル: GroupDataViewFilter.cs プロジェクト: NewSpring/Rock
        /// <summary>
        /// Sets the selection.
        /// Implement this version of SetSelection if your DataFilterComponent works the same in all FilterModes
        /// </summary>
        /// <param name="entityType">Type of the entity.</param>
        /// <param name="controls">The controls.</param>
        /// <param name="selection">The selection.</param>
        public override void SetSelection( Type entityType, Control[] controls, string selection )
        {
            var ddlDataView = controls.GetByName<DataViewPicker>( _CtlDataView );
            var ddlRoleType = controls.GetByName<RockDropDownList>( _CtlRoleType );
            var ddlGroupMemberStatus = controls.GetByName<RockDropDownList>( _CtlGroupStatus );

            var settings = new SelectSettings( selection );

            if ( !settings.IsValid )
            {
                return;
            }

            if ( settings.DataViewGuid.HasValue )
            {
                var dsService = new DataViewService( new RockContext() );

                var dataView = dsService.Get( settings.DataViewGuid.Value );

                if ( dataView != null )
                {
                    ddlDataView.SelectedValue = dataView.Id.ToString();
                }
            }

            ddlRoleType.SelectedValue = settings.RoleType.ToStringSafe();
            ddlGroupMemberStatus.SelectedValue = settings.MemberStatus.ToStringSafe();
        }
コード例 #2
0
ファイル: ContainsPeopleFilter.cs プロジェクト: azturner/Rock
        /// <summary>
        /// Sets the filter control values from a formatted string.
        /// </summary>
        /// <param name="entityType">The System Type of the entity to which the filter will be applied.</param>
        /// <param name="controls">The collection of controls used to set the filter values.</param>
        /// <param name="selection">A formatted string representing the filter settings.</param>
        public override void SetSelection( Type entityType, Control[] controls, string selection )
        {
            var ddlDataView = controls.GetByName<DataViewPicker>( _CtlDataView );
            var ddlCompare = controls.GetByName<RockDropDownList>( _CtlComparison );
            var nbValue = controls.GetByName<NumberBox>( _CtlMemberCount );

            var settings = new FilterSettings( selection );

            if (!settings.IsValid)
            {
                return;
            }

            ddlDataView.SelectedValue = DataComponentSettingsHelper.GetDataViewId( settings.PersonDataViewGuid ).ToStringSafe();
            ddlCompare.SelectedValue = settings.PersonCountComparison.ConvertToInt().ToString();
            nbValue.Text = settings.PersonCount.ToString();
        }
コード例 #3
0
ファイル: GroupDataViewFilter.cs プロジェクト: NewSpring/Rock
        /// <summary>
        /// Gets the selection.
        /// Implement this version of GetSelection if your DataFilterComponent works the same in all FilterModes
        /// </summary>
        /// <param name="entityType">The System Type of the entity to which the filter will be applied.</param>
        /// <param name="controls">The collection of controls used to set the filter values.</param>
        /// <returns>
        /// A formatted string.
        /// </returns>
        public override string GetSelection( Type entityType, Control[] controls )
        {
            var ddlDataView = controls.GetByName<DataViewPicker>( _CtlDataView );
            var ddlRoleType = controls.GetByName<RockDropDownList>( _CtlRoleType );
            var ddlGroupMemberStatus = controls.GetByName<RockDropDownList>( _CtlGroupStatus );

            var settings = new SelectSettings();

            settings.MemberStatus = ddlGroupMemberStatus.SelectedValue.ConvertToEnumOrNull<GroupMemberStatus>();
            settings.RoleType = ddlRoleType.SelectedValue.ConvertToEnumOrNull<RoleTypeSpecifier>();
            settings.DataViewGuid = DataComponentSettingsHelper.GetDataViewGuid( ddlDataView.SelectedValue );

            return settings.ToSelectionString();
        }
コード例 #4
0
ファイル: ContainsPeopleFilter.cs プロジェクト: azturner/Rock
        /// <summary>
        /// Gets a formatted string representing the current filter control values.
        /// </summary>
        /// <param name="entityType">The System Type of the entity to which the filter will be applied.</param>
        /// <param name="controls">The collection of controls used to set the filter values.</param>
        /// <returns>
        /// A formatted string.
        /// </returns>
        public override string GetSelection( Type entityType, Control[] controls )
        {
            var ddlDataView = controls.GetByName<DataViewPicker>( _CtlDataView );
            var ddlCompare = controls.GetByName<RockDropDownList>( _CtlComparison );
            var nbValue = controls.GetByName<NumberBox>( _CtlMemberCount );

            var settings = new FilterSettings();

            settings.PersonDataViewGuid = DataComponentSettingsHelper.GetDataViewGuid( ddlDataView.SelectedValue );
            settings.PersonCountComparison = ddlCompare.SelectedValueAsEnum<ComparisonType>( ComparisonType.GreaterThan );
            settings.PersonCount = nbValue.Text.AsInteger();

            return settings.ToSelectionString();
        }
コード例 #5
0
ファイル: ContainsPeopleFilter.cs プロジェクト: azturner/Rock
        /// <summary>
        /// Renders the child controls used to display and edit the filter settings for HTML presentation.
        /// </summary>
        /// <param name="entityType">The System Type of the entity to which the filter will be applied.</param>
        /// <param name="filterControl">The control that serves as the container for the controls being rendered.</param>
        /// <param name="writer">The writer being used to generate the HTML for the output page.</param>
        /// <param name="controls">The model representation of the child controls for this component.</param>
        public override void RenderControls( Type entityType, FilterField filterControl, HtmlTextWriter writer, Control[] controls )
        {
            var ddlDataView = controls.GetByName<DataViewPicker>( _CtlDataView );
            var ddlCompare = controls.GetByName<RockDropDownList>( _CtlComparison );
            var nbValue = controls.GetByName<NumberBox>( _CtlMemberCount );

            ddlDataView.RenderControl( writer );

            // Comparison Row
            writer.AddAttribute( "class", "row field-criteria" );
            writer.RenderBeginTag( HtmlTextWriterTag.Div );

            // Comparison Type
            writer.AddAttribute( "class", "col-md-4" );
            writer.RenderBeginTag( HtmlTextWriterTag.Div );
            ddlCompare.RenderControl( writer );
            writer.RenderEndTag();

            // Comparison Value
            writer.AddAttribute( "class", "col-md-8" );
            writer.RenderBeginTag( HtmlTextWriterTag.Div );
            nbValue.RenderControl( writer );
            writer.RenderEndTag();

            writer.RenderEndTag();

            RegisterFilterCompareChangeScript( filterControl );
        }
コード例 #6
0
        /// <summary>
        /// Gets the selection.
        /// This is typically a string that contains the values selected with the Controls
        /// </summary>
        /// <param name="controls">The controls.</param>
        /// <returns></returns>
        public override string GetSelection( Control[] controls )
        {
            var cblFamilyRelationshipType = controls.GetByName<RockCheckBoxList>( _CtlFamilyRelationshipType );
            var cblKnownRelationshipType = controls.GetByName<RockCheckBoxList>( _CtlKnownRelationshipType );
            var ddlFormat = controls.GetByName<RockDropDownList>( _CtlFormat );

            var settings = new RelatedPeopleSelectSettings();

            IEnumerable<Guid> selectedItems;

            // List Format
            settings.ListFormat = ddlFormat.SelectedValue.ConvertToEnum<ListFormatSpecifier>( ListFormatSpecifier.NameAndRelationship );

            // Family Relationships
            selectedItems = cblFamilyRelationshipType.Items.OfType<ListItem>().Where( x => x.Selected ).Select( x => x.Value.AsGuid() );

            settings.FamilyRelationshipTypeGuids.AddRange( selectedItems );

            // Known Relationships
            selectedItems = cblKnownRelationshipType.Items.OfType<ListItem>().Where( x => x.Selected ).Select( x => x.Value.AsGuid() );

            settings.KnownRelationshipTypeGuids.AddRange( selectedItems );

            return settings.ToSelectionString();
        }
コード例 #7
0
        /// <summary>
        /// Sets the selection.
        /// </summary>
        /// <param name="controls">The controls.</param>
        /// <param name="selection">The selection.</param>
        public override void SetSelection( Control[] controls, string selection )
        {
            var cblKnownRelationshipType = controls.GetByName<RockCheckBoxList>( _CtlKnownRelationshipType );
            var cblFamilyRelationshipType = controls.GetByName<RockCheckBoxList>( _CtlFamilyRelationshipType );
            var ddlFormat = controls.GetByName<RockDropDownList>( _CtlFormat );

            var settings = new RelatedPeopleSelectSettings( selection );

            if ( !settings.IsValid )
            {
                return;
            }

            // Family Relationships
            foreach ( var item in cblFamilyRelationshipType.Items.OfType<ListItem>() )
            {
                item.Selected = settings.FamilyRelationshipTypeGuids.Contains( item.Value.AsGuid() );
            }

            // Known Relationships
            foreach ( var item in cblKnownRelationshipType.Items.OfType<ListItem>() )
            {
                item.Selected = settings.KnownRelationshipTypeGuids.Contains( item.Value.AsGuid() );
            }

            // List Format
            ddlFormat.SelectedValue = settings.ListFormat.ToString();
        }
コード例 #8
0
        /// <summary>
        /// Gets the selection.
        /// Implement this version of GetSelection if your DataFilterComponent works the same in all FilterModes
        /// </summary>
        /// <param name="entityType">The System Type of the entity to which the filter will be applied.</param>
        /// <param name="controls">The collection of controls used to set the filter values.</param>
        /// <returns>
        /// A formatted string.
        /// </returns>
        public override string GetSelection( Type entityType, Control[] controls )
        {
            var ddlDataView = controls.GetByName<DataViewPicker>( _CtlDataView );
            var ddlLocationType = controls.GetByName<RockDropDownList>( _CtlLocationType );

            var settings = new FilterSettings();

            settings.LocationTypeGuid = ddlLocationType.SelectedValue.AsGuidOrNull();
            settings.DataViewGuid = DataComponentSettingsHelper.GetDataViewGuid( ddlDataView.SelectedValue );

            return settings.ToSelectionString();
        }
コード例 #9
0
        /// <summary>
        /// Sets the selection.
        /// Implement this version of SetSelection if your DataFilterComponent works the same in all FilterModes
        /// </summary>
        /// <param name="entityType">Type of the entity.</param>
        /// <param name="controls">The controls.</param>
        /// <param name="selection">The selection.</param>
        public override void SetSelection( Type entityType, Control[] controls, string selection )
        {
            var ddlDataView = controls.GetByName<DataViewPicker>( _CtlDataView );
            var ddlLocationType = controls.GetByName<RockDropDownList>( _CtlLocationType );

            var settings = new FilterSettings( selection );

            if (!settings.IsValid)
            {
                return;
            }

            ddlDataView.SelectedValue = DataComponentSettingsHelper.GetDataViewId( settings.DataViewGuid ).ToStringSafe();
            ddlLocationType.SelectedValue = settings.LocationTypeGuid.ToStringSafe();
        }
コード例 #10
0
        /// <summary>
        /// Sets the selection.
        /// Implement this version of SetSelection if your DataFilterComponent works the same in all FilterModes
        /// </summary>
        /// <param name="entityType">Type of the entity.</param>
        /// <param name="controls">The controls.</param>
        /// <param name="selection">The selection.</param>
        public override void SetSelection( Type entityType, Control[] controls, string selection )
        {
            // Get selection control instances.
            var pnlGroupAttributeFilterControls = controls.GetByName<DynamicControlsPanel>( _CtlGroup );
            var ddlProperty = controls.GetByName<DropDownList>( _CtlProperty );

            if (pnlGroupAttributeFilterControls == null)
            {
                return;
            }

            var settings = new FilterSettings( selection );

            if (!settings.IsValid)
            {
                return;
            }

            if (settings.AttributeFilterSettings.Any())
            {
                var entityFields = GetGroupMemberAttributes();

                var panelControls = new List<Control>();

                panelControls.AddRange( pnlGroupAttributeFilterControls.Controls.OfType<Control>() );

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

                parameters.AddRange( settings.AttributeFilterSettings );

                SetEntityFieldSelection( entityFields, ddlProperty, parameters, panelControls );
            }
        }
コード例 #11
0
        /// <summary>
        /// Renders the child controls used to display and edit the filter settings for HTML presentation.
        /// Implement this version of RenderControls if your DataFilterComponent works the same in all FilterModes
        /// </summary>
        /// <param name="entityType">The System Type of the entity to which the filter will be applied.</param>
        /// <param name="filterControl">The control that serves as the container for the controls being rendered.</param>
        /// <param name="writer">The writer being used to generate the HTML for the output page.</param>
        /// <param name="controls">The model representation of the child controls for this component.</param>
        public override void RenderControls( Type entityType, FilterField filterControl, HtmlTextWriter writer, Control[] controls )
        {
            var pnlGroupAttributeFilterControls = controls.GetByName<DynamicControlsPanel>( _CtlGroup );
            var ddlProperty = controls.GetByName<DropDownList>( _CtlProperty );

            if (pnlGroupAttributeFilterControls == null)
            {
                return;
            }

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

            var entityFields = GetGroupMemberAttributes();

            RenderEntityFieldsControls( entityType, filterControl, writer, entityFields, ddlProperty, panelControls, pnlGroupAttributeFilterControls.ID, FilterMode.AdvancedFilter );
        }
コード例 #12
0
        /// <summary>
        /// Gets the selection.
        /// Implement this version of GetSelection if your DataFilterComponent works the same in all FilterModes
        /// </summary>
        /// <param name="entityType">The System Type of the entity to which the filter will be applied.</param>
        /// <param name="controls">The collection of controls used to set the filter values.</param>
        /// <returns>
        /// A formatted string.
        /// </returns>
        public override string GetSelection( Type entityType, Control[] controls )
        {
            // Get selection control instances.
            var pnlGroupAttributeFilterControls = controls.GetByName<DynamicControlsPanel>( _CtlGroup );
            var ddlProperty = controls.GetByName<DropDownList>( _CtlProperty );

            if (pnlGroupAttributeFilterControls == null)
            {
                return null;
            }

            var settings = new FilterSettings();
            settings.AttributeKey = ddlProperty.SelectedValue;

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

                var control = panelControls.FirstOrDefault( c => c.ID.EndsWith( "_" + entityField.Name ) );

                if (control != null)
                {
                    entityField.FieldType.Field.GetFilterValues( control, entityField.FieldConfig, FilterMode.AdvancedFilter ).ForEach( v => settings.AttributeFilterSettings.Add( v ) );
                }
            }

            return settings.ToSelectionString();
        }
コード例 #13
0
ファイル: GroupDataViewFilter.cs プロジェクト: NewSpring/Rock
        /// <summary>
        /// Sets the selection.
        /// Implement this version of SetSelection if your DataFilterComponent works the same in all FilterModes
        /// </summary>
        /// <param name="entityType">Type of the entity.</param>
        /// <param name="controls">The controls.</param>
        /// <param name="selection">The selection.</param>
        public override void SetSelection( Type entityType, Control[] controls, string selection )
        {
            var ddlDataView = controls.GetByName<DataViewPicker>( _CtlDataView );

            var settings = new SelectSettings( selection );

            if ( !settings.IsValid )
            {
                return;
            }

            if ( settings.DataViewGuid.HasValue )
            {
                var dsService = new DataViewService( new RockContext() );

                var dataView = dsService.Get( settings.DataViewGuid.Value );

                if ( dataView != null )
                {
                    ddlDataView.SelectedValue = dataView.Id.ToString();
                }
            }
        }
コード例 #14
0
ファイル: GroupDataViewFilter.cs プロジェクト: NewSpring/Rock
        /// <summary>
        /// Gets the selection.
        /// Implement this version of GetSelection if your DataFilterComponent works the same in all FilterModes
        /// </summary>
        /// <param name="entityType">The System Type of the entity to which the filter will be applied.</param>
        /// <param name="controls">The collection of controls used to set the filter values.</param>
        /// <returns>
        /// A formatted string.
        /// </returns>
        public override string GetSelection( Type entityType, Control[] controls )
        {
            var ddlDataView = controls.GetByName<DataViewPicker>( _CtlDataView );

            var settings = new SelectSettings();

            settings.DataViewGuid = DataComponentSettingsHelper.GetDataViewGuid( ddlDataView.SelectedValue );

            return settings.ToSelectionString();
        }