2026-03-03 22:29:41 -06:00
|
|
|
@inject MetadataService MetadataService
|
2023-03-02 18:50:24 -06:00
|
|
|
|
2026-06-01 02:15:53 -05:00
|
|
|
<Modal Visible="_modalVisible" Title="Game Metadata Lookup" Footer="null" Class="game-metadata-lookup-modal" OnCancel="Close">
|
|
|
|
|
<MetadataLookupPanel
|
|
|
|
|
GameId="GameId"
|
|
|
|
|
AutoFocus="true"
|
|
|
|
|
Search="@Value"
|
|
|
|
|
OnImported="OnPanelImported"
|
|
|
|
|
OnCancel="Close" />
|
2023-03-02 18:50:24 -06:00
|
|
|
</Modal>
|
2023-02-04 12:18:10 -06:00
|
|
|
|
2026-03-03 22:29:41 -06:00
|
|
|
<Flex Gap="FlexGap.Small">
|
|
|
|
|
<Input @bind-Value="Value" BindOnInput="true" OnkeyDown="SearchFieldOnKeyDown" OnChange="ValueChanged" AutoFocus="AutoFocus" />
|
2026-06-01 02:15:53 -05:00
|
|
|
<Button OnClick="OpenLookup" Type="ButtonType.Primary" Disabled="@(String.IsNullOrWhiteSpace(Value) || !_hasProviders)">@ButtonText</Button>
|
2026-03-03 22:29:41 -06:00
|
|
|
</Flex>
|
2023-08-09 15:28:05 -05:00
|
|
|
|
2023-02-04 12:18:10 -06:00
|
|
|
@code {
|
2026-03-03 22:29:41 -06:00
|
|
|
[Parameter] public Guid GameId { get; set; }
|
|
|
|
|
[Parameter] public EventCallback<Guid> OnImported { get; set; }
|
2026-06-01 02:15:53 -05:00
|
|
|
[Parameter] public string ButtonText { get; set; } = "Lookup";
|
2025-02-23 09:18:06 -06:00
|
|
|
[Parameter] public bool AutoFocus { get; set; }
|
2024-03-12 00:46:44 -05:00
|
|
|
[Parameter] public string Value { get; set; }
|
|
|
|
|
[Parameter] public EventCallback<string> ValueChanged { get; set; }
|
2023-02-04 12:18:10 -06:00
|
|
|
|
2026-06-01 02:15:53 -05:00
|
|
|
bool _modalVisible;
|
|
|
|
|
bool _hasProviders;
|
2026-05-07 01:11:41 -05:00
|
|
|
|
2026-06-01 02:15:53 -05:00
|
|
|
protected override void OnInitialized()
|
2026-05-07 01:11:41 -05:00
|
|
|
{
|
2026-06-01 02:15:53 -05:00
|
|
|
_hasProviders = MetadataService.GetProviderNames().Any();
|
2023-02-04 12:18:10 -06:00
|
|
|
}
|
|
|
|
|
|
2024-03-12 00:46:44 -05:00
|
|
|
private async Task SearchFieldOnKeyDown(KeyboardEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if ((e.Code == "Enter" || e.Code == "NumpadEnter") && !String.IsNullOrWhiteSpace(Value))
|
2026-06-01 02:15:53 -05:00
|
|
|
OpenLookup();
|
2026-03-03 22:29:41 -06:00
|
|
|
}
|
2023-02-04 12:18:10 -06:00
|
|
|
|
2026-06-01 02:15:53 -05:00
|
|
|
private void OpenLookup()
|
2026-03-03 22:29:41 -06:00
|
|
|
{
|
2026-06-01 02:15:53 -05:00
|
|
|
_modalVisible = true;
|
2023-08-09 15:28:05 -05:00
|
|
|
}
|
2026-03-03 22:29:41 -06:00
|
|
|
|
|
|
|
|
private void Close()
|
|
|
|
|
{
|
|
|
|
|
_modalVisible = false;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-01 02:15:53 -05:00
|
|
|
private async Task OnPanelImported(Guid gameId)
|
2026-03-03 22:29:41 -06:00
|
|
|
{
|
2026-06-01 02:15:53 -05:00
|
|
|
_modalVisible = false;
|
|
|
|
|
await OnImported.InvokeAsync(gameId);
|
2026-03-03 22:29:41 -06:00
|
|
|
}
|
|
|
|
|
}
|