@using System.Collections.Immutable @inject IGameDataService GameDataService @inject IJSRuntime Js @Localizer["ID"] @Localizer["Title"] @{ // Disable nullable warnings, which seems to be a false positive #pragma warning disable CS8602 } @context.TitleId @context.TitleName @{ #pragma warning restore CS8602 } @Localizer["Currently Selected:"] @selectedTitle?.TitleName @Localizer["Cancel"] @Localizer["Dialog OK"] @code { [CascadingParameter] MudDialogInstance MudDialog { get; set; } = null!; [Parameter] public UserSetting UserSetting { get; set; } = new(); [Parameter] public bool AllowFreeProfileEditing { get; set; } [Parameter] public List Titles { get; set; } = new(); private Title? selectedTitle; private string searchString = string.Empty; protected override void OnInitialized() { base.OnInitialized(); var currentTitle = new Title { TitleName = UserSetting.Title }; if (Titles.Contains(currentTitle)) { selectedTitle = currentTitle; } } private bool Filter(Title? title) { if (title is null) { return false; } return string.IsNullOrEmpty(searchString) || title.TitleName.Contains(searchString, StringComparison.InvariantCultureIgnoreCase); } private async Task Submit() { if (selectedTitle is not null) { UserSetting.Title = selectedTitle.TitleName; UserSetting.TitlePlateId = selectedTitle.TitleRarity; } await Js.InvokeVoidAsync("updateTitleText", UserSetting.Title); MudDialog.Close(DialogResult.Ok(true)); } private void Cancel() => MudDialog.Cancel(); }