Tighten tables layout and grid behavior
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
<PageTitle>Critical Tables</PageTitle>
|
||||
|
||||
<section class="panel tables-page">
|
||||
<TablesPageHeader />
|
||||
<TablesPageHeader/>
|
||||
|
||||
@if (referenceData is null)
|
||||
{
|
||||
@@ -31,7 +31,7 @@
|
||||
PinnedTableSlugs="PinnedTablesState.Items.Select(item => item.Slug).ToArray()"
|
||||
RecentTableSlugs="RecentTablesState.Items.Select(item => item.Slug).ToArray()"
|
||||
IsPinned="PinnedTablesState.IsPinned"
|
||||
OnSelectTable="SelectTableAsync" />
|
||||
OnSelectTable="SelectTableAsync"/>
|
||||
</aside>
|
||||
|
||||
<div class="tables-reference-main">
|
||||
@@ -57,19 +57,9 @@
|
||||
<TablesContextBar
|
||||
Detail="detail"
|
||||
IsPinned="PinnedTablesState.IsPinned(detail.Slug)"
|
||||
CurrentMode="referenceMode"
|
||||
SelectedGroupKey="selectedGroupKey"
|
||||
SelectedColumnKey="selectedColumnKey"
|
||||
RollJumpValue="rollJumpValue"
|
||||
DensityMode="densityMode"
|
||||
OnTogglePin="TogglePinnedTableAsync"
|
||||
IsLegendOpen="isLegendOpen"
|
||||
OnToggleLegend="ToggleLegend"
|
||||
OnModeChanged="UpdateReferenceModeAsync"
|
||||
OnGroupChanged="UpdateSelectedGroupAsync"
|
||||
OnColumnChanged="UpdateSelectedColumnAsync"
|
||||
OnRollJumpChanged="UpdateRollJumpAsync"
|
||||
OnDensityChanged="UpdateDensityModeAsync" />
|
||||
OnToggleLegend="ToggleLegend"/>
|
||||
|
||||
<TablesCanvas
|
||||
Detail="detail"
|
||||
@@ -79,32 +69,21 @@
|
||||
RollJumpValue="rollJumpValue"
|
||||
DensityMode="densityMode"
|
||||
SelectedCell="selectedCell"
|
||||
OnSelectCell="SelectCell" />
|
||||
OnSelectCell="SelectCell"/>
|
||||
|
||||
@if (isLegendOpen)
|
||||
{
|
||||
<TablesLegend LegendEntries="@(detail.Legend ?? Array.Empty<CriticalTableLegendEntry>())" />
|
||||
<TablesLegend LegendEntries="@(detail.Legend ?? Array.Empty<CriticalTableLegendEntry>())"/>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (tableDetail is not null)
|
||||
{
|
||||
<aside class="tables-reference-inspector-shell">
|
||||
<TablesInspector
|
||||
SelectedCellDetail="SelectedCellDetail"
|
||||
OnEdit="OpenSelectedCellEditorAsync"
|
||||
OnCurate="OpenSelectedCellCurationAsync" />
|
||||
</aside>
|
||||
}
|
||||
</div>
|
||||
|
||||
<TablesInspectorSheet
|
||||
<TablesSelectionMenu
|
||||
SelectedCellDetail="SelectedCellDetail"
|
||||
OnClose="ClearSelectedCell"
|
||||
OnEdit="OpenSelectedCellEditorAsync"
|
||||
OnCurate="OpenSelectedCellCurationAsync" />
|
||||
OnCurate="OpenSelectedCellCurationAsync"/>
|
||||
}
|
||||
</section>
|
||||
|
||||
@@ -125,7 +104,7 @@
|
||||
OnEdit="OpenEditorFromCurationAsync"
|
||||
OnEnterQuickParse="EnterCurationQuickParseMode"
|
||||
OnCancelQuickParse="CancelCurationQuickParseMode"
|
||||
OnReparse="ReparseCurationCellAsync" />
|
||||
OnReparse="ReparseCurationCellAsync"/>
|
||||
}
|
||||
|
||||
@if (isEditorOpen)
|
||||
@@ -142,7 +121,7 @@
|
||||
SaveErrorMessage="@editorSaveError"
|
||||
OnClose="CloseCellEditorAsync"
|
||||
OnReparse="ReparseCellEditorAsync"
|
||||
OnSave="SaveCellEditorAsync" />
|
||||
OnSave="SaveCellEditorAsync"/>
|
||||
}
|
||||
|
||||
@code {
|
||||
@@ -151,9 +130,7 @@
|
||||
private CriticalTableDetail? tableDetail;
|
||||
private string selectedTableSlug = string.Empty;
|
||||
private bool isDetailLoading;
|
||||
private bool isReferenceDataLoading = true;
|
||||
private string? detailError;
|
||||
private bool IsTableSelectionDisabled => isReferenceDataLoading || (referenceData?.CriticalTables.Count ?? 0) == 0;
|
||||
private bool isEditorOpen;
|
||||
private bool isEditorLoading;
|
||||
private bool isEditorReparsing;
|
||||
@@ -181,17 +158,16 @@
|
||||
private TablesCellSelection? selectedCell;
|
||||
private bool isLegendOpen;
|
||||
private bool hasResolvedStoredTableSelection;
|
||||
|
||||
private CriticalTableReference? SelectedTableReference =>
|
||||
referenceData?.CriticalTables.FirstOrDefault(item => string.Equals(item.Key, selectedTableSlug, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
private CriticalTableCellDetail? SelectedCellDetail =>
|
||||
selectedCell is null
|
||||
? null
|
||||
: tableDetail?.Cells.FirstOrDefault(cell => cell.ResultId == selectedCell.ResultId);
|
||||
selectedCell is null ? null : tableDetail?.Cells.FirstOrDefault(cell => cell.ResultId == selectedCell.ResultId);
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
referenceData = await LookupService.GetReferenceDataAsync();
|
||||
isReferenceDataLoading = false;
|
||||
}
|
||||
|
||||
private async Task SelectTableAsync(string tableSlug)
|
||||
@@ -247,17 +223,12 @@
|
||||
|
||||
if (!hasResolvedStoredTableSelection && referenceData?.CriticalTables.Count > 0)
|
||||
{
|
||||
var initialContext = await TableContextState.RestoreAsync(
|
||||
NavigationManager.Uri,
|
||||
ContextDestination,
|
||||
referenceData.CriticalTables,
|
||||
RolemasterDb.App.Frontend.AppState.TableContextMode.Reference);
|
||||
var initialContext = await TableContextState.RestoreAsync(NavigationManager.Uri, ContextDestination, referenceData.CriticalTables, RolemasterDb.App.Frontend.AppState.TableContextMode.Reference);
|
||||
|
||||
hasResolvedStoredTableSelection = true;
|
||||
|
||||
var resolvedTableSlug = initialContext.TableSlug ?? string.Empty;
|
||||
if (string.IsNullOrWhiteSpace(selectedTableSlug) ||
|
||||
!string.Equals(resolvedTableSlug, selectedTableSlug, StringComparison.OrdinalIgnoreCase))
|
||||
if (string.IsNullOrWhiteSpace(selectedTableSlug) || !string.Equals(resolvedTableSlug, selectedTableSlug, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
selectedTableSlug = resolvedTableSlug;
|
||||
await LoadTableDetailAsync();
|
||||
@@ -489,11 +460,7 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
var orderedCells = tableDetail.Cells
|
||||
.OrderBy(cell => GetGroupSortOrder(cell.GroupKey))
|
||||
.ThenBy(cell => GetColumnSortOrder(cell.ColumnKey))
|
||||
.ThenBy(cell => GetRollBandSortOrder(cell.RollBand))
|
||||
.ToList();
|
||||
var orderedCells = tableDetail.Cells.OrderBy(cell => GetGroupSortOrder(cell.GroupKey)).ThenBy(cell => GetColumnSortOrder(cell.ColumnKey)).ThenBy(cell => GetRollBandSortOrder(cell.RollBand)).ToList();
|
||||
|
||||
var currentIndex = orderedCells.FindIndex(cell => cell.ResultId == currentResultId);
|
||||
for (var index = currentIndex + 1; index < orderedCells.Count; index++)
|
||||
@@ -514,9 +481,7 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
return tableDetail.Groups
|
||||
.FirstOrDefault(group => string.Equals(group.Key, groupKey, StringComparison.OrdinalIgnoreCase))
|
||||
?.SortOrder ?? int.MaxValue;
|
||||
return tableDetail.Groups.FirstOrDefault(group => string.Equals(group.Key, groupKey, StringComparison.OrdinalIgnoreCase))?.SortOrder ?? int.MaxValue;
|
||||
}
|
||||
|
||||
private int GetColumnSortOrder(string columnKey)
|
||||
@@ -526,9 +491,7 @@
|
||||
return int.MaxValue;
|
||||
}
|
||||
|
||||
return tableDetail.Columns
|
||||
.FirstOrDefault(column => string.Equals(column.Key, columnKey, StringComparison.OrdinalIgnoreCase))
|
||||
?.SortOrder ?? int.MaxValue;
|
||||
return tableDetail.Columns.FirstOrDefault(column => string.Equals(column.Key, columnKey, StringComparison.OrdinalIgnoreCase))?.SortOrder ?? int.MaxValue;
|
||||
}
|
||||
|
||||
private int GetRollBandSortOrder(string rollBandLabel)
|
||||
@@ -538,9 +501,7 @@
|
||||
return int.MaxValue;
|
||||
}
|
||||
|
||||
return tableDetail.RollBands
|
||||
.FirstOrDefault(rollBand => string.Equals(rollBand.Label, rollBandLabel, StringComparison.OrdinalIgnoreCase))
|
||||
?.SortOrder ?? int.MaxValue;
|
||||
return tableDetail.RollBands.FirstOrDefault(rollBand => string.Equals(rollBand.Label, rollBandLabel, StringComparison.OrdinalIgnoreCase))?.SortOrder ?? int.MaxValue;
|
||||
}
|
||||
|
||||
private async Task CloseCellEditorAsync()
|
||||
@@ -634,11 +595,7 @@
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
return PinnedTablesState.ToggleAsync(
|
||||
selectedTable.Key,
|
||||
selectedTable.Label,
|
||||
selectedTable.Family,
|
||||
selectedTable.CurationPercentage);
|
||||
return PinnedTablesState.ToggleAsync(selectedTable.Key, selectedTable.Label, selectedTable.Family, selectedTable.CurationPercentage);
|
||||
}
|
||||
|
||||
private Task RecordRecentTableVisitAsync()
|
||||
@@ -648,11 +605,7 @@
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
return RecentTablesState.RecordVisitAsync(
|
||||
selectedTable.Key,
|
||||
selectedTable.Label,
|
||||
selectedTable.Family,
|
||||
selectedTable.CurationPercentage);
|
||||
return RecentTablesState.RecordVisitAsync(selectedTable.Key, selectedTable.Label, selectedTable.Family, selectedTable.CurationPercentage);
|
||||
}
|
||||
|
||||
private async Task PersistAndSyncTableContextAsync()
|
||||
@@ -670,42 +623,7 @@
|
||||
}
|
||||
|
||||
private RolemasterDb.App.Frontend.AppState.TableContextSnapshot BuildCurrentTableContext() =>
|
||||
new(
|
||||
TableSlug: selectedTableSlug,
|
||||
Mode: RolemasterDb.App.Frontend.AppState.TableContextMode.Reference);
|
||||
|
||||
private Task UpdateReferenceModeAsync(string mode)
|
||||
{
|
||||
referenceMode = NormalizeMode(mode);
|
||||
NormalizeSelectedCellForCurrentView();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task UpdateSelectedGroupAsync(string groupKey)
|
||||
{
|
||||
selectedGroupKey = NormalizeOptionalFilter(groupKey);
|
||||
NormalizeSelectedCellForCurrentView();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task UpdateSelectedColumnAsync(string columnKey)
|
||||
{
|
||||
selectedColumnKey = NormalizeOptionalFilter(columnKey);
|
||||
NormalizeSelectedCellForCurrentView();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task UpdateRollJumpAsync(string rollValue)
|
||||
{
|
||||
rollJumpValue = NormalizeRollInput(rollValue);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task UpdateDensityModeAsync(string mode)
|
||||
{
|
||||
densityMode = NormalizeDensityMode(mode);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
new(TableSlug: selectedTableSlug, Mode: RolemasterDb.App.Frontend.AppState.TableContextMode.Reference);
|
||||
|
||||
private void SelectCell(TablesCellSelection selection)
|
||||
{
|
||||
@@ -718,21 +636,11 @@
|
||||
selectedCell = selection;
|
||||
}
|
||||
|
||||
private Task ClearSelectedCell()
|
||||
{
|
||||
selectedCell = null;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task OpenSelectedCellEditorAsync() =>
|
||||
selectedCell is null
|
||||
? Task.CompletedTask
|
||||
: OpenCellEditorAsync(selectedCell.ResultId);
|
||||
selectedCell is null ? Task.CompletedTask : OpenCellEditorAsync(selectedCell.ResultId);
|
||||
|
||||
private Task OpenSelectedCellCurationAsync() =>
|
||||
selectedCell is null
|
||||
? Task.CompletedTask
|
||||
: OpenCellCurationAsync(selectedCell.ResultId);
|
||||
selectedCell is null ? Task.CompletedTask : OpenCellCurationAsync(selectedCell.ResultId);
|
||||
|
||||
private Task ToggleLegend()
|
||||
{
|
||||
@@ -759,10 +667,7 @@
|
||||
selectedGroupKey = string.Empty;
|
||||
}
|
||||
|
||||
var matchingColumns = tableDetail.Columns
|
||||
.Where(column => string.IsNullOrWhiteSpace(selectedColumnKey)
|
||||
|| string.Equals(column.Key, selectedColumnKey, StringComparison.OrdinalIgnoreCase))
|
||||
.ToList();
|
||||
var matchingColumns = tableDetail.Columns.Where(column => string.IsNullOrWhiteSpace(selectedColumnKey) || string.Equals(column.Key, selectedColumnKey, StringComparison.OrdinalIgnoreCase)).ToList();
|
||||
|
||||
if (matchingColumns.Count == 0)
|
||||
{
|
||||
@@ -784,17 +689,12 @@
|
||||
mode switch
|
||||
{
|
||||
TablesReferenceMode.NeedsCuration => TablesReferenceMode.NeedsCuration,
|
||||
TablesReferenceMode.Curated => TablesReferenceMode.Curated,
|
||||
_ => TablesReferenceMode.Reference
|
||||
TablesReferenceMode.Curated => TablesReferenceMode.Curated,
|
||||
_ => TablesReferenceMode.Reference
|
||||
};
|
||||
|
||||
private static string NormalizeOptionalFilter(string? value) =>
|
||||
string.IsNullOrWhiteSpace(value) ? string.Empty : value.Trim();
|
||||
|
||||
private static string NormalizeDensityMode(string? mode) =>
|
||||
string.Equals(mode, TablesDensityMode.Dense, StringComparison.Ordinal)
|
||||
? TablesDensityMode.Dense
|
||||
: TablesDensityMode.Comfortable;
|
||||
string.Equals(mode, TablesDensityMode.Dense, StringComparison.Ordinal) ? TablesDensityMode.Dense : TablesDensityMode.Comfortable;
|
||||
|
||||
private static string NormalizeRollInput(string? value)
|
||||
{
|
||||
@@ -823,14 +723,12 @@
|
||||
|
||||
private bool MatchesCurrentView(CriticalTableCellDetail cell)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(selectedGroupKey) &&
|
||||
!string.Equals(cell.GroupKey, selectedGroupKey, StringComparison.OrdinalIgnoreCase))
|
||||
if (!string.IsNullOrWhiteSpace(selectedGroupKey) && !string.Equals(cell.GroupKey, selectedGroupKey, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(selectedColumnKey) &&
|
||||
!string.Equals(cell.ColumnKey, selectedColumnKey, StringComparison.OrdinalIgnoreCase))
|
||||
if (!string.IsNullOrWhiteSpace(selectedColumnKey) && !string.Equals(cell.ColumnKey, selectedColumnKey, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -838,8 +736,9 @@
|
||||
return referenceMode switch
|
||||
{
|
||||
TablesReferenceMode.NeedsCuration => !cell.IsCurated,
|
||||
TablesReferenceMode.Curated => cell.IsCurated,
|
||||
_ => true
|
||||
TablesReferenceMode.Curated => cell.IsCurated,
|
||||
_ => true
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user