Browse Source

allow editing block template start and end year

pull/2757/head
Jason Dove 7 months ago
parent
commit
8fc61f17bd
No known key found for this signature in database
  1. 4
      ErsatzTV.Application/Scheduling/Commands/ReplacePlayoutTemplate.cs
  2. 4
      ErsatzTV.Application/Scheduling/Commands/ReplacePlayoutTemplateItemsHandler.cs
  3. 4
      ErsatzTV.Application/Scheduling/Mapper.cs
  4. 4
      ErsatzTV.Application/Scheduling/PlayoutTemplateViewModel.cs
  5. 29
      ErsatzTV/Pages/PlayoutTemplatesEditor.razor
  6. 8
      ErsatzTV/ViewModels/PlayoutTemplateEditViewModel.cs

4
ErsatzTV.Application/Scheduling/Commands/ReplacePlayoutTemplate.cs

@ -11,5 +11,7 @@ public record ReplacePlayoutTemplate( @@ -11,5 +11,7 @@ public record ReplacePlayoutTemplate(
bool LimitToDateRange,
int StartMonth,
int StartDay,
int? StartYear,
int EndMonth,
int EndDay);
int EndDay,
int? EndYear);

4
ErsatzTV.Application/Scheduling/Commands/ReplacePlayoutTemplateItemsHandler.cs

@ -59,8 +59,10 @@ public class ReplacePlayoutTemplateItemsHandler( @@ -59,8 +59,10 @@ public class ReplacePlayoutTemplateItemsHandler(
LimitToDateRange = add.LimitToDateRange,
StartMonth = add.StartMonth,
StartDay = add.StartDay,
StartYear = add.StartYear,
EndMonth = add.EndMonth,
EndDay = add.EndDay,
EndYear = add.EndYear,
DateUpdated = now
});
}
@ -78,8 +80,10 @@ public class ReplacePlayoutTemplateItemsHandler( @@ -78,8 +80,10 @@ public class ReplacePlayoutTemplateItemsHandler(
ex.LimitToDateRange = update.LimitToDateRange;
ex.StartMonth = update.StartMonth;
ex.StartDay = update.StartDay;
ex.StartYear = update.StartYear;
ex.EndMonth = update.EndMonth;
ex.EndDay = update.EndDay;
ex.EndYear = update.EndYear;
ex.DateUpdated = now;
}
}

4
ErsatzTV.Application/Scheduling/Mapper.cs

