2024-05-25 19:12:30 +02:00
|
|
|
@using System.Collections.Immutable
|
2022-09-15 11:47:46 +02:00
|
|
|
@inject IGameDataService GameDataService
|
2024-05-03 23:46:27 +02:00
|
|
|
@inject IJSRuntime Js
|
2022-09-15 11:47:46 +02:00
|
|
|
|
|
|
|
<MudDialog>
|
|
|
|
<DialogContent>
|
2024-05-25 19:12:30 +02:00
|
|
|
<MudTable Items="@Titles" Filter="@Filter" @bind-SelectedItem="@selectedTitle" Height="40vh" Hover="true">
|
2022-09-15 13:05:36 +02:00
|
|
|
<ColGroup>
|
2022-09-15 17:57:39 +02:00
|
|
|
<col style="width: 50px;" />
|
2022-09-15 13:05:36 +02:00
|
|
|
<col />
|
|
|
|
</ColGroup>
|
2022-09-15 11:47:46 +02:00
|
|
|
<ToolBarContent>
|
|
|
|
<MudTextField @bind-Value="searchString" Placeholder="Search" Adornment="Adornment.Start" Immediate="true"
|
2024-03-09 00:42:56 +01:00
|
|
|
AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Class="mt-0">
|
2022-09-15 11:47:46 +02:00
|
|
|
</MudTextField>
|
|
|
|
</ToolBarContent>
|
|
|
|
<HeaderContent>
|
|
|
|
<MudTh>
|
|
|
|
<MudTableSortLabel SortBy="@(new Func<Title, object>(x => x.TitleId))">
|
2024-03-08 17:13:56 +01:00
|
|
|
@Localizer["ID"]
|
2024-03-09 00:42:56 +01:00
|
|
|
</MudTableSortLabel>
|
2022-09-15 11:47:46 +02:00
|
|
|
</MudTh>
|
|
|
|
<MudTh>
|
|
|
|
<MudTableSortLabel SortBy="@(new Func<Title, object>(x => x.TitleName))">
|
2024-03-08 17:13:56 +01:00
|
|
|
@Localizer["Title"]
|
2022-09-15 11:47:46 +02:00
|
|
|
</MudTableSortLabel>
|
|
|
|
</MudTh>
|
|
|
|
</HeaderContent>
|
|
|
|
<RowTemplate>
|
2022-09-16 15:48:16 +02:00
|
|
|
@{
|
|
|
|
// Disable nullable warnings, which seems to be a false positive
|
2024-03-09 00:42:56 +01:00
|
|
|
#pragma warning disable CS8602
|
2022-09-16 15:48:16 +02:00
|
|
|
}
|
2022-09-15 13:05:36 +02:00
|
|
|
<MudTd DataLabel="Id" Class="cursor-pointer">@context.TitleId</MudTd>
|
2022-09-15 17:59:40 +02:00
|
|
|
<MudTd DataLabel="Title" Class="cursor-pointer">@context.TitleName</MudTd>
|
2022-09-16 15:48:16 +02:00
|
|
|
@{
|
2024-03-09 00:42:56 +01:00
|
|
|
#pragma warning restore CS8602
|
2022-09-16 15:48:16 +02:00
|
|
|
}
|
2022-09-15 11:47:46 +02:00
|
|
|
</RowTemplate>
|
|
|
|
<PagerContent>
|
2024-05-03 23:46:27 +02:00
|
|
|
<MudTablePager RowsPerPageString=@Localizer["Rows Per Page"] />
|
2022-09-15 11:47:46 +02:00
|
|
|
</PagerContent>
|
|
|
|
</MudTable>
|
2024-06-05 03:07:33 +02:00
|
|
|
<MudText Class="mt-4 d-block" Typo="Typo.caption"> <b>@Localizer["Currently Selected:"]</b> @selectedTitle?.TitleName</MudText>
|
2022-09-15 11:47:46 +02:00
|
|
|
</DialogContent>
|
|
|
|
<DialogActions>
|
2024-03-09 00:42:56 +01:00
|
|
|
<MudButton OnClick="Cancel">
|
|
|
|
@Localizer["Cancel"]
|
|
|
|
</MudButton>
|
2024-03-08 17:13:56 +01:00
|
|
|
<MudButton Color="Color.Primary" OnClick="Submit">
|
2024-06-05 03:07:33 +02:00
|
|
|
@Localizer["Dialog OK"]
|
2024-03-08 17:13:56 +01:00
|
|
|
</MudButton>
|
2022-09-15 11:47:46 +02:00
|
|
|
</DialogActions>
|
|
|
|
</MudDialog>
|
|
|
|
|
|
|
|
@code {
|
|
|
|
|
|
|
|
[CascadingParameter]
|
|
|
|
MudDialogInstance MudDialog { get; set; } = null!;
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
public UserSetting UserSetting { get; set; } = new();
|
|
|
|
|
2023-11-13 00:12:54 +01:00
|
|
|
[Parameter]
|
|
|
|
public bool AllowFreeProfileEditing { get; set; }
|
2024-05-17 00:32:46 +02:00
|
|
|
|
|
|
|
[Parameter]
|
2024-05-25 19:12:30 +02:00
|
|
|
public List<Title> Titles { get; set; } = new();
|
2022-09-15 11:47:46 +02:00
|
|
|
|
|
|
|
private Title? selectedTitle;
|
|
|
|
|
|
|
|
private string searchString = string.Empty;
|
|
|
|
|
|
|
|
protected override void OnInitialized()
|
|
|
|
{
|
|
|
|
base.OnInitialized();
|
2022-09-15 18:06:26 +02:00
|
|
|
var currentTitle = new Title
|
|
|
|
{
|
|
|
|
TitleName = UserSetting.Title
|
2024-03-09 00:42:56 +01:00
|
|
|
};
|
2024-05-25 19:12:30 +02:00
|
|
|
if (Titles.Contains(currentTitle))
|
2024-03-09 00:42:56 +01:00
|
|
|
{
|
2024-05-25 19:12:30 +02:00
|
|
|
selectedTitle = currentTitle;
|
2022-09-15 18:06:26 +02:00
|
|
|
}
|
2022-09-15 11:47:46 +02:00
|
|
|
}
|
|
|
|
|
2022-09-16 15:48:16 +02:00
|
|
|
private bool Filter(Title? title)
|
2022-09-15 11:47:46 +02:00
|
|
|
{
|
2022-09-16 15:48:16 +02:00
|
|
|
if (title is null)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2022-09-15 11:47:46 +02:00
|
|
|
return string.IsNullOrEmpty(searchString) ||
|
2024-03-09 00:42:56 +01:00
|
|
|
title.TitleName.Contains(searchString, StringComparison.InvariantCultureIgnoreCase);
|
2022-09-15 11:47:46 +02:00
|
|
|
}
|
|
|
|
|
2024-05-03 23:46:27 +02:00
|
|
|
private async Task Submit()
|
2022-09-15 11:47:46 +02:00
|
|
|
{
|
|
|
|
if (selectedTitle is not null)
|
|
|
|
{
|
|
|
|
UserSetting.Title = selectedTitle.TitleName;
|
2023-11-13 00:12:54 +01:00
|
|
|
UserSetting.TitlePlateId = selectedTitle.TitleRarity;
|
2022-09-15 11:47:46 +02:00
|
|
|
}
|
2024-05-03 23:46:27 +02:00
|
|
|
|
|
|
|
await Js.InvokeVoidAsync("updateTitleText", UserSetting.Title);
|
2022-09-15 11:47:46 +02:00
|
|
|
MudDialog.Close(DialogResult.Ok(true));
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Cancel() => MudDialog.Cancel();
|
|
|
|
|
|
|
|
}
|