Files
deepdrft/DeepDrftManager/Components/Pages/Tracks/CmsMediumTable.razor
T
daniel-c-harvey a7e2335c20 Add Edit action to medium browsers; extract CmsMediumBrowserBase + CmsMediumTable
Session/Mix browsers share base (load/state/thumb) and a shared table shell carrying the per-row Edit link to BatchEdit; subclasses supply only their medium action.
2026-06-13 11:08:43 -04:00

75 lines
3.3 KiB
Plaintext

@namespace DeepDrftManager.Components.Pages.Tracks
@typeparam TRow
@using DeepDrftModels.DTOs
@* Shared table shell for the single-track medium browsers (Sessions, Mixes). Renders the cover
thumbnail, title, artist, and a shared Edit affordance that every medium gets (9.5.E). The
medium-specific cells (hero / waveform / generate-or-upload action) are supplied per row via the
ActionContent slot, which receives the subclass's typed row. Fully controlled by the parent:
loading and row state are passed in. *@
@if (Loading)
{
<MudProgressCircular Indeterminate="true" Class="mt-4" />
}
else if (Rows.Count == 0)
{
<MudText Typo="Typo.body1" Class="mt-4">@EmptyMessage</MudText>
}
else
{
<MudTable T="TRow" Items="Rows" Hover="true" Striped="true" Dense="true" Bordered="false" FixedHeader="true">
<HeaderContent>
<MudTh Style="width: 1%;">Cover</MudTh>
<MudTh>@TitleHeader</MudTh>
<MudTh>Artist</MudTh>
<MudTh Style="width: 1%; white-space: nowrap;">Actions</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd DataLabel="Cover">
@{ var release = ReleaseAccessor(context); }
@if (!string.IsNullOrEmpty(release.ImagePath))
{
<div class="cms-album-thumb" style="background-image: url('@ThumbUrl(release.ImagePath)');"></div>
}
else
{
<div class="cms-album-thumb cms-album-thumb--fallback"></div>
}
</MudTd>
<MudTd DataLabel="@TitleHeader">@ReleaseAccessor(context).Title</MudTd>
<MudTd DataLabel="Artist">@ReleaseAccessor(context).Artist</MudTd>
<MudTd DataLabel="Actions">
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
@ActionContent(context)
<MudTooltip Text="Edit release">
<MudIconButton Icon="@Icons.Material.Filled.Edit"
Size="Size.Small"
Color="Color.Primary"
Href="@($"/tracks/album/{Uri.EscapeDataString(ReleaseAccessor(context).Title)}/edit")" />
</MudTooltip>
</MudStack>
</MudTd>
</RowTemplate>
</MudTable>
}
@code {
[Parameter] public required IReadOnlyList<TRow> Rows { get; set; }
[Parameter] public bool Loading { get; set; }
/// <summary>Projects a row to its underlying release for the cover/title/artist cells.</summary>
[Parameter] public required Func<TRow, ReleaseDto> ReleaseAccessor { get; set; }
/// <summary>Medium-specific cell content (hero / waveform / generate action) for each row.</summary>
[Parameter] public required RenderFragment<TRow> ActionContent { get; set; }
/// <summary>Relative thumbnail URL builder; the base class supplies its proxy-aware helper.</summary>
[Parameter] public required Func<string, string> ThumbUrl { get; set; }
/// <summary>Column header / data-label for the title column (e.g. "Session", "Mix").</summary>
[Parameter] public string TitleHeader { get; set; } = "Title";
[Parameter] public string EmptyMessage { get; set; } = "Nothing here yet.";
}