Browse Source

sorting fixes (#297)

* sorting fixes

* use natural sort for add to schedule dialog
pull/298/head
Jason Dove 4 years ago committed by GitHub
parent
commit
22cf759a29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CHANGELOG.md
  2. 1
      ErsatzTV.Application/MediaCollections/Queries/GetPagedCollectionsHandler.cs
  3. 1
      ErsatzTV/ErsatzTV.csproj
  4. 3
      ErsatzTV/Pages/Schedules.razor
  5. 2
      ErsatzTV/Shared/AddToCollectionDialog.razor
  6. 4
      ErsatzTV/Shared/AddToScheduleDialog.razor

4
CHANGELOG.md

@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added ### Added
- Include audio language metadata in all streaming modes - Include audio language metadata in all streaming modes
### Changed
- Use case-insensitive sorting for collections page and `Add to Collection` dialog
- Use natural sorting for schedules page and `Add to Schedule` dialog
### Fixed ### Fixed
- Fix flooding schedule items that have a fixed start time - Fix flooding schedule items that have a fixed start time

1
ErsatzTV.Application/MediaCollections/Queries/GetPagedCollectionsHandler.cs

@ -33,6 +33,7 @@ namespace ErsatzTV.Application.MediaCollections.Queries
List<MediaCollectionViewModel> page = await dbContext.Collections.FromSqlRaw( List<MediaCollectionViewModel> page = await dbContext.Collections.FromSqlRaw(
@"SELECT * FROM Collection @"SELECT * FROM Collection
ORDER BY Name ORDER BY Name
COLLATE NOCASE
LIMIT {0} OFFSET {1}", LIMIT {0} OFFSET {1}",
request.PageSize, request.PageSize,
request.PageNum * request.PageSize) request.PageNum * request.PageSize)

1
ErsatzTV/ErsatzTV.csproj

@ -35,6 +35,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="MudBlazor" Version="5.0.15" /> <PackageReference Include="MudBlazor" Version="5.0.15" />
<PackageReference Include="NaturalSort.Extension" Version="3.1.0" />
<PackageReference Include="PPioli.FluentValidation.Blazor" Version="5.0.0" /> <PackageReference Include="PPioli.FluentValidation.Blazor" Version="5.0.0" />
<PackageReference Include="Refit.HttpClientFactory" Version="6.0.38" /> <PackageReference Include="Refit.HttpClientFactory" Version="6.0.38" />
<PackageReference Include="Serilog" Version="2.10.0" /> <PackageReference Include="Serilog" Version="2.10.0" />

3
ErsatzTV/Pages/Schedules.razor

@ -4,6 +4,7 @@
@using ErsatzTV.Application.ProgramSchedules.Queries @using ErsatzTV.Application.ProgramSchedules.Queries
@using ErsatzTV.Application.Configuration.Queries @using ErsatzTV.Application.Configuration.Queries
@using ErsatzTV.Application.Configuration.Commands @using ErsatzTV.Application.Configuration.Commands
@using NaturalSort.Extension
@inject IDialogService _dialog @inject IDialogService _dialog
@inject IMediator _mediator @inject IMediator _mediator
@ -135,7 +136,7 @@
await _mediator.Send(new SaveConfigElementByKey(ConfigElementKey.SchedulesPageSize, state.PageSize.ToString())); await _mediator.Send(new SaveConfigElementByKey(ConfigElementKey.SchedulesPageSize, state.PageSize.ToString()));
List<ProgramScheduleViewModel> schedules = await _mediator.Send(new GetAllProgramSchedules()); List<ProgramScheduleViewModel> schedules = await _mediator.Send(new GetAllProgramSchedules());
IOrderedEnumerable<ProgramScheduleViewModel> sorted = schedules.OrderBy(s => s.Name); IOrderedEnumerable<ProgramScheduleViewModel> sorted = schedules.OrderBy(s => s.Name, new NaturalSortComparer(StringComparison.CurrentCultureIgnoreCase));
// TODO: properly page this data // TODO: properly page this data
return new TableData<ProgramScheduleViewModel> return new TableData<ProgramScheduleViewModel>

2
ErsatzTV/Shared/AddToCollectionDialog.razor

@ -72,7 +72,7 @@
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
_collections = await _mediator.Send(new GetAllCollections()) _collections = await _mediator.Send(new GetAllCollections())
.Map(list => new[] { _newCollection }.Append(list).ToList()); .Map(list => new[] { _newCollection }.Append(list.OrderBy(vm => vm.Name, StringComparer.CurrentCultureIgnoreCase)).ToList());
if (_memoryCache.TryGetValue("AddToCollectionDialog.SelectedCollectionId", out int id)) if (_memoryCache.TryGetValue("AddToCollectionDialog.SelectedCollectionId", out int id))
{ {

4
ErsatzTV/Shared/AddToScheduleDialog.razor

@ -1,5 +1,6 @@
@using ErsatzTV.Application.ProgramSchedules @using ErsatzTV.Application.ProgramSchedules
@using ErsatzTV.Application.ProgramSchedules.Queries @using ErsatzTV.Application.ProgramSchedules.Queries
@using NaturalSort.Extension
@inject IMediator _mediator @inject IMediator _mediator
<div @onkeydown="@OnKeyDown"> <div @onkeydown="@OnKeyDown">
@ -49,7 +50,8 @@
private ProgramScheduleViewModel _selectedSchedule; private ProgramScheduleViewModel _selectedSchedule;
protected override async Task OnParametersSetAsync() => protected override async Task OnParametersSetAsync() =>
_schedules = await _mediator.Send(new GetAllProgramSchedules()); _schedules = await _mediator.Send(new GetAllProgramSchedules())
.Map(list => list.OrderBy(vm => vm.Name, new NaturalSortComparer(StringComparison.CurrentCultureIgnoreCase)).ToList());
private string FormatText() => $"Select the schedule to add the {EntityType} {EntityName}"; private string FormatText() => $"Select the schedule to add the {EntityType} {EntityName}";

Loading…
Cancel
Save