Skip to content

Commit 0059f53

Browse files
committed
Merge branch 'hotfix-18.2' into develop
# Conflicts: # Rock.JavaScript.Obsidian.Blocks/src/Cms/ContentChannelDetail/editPanel.partial.obs # Rock.JavaScript.Obsidian.Blocks/src/Engagement/StepProgramDetail/editPanel.partial.obs
2 parents 39636cf + 02454af commit 0059f53

File tree

14 files changed

+380
-418
lines changed

14 files changed

+380
-418
lines changed

Rock.Blocks/Cms/ContentChannelDetail.cs

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -752,10 +752,18 @@ private void SaveAttributes( int channelId, int entityTypeId, List<PublicEditabl
752752
RockContext.SaveChanges();
753753

754754
// Update the Attributes that were assigned in the UI
755-
foreach ( var attr in attributes )
755+
// The attributes are coming from the frontend already sorted in the correct order.
756+
int order = 0;
757+
foreach ( var attrBag in attributes )
756758
{
757-
Rock.Attribute.Helper.SaveAttributeEdits( attr, entityTypeId, qualifierColumn, qualifierValue, RockContext );
759+
var attr = Rock.Attribute.Helper.SaveAttributeEdits( attrBag, entityTypeId, qualifierColumn, qualifierValue, RockContext );
760+
if ( attr != null )
761+
{
762+
attr.Order = order++;
763+
}
758764
}
765+
766+
RockContext.SaveChanges();
759767
}
760768

761769
#endregion
@@ -942,30 +950,6 @@ public BlockActionResult GetLicenseMessage( Guid? selectedLicenseType, string id
942950
return ActionOk( new { IsMessageVisible = false, Message = "" } );
943951
}
944952

945-
/// <summary>
946-
/// Changes the ordered position of a single item.
947-
/// </summary>
948-
/// <param name="guid">The identifier of the item that will be moved.</param>
949-
/// <param name="beforeGuid">The identifier of the item it will be placed before.</param>
950-
/// <returns>An empty result that indicates if the operation succeeded.</returns>
951-
[BlockAction]
952-
public BlockActionResult ReorderAttributes( string idKey, Guid guid, Guid? beforeGuid )
953-
{
954-
// Get the queryable and make sure it is ordered correctly.
955-
var id = Rock.Utility.IdHasher.Instance.GetId( idKey );
956-
957-
var attributes = GetItemAttributes( id ?? 0 );
958-
959-
if ( !attributes.ReorderEntity( guid.ToString(), beforeGuid.ToString() ) )
960-
{
961-
return ActionBadRequest( "Invalid reorder attempt." );
962-
}
963-
964-
RockContext.SaveChanges();
965-
966-
return ActionOk();
967-
}
968-
969953
#endregion
970954
}
971955
}

Rock.Blocks/Cms/ContentChannelTypeDetail.cs

Lines changed: 10 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,18 @@ private void SaveAttributes( int contentTypeId, int entityTypeId, List<PublicEdi
372372
rockContext.SaveChanges();
373373

374374
// Update the Attributes that were assigned in the UI
375-
foreach ( var attr in attributes )
375+
// The attributes are coming from the frontend already sorted in the correct order.
376+
int order = 0;
377+
foreach ( var attrBag in attributes )
376378
{
377-
Rock.Attribute.Helper.SaveAttributeEdits( attr, entityTypeId, qualifierColumn, qualifierValue, rockContext );
379+
var attr = Rock.Attribute.Helper.SaveAttributeEdits( attrBag, entityTypeId, qualifierColumn, qualifierValue, rockContext );
380+
if ( attr != null )
381+
{
382+
attr.Order = order++;
383+
}
378384
}
385+
386+
rockContext.SaveChanges();
379387
}
380388

381389
#endregion
@@ -479,62 +487,6 @@ public BlockActionResult RefreshAttributes( DetailBlockBox<ContentChannelTypeBag
479487
return ActionBadRequest( "Attributes are not supported by this block." );
480488
}
481489

