Skip to content

Commit e8b383f

Browse files
committed
Merge remote-tracking branch 'origin/hotfix-19.1' into develop
2 parents 3263eab + f759d48 commit e8b383f

8 files changed

Lines changed: 72 additions & 13 deletions

File tree

Rock.Blocks/CheckIn/Manager/CheckInContextSetter.cs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,13 @@ private CheckInContextSetterOptionsBag GetConfigurationOptionsBag()
191191
return _options;
192192
}
193193

194-
var options = new CheckInContextSetterOptionsBag();
194+
var options = new CheckInContextSetterOptionsBag
195+
{
196+
// Temporary. This will be used to redirect to the same page
197+
// for WebForms blocks. Once they have all been converted to
198+
// Obsidian, this can be removed.
199+
IsRedirectRequired = PageCache.Guid != new Guid( "ba04bf01-5244-4637-b12d-7a962d2a9e77" ),
200+
};
195201

196202
InitializeCampusOptions( options );
197203

@@ -340,16 +346,21 @@ private Location GetContextLocation()
340346
return location;
341347
}
342348

343-
if ( location == null || location.Id != locationId )
344-
{
345-
location = new LocationService( RockContext ).Get( locationId.Value );
349+
location = new LocationService( RockContext ).Get( locationId.Value );
346350

347-
if ( location != null )
348-
{
349-
RequestContext.SetContextEntity( location, pageSpecific: false );
350-
}
351+
if ( location != null )
352+
{
353+
RequestContext.SetContextEntity( location, pageSpecific: false );
351354
}
352355

356+
// We also need to redirect back to the current page without
357+
// the LocationId query parameter so that everything on the
358+
// page is in sync with the new location context.
359+
var queryParams = RequestContext.QueryString.ToSimpleQueryStringDictionary();
360+
queryParams.Remove( PageParameterKey.LocationId );
361+
362+
RequestContext.Response.RedirectToUrl( this.GetCurrentPageUrl( queryParams, skipExistingParameters: true ) );
363+
353364
return location;
354365
}
355366

Rock.JavaScript.Obsidian.Blocks/src/CheckIn/Manager/checkInContextSetter.obs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@
9494
function createLocationProvider(campusGuid: string | null | undefined): ITreeItemProvider {
9595
const provider = new LocationTreeItemProvider();
9696

97+
provider.includeInactive = true;
98+
9799
if (campusGuid) {
98100
provider.rootLocationGuid = config.rootLocations?.[campusGuid];
99101
}
@@ -116,6 +118,13 @@
116118
}
117119
}
118120

121+
function maybeRedirect(): void {
122+
if (config.isRedirectRequired) {
123+
const url = window.location.href;
124+
window.location.href = url;
125+
}
126+
}
127+
119128
// #endregion
120129

121130
// #region Event Handlers
@@ -127,6 +136,8 @@
127136
*/
128137
async function onCampusSelected(campusValue: ListItemBag): Promise<void> {
129138
await contextEntities.set("Rock.Model.Campus", campusValue);
139+
140+
maybeRedirect();
130141
}
131142

132143
/**
@@ -136,6 +147,8 @@
136147
*/
137148
async function onLocationSelected(locationValue: ListItemBag | null): Promise<void> {
138149
await contextEntities.set("Rock.Model.Location", locationValue);
150+
151+
maybeRedirect();
139152
}
140153

141154
/**
@@ -145,6 +158,8 @@
145158
*/
146159
async function onScheduleSelected(scheduleValue: ListItemBag | null): Promise<void> {
147160
await contextEntities.set("Rock.Model.Schedule", scheduleValue);
161+
162+
maybeRedirect();
148163
}
149164

