Add sticky tables context controls
This commit is contained in:
@@ -3,11 +3,11 @@
|
||||
@if (Detail.Groups.Count > 0)
|
||||
{
|
||||
<div class="critical-table-grid-header-cell critical-table-grid-corner" aria-hidden="true"></div>
|
||||
@foreach (var group in Detail.Groups)
|
||||
@foreach (var group in visibleGroups)
|
||||
{
|
||||
<div
|
||||
class="critical-table-grid-header-cell critical-table-grid-group-header"
|
||||
style="@BuildColumnSpanStyle(Detail.Columns.Count)">
|
||||
style="@BuildColumnSpanStyle(visibleColumns.Count)">
|
||||
<span>@group.Label</span>
|
||||
</div>
|
||||
}
|
||||
@@ -30,39 +30,48 @@
|
||||
{
|
||||
var cell = resolvedCell;
|
||||
|
||||
<div class="@GetCellCssClass(cell)">
|
||||
<div class="critical-table-cell-shell">
|
||||
<div class="critical-table-cell-actions">
|
||||
@if (cell.IsCurated)
|
||||
{
|
||||
<span class="critical-cell-status-chip is-curated">Curated</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (MatchesModeFilter(cell))
|
||||
{
|
||||
<div class="@GetCellCssClass(cell)">
|
||||
<div class="critical-table-cell-shell">
|
||||
<div class="critical-table-cell-actions">
|
||||
@if (cell.IsCurated)
|
||||
{
|
||||
<span class="critical-cell-status-chip is-curated">Curated</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button
|
||||
type="button"
|
||||
class="critical-cell-action-button is-curation"
|
||||
title="Open the curation preview for this cell."
|
||||
@onclick="() => OnOpenCuration.InvokeAsync(cell.ResultId)">
|
||||
Needs Curation
|
||||
</button>
|
||||
}
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="critical-cell-action-button is-curation"
|
||||
title="Open the curation preview for this cell."
|
||||
@onclick="() => OnOpenCuration.InvokeAsync(cell.ResultId)">
|
||||
Needs Curation
|
||||
class="critical-cell-action-button is-edit"
|
||||
title="Open the full editor for this cell."
|
||||
@onclick="() => OnOpenEditor.InvokeAsync(cell.ResultId)">
|
||||
Edit
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="critical-cell-action-button is-edit"
|
||||
title="Open the full editor for this cell."
|
||||
@onclick="() => OnOpenEditor.InvokeAsync(cell.ResultId)">
|
||||
Edit
|
||||
</button>
|
||||
<CompactCriticalCell
|
||||
Description="@(cell.Description ?? string.Empty)"
|
||||
Effects="@(cell.Effects ?? Array.Empty<CriticalEffectLookupResponse>())"
|
||||
Branches="@(cell.Branches ?? Array.Empty<CriticalBranchLookupResponse>())" />
|
||||
</div>
|
||||
|
||||
<CompactCriticalCell
|
||||
Description="@(cell.Description ?? string.Empty)"
|
||||
Effects="@(cell.Effects ?? Array.Empty<CriticalEffectLookupResponse>())"
|
||||
Branches="@(cell.Branches ?? Array.Empty<CriticalBranchLookupResponse>())" />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="critical-table-cell critical-table-cell-empty tables-filtered-cell">
|
||||
<span class="empty-cell">Filtered</span>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -80,11 +89,22 @@
|
||||
@code {
|
||||
private readonly Dictionary<(string RollBand, string? GroupKey, string ColumnKey), CriticalTableCellDetail> cellIndex = new();
|
||||
private readonly List<(string? GroupKey, string ColumnKey, string ColumnLabel)> displayColumns = new();
|
||||
private readonly List<CriticalGroupReference> visibleGroups = new();
|
||||
private readonly List<CriticalColumnReference> visibleColumns = new();
|
||||
private string gridTemplateStyle = string.Empty;
|
||||
|
||||
[Parameter, EditorRequired]
|
||||
public CriticalTableDetail Detail { get; set; } = default!;
|
||||
|
||||
[Parameter]
|
||||
public string CurrentMode { get; set; } = TablesReferenceMode.Reference;
|
||||
|
||||
[Parameter]
|
||||
public string SelectedGroupKey { get; set; } = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public string SelectedColumnKey { get; set; } = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<int> OnOpenCuration { get; set; }
|
||||
|
||||
@@ -95,6 +115,8 @@
|
||||
{
|
||||
cellIndex.Clear();
|
||||
displayColumns.Clear();
|
||||
visibleGroups.Clear();
|
||||
visibleColumns.Clear();
|
||||
|
||||
foreach (var cell in Detail.Cells)
|
||||
{
|
||||
@@ -103,29 +125,56 @@
|
||||
|
||||
if (Detail.Groups.Count == 0)
|
||||
{
|
||||
foreach (var column in Detail.Columns)
|
||||
foreach (var column in Detail.Columns.Where(MatchesColumnFilter))
|
||||
{
|
||||
visibleColumns.Add(column);
|
||||
displayColumns.Add((null, column.Key, column.Label));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var group in Detail.Groups)
|
||||
foreach (var group in Detail.Groups.Where(MatchesGroupFilter))
|
||||
{
|
||||
foreach (var column in Detail.Columns)
|
||||
visibleGroups.Add(group);
|
||||
}
|
||||
|
||||
foreach (var column in Detail.Columns.Where(MatchesColumnFilter))
|
||||
{
|
||||
visibleColumns.Add(column);
|
||||
}
|
||||
|
||||
foreach (var group in visibleGroups)
|
||||
{
|
||||
foreach (var column in visibleColumns)
|
||||
{
|
||||
displayColumns.Add((group.Key, column.Key, column.Label));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var dataColumnCount = Detail.Columns.Count * Math.Max(Detail.Groups.Count, 1);
|
||||
var dataColumnCount = displayColumns.Count;
|
||||
gridTemplateStyle = $"grid-template-columns: max-content repeat({dataColumnCount}, minmax(0, 1fr));";
|
||||
}
|
||||
|
||||
private bool TryGetCell(string rollBand, string? groupKey, string columnKey, out CriticalTableCellDetail? cell) =>
|
||||
cellIndex.TryGetValue((rollBand, groupKey, columnKey), out cell);
|
||||
|
||||
private bool MatchesGroupFilter(CriticalGroupReference group) =>
|
||||
string.IsNullOrWhiteSpace(SelectedGroupKey)
|
||||
|| string.Equals(group.Key, SelectedGroupKey, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
private bool MatchesColumnFilter(CriticalColumnReference column) =>
|
||||
string.IsNullOrWhiteSpace(SelectedColumnKey)
|
||||
|| string.Equals(column.Key, SelectedColumnKey, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
private bool MatchesModeFilter(CriticalTableCellDetail cell) =>
|
||||
CurrentMode switch
|
||||
{
|
||||
TablesReferenceMode.NeedsCuration => !cell.IsCurated,
|
||||
TablesReferenceMode.Curated => cell.IsCurated,
|
||||
_ => true
|
||||
};
|
||||
|
||||
private static string BuildColumnSpanStyle(int span) => $"grid-column: span {span};";
|
||||
|
||||
private static string GetCellCssClass(CriticalTableCellDetail cell) =>
|
||||
|
||||
Reference in New Issue
Block a user