/// <summary> /// Creates the group editor controls. /// </summary> /// <param name="group">The group.</param> /// <param name="parentControl">The parent control.</param> /// <param name="forceContentVisible">if set to <c>true</c> [force content visible].</param> private void CreateGroupEditorControls( Group group, Control parentControl, bool forceContentVisible = false ) { CheckinGroupEditor groupEditor = new CheckinGroupEditor(); groupEditor.ID = "GroupEditor_" + group.Guid.ToString( "N" ); groupEditor.SetGroup( group ); groupEditor.Locations = group.GroupLocations .Select( a => new CheckinGroupEditor.LocationGridItem() { LocationId = a.LocationId, Name = a.Location.Name } ) .OrderBy( o => o.Name ) .ToList(); groupEditor.AddLocationClick += groupEditor_AddLocationClick; groupEditor.DeleteLocationClick += groupEditor_DeleteLocationClick; groupEditor.DeleteGroupClick += groupEditor_DeleteGroupClick; parentControl.Controls.Add( groupEditor ); }
/// <summary> /// Creates the group editor controls. /// </summary> /// <param name="group">The group.</param> /// <param name="parentControl">The parent control.</param> /// <param name="rockContext">The rock context.</param> /// <param name="createExpanded">if set to <c>true</c> [create expanded].</param> private void CreateGroupEditorControls( Group group, Control parentControl, RockContext rockContext, bool createExpanded = false ) { CheckinGroupEditor groupEditor = new CheckinGroupEditor(); groupEditor.ID = "GroupEditor_" + group.Guid.ToString( "N" ); if ( createExpanded ) { groupEditor.Expanded = true; } parentControl.Controls.Add( groupEditor ); groupEditor.SetGroup( group, rockContext ); var locationService = new LocationService( rockContext ); var locationQry = locationService.Queryable().Select( a => new { a.Id, a.ParentLocationId, a.Name } ); groupEditor.Locations = new List<CheckinGroupEditor.LocationGridItem>(); foreach ( var location in group.GroupLocations.Select( a => a.Location ).OrderBy( o => o.Name ) ) { var gridItem = new CheckinGroupEditor.LocationGridItem(); gridItem.LocationId = location.Id; gridItem.Name = location.Name; gridItem.FullNamePath = location.Name; gridItem.ParentLocationId = location.ParentLocationId; var parentLocationId = location.ParentLocationId; while ( parentLocationId != null ) { var parentLocation = locationQry.FirstOrDefault( a => a.Id == parentLocationId ); gridItem.FullNamePath = parentLocation.Name + " > " + gridItem.FullNamePath; parentLocationId = parentLocation.ParentLocationId; } groupEditor.Locations.Add( gridItem ); } groupEditor.AddLocationClick += groupEditor_AddLocationClick; groupEditor.DeleteLocationClick += groupEditor_DeleteLocationClick; groupEditor.DeleteGroupClick += groupEditor_DeleteGroupClick; }
private void ExpandGroupEditorParent( CheckinGroupEditor groupEditor ) { if ( groupEditor.Parent is CheckinGroupEditor ) { ( (CheckinGroupEditor)groupEditor.Parent ).Expanded = true; } else if ( groupEditor.Parent is CheckinGroupTypeEditor ) { ( (CheckinGroupTypeEditor)groupEditor.Parent ).Expanded = true; } }