482-
/// <summary>
483-
/// Reorders the Item attributes.
484-
/// </summary>
485-
/// <param name="idKey">The identifier key.</param>
486-
/// <param name="guid">The unique identifier.</param>
487-
/// <param name="beforeGuid">The before unique identifier.</param>
488-
/// <returns></returns>
489-
[BlockAction]
490-
public BlockActionResult ReorderItemAttributes( string idKey, Guid guid, Guid? beforeGuid )
491-
{
492-
using ( var rockContext = new RockContext() )
493-
{
494-
// Get the queryable and make sure it is ordered correctly.
495-
var id = Rock.Utility.IdHasher.Instance.GetId( idKey );
496-
497-
var attributes = GetAttributes( rockContext, id ?? 0, new ContentChannelItem().TypeId );
498-
499-
if ( !attributes.ReorderEntity( guid.ToString(), beforeGuid.ToString() ) )
500-
{
501-
return ActionBadRequest( "Invalid reorder attempt." );
502-
}
503-
504-
rockContext.SaveChanges();
505-
506-
return ActionOk();
507-
}
508-
}
509-
510-
/// <summary>
511-
/// Reorders the channel attributes.
512-
/// </summary>
513-
/// <param name="idKey">The identifier key.</param>
514-
/// <param name="guid">The unique identifier.</param>
515-
/// <param name="beforeGuid">The before unique identifier.</param>
516-
/// <returns></returns>
517-
[BlockAction]
518-
public BlockActionResult ReorderChannelAttributes( string idKey, Guid guid, Guid? beforeGuid )
519-
{
520-
using ( var rockContext = new RockContext() )
521-
{
522-
// Get the queryable and make sure it is ordered correctly.
523-
var id = Rock.Utility.IdHasher.Instance.GetId( idKey );
524-
525-
var attributes = GetAttributes( rockContext, id ?? 0, new ContentChannel().TypeId );
526-
527-
if ( !attributes.ReorderEntity( guid.ToString(), beforeGuid.ToString() ) )
528-
{
529-
return ActionBadRequest( "Invalid reorder attempt." );
530-
}
531-
532-
rockContext.SaveChanges();
533-
534-
return ActionOk();
535-
}
536-
}
537-
538490
#endregion
539491
}
540492
}

Rock.Blocks/Core/AttributeMatrixTemplateDetail.cs

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -308,40 +308,24 @@ private void SaveAttributes( List<PublicEditableAttributeBag> AttributesState, A
308308
}
309309

310310
// Update the Attributes that were assigned in the UI
311+
// The attributes are coming from the frontend already sorted in the correct order.
312+
int order = 0;
311313
foreach ( var attributeState in AttributesState )
312314
{
313-
Helper.SaveAttributeEdits( attributeState, entityTypeIdAttributeMatrix, "AttributeMatrixTemplateId", qualifierValue, RockContext );
315+
var attr = Helper.SaveAttributeEdits( attributeState, entityTypeIdAttributeMatrix, "AttributeMatrixTemplateId", qualifierValue, RockContext );
316+
if ( attr != null )
317+
{
318+
attr.Order = order++;
319+
}
314320
}
321+
322+
RockContext.SaveChanges();
315323
}
316324

317325
#endregion
318326

319327
#region Block Actions
320328

321-
/// <summary>
322-
/// Changes the ordered position of a single item.
323-
/// </summary>
324-
/// <param name="key">The identifier of the item that will be moved.</param>
325-
/// <param name="beforeKey">The identifier of the item it will be placed before.</param>
326-
/// <returns>An empty result that indicates if the operation succeeded.</returns>
327-
[BlockAction]
328-
public BlockActionResult ReorderAttributes( string idKey, Guid guid, Guid? beforeGuid )
329-
{
330-
// Get the queryable and make sure it is ordered correctly.
331-
var id = Rock.Utility.IdHasher.Instance.GetId( idKey );
332-
333-
var attributes = GetAttributes( id ?? 0 );
334-
335-
if ( !attributes.ReorderEntity( guid.ToString(), beforeGuid.ToString() ) )
336-
{
337-
return ActionBadRequest( "Invalid reorder attempt." );
338-
}
339-
340-
RockContext.SaveChanges();
341-
342-
return ActionOk();
343-
}
344-
345329
/// <summary>
346330
/// Saves the entity contained in the box.
347331
/// </summary>

Rock.Blocks/Engagement/StepProgramDetail.cs

Lines changed: 30 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ protected override StepProgramBag GetEntityBagForEdit( StepProgram entity )
347347
bag.Statuses = GetStepStatuses( entity.Id ).Select( s => new StepStatusBag()
348348
{
349349
Guid = s.Guid,
350-
Id = s.Id,
351350
IsActive = s.IsActive,
352351
IsCompleteStatus = s.IsCompleteStatus,
353352
Name = s.Name,
@@ -367,8 +366,6 @@ protected override StepProgramBag GetEntityBagForEdit( StepProgram entity )
367366
SecondaryQualifier = GetStepStatuses( entity.Id ).Find( ss => ss.Id == new StepWorkflowTrigger.StatusChangeTriggerSettings( wt.TypeQualifier ).ToStatusId )?.Guid.ToString(),
368367
} ).ToList();
369368

370-
bag.StatusOptions = new StepStatusService( RockContext ).Queryable().Where( s => s.StepProgramId == entity.Id ).AsEnumerable().ToListItemBagList();
371-
372369
return bag;
373370
}
374371

@@ -476,9 +473,6 @@ protected override bool UpdateEntityFromBox( StepProgram entity, ValidProperties
476473
box.IfValidProperty( nameof( box.Bag.Statuses ),
477474
() => SaveStatuses( box.Bag, entity, RockContext ) );
478475

479-
box.IfValidProperty( nameof( box.Bag.WorkflowTriggers ),
480-
() => SaveWorkflowTriggers( box.Bag, entity, RockContext ) );
481-
482476
box.IfValidProperty( nameof( box.Bag.CompletionFlow ),
483477
() => entity.CompletionFlow = box.Bag.CompletionFlow.Value );
484478

@@ -568,10 +562,18 @@ private void SaveAttributes( int entityTypeId, string qualifierColumn, string qu
568562
}
569563

570564
// Update the Attributes that were assigned in the UI
565+
// The attributes are coming from the frontend already sorted in the correct order.
566+
int order = 0;
571567
foreach ( var attributeState in viewStateAttributes )
572568
{
573-
Helper.SaveAttributeEdits( attributeState, entityTypeId, qualifierColumn, qualifierValue, RockContext );
569+
var attr = Helper.SaveAttributeEdits( attributeState, entityTypeId, qualifierColumn, qualifierValue, RockContext );
570+
if ( attr != null )
571+
{
572+
attr.Order = order++;
573+
}
574574
}
575+
576+
RockContext.SaveChanges();
575577
}
576578

577579
/// <summary>
@@ -656,8 +658,10 @@ private static void SaveStatuses( StepProgramBag bag, StepProgram entity, RockCo
656658
}
657659

658660
// Step Statuses: Update modified Statuses
659-
foreach ( var stepStatusState in bag.Statuses )
661+
// The statuses are coming from the frontend already sorted in the correct order.
662+
for ( int i = 0; i < bag.Statuses.Count; i++ )
660663
{
664+
var stepStatusState = bag.Statuses[i];
661665
var stepStatus = entity.StepStatuses.FirstOrDefault( a => a.Guid == stepStatusState.Guid );
662666

663667
if ( stepStatus == null )
@@ -666,10 +670,13 @@ private static void SaveStatuses( StepProgramBag bag, StepProgram entity, RockCo
666670
entity.StepStatuses.Add( stepStatus );
667671
}
668672

673+
stepStatus.Guid = stepStatusState.Guid;
674+
669675
stepStatus.Name = stepStatusState.Name;
670676
stepStatus.IsActive = stepStatusState.IsActive;
671677
stepStatus.IsCompleteStatus = stepStatusState.IsCompleteStatus;
672678
stepStatus.StatusColor = stepStatusState.StatusColor;
679+
stepStatus.Order = i;
673680

674681
stepStatus.StepProgramId = entity.Id;
675682
}
@@ -2097,58 +2104,6 @@ private Dictionary<string, object> GetStepFlowParameters( int maxLevels, Sliding
20972104

20982105
#region Block Actions
20992106

2100-
/// <summary>
2101-
/// Changes the ordered position of a single step status.
2102-
/// </summary>
2103-
/// <param name="key">The identifier of the step status that will be moved.</param>
2104-
/// <param name="beforeKey">The identifier of the step status it will be placed before.</param>
2105-
/// <returns>An empty result that indicates if the operation succeeded.</returns>
2106-
[BlockAction]
2107-
public BlockActionResult ReorderStepStatus( string key, string beforeKey )
2108-
{
2109-
var stepProgram = StepProgramCache.Get( PageParameter( PageParameterKey.StepProgramId ), !PageCache.Layout.Site.DisablePredictableIds );
2110-
if ( stepProgram == null )
2111-
{
2112-
return ActionBadRequest( "Step program not found." );
2113-
}
2114-
2115-
var items = GetStepStatuses( stepProgram.Id );
2116-
2117-
if ( !items.ReorderEntity( key, beforeKey ) )
2118-
{
2119-
return ActionBadRequest( "Invalid reorder attempt." );
2120-
}
2121-
2122-
RockContext.SaveChanges();
2123-
return ActionOk();
2124-
}
2125-
2126-
/// <summary>
2127-
/// Changes the ordered position of a single step type attribute.
2128-
/// </summary>
2129-
/// <param name="key">The identifier of the step type attribute that will be moved.</param>
2130-
/// <param name="beforeKey">The identifier of the step type attribute it will be placed before.</param>
2131-
/// <returns>An empty result that indicates if the operation succeeded.</returns>
2132-
[BlockAction]
2133-
public BlockActionResult ReorderStepTypeAttribute( string key, string beforeKey )
2134-
{
2135-
var stepProgram = StepProgramCache.Get( PageParameter( PageParameterKey.StepProgramId ), !PageCache.Layout.Site.DisablePredictableIds );
2136-
if ( stepProgram == null )
2137-
{
2138-
return ActionBadRequest( "Step program not found." );
2139-
}
2140-
2141-
var items = GetStepTypeAttributes( stepProgram.Id.ToString() );
2142-
2143-
if ( !items.ReorderEntity( key, beforeKey ) )
2144-
{
2145-
return ActionBadRequest( "Invalid reorder attempt." );
2146-
}
2147-
2148-
RockContext.SaveChanges();
2149-
return ActionOk();
2150-
}
2151-
21522107
/// <summary>
21532108
/// Gets the box that will contain all the information needed to begin
21542109
/// the edit operation.
@@ -2212,6 +2167,21 @@ public BlockActionResult Save( ValidPropertiesBox<StepProgramBag> box )
22122167
{
22132168
RockContext.SaveChanges();
22142169
entity.SaveAttributeValues( RockContext );
2170+
2171+
/*
2172+
1/3/2026 - MSE
2173+
2174+
Newly created Step Statuses can now be selected when configuring Workflow Triggers
2175+
before they are saved to the database, rather than limiting selection to
2176+
previously persisted statuses only. Because Workflow Triggers serialize
2177+
Step Status references using database IDs, the statuses must be saved first
2178+
so those IDs exist.
2179+
2180+
Reason: Ensure Workflow Trigger serialization uses valid Step Status IDs.
2181+
*/
2182+
SaveWorkflowTriggers( box.Bag, entity, RockContext );
2183+
2184+
RockContext.SaveChanges();
22152185
} );
22162186

