|
|
|
@ -7,36 +7,35 @@ |
|
|
|
@inject ISnackbar Snackbar |
|
|
|
@inject ISnackbar Snackbar |
|
|
|
@inject ILogger<AddToCollectionDialog> Logger |
|
|
|
@inject ILogger<AddToCollectionDialog> Logger |
|
|
|
|
|
|
|
|
|
|
|
<div @onkeydown="@OnKeyDown"> |
|
|
|
<MudDialog> |
|
|
|
<MudDialog> |
|
|
|
<DialogContent> |
|
|
|
<DialogContent> |
|
|
|
<EditForm Model="@_dummyModel" OnSubmit="@(_ => Submit())"> |
|
|
|
<MudContainer Class="mb-6"> |
|
|
|
<MudContainer Class="mb-6"> |
|
|
|
<MudHighlighter Class="mud-primary-text" |
|
|
|
<MudHighlighter Class="mud-primary-text" |
|
|
|
Style="background-color: transparent; font-weight: bold" |
|
|
|
Style="background-color: transparent; font-weight: bold" |
|
|
|
Text="@FormatText()" |
|
|
|
Text="@FormatText()" |
|
|
|
HighlightedText="@EntityName"/> |
|
|
|
HighlightedText="@EntityName"/> |
|
|
|
</MudContainer> |
|
|
|
</MudContainer> |
|
|
|
<MudSelect Label="Collection" @bind-Value="_selectedCollection" For="@(() => _selectedCollection)" Class="mb-6 mx-4"> |
|
|
|
<MudSelect Label="Collection" @bind-Value="_selectedCollection" Class="mb-6 mx-4"> |
|
|
|
@foreach (MediaCollectionViewModel collection in _collections) |
|
|
|
@foreach (MediaCollectionViewModel collection in _collections) |
|
|
|
{ |
|
|
|
{ |
|
|
|
<MudSelectItem Value="@collection">@collection.Name</MudSelectItem> |
|
|
|
<MudSelectItem Value="@collection">@collection.Name</MudSelectItem> |
|
|
|
} |
|
|
|
} |
|
|
|
</MudSelect> |
|
|
|
</MudSelect> |
|
|
|
<MudTextFieldString Label="New Collection Name" |
|
|
|
<MudTextFieldString Label="New Collection Name" |
|
|
|
Disabled="@(_selectedCollection != _newCollection)" |
|
|
|
Disabled="@(_selectedCollection != _newCollection)" |
|
|
|
@bind-Text="@_newCollectionName" |
|
|
|
@bind-Text="@_newCollectionName" |
|
|
|
Immediate="true" |
|
|
|
Class="mb-6 mx-4"> |
|
|
|
Class="mb-6 mx-4"> |
|
|
|
</MudTextFieldString> |
|
|
|
</MudTextFieldString> |
|
|
|
</EditForm> |
|
|
|
</DialogContent> |
|
|
|
</DialogContent> |
|
|
|
<DialogActions> |
|
|
|
<DialogActions> |
|
|
|
<MudButton OnClick="Cancel">Cancel</MudButton> |
|
|
|
<MudButton OnClick="Cancel" ButtonType="ButtonType.Reset">Cancel</MudButton> |
|
|
|
<MudButton Color="Color.Primary" Variant="Variant.Filled" Disabled="@(!CanSubmit())" OnClick="Submit"> |
|
|
|
<MudButton Color="Color.Primary" Variant="Variant.Filled" OnClick="Submit"> |
|
|
|
Add To Collection |
|
|
|
Add To Collection |
|
|
|
</MudButton> |
|
|
|
</MudButton> |
|
|
|
</DialogActions> |
|
|
|
</DialogActions> |
|
|
|
</MudDialog> |
|
|
|
</MudDialog> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@code { |
|
|
|
@code { |
|
|
|
@ -62,6 +61,9 @@ |
|
|
|
private List<MediaCollectionViewModel> _collections; |
|
|
|
private List<MediaCollectionViewModel> _collections; |
|
|
|
|
|
|
|
|
|
|
|
private MediaCollectionViewModel _selectedCollection; |
|
|
|
private MediaCollectionViewModel _selectedCollection; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private record DummyModel; |
|
|
|
|
|
|
|
private DummyModel _dummyModel = new(); |
|
|
|
|
|
|
|
|
|
|
|
private bool CanSubmit() => |
|
|
|
private bool CanSubmit() => |
|
|
|
_selectedCollection != null && (_selectedCollection != _newCollection || !string.IsNullOrWhiteSpace(_newCollectionName)); |
|
|
|
_selectedCollection != null && (_selectedCollection != _newCollection || !string.IsNullOrWhiteSpace(_newCollectionName)); |
|
|
|
@ -85,6 +87,11 @@ |
|
|
|
|
|
|
|
|
|
|
|
private async Task Submit() |
|
|
|
private async Task Submit() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (!CanSubmit()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (_selectedCollection == _newCollection) |
|
|
|
if (_selectedCollection == _newCollection) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Either<BaseError, MediaCollectionViewModel> maybeResult = |
|
|
|
Either<BaseError, MediaCollectionViewModel> maybeResult = |
|
|
|
@ -110,14 +117,17 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void Cancel() => MudDialog.Cancel(); |
|
|
|
private async Task Cancel(MouseEventArgs e) |
|
|
|
|
|
|
|
|
|
|
|
private async Task OnKeyDown(KeyboardEventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (e.Code is "Enter" or "NumpadEnter" && CanSubmit()) |
|
|
|
// this is gross, but [enter] seems to sometimes trigger cancel instead of submit |
|
|
|
|
|
|
|
if (e.Detail == 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
await Submit(); |
|
|
|
await Submit(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
MudDialog.Cancel(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |