-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathStaff.ascx.cs
73 lines (66 loc) · 2.51 KB
/
Staff.ascx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.ComponentModel;
using System.Linq;
using System.Web.UI.WebControls;
using Rock;
using Rock.Attribute;
using Rock.Data;
using Rock.Model;
using Rock.SystemGuid;
using Rock.Web.UI;
namespace RockWeb.Plugins.org_newpointe.Staff
{
[DisplayName( "Staff" )]
[Category( "NewPointe.org Web Blocks" )]
[Description( "This block will display all members of the selected group" )]
[GroupField( "Root Group", "Select the root group to use as a starting point for the tree view.", false, order: 1 )]
public partial class Staff : RockBlock
{
protected void Page_Load( object sender, EventArgs e )
{
Guid? rootGroupGuid = GetAttributeValue( "RootGroup" ).AsGuidOrNull();
if ( rootGroupGuid != null )
{
var staffGroup = new GroupService( new RockContext() ).Get( rootGroupGuid.Value );
lblGroupName.Text = staffGroup.Name;
rptStaff.DataSource = staffGroup
.Members
.OrderByDescending( g => g.GroupMemberStatus )
.ThenBy( m => m.Person.LastName )
.ThenBy( m => m.Person.FirstName )
.Select( m => m.Person )
.ToList().Select( person =>
{
person.LoadAttributes();
return new
{
Name = person.FullName,
PhotoUrl = person.PhotoUrl,
Position = person.GetAttributeValue( "StaffPosition" )
};
}
);
rptStaff.DataBind();
}
}
protected void rptStaff_ItemDataBound( object sender, RepeaterItemEventArgs e )
{
if ( ( e.Item.ItemIndex + 1 ) % 6 == 0 )
{
e.Item.Controls.Add( new Panel { CssClass = "clearfix visible-lg-block" } );
}
if ( ( e.Item.ItemIndex + 1 ) % 4 == 0 )
{
e.Item.Controls.Add( new Panel { CssClass = "clearfix visible-md-block" } );
}
if ( ( e.Item.ItemIndex + 1 ) % 3 == 0 )
{
e.Item.Controls.Add( new Panel { CssClass = "clearfix visible-sm-block" } );
}
if ( ( e.Item.ItemIndex + 1 ) % 2 == 0 )
{
e.Item.Controls.Add( new Panel { CssClass = "clearfix visible-xs-block" } );
}
}
}
}