File size: 3,879 Bytes
fc06b79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
@model IEnumerable<ContactManagementAPI.Models.UserGroup>
@{
    ViewData["Title"] = "User Groups";
    var isSuperAdmin = (ViewBag.IsSuperAdmin as bool?) == true;
}

<div class="admin-container">
    <div class="admin-header">
        <h2><i class="fas fa-layer-group"></i> User Groups</h2>
        <a href="/admin/creategroup" class="btn btn-primary"><i class="fas fa-plus"></i> New Group</a>
    </div>

    @if (TempData["SuccessMessage"] != null)
    {
        <div class="alert alert-success">@TempData["SuccessMessage"]</div>
    }

    @if (TempData["ErrorMessage"] != null)
    {
        <div class="alert alert-danger">@TempData["ErrorMessage"]</div>
    }

    <div class="table-responsive">
        @if (isSuperAdmin)
        {
            <form method="post" action="/admin/deleteselectedgroups" onsubmit="return confirm('Delete selected user groups? This cannot be undone.');">
                @Html.AntiForgeryToken()
                <div style="display:flex; gap:10px; align-items:center; margin-bottom:12px; flex-wrap:wrap;">
                    <button type="submit" class="btn btn-danger"><i class="fas fa-trash"></i> Delete Selected</button>
                    <span class="text-muted" style="font-size: 13px;">Order: delete contacts → delete users → delete user group.</span>
                </div>
                <table class="table">
            <thead>
                <tr>
                    <th style="width: 50px; text-align:center;">Select</th>
                    <th>Group Name</th>
                    <th>Description</th>
                    <th style="width: 220px;">Actions</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var group in Model)
                {
                    <tr>
                        <td style="text-align:center; vertical-align:middle;">
                            @if (string.Equals(group.Name, "Administrators", StringComparison.OrdinalIgnoreCase))
                            {
                                <input type="checkbox" disabled title="Protected group" />
                            }
                            else
                            {
                                <input type="checkbox" name="groupIds" value="@group.Id" />
                            }
                        </td>
                        <td>@group.Name</td>
                        <td>@group.Description</td>
                        <td>
                            <a href="/admin/editgroup/@group.Id" class="btn btn-sm btn-warning"><i class="fas fa-edit"></i> Edit</a>
                            <a href="/admin/grouprights/@group.Id" class="btn btn-sm btn-info"><i class="fas fa-key"></i> Rights</a>
                        </td>
                    </tr>
                }
            </tbody>
                </table>
            </form>
        }
        else
        {
            <table class="table">
                <thead>
                    <tr>
                        <th>Group Name</th>
                        <th>Description</th>
                        <th style="width: 220px;">Actions</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var group in Model)
                    {
                        <tr>
                            <td>@group.Name</td>
                            <td>@group.Description</td>
                            <td>
                                <a href="/admin/editgroup/@group.Id" class="btn btn-sm btn-warning"><i class="fas fa-edit"></i> Edit</a>
                                <a href="/admin/grouprights/@group.Id" class="btn btn-sm btn-info"><i class="fas fa-key"></i> Rights</a>
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        }
    </div>
</div>