Skip to content

Commit

Permalink
+ (Reporting) Fixed issue of some Person Data View filters not honori…
Browse files Browse the repository at this point in the history
…ng the "Include Deceased" toggle. (Fixes #5428)
  • Loading branch information
PraveenMathew92 committed May 17, 2023
1 parent d6eb750 commit f866c2d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 25 deletions.
4 changes: 2 additions & 2 deletions Rock/Reporting/DataFilter/Person/GroupDataViewFilter.cs
@@ -1,4 +1,4 @@
// <copyright>
// <copyright>
// Copyright by the Spark Development Network
//
// Licensed under the Rock Community License (the "License");
Expand Down Expand Up @@ -200,7 +200,7 @@ public override Expression GetExpression( Type entityType, IService serviceInsta
//
// Construct the Query to return the list of Group Members matching the filter conditions.
//
var groupMemberQuery = new GroupMemberService( context ).Queryable();
var groupMemberQuery = new GroupMemberService( context ).Queryable( true );

// Filter By Group.
groupMemberQuery = groupMemberQuery.Where( x => groupKeys.Contains( x.GroupId ) );
Expand Down
4 changes: 2 additions & 2 deletions Rock/Reporting/DataFilter/Person/GroupMemberDataViewFilter.cs
@@ -1,4 +1,4 @@
// <copyright>
// <copyright>
// Copyright by the Spark Development Network
//
// Licensed under the Rock Community License (the "License");
Expand Down Expand Up @@ -374,7 +374,7 @@ public override Expression GetExpression( Type entityType, IService serviceInsta

var memberService = new GroupMemberService( context );

var memberQuery = memberService.Queryable();
var memberQuery = memberService.Queryable( true );

if ( dataView != null )
{
Expand Down
4 changes: 2 additions & 2 deletions Rock/Reporting/DataFilter/Person/LocationDataViewFilter.cs
@@ -1,4 +1,4 @@
// <copyright>
// <copyright>
// Copyright by the Spark Development Network
//
// Licensed under the Rock Community License (the "License");
Expand Down Expand Up @@ -348,7 +348,7 @@ public override Expression GetExpression( Type entityType, IService serviceInsta
}

// Get all of the Group Members of the qualifying Families.
var groupMemberServiceQry = new GroupMemberService( context ).Queryable()
var groupMemberServiceQry = new GroupMemberService( context ).Queryable( true )
.Where( gm => groupLocationsQuery.Any( gl => gl.GroupId == gm.GroupId ) );

// Get all of the People corresponding to the qualifying Group Members.
Expand Down
37 changes: 18 additions & 19 deletions Rock/Reporting/DataFilter/Person/LocationFilter.cs
@@ -1,4 +1,4 @@
// <copyright>
// <copyright>
// Copyright by the Spark Development Network
//
// Licensed under the Rock Community License (the "License");
Expand All @@ -14,15 +14,6 @@
// limitations under the License.
// </copyright>
//
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Composition;
using System.Linq;
using System.Linq.Expressions;
using System.Web.UI;
using System.Web.UI.WebControls;

using Rock;
using Rock.Constants;
using Rock.Data;
Expand All @@ -31,16 +22,24 @@
using Rock.Web.Cache;
using Rock.Web.UI.Controls;
using Rock.Web.Utilities;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Composition;
using System.Linq;
using System.Linq.Expressions;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Rock.Reporting.DataFilter.Person
{
/// <summary>
/// A DataFilter that selects people associated with locations matching the filter.
/// </summary>
[Description( "Filter people by their family address." )]
[Export( typeof(DataFilterComponent) )]
[Export( typeof( DataFilterComponent ) )]
[ExportMetadata( "ComponentName", "Location Filter" )]
[Rock.SystemGuid.EntityTypeGuid( "02920962-40D0-4394-B625-C894AFF67103")]
[Rock.SystemGuid.EntityTypeGuid( "02920962-40D0-4394-B625-C894AFF67103" )]
public class LocationFilter : DataFilterComponent
{
#region Settings
Expand Down Expand Up @@ -78,7 +77,7 @@ public override bool IsValid
get
{
// at least one item should be set for this to be valid (otherwise it's just data view bloat).
return LocationTypeGuid.HasValue || ! string.IsNullOrWhiteSpace( Street1 ) || !string.IsNullOrWhiteSpace( City )
return LocationTypeGuid.HasValue || !string.IsNullOrWhiteSpace( Street1 ) || !string.IsNullOrWhiteSpace( City )
|| !string.IsNullOrWhiteSpace( State ) || !string.IsNullOrWhiteSpace( PostalCode ) || !string.IsNullOrWhiteSpace( Country );
}
}
Expand Down Expand Up @@ -258,9 +257,9 @@ public override string FormatSelection( Type entityType, string selection )
string postalCode = string.IsNullOrWhiteSpace( settings.PostalCode ) ? null : settings.PostalCode;

string countryName = GlobalAttributesCache.Get().GetValue( "SupportInternationalAddresses" ).AsBoolean() &&
! string.IsNullOrWhiteSpace( settings.Country ) ? settings.Country : null;
!string.IsNullOrWhiteSpace( settings.Country ) ? settings.Country : null;

if ( settings.LocationTypeGuid.HasValue)
if ( settings.LocationTypeGuid.HasValue )
{
locationTypeName = DefinedValueCache.Get( settings.LocationTypeGuid.Value, context ).Value;
}
Expand Down Expand Up @@ -297,7 +296,7 @@ public override Control[] CreateChildControls( Type entityType, FilterField pare

var familyLocations = GroupTypeCache.GetFamilyGroupType().LocationTypeValues.OrderBy( a => a.Order ).ThenBy( a => a.Value );

foreach (var value in familyLocations)
foreach ( var value in familyLocations )
{
ddlLocationType.Items.Add( new ListItem( value.Value, value.Guid.ToString() ) );
}
Expand Down Expand Up @@ -370,7 +369,7 @@ public override void SetSelection( Type entityType, Control[] controls, string s
acAddress.City = settings.City;
acAddress.State = settings.State;
acAddress.PostalCode = settings.PostalCode;
acAddress.Country = settings.Country;
acAddress.Country = settings.Country;
}

/// <summary>
Expand Down Expand Up @@ -428,14 +427,14 @@ public override Expression GetExpression( Type entityType, IService serviceInsta
.Where( gl => gl.Group.GroupTypeId == familyGroupTypeId && locationQuery.Any( l => l.Id == gl.LocationId ) );

// If a Location Type is specified, apply the filter condition.
if (settings.LocationTypeGuid.HasValue)
if ( settings.LocationTypeGuid.HasValue )
{
int groupLocationTypeId = DefinedValueCache.Get( settings.LocationTypeGuid.Value ).Id;
groupLocationsQuery = groupLocationsQuery.Where( x => x.GroupLocationTypeValue.Id == groupLocationTypeId );
}

// Get all of the Group Members of the qualifying Families.
var groupMemberServiceQry = new GroupMemberService( context ).Queryable()
var groupMemberServiceQry = new GroupMemberService( context ).Queryable( true )
.Where( gm => groupLocationsQuery.Any( gl => gl.GroupId == gm.GroupId ) );

// Get all of the People corresponding to the qualifying Group Members.
Expand Down

0 comments on commit f866c2d

Please sign in to comment.