fixes #506 - Song list - make columns headers clickable for sorting

This commit is contained in:
Luke Pulverenti 2013-09-06 15:17:15 -04:00
parent 83dd13cc7c
commit 1d9c163f5f
10 changed files with 77 additions and 28 deletions

View File

@ -126,6 +126,9 @@ namespace MediaBrowser.Api.UserLibrary
[ApiMember(Name = "NameStartsWithOrGreater", Description = "Optional filter by items whose name is sorted equally or greater than a given input string.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string NameStartsWithOrGreater { get; set; }
[ApiMember(Name = "AlbumArtistStartsWithOrGreater", Description = "Optional filter by items whose album artist is sorted equally or greater than a given input string.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string AlbumArtistStartsWithOrGreater { get; set; }
/// <summary>
/// Gets or sets the air days.
/// </summary>
@ -576,6 +579,13 @@ namespace MediaBrowser.Api.UserLibrary
items = items.Where(i => string.Compare(request.NameStartsWithOrGreater, i.SortName, StringComparison.CurrentCultureIgnoreCase) < 1);
}
if (!string.IsNullOrEmpty(request.AlbumArtistStartsWithOrGreater))
{
items = items.OfType<IHasAlbumArtist>()
.Where(i => string.Compare(request.AlbumArtistStartsWithOrGreater, i.AlbumArtist, StringComparison.CurrentCultureIgnoreCase) < 1)
.Cast<BaseItem>();
}
// Filter by Series Status
if (!string.IsNullOrEmpty(request.SeriesStatus))
{

View File

@ -9,7 +9,7 @@ namespace MediaBrowser.Controller.Entities.Audio
/// <summary>
/// Class Audio
/// </summary>
public class Audio : BaseItem, IHasMediaStreams
public class Audio : BaseItem, IHasMediaStreams, IHasAlbumArtist
{
public Audio()
{

View File

@ -0,0 +1,8 @@

namespace MediaBrowser.Controller.Entities.Audio
{
public interface IHasAlbumArtist
{
string AlbumArtist { get; }
}
}

View File

@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Entities.Audio
/// <summary>
/// Class MusicAlbum
/// </summary>
public class MusicAlbum : Folder
public class MusicAlbum : Folder, IHasAlbumArtist
{
public string LastFmImageUrl { get; set; }
@ -62,6 +62,17 @@ namespace MediaBrowser.Controller.Entities.Audio
{
return RecursiveChildren.OfType<Audio>().Any(i => i.HasArtist(artist));
}
public string AlbumArtist
{
get
{
return RecursiveChildren
.OfType<Audio>()
.Select(i => i.AlbumArtist)
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
}
}
}
public class MusicAlbumDisc : Folder

View File

@ -73,6 +73,7 @@
</Compile>
<Compile Include="Dto\IDtoService.cs" />
<Compile Include="Entities\AdultVideo.cs" />
<Compile Include="Entities\Audio\IHasAlbumArtist.cs" />
<Compile Include="Entities\Book.cs" />
<Compile Include="Configuration\IServerConfigurationManager.cs" />
<Compile Include="Entities\Audio\MusicGenre.cs" />

View File

@ -46,6 +46,7 @@ namespace MediaBrowser.Model.Querying
/// The sort name
/// </summary>
public const string SortName = "SortName";
public const string Name = "Name";
/// <summary>
/// The random
/// </summary>

View File

@ -892,7 +892,6 @@ namespace MediaBrowser.Server.Implementations.Dto
if (audio != null)
{
dto.Album = audio.Album;
dto.AlbumArtist = audio.AlbumArtist;
dto.Artists = audio.Artists.ToArray();
var albumParent = audio.FindParent<MusicAlbum>();
@ -916,14 +915,19 @@ namespace MediaBrowser.Server.Implementations.Dto
{
var songs = album.RecursiveChildren.OfType<Audio>().ToList();
dto.AlbumArtist = songs.Select(i => i.AlbumArtist).FirstOrDefault(i => !string.IsNullOrEmpty(i));
dto.Artists =
songs.SelectMany(i => i.Artists)
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToArray();
}
var hasAlbumArtist = item as IHasAlbumArtist;
if (hasAlbumArtist != null)
{
dto.AlbumArtist = hasAlbumArtist.AlbumArtist;
}
// Add video info
var video = item as Video;
if (video != null)

View File

@ -178,6 +178,7 @@
<Compile Include="Sorting\DatePlayedComparer.cs" />
<Compile Include="Sorting\IsFolderComparer.cs" />
<Compile Include="Sorting\IsUnplayedComparer.cs" />
<Compile Include="Sorting\NameComparer.cs" />
<Compile Include="Sorting\OfficialRatingComparer.cs" />
<Compile Include="Sorting\PlayCountComparer.cs" />
<Compile Include="Sorting\PremiereDateComparer.cs" />

View File

@ -1,5 +1,4 @@
using System.Linq;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
@ -30,28 +29,9 @@ namespace MediaBrowser.Server.Implementations.Sorting
/// <returns>System.String.</returns>
private string GetValue(BaseItem x)
{
var audio = x as Audio;
var audio = x as IHasAlbumArtist;
if (audio != null)
{
return audio.AlbumArtist;
}
var album = x as MusicAlbum;
if (album != null)
{
var song = album.RecursiveChildren
.OfType<Audio>()
.FirstOrDefault(i => !string.IsNullOrEmpty(i.AlbumArtist));
if (song != null)
{
return song.AlbumArtist;
}
}
return null;
return audio != null ? audio.AlbumArtist : null;
}
/// <summary>

View File

@ -0,0 +1,33 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
using System;
namespace MediaBrowser.Server.Implementations.Sorting
{
/// <summary>
/// Class NameComparer
/// </summary>
public class NameComparer : IBaseItemComparer
{
/// <summary>
/// Compares the specified x.
/// </summary>
/// <param name="x">The x.</param>
/// <param name="y">The y.</param>
/// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y)
{
return string.Compare(x.Name, y.Name, StringComparison.CurrentCultureIgnoreCase);
}
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
public string Name
{
get { return ItemSortBy.Name; }
}
}
}