@ -195,8 +195,10 @@ internal static class Mapper @@ -195,8 +195,10 @@ internal static class Mapper
playoutTemplate.LimitToDateRange,
playoutTemplate.StartMonth,
playoutTemplate.StartDay,
playoutTemplate.StartYear,
playoutTemplate.EndMonth,
playoutTemplate.EndDay);
playoutTemplate.EndDay,
playoutTemplate.EndYear);
internal static PlayoutItemPreviewViewModel ProjectToViewModel(PlayoutItem playoutItem) =>
new(

4
ErsatzTV.Application/Scheduling/PlayoutTemplateViewModel.cs

@ -11,5 +11,7 @@ public record PlayoutTemplateViewModel( @@ -11,5 +11,7 @@ public record PlayoutTemplateViewModel(
bool LimitToDateRange,
int StartMonth,
int StartDay,
int? StartYear,
int EndMonth,
int EndDay);
int EndDay,
int? EndYear);

29
ErsatzTV/Pages/PlayoutTemplatesEditor.razor

@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
@using System.Text
@using ErsatzTV.Application.Channels
@using ErsatzTV.Application.Scheduling
@using ErsatzTV.Core.Domain.Scheduling
@using ErsatzTV.Core.Scheduling
@implements IDisposable
@inject NavigationManager NavigationManager
@ -39,7 +38,7 @@ @@ -39,7 +38,7 @@
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="pt-8">
<MudText Typo="Typo.h5" Class="mb-2">@_channelName - Templates</MudText>
<MudDivider Class="mb-6"/>
<MudText Typo="Typo.body2" Class="mb-6">In priority order from top to bottom. The bottom entry will *always* match all days and all months, as a catch-all.</MudText>
<MudText Typo="Typo.body2" Class="mb-6">In priority order from top to bottom.</MudText>
<MudTable T="PlayoutTemplateEditViewModel" Class="mt-4" Hover="true" Items="_items.OrderBy(i => i.Index)" Dense="true" SelectedItem="@_selectedItem" SelectedItemChanged="@(vm => SelectedItemChanged(vm))" RowClassFunc="@SelectedRowClassFunc">
<ColGroup>
<MudHidden Breakpoint="Breakpoint.Xs">
@ -173,6 +172,15 @@ @@ -173,6 +172,15 @@
}
</MudSelect>
</MudStack>
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
<div class="d-flex"></div>
<MudSelect T="int?" @bind-Value="_selectedItem.StartYear" Disabled="@(!_selectedItem.LimitToDateRange)" Clearable="true">
@foreach (int year in Enumerable.Range(DateTime.Today.Year, 50))
{
<MudSelectItem T="int?" Value="@year">@year.ToString()</MudSelectItem>
}
</MudSelect>
</MudStack>
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
<div class="d-flex">
<MudText>End Day</MudText>
@ -193,6 +201,15 @@ @@ -193,6 +201,15 @@
}
</MudSelect>
</MudStack>
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
<div class="d-flex"></div>
<MudSelect T="int?" @bind-Value="_selectedItem.EndYear" Disabled="@(!_selectedItem.LimitToDateRange)" Clearable="true">
@foreach (int year in Enumerable.Range(DateTime.Today.Year, 50))
{
<MudSelectItem T="int?" Value="@year">@year.ToString()</MudSelectItem>
}
</MudSelect>
</MudStack>
<MudStack Row="true" Breakpoint="Breakpoint.SmAndDown" Class="form-field-stack gap-md-8 mb-5">
<div class="d-flex">
<MudText>Days of the Week</MudText>
@ -323,8 +340,10 @@ @@ -323,8 +340,10 @@
LimitToDateRange = item.LimitToDateRange,
StartMonth = item.StartMonth,
StartDay = item.StartDay,
StartYear = item.StartYear,
EndMonth = item.EndMonth,
EndDay = item.EndDay
EndDay = item.EndDay,
EndYear = item.EndYear
};
private async Task UpdateTemplateGroupItems(TemplateGroupViewModel templateGroup)
@ -434,8 +453,10 @@ @@ -434,8 +453,10 @@
item.LimitToDateRange,
item.StartMonth,
item.StartDay,
item.StartYear,
item.EndMonth,
item.EndDay)).ToList();
item.EndDay,
item.EndYear)).ToList();
Option<BaseError> maybeError = await Mediator.Send(new ReplacePlayoutTemplateItems(Id, items), _cts.Token);

8
ErsatzTV/ViewModels/PlayoutTemplateEditViewModel.cs

@ -35,6 +35,8 @@ public class PlayoutTemplateEditViewModel @@ -35,6 +35,8 @@ public class PlayoutTemplateEditViewModel
set => _startDay = value;
}
public int? StartYear { get; set; }
public int EndMonth
{
get => _endMonth == 0 ? 12 : _endMonth;
@ -47,6 +49,8 @@ public class PlayoutTemplateEditViewModel @@ -47,6 +49,8 @@ public class PlayoutTemplateEditViewModel
set => _endDay = value;
}
public int? EndYear { get; set; }
public bool AppliesToDate(DateTime date)
{
// share the PlayoutTemplateSelector logic
@ -59,8 +63,10 @@ public class PlayoutTemplateEditViewModel @@ -59,8 +63,10 @@ public class PlayoutTemplateEditViewModel
LimitToDateRange = LimitToDateRange,
StartMonth = StartMonth,
StartDay = StartDay,
StartYear = StartYear,
EndMonth = EndMonth,
EndDay = EndDay
EndDay = EndDay,
EndYear = EndYear
};
TimeSpan offset = TimeZoneInfo.Local.GetUtcOffset(

Loading…
Cancel
Save