diff --git a/ErsatzTV/Pages/ArtistList.razor b/ErsatzTV/Pages/ArtistList.razor index c3e29ce36..848e21c90 100644 --- a/ErsatzTV/Pages/ArtistList.razor +++ b/ErsatzTV/Pages/ArtistList.razor @@ -18,6 +18,8 @@ AddSelectionToCollection="@AddSelectionToCollection" AddSelectionToPlaylist="@AddSelectionToPlaylist" ClearSelection="@ClearSelection" + CanSelectAllOnPage="@(() => _data.Cards.Count > 0)" + SelectAllOnPage="@(() => SelectAllPageItems(_data.Cards))" IsSelectMode="@IsSelectMode" SelectionLabel="@SelectionLabel"/> diff --git a/ErsatzTV/Pages/EpisodeList.razor b/ErsatzTV/Pages/EpisodeList.razor index d2d7e18db..92747e8f0 100644 --- a/ErsatzTV/Pages/EpisodeList.razor +++ b/ErsatzTV/Pages/EpisodeList.razor @@ -18,6 +18,8 @@ AddSelectionToCollection="@AddSelectionToCollection" AddSelectionToPlaylist="@AddSelectionToPlaylist" ClearSelection="@ClearSelection" + CanSelectAllOnPage="@(() => _data.Cards.Count > 0)" + SelectAllOnPage="@(() => SelectAllPageItems(_data.Cards))" IsSelectMode="@IsSelectMode" SelectionLabel="@SelectionLabel"/> diff --git a/ErsatzTV/Pages/ImageList.razor b/ErsatzTV/Pages/ImageList.razor index c9b1f1646..4ff230fbd 100644 --- a/ErsatzTV/Pages/ImageList.razor +++ b/ErsatzTV/Pages/ImageList.razor @@ -18,6 +18,8 @@ AddSelectionToCollection="@AddSelectionToCollection" AddSelectionToPlaylist="@AddSelectionToPlaylist" ClearSelection="@ClearSelection" + CanSelectAllOnPage="@(() => _data.Cards.Count > 0)" + SelectAllOnPage="@(() => SelectAllPageItems(_data.Cards))" IsSelectMode="@IsSelectMode" SelectionLabel="@SelectionLabel"/> diff --git a/ErsatzTV/Pages/MovieList.razor b/ErsatzTV/Pages/MovieList.razor index 9c4cadf9b..0b4c5310c 100644 --- a/ErsatzTV/Pages/MovieList.razor +++ b/ErsatzTV/Pages/MovieList.razor @@ -20,6 +20,8 @@ AddSelectionToCollection="@AddSelectionToCollection" AddSelectionToPlaylist="@AddSelectionToPlaylist" ClearSelection="@ClearSelection" + CanSelectAllOnPage="@(() => _data.Cards.Count > 0)" + SelectAllOnPage="@(() => SelectAllPageItems(_data.Cards))" IsSelectMode="@IsSelectMode" SelectionLabel="@SelectionLabel"/> diff --git a/ErsatzTV/Pages/MultiSelectBase.cs b/ErsatzTV/Pages/MultiSelectBase.cs index bb2ed5608..e5eb72673 100644 --- a/ErsatzTV/Pages/MultiSelectBase.cs +++ b/ErsatzTV/Pages/MultiSelectBase.cs @@ -38,6 +38,18 @@ public class MultiSelectBase : FragmentNavigationBase protected string SelectionLabel() => $"{SelectedItems.Count} {(SelectedItems.Count == 1 ? "Item" : "Items")} Selected"; + protected void SelectAllPageItems(IEnumerable cards) + { + SelectedItems.Clear(); + foreach (MediaCardViewModel card in cards) + { + _recentlySelected = card; + SelectedItems.Add(card); + } + + StateHasChanged(); + } + protected void ClearSelection() { SelectedItems.Clear(); diff --git a/ErsatzTV/Pages/MusicVideoList.razor b/ErsatzTV/Pages/MusicVideoList.razor index 4a7a1dc98..24a2590bb 100644 --- a/ErsatzTV/Pages/MusicVideoList.razor +++ b/ErsatzTV/Pages/MusicVideoList.razor @@ -18,6 +18,8 @@ AddSelectionToCollection="@AddSelectionToCollection" AddSelectionToPlaylist="@AddSelectionToPlaylist" ClearSelection="@ClearSelection" + CanSelectAllOnPage="@(() => _data.Cards.Count > 0)" + SelectAllOnPage="@(() => SelectAllPageItems(_data.Cards))" IsSelectMode="@IsSelectMode" SelectionLabel="@SelectionLabel"/> diff --git a/ErsatzTV/Pages/OtherVideoList.razor b/ErsatzTV/Pages/OtherVideoList.razor index bb4509216..ebc1cbe57 100644 --- a/ErsatzTV/Pages/OtherVideoList.razor +++ b/ErsatzTV/Pages/OtherVideoList.razor @@ -18,6 +18,8 @@ AddSelectionToCollection="@AddSelectionToCollection" AddSelectionToPlaylist="@AddSelectionToPlaylist" ClearSelection="@ClearSelection" + CanSelectAllOnPage="@(() => _data.Cards.Count > 0)" + SelectAllOnPage="@(() => SelectAllPageItems(_data.Cards))" IsSelectMode="@IsSelectMode" SelectionLabel="@SelectionLabel"/> diff --git a/ErsatzTV/Pages/RemoteStreamList.razor b/ErsatzTV/Pages/RemoteStreamList.razor index d2d78bd1f..9131c07a9 100644 --- a/ErsatzTV/Pages/RemoteStreamList.razor +++ b/ErsatzTV/Pages/RemoteStreamList.razor @@ -18,6 +18,8 @@ AddSelectionToCollection="@AddSelectionToCollection" AddSelectionToPlaylist="@AddSelectionToPlaylist" ClearSelection="@ClearSelection" + CanSelectAllOnPage="@(() => _data.Cards.Count > 0)" + SelectAllOnPage="@(() => SelectAllPageItems(_data.Cards))" IsSelectMode="@IsSelectMode" SelectionLabel="@SelectionLabel"/> diff --git a/ErsatzTV/Pages/SongList.razor b/ErsatzTV/Pages/SongList.razor index b7d2b071e..c0b13cd92 100644 --- a/ErsatzTV/Pages/SongList.razor +++ b/ErsatzTV/Pages/SongList.razor @@ -18,6 +18,8 @@ AddSelectionToCollection="@AddSelectionToCollection" AddSelectionToPlaylist="@AddSelectionToPlaylist" ClearSelection="@ClearSelection" + CanSelectAllOnPage="@(() => _data.Cards.Count > 0)" + SelectAllOnPage="@(() => SelectAllPageItems(_data.Cards))" IsSelectMode="@IsSelectMode" SelectionLabel="@SelectionLabel"/> diff --git a/ErsatzTV/Pages/TelevisionShowList.razor b/ErsatzTV/Pages/TelevisionShowList.razor index 45c73b94e..c23f36faf 100644 --- a/ErsatzTV/Pages/TelevisionShowList.razor +++ b/ErsatzTV/Pages/TelevisionShowList.razor @@ -20,6 +20,8 @@ AddSelectionToCollection="@AddSelectionToCollection" AddSelectionToPlaylist="@AddSelectionToPlaylist" ClearSelection="@ClearSelection" + CanSelectAllOnPage="@(() => _data.Cards.Count > 0)" + SelectAllOnPage="@(() => SelectAllPageItems(_data.Cards))" IsSelectMode="@IsSelectMode" SelectionLabel="@SelectionLabel"/> diff --git a/ErsatzTV/Pages/Trash.razor b/ErsatzTV/Pages/Trash.razor index dfb1d241e..81e3f44d0 100644 --- a/ErsatzTV/Pages/Trash.razor +++ b/ErsatzTV/Pages/Trash.razor @@ -92,25 +92,37 @@ @_remoteStreams.Count Remote Streams }
-
- - Empty Trash - -
+ + Select All + + + Empty Trash +
-
- - Empty Trash - -
+ + Select All + + + Empty Trash +
} else @@ -509,7 +521,20 @@ } private bool IsNotEmpty => - _movies?.Cards.Count > 0 || _shows?.Cards.Count > 0 || _seasons?.Cards.Count > 0 || _episodes?.Cards.Count > 0 || _musicVideos?.Cards.Count > 0 || _otherVideos?.Cards.Count > 0 || _songs?.Cards.Count > 0 || _artists?.Cards.Count > 0 || _images?.Cards.Count > 0; + _movies?.Cards.Count > 0 || _shows?.Cards.Count > 0 || _seasons?.Cards.Count > 0 || _episodes?.Cards.Count > 0 || _musicVideos?.Cards.Count > 0 || _otherVideos?.Cards.Count > 0 || _songs?.Cards.Count > 0 || _artists?.Cards.Count > 0 || _images?.Cards.Count > 0 || _remoteStreams?.Cards.Count > 0; + + private IEnumerable AllCardsOnPage() => + Enumerable.Empty() + .Concat(_movies.Cards) + .Concat(_shows.Cards) + .Concat(_seasons.Cards) + .Concat(_episodes.Cards) + .Concat(_artists.Cards) + .Concat(_musicVideos.Cards) + .Concat(_otherVideos.Cards) + .Concat(_songs.Cards) + .Concat(_images.Cards) + .Concat(_remoteStreams.Cards); private void SelectClicked(MediaCardViewModel card, MouseEventArgs e) { diff --git a/ErsatzTV/Shared/MediaCardPager.razor b/ErsatzTV/Shared/MediaCardPager.razor index 46658b280..da258b077 100644 --- a/ErsatzTV/Shared/MediaCardPager.razor +++ b/ErsatzTV/Shared/MediaCardPager.razor @@ -44,6 +44,16 @@
@Query
+ @if (SelectAllOnPage is not null) + { + + Select All + + }
CanSelectAllOnPage { get; set; } + + [Parameter] + public Action SelectAllOnPage { get; set; } + private static MarkupString PaddedString(int value, int maximum) { int length = maximum.ToString(CultureInfo.InvariantCulture).Length;