Add series # to grid display (#529)
This commit is contained in:
parent
18cf20ecad
commit
565c84c4ab
@ -8,7 +8,7 @@ namespace DataLayer
|
|||||||
internal int BookId { get; private set; }
|
internal int BookId { get; private set; }
|
||||||
|
|
||||||
public string Order { get; private set; }
|
public string Order { get; private set; }
|
||||||
public float Index => StringLib.ExtractFirstNumber(Order);
|
public float Index { get; }
|
||||||
|
|
||||||
public Series Series { get; private set; }
|
public Series Series { get; private set; }
|
||||||
public Book Book { get; private set; }
|
public Book Book { get; private set; }
|
||||||
@ -22,7 +22,8 @@ namespace DataLayer
|
|||||||
Series = series;
|
Series = series;
|
||||||
Book = book;
|
Book = book;
|
||||||
Order = order;
|
Order = order;
|
||||||
}
|
Index = StringLib.ExtractFirstNumber(Order);
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdateOrder(string order)
|
public void UpdateOrder(string order)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -18,9 +18,9 @@ namespace DataLayer
|
|||||||
/// <summary>True if exists and IsLiberated. Else false</summary>
|
/// <summary>True if exists and IsLiberated. Else false</summary>
|
||||||
public static bool PDF_Exists(this Book book) => book.UserDefinedItem.PdfStatus == LiberatedStatus.Liberated;
|
public static bool PDF_Exists(this Book book) => book.UserDefinedItem.PdfStatus == LiberatedStatus.Liberated;
|
||||||
|
|
||||||
public static string SeriesSortable(this Book book) => Formatters.GetSortName(book.SeriesNames());
|
public static string SeriesSortable(this Book book) => Formatters.GetSortName(book.SeriesNames(true));
|
||||||
public static bool HasPdf(this Book book) => book.Supplements.Any();
|
public static bool HasPdf(this Book book) => book.Supplements.Any();
|
||||||
public static string SeriesNames(this Book book)
|
public static string SeriesNames(this Book book, bool includeIndex = false)
|
||||||
{
|
{
|
||||||
if (book.SeriesLink is null)
|
if (book.SeriesLink is null)
|
||||||
return "";
|
return "";
|
||||||
@ -28,7 +28,7 @@ namespace DataLayer
|
|||||||
// first: alphabetical by name
|
// first: alphabetical by name
|
||||||
var withNames = book.SeriesLink
|
var withNames = book.SeriesLink
|
||||||
.Where(s => !string.IsNullOrWhiteSpace(s.Series.Name))
|
.Where(s => !string.IsNullOrWhiteSpace(s.Series.Name))
|
||||||
.Select(s => s.Series.Name)
|
.Select(getSeriesNameString)
|
||||||
.OrderBy(a => a)
|
.OrderBy(a => a)
|
||||||
.ToList();
|
.ToList();
|
||||||
// then un-named are alpha by series id
|
// then un-named are alpha by series id
|
||||||
@ -40,7 +40,12 @@ namespace DataLayer
|
|||||||
|
|
||||||
var all = withNames.Union(nullNames).ToList();
|
var all = withNames.Union(nullNames).ToList();
|
||||||
return string.Join(", ", all);
|
return string.Join(", ", all);
|
||||||
}
|
|
||||||
|
string getSeriesNameString(SeriesBook sb)
|
||||||
|
=> includeIndex && !string.IsNullOrWhiteSpace(sb.Order) && sb.Order != "-1"
|
||||||
|
? $"{sb.Series.Name} (#{sb.Order})"
|
||||||
|
: sb.Series.Name;
|
||||||
|
}
|
||||||
public static string[] CategoriesNames(this Book book)
|
public static string[] CategoriesNames(this Book book)
|
||||||
=> book.Category is null ? new string[0]
|
=> book.Category is null ? new string[0]
|
||||||
: book.Category.ParentCategory is null ? new[] { book.Category.Name }
|
: book.Category.ParentCategory is null ? new[] { book.Category.Name }
|
||||||
|
|||||||
@ -104,7 +104,7 @@ namespace LibationUiBase.GridView
|
|||||||
Liberate.Expanded = expanded;
|
Liberate.Expanded = expanded;
|
||||||
|
|
||||||
Title = Book.Title;
|
Title = Book.Title;
|
||||||
Series = Book.SeriesNames();
|
Series = Book.SeriesNames(includeIndex: true);
|
||||||
Length = GetBookLengthString();
|
Length = GetBookLengthString();
|
||||||
//Ratings are changed using Update(), which is a problem for Avalonia data bindings because
|
//Ratings are changed using Update(), which is a problem for Avalonia data bindings because
|
||||||
//the reference doesn't change. Clone the rating so that it updates within Avalonia properly.
|
//the reference doesn't change. Clone the rating so that it updates within Avalonia properly.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user