Renamed Raid Templates to Event Templates

Added Filter to Event Templates
This commit is contained in:
Sarah Faey 2022-12-04 10:51:09 +01:00
parent 2216565d9e
commit 50120badcc
3 changed files with 70 additions and 10 deletions

View file

@ -16,7 +16,7 @@
@inject IJSRuntime JsRuntime @inject IJSRuntime JsRuntime
<h3>CreateRaid</h3> <h3>Create or edit Template</h3>
<AuthorizeView Policy="@Constants.Roles.RaidLead.Name" Context="authorizationContext"> <AuthorizeView Policy="@Constants.Roles.RaidLead.Name" Context="authorizationContext">
<EditForm Model="@_template" OnValidSubmit="@HandleValidSubmit"> <EditForm Model="@_template" OnValidSubmit="@HandleValidSubmit">
@ -81,7 +81,7 @@
<p> <p>
<label> <label>
Time Zone: Time Zone:
<InputSelect @bind-Value="_template.RequiredRole"> <InputSelect @bind-Value="_template.TimeZone">
<option value="@_template.TimeZone">@_template.TimeZone</option> <option value="@_template.TimeZone">@_template.TimeZone</option>
@if(_userTimeZone != @_template.TimeZone) @if(_userTimeZone != @_template.TimeZone)
{ {

View file

@ -8,18 +8,42 @@
@inject AuthenticationStateProvider AuthenticationStateProvider @inject AuthenticationStateProvider AuthenticationStateProvider
<h3>RaidTemplateOverview</h3> <h3>Event Templates</h3>
<AuthorizeView Policy="@Constants.Roles.RaidLead.Name"> <AuthorizeView Policy="@Constants.Roles.RaidLead.Name">
<div class="nav-item px-3"> <div class="nav-item px-3">
<NavLink class="nav-link" href="raidtemplateedit"> <NavLink class="nav-link" href="raidtemplateedit">
<span class="oi oi-plus" aria-hidden="true"></span> Add Raid <span class="oi oi-plus" aria-hidden="true"></span> Add Template
</NavLink> </NavLink>
</div> </div>
</AuthorizeView> </AuthorizeView>
@foreach (var raid in _templates.OrderBy(r => r.StartTime)) <br />
<label>Raid Group:</label>
<select @onchange="args => GroupFilterChanged(args)" >
<option value="">All</option>
<option value="No Group">No Group</option>
@foreach(LiebRole role in UserService.GetLiebRoles())
{
if (role.Type != RoleType.SystemRole)
{
<option value="@role.RoleName">@role.RoleName</option>
}
}
</select>
<label>Event Type:</label>
<select @onchange="args => EventTypeFilterChanged(args)" >
<option value="">All</option>
@foreach(EventType eventType in (EventType[]) Enum.GetValues(typeof(EventType)))
{
<option value="@eventType">@eventType.ToString()</option>
}
</select>
<br />
@foreach (var raid in _templatesToShow.OrderBy(r => r.StartTime))
{ {
<br /> <br />
<RaidTemplateDetails _template=@raid _user=@_user/> <RaidTemplateDetails _template=@raid _user=@_user/>
@ -29,6 +53,9 @@
{ {
private List<RaidTemplate> _templates; private List<RaidTemplate> _templates;
private LiebUser? _user; private LiebUser? _user;
private string _filterRole = string.Empty;
private string _filterEventType = string.Empty;
private List<RaidTemplate> _templatesToShow;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -40,5 +67,38 @@
ulong discordId = ulong.Parse(authState.User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value); ulong discordId = ulong.Parse(authState.User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value);
_user = UserService.GetLiebUser(discordId); _user = UserService.GetLiebUser(discordId);
} }
ApplyFilter();
}
private void GroupFilterChanged(ChangeEventArgs e)
{
_filterRole = e.Value?.ToString();
ApplyFilter();
}
private void EventTypeFilterChanged(ChangeEventArgs e)
{
_filterEventType = e.Value?.ToString();
ApplyFilter();
}
private void ApplyFilter()
{
if(String.IsNullOrEmpty(_filterRole))
{
_templatesToShow = _templates;
}
else if(_filterRole == "No Group")
{
_templatesToShow = _templates.Where(r => string.IsNullOrEmpty(r.RequiredRole)).ToList();
}
else
{
_templatesToShow = _templates.Where(r => r.RequiredRole == _filterRole).ToList();
}
if(!String.IsNullOrEmpty(_filterEventType))
{
_templatesToShow = _templatesToShow.Where(r => r.EventType.ToString() == _filterEventType).ToList();
}
} }
} }

View file

@ -36,7 +36,7 @@
<Authorized> <Authorized>
<div class="nav-item px-3"> <div class="nav-item px-3">
<NavLink class="nav-link" href="raidtemplateoverview"> <NavLink class="nav-link" href="raidtemplateoverview">
<span class="oi oi-list-rich" aria-hidden="true"></span> Raid Templates <span class="oi oi-list-rich" aria-hidden="true"></span> Event Templates
</NavLink> </NavLink>
</div> </div>
</Authorized> </Authorized>