mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.4 KiB
77 lines
2.4 KiB
@using ErsatzTV.Application.ProgramSchedules |
|
@using NaturalSort.Extension |
|
@implements IDisposable |
|
@inject IMediator Mediator |
|
|
|
<div @onkeydown="@OnKeyDown"> |
|
<MudDialog> |
|
<DialogContent> |
|
<MudContainer Class="mb-6"> |
|
<MudHighlighter Class="mud-primary-text" |
|
Style="background-color: transparent; font-weight: bold" |
|
Text="@FormatText()" |
|
HighlightedText="@EntityName"/> |
|
</MudContainer> |
|
<MudSelect T="ProgramScheduleViewModel" Label="Schedule" @bind-Value="_selectedSchedule" Class="mb-6 mx-4"> |
|
@foreach (ProgramScheduleViewModel schedule in _schedules) |
|
{ |
|
<MudSelectItem Value="@schedule">@schedule.Name</MudSelectItem> |
|
} |
|
</MudSelect> |
|
</DialogContent> |
|
<DialogActions> |
|
<MudButton OnClick="Cancel">Cancel</MudButton> |
|
<MudButton Color="Color.Primary" Variant="Variant.Filled" Disabled="@(_selectedSchedule == null)" OnClick="Submit"> |
|
Add To Schedule |
|
</MudButton> |
|
</DialogActions> |
|
</MudDialog> |
|
</div> |
|
|
|
@code { |
|
private readonly CancellationTokenSource _cts = new(); |
|
|
|
[CascadingParameter] |
|
IMudDialogInstance 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<ProgramScheduleViewModel> _schedules; |
|
|
|
private ProgramScheduleViewModel _selectedSchedule; |
|
|
|
public void Dispose() |
|
{ |
|
_cts.Cancel(); |
|
_cts.Dispose(); |
|
} |
|
|
|
protected override async Task OnParametersSetAsync() => |
|
_schedules = await Mediator.Send(new GetAllProgramSchedules(), _cts.Token) |
|
.Map(list => list.OrderBy(vm => vm.Name, new NaturalSortComparer(StringComparison.CurrentCultureIgnoreCase)).ToList()); |
|
|
|
private string FormatText() => $"Select the schedule to add the {EntityType} {EntityName}"; |
|
|
|
private void Submit() => MudDialog.Close(DialogResult.Ok(_selectedSchedule)); |
|
|
|
private void Cancel() => MudDialog.Cancel(); |
|
|
|
private void OnKeyDown(KeyboardEventArgs e) |
|
{ |
|
if (e.Code is "Enter" or "NumpadEnter") |
|
{ |
|
Submit(); |
|
} |
|
} |
|
|
|
} |