150165
async function loadSchedules(): Promise<void> {

Rock.JavaScript.Obsidian/Framework/Utility/treeItemProviders.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ export class LocationTreeItemProvider implements ITreeItemProvider {
187187
*/
188188
public rootLocationGuid?: Guid | null;
189189

190+
/**
191+
* Determines if inactive locations should be included in the results.
192+
*/
193+
public includeInactive: boolean = false;
194+
190195
/**
191196
* Gets the child items from the server.
192197
*
@@ -200,7 +205,8 @@ export class LocationTreeItemProvider implements ITreeItemProvider {
200205
guid: toGuidOrNull(parentGuid) ?? emptyGuid,
201206
rootLocationGuid: this.rootLocationGuid ?? emptyGuid,
202207
expandToValues: expandToValues,
203-
securityGrantToken: this.securityGrantToken
208+
securityGrantToken: this.securityGrantToken,
209+
includeInactive: this.includeInactive,
204210
};
205211
const url = "/api/v2/Controls/LocationItemPickerGetActiveChildren";
206212
const response = await this.http.post<TreeItemBag[]>(url, undefined, options);

Rock.JavaScript.Obsidian/Framework/ViewModels/Blocks/CheckIn/Manager/CheckInContextSetter/checkInContextSetterOptionsBag.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ export type CheckInContextSetterOptionsBag = {
2929
/** The list of campuses to display in the dropdown. */
3030
campuses?: ListItemBag[] | null;
3131

32+
/**
33+
* When a context item changes, this will cause the page to redirect
34+
* back to itself so that the new context can be applied to legacy
35+
* WebForms blocks.
36+
*/
37+
isRedirectRequired: boolean;
38+
3239
/** The root locations to use for the location picker. */
3340
rootLocations?: Record<Guid, Guid> | null;
3441

Rock.JavaScript.Obsidian/Framework/ViewModels/Rest/Controls/locationItemPickerGetActiveChildrenOptionsBag.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ export type LocationItemPickerGetActiveChildrenOptionsBag = {
4343
*/
4444
guid: Guid;
4545

46+
/** Determines if inactive locations should be included in the results. */
47+
includeInactive: boolean;
48+
4649
/**
4750
* Gets or sets the root location unique identifier. This is used if Rock.ViewModels.Rest.Controls.LocationItemPickerGetActiveChildrenOptionsBag.Guid
4851
* is empty to specify the root location to limit the tree to.

Rock.Rest/v2/ControlsController.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7740,7 +7740,8 @@ public IActionResult LocationItemPickerGetActiveChildren( [FromBody] LocationIte
77407740
grant,
77417741
locationService,
77427742
LocationItemPickerGetAutoExpandGuids( options.ExpandToValues ),
7743-
0 );
7743+
0,
7744+
options.IncludeInactive );
77447745

77457746
return Ok( locationNameList );
77467747
}
@@ -7792,8 +7793,9 @@ private List<Guid> LocationItemPickerGetAutoExpandGuids( List<string> selectedVa
77927793
/// <param name="locationService">The service to use when accessing the database.</param>
77937794
/// <param name="autoExpandGuids">The unique identifiers of the items to automatically expand.</param>
77947795
/// <param name="depth">The current depth for recursion safety.</param>
7796+
/// <param name="includeInactive">Whether to include inactive locations.</param>
77957797
/// <returns>A list of tree items.</returns>
7796-
private List<TreeItemBag> LocationItemPickerGetChildrenInternal( Guid parentLocationGuid, Guid rootLocationGuid, SecurityGrant grant, LocationService locationService, List<Guid> autoExpandGuids, int depth )
7798+
private List<TreeItemBag> LocationItemPickerGetChildrenInternal( Guid parentLocationGuid, Guid rootLocationGuid, SecurityGrant grant, LocationService locationService, List<Guid> autoExpandGuids, int depth, bool includeInactive )
77977799
{
77987800
if ( depth > 50 )
77997801
{
@@ -7817,7 +7819,10 @@ private List<TreeItemBag> LocationItemPickerGetChildrenInternal( Guid parentLoca
78177819
}
78187820

78197821
// limit to only active locations.
7820-
qry = qry.Where( a => a.IsActive );
7822+
if ( !includeInactive )
7823+
{
7824+
qry = qry.Where( a => a.IsActive );
7825+
}
78217826

78227827
// limit to only Named Locations (don't show home addresses, etc)
78237828
qry = qry.Where( a => a.Name != null && a.Name != string.Empty );
@@ -7839,7 +7844,7 @@ private List<TreeItemBag> LocationItemPickerGetChildrenInternal( Guid parentLoca
78397844

78407845
if ( autoExpandGuids.Contains( location.Guid ) )
78417846
{
7842-
treeViewItem.Children = LocationItemPickerGetChildrenInternal( location.Guid, Guid.Empty, grant, locationService, autoExpandGuids, depth + 1 );
7847+
treeViewItem.Children = LocationItemPickerGetChildrenInternal( location.Guid, Guid.Empty, grant, locationService, autoExpandGuids, depth + 1, includeInactive );
78437848
}
78447849
}
78457850
}

Rock.ViewModels/Blocks/CheckIn/Manager/CheckInContextSetter/CheckInContextSetterOptionsBag.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,12 @@ public class CheckInContextSetterOptionsBag
5656
/// The selected schedule when the block loaded.
5757
/// </summary>
5858
public ListItemBag SelectedSchedule { get; set; }
59+
60+
/// <summary>
61+
/// When a context item changes, this will cause the page to redirect
62+
/// back to itself so that the new context can be applied to legacy
63+
/// WebForms blocks.
64+
/// </summary>
65+
public bool IsRedirectRequired { get; set; }
5966
}
6067
}

Rock.ViewModels/Rest/Controls/LocationItemPickerGetActiveChildrenOptionsBag.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,10 @@ public class LocationItemPickerGetActiveChildrenOptionsBag
5656
/// </summary>
5757

5858
public List<string> ExpandToValues { get; set; }
59+
60+
/// <summary>
61+
/// Determines if inactive locations should be included in the results.
62+
/// </summary>
63+
public bool IncludeInactive { get; set; }
5964
}
6065
}

0 commit comments

Comments
 (0)