Uses contributor references on the book page

This commit is contained in:
BinaryAlley committed 2026-11-27 18:23:20 +02:00
1 parent dab6bac9a7
commit ad072eeffc
28 files changed
+217 -199

No files matched your search

@@ -1,23 +0,0 @@
#region ========================================================================= USING =====================================================================================
using Nemera.Presentation.Web.Common.Enums.MediaContributors;
using System.Diagnostics;
#endregion
namespace Nemera.Presentation.Web.Common.DTO.MediaContributors;
/// <summary>
/// Data transfer object for a media contributor.
/// </summary>
[DebuggerDisplay("Name: {Name}")]
public class MediaContributorDto
{
/// <summary>
/// Gets the name of the contributor.
/// </summary>
public MediaContributorNameDto? Name { get; set; }
/// <summary>
/// Gets the canonical role of the contributor, used as the key of its localized display string.
/// </summary>
public MediaContributorRole? Role { get; set; }
}
@@ -1,22 +0,0 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Nemera.Presentation.Web.Common.DTO.MediaContributors;
/// <summary>
/// Data transfer object for a media contributor name.
/// </summary>
[DebuggerDisplay("DisplayName: {DisplayName}")]
public class MediaContributorNameDto
{
/// <summary>
/// Gets the name by which the contributor is popularly known.
/// </summary>
public string? DisplayName { get; set; }
/// <summary>
/// Gets the legal name of the contributor.
/// </summary>
public string? LegalName { get; set; }
}
@@ -102,9 +102,9 @@ public class BookDetailsDto
public List<IsbnDto>? ISBNs { get; set; }
/// <summary>
/// Gets or sets the list of media contributors of the book.
/// Gets or sets the list of references to the media contributors of the book, each with the role they played.
/// </summary>
public List<MediaContributorDto>? Contributors { get; set; }
public List<MediaContributorReferenceDto>? Contributors { get; set; }
/// <summary>
/// Gets or sets the list of ratings of the book.
@@ -30,7 +30,7 @@ namespace Nemera.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.
/// <param name="BarnesAndNobleId">The Barnes &amp; Noble Id of the book. Optional.</param>
/// <param name="AppleBooksId">The Apple Books Id of the book. Optional.</param>
/// <param name="ISBNs">The list of ISBN (International Standard Book Number) of the book. Required.</param>
/// <param name="Contributors">The list of media contributors of the book. Required.</param>
/// <param name="Contributors">The list of references to the media contributors of the book, each with the role they played. Required.</param>
/// <param name="Ratings">The list of ratings of the book. Required.</param>
[DebuggerDisplay("Title: {Metadata?.Title}")]
public record UpdateBookRequest(
@@ -51,6 +51,6 @@ public record UpdateBookRequest(
string? BarnesAndNobleId,
string? AppleBooksId,
List<IsbnDto>? ISBNs,
List<MediaContributorDto>? Contributors,
List<MediaContributorReferenceDto>? Contributors,
List<BookRatingDto>? Ratings
);
@@ -69,7 +69,7 @@ public class SaveBookEndpointSummary : Summary<SaveBookEndpoint, UpdateBookReque
RequestParam(r => r.BarnesAndNobleId, "The Barnes & Noble Id of the book. Optional.");
RequestParam(r => r.AppleBooksId, "The Apple Books Id of the book. Optional.");
RequestParam(r => r.ISBNs, "The list of ISBN (International Standard Book Number) of the book. Required.");
RequestParam(r => r.Contributors, "The list of media contributors of the book. Required.");
RequestParam(r => r.Contributors, "The list of references to the media contributors of the book, each with the role they played. Required.");
RequestParam(r => r.Ratings, "The list of ratings of the book. Required.");
ExampleRequest = new UpdateBookRequest(
@@ -139,14 +139,14 @@ public class SaveBookEndpointSummary : Summary<SaveBookEndpoint, UpdateBookReque
],
Contributors:
[
new MediaContributorDto
new MediaContributorReferenceDto
{
Name = new MediaContributorNameDto { DisplayName = "J.R.R. Tolkien", LegalName = "John Ronald Reuel Tolkien" },
ContributorId = Guid.NewGuid(),
Role = MediaContributorRole.Author
},
new MediaContributorDto
new MediaContributorReferenceDto
{
Name = new MediaContributorNameDto { DisplayName = "Alan Lee", LegalName = "Alan Lee" },
ContributorId = Guid.NewGuid(),
Role = MediaContributorRole.Illustrator
}
],
@@ -51,9 +51,6 @@
<data name="ChangeCover" xml:space="preserve">
<value>تغيير الغلاف</value>
</data>
<data name="ContributorName" xml:space="preserve">
<value>الاسم</value>
</data>
<data name="ContributorsDescription" xml:space="preserve">
<value>الأشخاص الذين ساهموا في الكتاب، مثل مؤلفيه.</value>
</data>
@@ -51,9 +51,6 @@
<data name="ChangeCover" xml:space="preserve">
<value>Titelbild ändern</value>
</data>
<data name="ContributorName" xml:space="preserve">
<value>Name</value>
</data>
<data name="ContributorsDescription" xml:space="preserve">
<value>Die Personen, die zum Buch beigetragen haben, wie seine Autoren.</value>
</data>
@@ -150,9 +150,6 @@
<data name="Contributors" xml:space="preserve">
<value>Contributors</value>
</data>
<data name="ContributorName" xml:space="preserve">
<value>Name</value>
</data>
<data name="RoleName" xml:space="preserve">
<value>Role</value>
</data>
@@ -51,9 +51,6 @@
<data name="ChangeCover" xml:space="preserve">
<value>Cambiar portada</value>
</data>
<data name="ContributorName" xml:space="preserve">
<value>Nombre</value>
</data>
<data name="ContributorsDescription" xml:space="preserve">
<value>Las personas que contribuyeron al libro, como sus autores.</value>
</data>
@@ -51,9 +51,6 @@
<data name="ChangeCover" xml:space="preserve">
<value>Changer la couverture</value>
</data>
<data name="ContributorName" xml:space="preserve">
<value>Nom</value>
</data>
<data name="ContributorsDescription" xml:space="preserve">
<value>Les personnes ayant contribué au livre, comme ses auteurs.</value>
</data>
@@ -51,9 +51,6 @@
<data name="ChangeCover" xml:space="preserve">
<value>Cambia copertina</value>
</data>
<data name="ContributorName" xml:space="preserve">
<value>Nome</value>
</data>
<data name="ContributorsDescription" xml:space="preserve">
<value>Le persone che hanno contribuito al libro, come i suoi autori.</value>
</data>
@@ -51,9 +51,6 @@
<data name="ChangeCover" xml:space="preserve">
<value>表紙を変更</value>
</data>
<data name="ContributorName" xml:space="preserve">
<value>名前</value>
</data>
<data name="ContributorsDescription" xml:space="preserve">
<value>著者など、本に貢献した人々。</value>
</data>
@@ -150,9 +150,6 @@
<data name="Contributors" xml:space="preserve">
<value>Contributors</value>
</data>
<data name="ContributorName" xml:space="preserve">
<value>Name</value>
</data>
<data name="RoleName" xml:space="preserve">
<value>Role</value>
</data>
@@ -51,9 +51,6 @@
<data name="ChangeCover" xml:space="preserve">
<value>Schimbă coperta</value>
</data>
<data name="ContributorName" xml:space="preserve">
<value>Nume</value>
</data>
<data name="ContributorsDescription" xml:space="preserve">
<value>Persoanele care au contribuit la carte, precum autorii ei.</value>
</data>
@@ -51,9 +51,6 @@
<data name="ChangeCover" xml:space="preserve">
<value>Змінити обкладинку</value>
</data>
<data name="ContributorName" xml:space="preserve">
<value>Ім'я</value>
</data>
<data name="ContributorsDescription" xml:space="preserve">
<value>Люди, які долучилися до створення книги, як-от її автори.</value>
</data>
@@ -51,9 +51,6 @@
<data name="ChangeCover" xml:space="preserve">
<value>更换封面</value>
</data>
<data name="ContributorName" xml:space="preserve">
<value>姓名</value>
</data>
<data name="ContributorsDescription" xml:space="preserve">
<value>为图书作出贡献的人,例如其作者。</value>
</data>
@@ -34,7 +34,7 @@
var genres = metadata?.Genres ?? [];
var tags = metadata?.Tags ?? [];
var isbns = Model.ISBNs ?? [];
var contributors = Model.Contributors ?? [];
var contributors = Model.Contributors ?? [];
var ratings = Model.Ratings ?? [];
// The full set of canonical media contributor roles, mirroring the MediaContributorRole enum members, offered by the role combobox.
var contributorRoles = new[]
@@ -42,7 +42,7 @@
"Other", "Author", "Translator", "Illustrator", "Publisher", "Narrator", "Actor", "Director", "Screenwriter",
"Composer", "Lyricist", "Arranger", "Conductor", "Producer", "ExecutiveProducer", "Engineer", "Mixer", "Remixer",
"RecordLabel", "Vocals", "BackingVocals", "Guitar", "BassGuitar", "Drums", "Percussion", "Keyboards", "Piano",
"Synthesizer", "Strings", "Woodwinds", "Brass", "Choir", "Orchestrator"
"Synthesizer", "Strings", "Woodwinds", "Brass", "Choir", "Orchestrator", "Performer"
};
// Resolves the localized label of a contributor role, keyed by its canonical value.
Func<string?, string> roleLabel = role => role switch
@@ -441,7 +441,7 @@
<table class="w-100 form-table book-list-table">
<thead>
<tr>
<th>@_localizer["ContributorName"]</th>
<th>@_localizer["ContributorId"]</th>
<th>@_localizer["Role"]</th>
<th class="w-40px"></th>
</tr>
@@ -451,7 +451,7 @@
@foreach (var contributor in contributors)
{
<tr class="contributor-row">
<td><input type="text" class="enlightenment-input contributor-name w-100" value="@(contributor.Name?.DisplayName ?? string.Empty)" /></td>
<td><input type="text" class="enlightenment-input contributor-id w-100" value="@(contributor.ContributorId.ToString())" /></td>
<td>
<div class="enlightenment-combobox inline-block w-100 contributor-role-combobox">
<div class="shine-effect" style="top: 1px;"></div>
@@ -637,7 +637,7 @@
Format: readRowComboboxValue(row, '.isbn-format-combobox') || null
})),
Contributors: Array.from(contributorsBody.querySelectorAll('.contributor-row')).map(row => ({
Name: { DisplayName: row.querySelector('.contributor-name').value.trim() || null },
ContributorId: row.querySelector('.contributor-id').value.trim() || '00000000-0000-0000-0000-000000000000',
Role: readRowComboboxValue(row, '.contributor-role-combobox') || null
})),
Ratings: Array.from(ratingsBody.querySelectorAll('.rating-row')).map(row => ({
@@ -787,15 +787,13 @@
await updateContentAsync(`${libraryIndexUrl}?libraryId=${encodeURIComponent(libraryId)}`, true);
}
// Builds the HTML of an enlightenment combobox of a row, with the provided option values.
function buildRowCombobox(optionValues, selectedValue) {
// Builds the HTML of an enlightenment combobox of a row, with the provided option values and an optional wrapper class.
function buildRowCombobox(optionValues, selectedValue, wrapperClass) {
const id = `row-combobox-${generatedId++}`;
const options = optionValues.map(option => {
const selected = option.value === selectedValue ? ' selected' : '';
return `<div class="enlightenment-option" data-value="${option.value}">${option.label}</div>`;
}).join('');
const options = optionValues.map(option =>
`<div class="enlightenment-option" data-value="${option.value}">${option.label}</div>`).join('');
return `
<div class="enlightenment-combobox inline-block w-100">
<div class="enlightenment-combobox inline-block w-100 ${wrapperClass || ''}">
<div class="shine-effect" style="top: 1px;"></div>
<input type="checkbox" class="enlightenment-toggle-checkbox" id="${id}" />
<label class="enlightenment-toggle" for="${id}">
@@ -845,7 +843,7 @@
isbnsBody.insertAdjacentHTML('beforeend', `
<tr class="isbn-row">
<td><input type="text" class="enlightenment-input isbn-value" /></td>
<td>${buildRowCombobox(isbnOptions, '')}</td>
<td>${buildRowCombobox(isbnOptions, '', 'isbn-format-combobox')}</td>
<td><img src="/images/ui/delete.svg" alt="${jsLocalizedStrings.remove}" title="${jsLocalizedStrings.remove}" class="remove-form-table-row-icon" /></td>
</tr>`);
}
@@ -854,8 +852,8 @@
function addContributorRow() {
contributorsBody.insertAdjacentHTML('beforeend', `
<tr class="contributor-row">
<td><input type="text" class="enlightenment-input contributor-name w-100" /></td>
<td>${buildRowCombobox(contributorRoleOptions, 'Author')}</td>
<td><input type="text" class="enlightenment-input contributor-id w-100" /></td>
<td>${buildRowCombobox(contributorRoleOptions, 'Author', 'contributor-role-combobox')}</td>
<td><img src="/images/ui/delete.svg" alt="${jsLocalizedStrings.remove}" title="${jsLocalizedStrings.remove}" class="remove-form-table-row-icon" /></td>
</tr>`);
}
@@ -866,7 +864,7 @@
<tr class="rating-row">
<td><input type="number" step="any" min="0" class="enlightenment-input rating-value" /></td>
<td><input type="number" step="any" min="0" class="enlightenment-input rating-max-value" /></td>
<td>${buildRowCombobox(ratingSourceOptions, '')}</td>
<td>${buildRowCombobox(ratingSourceOptions, '', 'rating-source-combobox')}</td>
<td><input type="number" min="0" class="enlightenment-input rating-vote-count" /></td>
<td><img src="/images/ui/delete.svg" alt="${jsLocalizedStrings.remove}" title="${jsLocalizedStrings.remove}" class="remove-form-table-row-icon" /></td>
</tr>`);