mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-21 02:17:20 +02:00
feat: split search components
This commit is contained in:
1 parent
b928e0fec9
commit
6f7a7609ac
6 files changed
+84
-29
No files matched your search
@@ -0,0 +1,7 @@
|
||||
@Clan.Tag
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public IFindClans_Clans Clan { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
@Player.AccountId
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public IFindPlayers_Players Player { get; set; }
|
||||
|
||||
|
||||
}
|
||||
@@ -16,18 +16,32 @@
|
||||
</div>
|
||||
</div>
|
||||
<RadzenProgressBar Value="100" ShowValue="false" Mode="ProgressBarMode.Indeterminate"
|
||||
Visible="@ComponentBusy"
|
||||
Style="width: 100%; margin-top: 10px;" />
|
||||
<RadzenListBox @bind-Value=@CurrentValue
|
||||
Data=@FilteredList
|
||||
ValueProperty="ItemId"
|
||||
Style="height:330px; width: 100%; margin-top: 10px;"
|
||||
Visible="@(!ComponentBusy)">
|
||||
<Template>
|
||||
<!--ToDo: Create new component that will show nick[clan] {WinRate with color}, {battles count with translatable word "battles"}. And another component for Clans-->
|
||||
@(((SearchItem) context).ItemName) | accountId: @(((SearchItem) context).ItemId)
|
||||
</Template>
|
||||
</RadzenListBox>
|
||||
Visible="@ComponentBusy"
|
||||
Style="width: 100%; margin-top: 10px;" />
|
||||
@if (DialogType == DialogType.FindPlayer)
|
||||
{
|
||||
<RadzenListBox @bind-Value=@CurrentValue
|
||||
Data=@PlayersList
|
||||
ValueProperty="AccountId"
|
||||
Style="height: 330px; width: 100%; margin-top: 10px;"
|
||||
Visible="@(!ComponentBusy)">
|
||||
<Template>
|
||||
<FindPlayerListItem Player="@((IFindPlayers_Players) context)"></FindPlayerListItem>
|
||||
</Template>
|
||||
</RadzenListBox>
|
||||
}
|
||||
@if (DialogType == DialogType.FindClan)
|
||||
{
|
||||
<RadzenListBox @bind-Value=@CurrentValue
|
||||
Data=@ClansList
|
||||
ValueProperty="ClanId"
|
||||
Style="height: 330px; width: 100%; margin-top: 10px;"
|
||||
Visible="@(!ComponentBusy)">
|
||||
<Template>
|
||||
<FindClanListItem Clan="((IFindClans_Clans)context)"></FindClanListItem>
|
||||
</Template>
|
||||
</RadzenListBox>
|
||||
}
|
||||
<RadzenButton Click=@(args => OnOkButtonClick())
|
||||
Text="Ok"
|
||||
Visible="@(!ComponentBusy)"
|
||||
|
||||
@@ -29,10 +29,11 @@ namespace WotBlitzStatisticsPro.Blazor.Pages
|
||||
[Parameter]
|
||||
public DialogType DialogType { get; set; }
|
||||
|
||||
public List<SearchItem> FilteredList { get; set; } = new();
|
||||
|
||||
public List<RealmSelector> Realms { get; set; }
|
||||
|
||||
public List<IFindPlayers_Players> PlayersList { get; set; } = new();
|
||||
public List<IFindClans_Clans> ClansList { get; set; } = new();
|
||||
|
||||
public RealmType CurrentRealmType { get; set; } = RealmType.Eu;
|
||||
|
||||
public long CurrentValue { get; set; }
|
||||
@@ -58,22 +59,18 @@ namespace WotBlitzStatisticsPro.Blazor.Pages
|
||||
return;
|
||||
}
|
||||
|
||||
FilteredList.Clear();
|
||||
ComponentBusy = true;
|
||||
PlayersList.Clear();
|
||||
ClansList.Clear();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
var accounts =
|
||||
await GraphQlBackendService.FindPlayers(value, CurrentRealmType);
|
||||
|
||||
if (accounts != null)
|
||||
if (DialogType == DialogType.FindPlayer)
|
||||
{
|
||||
await FindPlayers(value);
|
||||
}
|
||||
|
||||
foreach (var account in accounts)
|
||||
{
|
||||
FilteredList.Add(new SearchItem(account.AccountId, $"{account.Nickname} [{account.ClanTag}] | {account.WinRate}%"));
|
||||
|
||||
}
|
||||
|
||||
if (DialogType == DialogType.FindClan)
|
||||
{
|
||||
await FindClans(value);
|
||||
}
|
||||
|
||||
ComponentBusy = false;
|
||||
@@ -84,10 +81,39 @@ namespace WotBlitzStatisticsPro.Blazor.Pages
|
||||
{
|
||||
if (CurrentValue > 0)
|
||||
{
|
||||
await Mediator.Publish(new OpenPlayerInfoMessage(CurrentValue, false));
|
||||
if (DialogType == DialogType.FindPlayer)
|
||||
{
|
||||
await Mediator.Publish(new OpenPlayerInfoMessage(CurrentValue, false));
|
||||
}
|
||||
|
||||
if (DialogType == DialogType.FindClan)
|
||||
{
|
||||
//await Mediator.Publish(new OpenClanInfoMessage(CurrentValue, false));
|
||||
}
|
||||
}
|
||||
|
||||
DialogService.Close(true);
|
||||
}
|
||||
|
||||
private async Task FindPlayers(string searchString)
|
||||
{
|
||||
var accounts =
|
||||
await GraphQlBackendService.FindPlayers(searchString, CurrentRealmType);
|
||||
if (accounts != null)
|
||||
{
|
||||
PlayersList = new List<IFindPlayers_Players>(accounts);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private async Task FindClans(string searchString)
|
||||
{
|
||||
var clans =
|
||||
await GraphQlBackendService.FindClans(searchString, CurrentRealmType);
|
||||
if (clans != null)
|
||||
{
|
||||
ClansList = new List<IFindClans_Clans>(clans);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ namespace WotBlitzStatisticsPro.Blazor.Services
|
||||
{
|
||||
result.Add(new FindClans_Clans_ClanSearchResponseItem(
|
||||
faker.Random.Long(100000, 999999),
|
||||
Convert.ToInt32((faker.Date.Past() - new DateTime(1970, 1, 1)).TotalMilliseconds),
|
||||
Convert.ToInt32((faker.Date.Past() - new DateTime(1970, 1, 1)).TotalSeconds),
|
||||
faker.Random.Number(1, 50),
|
||||
faker.Lorem.Word(),
|
||||
faker.Lorem.Letter()));
|
||||
|
||||
@@ -19,7 +19,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WotBlitzStatisticsPro.Tests
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WotBlitzStatisticsPro.Blazor", "WotBlitzStatisticsPro.Blazor\WotBlitzStatisticsPro.Blazor.csproj", "{3A27736F-B5DD-4310-A013-2BB65C975104}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WotBlitzStatisticsPro.Blazor.Tests", "WotBlitzStatisticsPro.Blazor.Tests\WotBlitzStatisticsPro.Blazor.Tests.csproj", "{7969D13E-2148-4608-8500-2DA22947A39C}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WotBlitzStatisticsPro.Blazor.Tests", "WotBlitzStatisticsPro.Blazor.Tests\WotBlitzStatisticsPro.Blazor.Tests.csproj", "{7969D13E-2148-4608-8500-2DA22947A39C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
||||
Reference in new issue
Block a user