included build filters to BuildOverview and ManageGW2Account
This commit is contained in:
parent
3d7d409646
commit
8afe8af4c5
3 changed files with 72 additions and 19 deletions
|
@ -13,7 +13,6 @@
|
|||
<AuthorizeView Policy="@Constants.Roles.Admin" Context="authorizationContext">
|
||||
<EditForm Model="@_build" OnValidSubmit="@HandleValidSubmit">
|
||||
<DataAnnotationsValidator />
|
||||
<ValidationSummary />
|
||||
|
||||
<p>
|
||||
<label>
|
||||
|
@ -69,6 +68,8 @@
|
|||
</InputSelect>
|
||||
</label>
|
||||
</p>
|
||||
|
||||
<ValidationSummary />
|
||||
<button type="submit">Submit</button>
|
||||
|
||||
</EditForm>
|
||||
|
|
|
@ -15,6 +15,17 @@
|
|||
</NavLink>
|
||||
</div>
|
||||
|
||||
<label>
|
||||
Filter:
|
||||
<select @onchange="args => ChangeFilter(args)" >
|
||||
<option value="All">All</option>
|
||||
@foreach(GuildWars2Class gw2Class in Enum.GetValues(typeof(GuildWars2Class)))
|
||||
{
|
||||
<option value="@gw2Class">@gw2Class.ToString()</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
|
@ -25,8 +36,7 @@
|
|||
<th>Quick</th>
|
||||
<th>Alac</th>
|
||||
</tr>
|
||||
|
||||
@foreach (var build in _builds.OrderBy(b => b.Class).ThenBy(b => b.EliteSpecialization))
|
||||
@foreach (var build in _buildsToShow.OrderBy(b => b.Class).ThenBy(b => b.EliteSpecialization))
|
||||
{
|
||||
<tr>
|
||||
<td class="nav-item px-3">
|
||||
|
@ -49,9 +59,23 @@
|
|||
@code
|
||||
{
|
||||
private List<GuildWars2Build> _builds;
|
||||
private List<GuildWars2Build> _buildsToShow;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_builds = GuildWars2BuildService.GetBuilds();
|
||||
_buildsToShow = _builds;
|
||||
}
|
||||
|
||||
private void ChangeFilter( ChangeEventArgs e)
|
||||
{
|
||||
if(Enum.TryParse<GuildWars2Class>(e.Value?.ToString(),out GuildWars2Class selectedClass))
|
||||
{
|
||||
_buildsToShow = _builds.Where(b => b.Class == selectedClass).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_buildsToShow = _builds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,16 @@
|
|||
@if (_account.GuildWars2AccountId != 0)
|
||||
{
|
||||
<br />
|
||||
<label>
|
||||
Filter:
|
||||
<select @onchange="args => ChangeBuildFilter(args)" >
|
||||
<option value="All">All</option>
|
||||
@foreach(GuildWars2Class gw2Class in Enum.GetValues(typeof(GuildWars2Class)))
|
||||
{
|
||||
<option value="@gw2Class">@gw2Class.ToString()</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Equipped</th>
|
||||
|
@ -54,7 +64,7 @@
|
|||
<th>Quick</th>
|
||||
<th>Alac</th>
|
||||
</tr>
|
||||
@foreach (GuildWars2Build build in GuildWars2BuildService.GetBuilds())
|
||||
@foreach (GuildWars2Build build in _buildsToShow.OrderBy(b => b.Class).ThenBy(b => b.EliteSpecialization))
|
||||
{
|
||||
Equipped? equippedBuild = _account.EquippedBuilds.FirstOrDefault(e => e.GuildWars2BuildId == build.GuildWars2BuildId);
|
||||
bool isEquipped = equippedBuild != null;
|
||||
|
@ -97,6 +107,10 @@
|
|||
|
||||
private string _saveMessage = string.Empty;
|
||||
|
||||
private List<GuildWars2Build> _builds;
|
||||
|
||||
private List<GuildWars2Build> _buildsToShow;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
||||
|
@ -111,6 +125,8 @@
|
|||
{
|
||||
_account = new GuildWars2Account();
|
||||
}
|
||||
_builds = GuildWars2BuildService.GetBuilds();
|
||||
_buildsToShow = _builds;
|
||||
}
|
||||
|
||||
async Task EquippedStatusChanged(int buildId, ChangeEventArgs args)
|
||||
|
@ -149,4 +165,16 @@
|
|||
_account = GuildWars2AccountService.GetAccount(_account.GuildWars2AccountId);
|
||||
_saveMessage = "changes saved successfully";
|
||||
}
|
||||
|
||||
private void ChangeBuildFilter( ChangeEventArgs e)
|
||||
{
|
||||
if(Enum.TryParse<GuildWars2Class>(e.Value?.ToString(),out GuildWars2Class selectedClass))
|
||||
{
|
||||
_buildsToShow = _builds.Where(b => b.Class == selectedClass).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_buildsToShow = _builds;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue