70 lines
2.3 KiB
Plaintext
70 lines
2.3 KiB
Plaintext
@using Microsoft.Extensions.Caching.Memory
|
|
@using ErsatzTV.Application.MediaCollections
|
|
@using ErsatzTV.Application.MediaCollections.Queries
|
|
@inject IMediator Mediator
|
|
@inject IMemoryCache MemoryCache
|
|
|
|
<MudDialog>
|
|
<DialogContent>
|
|
<MudContainer Class="mb-6">
|
|
<MudHighlighter Class="mud-primary-text"
|
|
Style="background-color: transparent; font-weight: bold"
|
|
Text="@FormatText()"
|
|
HighlightedText="@EntityName"/>
|
|
</MudContainer>
|
|
<MudSelect Label="Collection" @bind-Value="_selectedCollection" For="@(() => _selectedCollection)" Class="mb-6 mx-4">
|
|
@foreach (MediaCollectionViewModel collection in _collections)
|
|
{
|
|
<MudSelectItem Value="@collection">@collection.Name</MudSelectItem>
|
|
}
|
|
</MudSelect>
|
|
</DialogContent>
|
|
<DialogActions>
|
|
<MudButton OnClick="Cancel">Cancel</MudButton>
|
|
<MudButton Color="Color.Primary" Variant="Variant.Filled" Disabled="@(_selectedCollection == null)" OnClick="Submit">
|
|
Add To Collection
|
|
</MudButton>
|
|
</DialogActions>
|
|
</MudDialog>
|
|
|
|
@code {
|
|
|
|
[CascadingParameter]
|
|
MudDialogInstance MudDialog { get; set; }
|
|
|
|
[Parameter]
|
|
public string EntityType { get; set; }
|
|
|
|
[Parameter]
|
|
public string EntityName { get; set; }
|
|
|
|
[Parameter]
|
|
public string DetailText { get; set; }
|
|
|
|
[Parameter]
|
|
public string DetailHighlight { get; set; }
|
|
|
|
private List<MediaCollectionViewModel> _collections;
|
|
|
|
private MediaCollectionViewModel _selectedCollection;
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
_collections = await Mediator.Send(new GetAllCollections());
|
|
if (MemoryCache.TryGetValue("AddToCollectionDialog.SelectedCollectionId", out int id))
|
|
{
|
|
_selectedCollection = _collections.SingleOrDefault(c => c.Id == id);
|
|
}
|
|
}
|
|
|
|
private string FormatText() => $"Select the collection to add the {EntityType} {EntityName}";
|
|
|
|
private void Submit()
|
|
{
|
|
MemoryCache.Set("AddToCollectionDialog.SelectedCollectionId", _selectedCollection.Id);
|
|
MudDialog.Close(DialogResult.Ok(_selectedCollection));
|
|
}
|
|
|
|
private void Cancel() => MudDialog.Cancel();
|
|
|
|
} |