From 1831fd646c35006f1e9b703fc70679a514524514 Mon Sep 17 00:00:00 2001 From: dingo Date: Sun, 22 Mar 2026 15:33:14 -0400 Subject: [PATCH] Add Previous Tier autocomplete to card editor ArchSpirit cards can now have their Previous Tier set via a searchable dropdown in the Stats tab. Type to filter by name, select to bind the GUID. Shows current selection with a clear button. Excludes the card itself from the list. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- .../Components/Pages/Cards/CardEditor.razor | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/Server/src/SOR.Admin/Components/Pages/Cards/CardEditor.razor b/Server/src/SOR.Admin/Components/Pages/Cards/CardEditor.razor index 8a7d466..746f9cd 100644 --- a/Server/src/SOR.Admin/Components/Pages/Cards/CardEditor.razor +++ b/Server/src/SOR.Admin/Components/Pages/Cards/CardEditor.razor @@ -141,6 +141,47 @@ else +
+ + + @if (_showPrevTierDropdown) + { + var filtered = FilteredPrevTierCards.ToList(); + @if (filtered.Count > 0) + { +
+ @foreach (var c in filtered) + { + var cap = c; + + } +
+ } + } + @if (_card.PreviousTierId.HasValue) + { +
+ @_prevTierSearch + +
+ } +
}
Combat
@@ -671,6 +712,38 @@ else private readonly HashSet _uploading = new(); private string? _uploadError; + // ── Previous Tier autocomplete ──────────────────────────────────────────── + private sealed record CardPickEntry(Guid Id, string Name, int? Tier); + private List _archSpiritCards = []; + private string _prevTierSearch = string.Empty; + private bool _showPrevTierDropdown; + + private IEnumerable FilteredPrevTierCards => + string.IsNullOrWhiteSpace(_prevTierSearch) + ? _archSpiritCards + : _archSpiritCards.Where(c => + c.Name.Contains(_prevTierSearch, StringComparison.OrdinalIgnoreCase)); + + private void SelectPrevTier(CardPickEntry c) + { + _card!.PreviousTierId = c.Id; + _prevTierSearch = c.Name; + _showPrevTierDropdown = false; + } + + private void ClearPrevTier() + { + _card!.PreviousTierId = null; + _prevTierSearch = string.Empty; + } + + private async Task HidePrevTierDropdownAsync() + { + // Delay lets onmousedown on a list item fire before the dropdown disappears. + await Task.Delay(150); + _showPrevTierDropdown = false; + } + // ── CDN Picker ─────────────────────────────────────────────────────────── private bool _pickerOpen; @@ -832,6 +905,14 @@ else .OrderBy(g => g) .ToList(); + // Load all ArchSpirit cards for the Previous Tier autocomplete. + // Exclude the current card so it can't point to itself. + _archSpiritCards = await Db.CardDefinitions + .Where(c => c.CardType == CardType.ArchSpirit && c.Id != (Id ?? Guid.Empty)) + .OrderBy(c => c.Name) + .Select(c => new CardPickEntry(c.Id, c.Name, c.Tier)) + .ToListAsync(); + if (_isNew) { _card = new CardDefinition @@ -851,6 +932,13 @@ else if (_card != null) { + // Resolve the display name for the currently saved PreviousTierId. + if (_card.PreviousTierId.HasValue) + { + var prev = _archSpiritCards.FirstOrDefault(c => c.Id == _card.PreviousTierId.Value); + _prevTierSearch = prev?.Name ?? _card.PreviousTierId.Value.ToString(); + } + _selectedGenus = _card.Genus?.ToList() ?? new List(); // Ensure any card-specific tags appear in the available list. foreach (var tag in _selectedGenus)