feat: split search components

This commit is contained in:
Mikhail Shabanov committed 2021-05-16 22:43:49 +02:00
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>
</div> </div>
<RadzenProgressBar Value="100" ShowValue="false" Mode="ProgressBarMode.Indeterminate" <RadzenProgressBar Value="100" ShowValue="false" Mode="ProgressBarMode.Indeterminate"
Visible="@ComponentBusy" Visible="@ComponentBusy"
Style="width: 100%; margin-top: 10px;" /> Style="width: 100%; margin-top: 10px;" />
<RadzenListBox @bind-Value=@CurrentValue @if (DialogType == DialogType.FindPlayer)
Data=@FilteredList {
ValueProperty="ItemId" <RadzenListBox @bind-Value=@CurrentValue
Style="height:330px; width: 100%; margin-top: 10px;" Data=@PlayersList
Visible="@(!ComponentBusy)"> ValueProperty="AccountId"
<Template> Style="height: 330px; width: 100%; margin-top: 10px;"
<!--ToDo: Create new component that will show nick[clan] {WinRate with color}, {battles count with translatable word "battles"}. And another component for Clans--> Visible="@(!ComponentBusy)">
@(((SearchItem) context).ItemName) | accountId: @(((SearchItem) context).ItemId) <Template>
</Template> <FindPlayerListItem Player="@((IFindPlayers_Players) context)"></FindPlayerListItem>
</RadzenListBox> </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()) <RadzenButton Click=@(args => OnOkButtonClick())
Text="Ok" Text="Ok"
Visible="@(!ComponentBusy)" Visible="@(!ComponentBusy)"
@@ -29,10 +29,11 @@ namespace WotBlitzStatisticsPro.Blazor.Pages
[Parameter] [Parameter]
public DialogType DialogType { get; set; } public DialogType DialogType { get; set; }
public List<SearchItem> FilteredList { get; set; } = new();
public List<RealmSelector> Realms { get; set; } 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 RealmType CurrentRealmType { get; set; } = RealmType.Eu;
public long CurrentValue { get; set; } public long CurrentValue { get; set; }
@@ -58,22 +59,18 @@ namespace WotBlitzStatisticsPro.Blazor.Pages
return; return;
} }
FilteredList.Clear();
ComponentBusy = true; ComponentBusy = true;
PlayersList.Clear();
ClansList.Clear();
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
if (DialogType == DialogType.FindPlayer)
var accounts =
await GraphQlBackendService.FindPlayers(value, CurrentRealmType);
if (accounts != null)
{ {
await FindPlayers(value);
}
foreach (var account in accounts) if (DialogType == DialogType.FindClan)
{ {
FilteredList.Add(new SearchItem(account.AccountId, $"{account.Nickname} [{account.ClanTag}] | {account.WinRate}%")); await FindClans(value);
}
} }
ComponentBusy = false; ComponentBusy = false;
@@ -84,10 +81,39 @@ namespace WotBlitzStatisticsPro.Blazor.Pages
{ {
if (CurrentValue > 0) 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); 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( result.Add(new FindClans_Clans_ClanSearchResponseItem(
faker.Random.Long(100000, 999999), 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.Random.Number(1, 50),
faker.Lorem.Word(), faker.Lorem.Word(),
faker.Lorem.Letter())); faker.Lorem.Letter()));
+1 -1
View File
@@ -19,7 +19,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WotBlitzStatisticsPro.Tests
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WotBlitzStatisticsPro.Blazor", "WotBlitzStatisticsPro.Blazor\WotBlitzStatisticsPro.Blazor.csproj", "{3A27736F-B5DD-4310-A013-2BB65C975104}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WotBlitzStatisticsPro.Blazor", "WotBlitzStatisticsPro.Blazor\WotBlitzStatisticsPro.Blazor.csproj", "{3A27736F-B5DD-4310-A013-2BB65C975104}"
EndProject 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 EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution