Browse Source

allow enter key to submit add to collection dialog (#167)

pull/168/head
Jason Dove 5 years ago committed by GitHub
parent
commit
a854294cb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 67
      ErsatzTV/Shared/AddToCollectionDialog.razor

67
ErsatzTV/Shared/AddToCollectionDialog.razor

@ -7,34 +7,37 @@
@inject ISnackbar Snackbar @inject ISnackbar Snackbar
@inject ILogger<AddToCollectionDialog> Logger @inject ILogger<AddToCollectionDialog> Logger
<MudDialog> <div @onkeydown="@OnKeyDown">
<DialogContent> <MudDialog>
<MudContainer Class="mb-6"> <DialogContent>
<MudHighlighter Class="mud-primary-text" <MudContainer Class="mb-6">
Style="background-color: transparent; font-weight: bold" <MudHighlighter Class="mud-primary-text"
Text="@FormatText()" Style="background-color: transparent; font-weight: bold"
HighlightedText="@EntityName"/> Text="@FormatText()"
</MudContainer> HighlightedText="@EntityName"/>
<MudSelect Label="Collection" @bind-Value="_selectedCollection" For="@(() => _selectedCollection)" Class="mb-6 mx-4"> </MudContainer>
@foreach (MediaCollectionViewModel collection in _collections) <MudSelect Label="Collection" @bind-Value="_selectedCollection" For="@(() => _selectedCollection)" Class="mb-6 mx-4">
{ @foreach (MediaCollectionViewModel collection in _collections)
<MudSelectItem Value="@collection">@collection.Name</MudSelectItem> {
} <MudSelectItem Value="@collection">@collection.Name</MudSelectItem>
</MudSelect> }
<MudTextFieldString Label="New Collection Name" </MudSelect>
Disabled="@(_selectedCollection != _newCollection)" <MudTextFieldString Label="New Collection Name"
@bind-Text="@_newCollectionName" Disabled="@(_selectedCollection != _newCollection)"
Immediate="true" @bind-Text="@_newCollectionName"
Class="mb-6 mx-4"> Immediate="true"
</MudTextFieldString> Class="mb-6 mx-4">
</DialogContent> </MudTextFieldString>
<DialogActions> </DialogContent>
<MudButton OnClick="Cancel">Cancel</MudButton> <DialogActions>
<MudButton Color="Color.Primary" Variant="Variant.Filled" Disabled="@(!CanSubmit())" OnClick="Submit"> <MudButton OnClick="Cancel">Cancel</MudButton>
Add To Collection <MudButton Color="Color.Primary" Variant="Variant.Filled" Disabled="@(!CanSubmit())" OnClick="Submit">
</MudButton> Add To Collection
</DialogActions> </MudButton>
</MudDialog> </DialogActions>
</MudDialog>
</div>
@code { @code {
@ -109,4 +112,12 @@
private void Cancel() => MudDialog.Cancel(); private void Cancel() => MudDialog.Cancel();
private async Task OnKeyDown(KeyboardEventArgs e)
{
if (e.Code is "Enter" or "NumpadEnter" && CanSubmit())
{
await Submit();
}
}
} }
Loading…
Cancel
Save