22172187
SaveAttributes( new StepType().TypeId, "StepProgramId", entity.Id.ToString(), box.Bag.StepProgramAttributes );

Rock.Blocks/Engagement/StepTypeDetail.cs

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -906,10 +906,18 @@ private void SaveAttributes( int entityTypeId, string qualifierColumn, string qu
906906
}
907907

908908
// Update the Attributes that were assigned in the UI
909+
// The attributes are coming from the frontend already sorted in the correct order.
910+
int order = 0;
909911
foreach ( var attributeState in viewStateAttributes )
910912
{
911-
Helper.SaveAttributeEdits( attributeState, entityTypeId, qualifierColumn, qualifierValue, RockContext );
913+
var attr = Helper.SaveAttributeEdits( attributeState, entityTypeId, qualifierColumn, qualifierValue, RockContext );
914+
if ( attr != null )
915+
{
916+
attr.Order = order++;
917+
}
912918
}
919+
920+
RockContext.SaveChanges();
913921
}
914922

915923
/// <summary>
@@ -1614,32 +1622,6 @@ public BlockActionResult TransferStepType( StepTypeTransferBag transferBag )
16141622

16151623
#endregion
16161624

1617-
/// <summary>
1618-
/// Changes the ordered position of a single step attribute.
1619-
/// </summary>
1620-
/// <param name="key">The identifier of the step attribute that will be moved.</param>
1621-
/// <param name="beforeKey">The identifier of the step attribute it will be placed before.</param>
1622-
/// <returns>An empty result that indicates if the operation succeeded.</returns>
1623-
[BlockAction]
1624-
public BlockActionResult ReorderItem( string key, string beforeKey )
1625-
{
1626-
var stepType = GetStepType();
1627-
if ( stepType == null )
1628-
{
1629-
return ActionBadRequest( "Step type not found." );
1630-
}
1631-
1632-
var items = GetStepTypeAttributes( stepType.Id.ToString() );
1633-
1634-
if ( !items.ReorderEntity( key, beforeKey ) )
1635-
{
1636-
return ActionBadRequest( "Invalid reorder attempt." );
1637-
}
1638-
1639-
RockContext.SaveChanges();
1640-
return ActionOk();
1641-
}
1642-
16431625
private class StepStatusProjection
16441626
{
16451627
public int DateKey { get; set; }

0 commit comments

Comments
 (0)