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 <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -141,6 +141,47 @@ else
|
||||
<label class="form-label">Tier</label>
|
||||
<input @bind="_card.Tier" type="number" min="1" max="5" class="form-control" />
|
||||
</div>
|
||||
<div class="col-md-4 position-relative">
|
||||
<label class="form-label">Previous Tier</label>
|
||||
<input value="@_prevTierSearch"
|
||||
@oninput="e => { _prevTierSearch = e.Value?.ToString() ?? string.Empty; _showPrevTierDropdown = true; }"
|
||||
@onfocus="() => _showPrevTierDropdown = true"
|
||||
@onblur="HidePrevTierDropdownAsync"
|
||||
class="form-control"
|
||||
placeholder="Search ArchSpirit…"
|
||||
autocomplete="off" />
|
||||
@if (_showPrevTierDropdown)
|
||||
{
|
||||
var filtered = FilteredPrevTierCards.ToList();
|
||||
@if (filtered.Count > 0)
|
||||
{
|
||||
<div class="list-group shadow position-absolute"
|
||||
style="z-index:1000;max-height:220px;overflow-y:auto;width:100%;top:100%">
|
||||
@foreach (var c in filtered)
|
||||
{
|
||||
var cap = c;
|
||||
<button type="button"
|
||||
class="list-group-item list-group-item-action d-flex justify-content-between align-items-center py-1"
|
||||
@onmousedown="() => SelectPrevTier(cap)">
|
||||
<span>@cap.Name</span>
|
||||
@if (cap.Tier.HasValue)
|
||||
{
|
||||
<small class="text-muted ms-2">Tier @cap.Tier</small>
|
||||
}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@if (_card.PreviousTierId.HasValue)
|
||||
{
|
||||
<div class="form-text d-flex align-items-center gap-1">
|
||||
<span class="text-success"><i class="bi bi-check-circle me-1"></i>@_prevTierSearch</span>
|
||||
<button type="button" class="btn btn-link btn-sm text-danger p-0 ms-1"
|
||||
@onclick="ClearPrevTier">clear</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="col-12"><h6 class="text-muted mt-2">Combat</h6></div>
|
||||
@@ -671,6 +712,38 @@ else
|
||||
private readonly HashSet<Guid> _uploading = new();
|
||||
private string? _uploadError;
|
||||
|
||||
// ── Previous Tier autocomplete ────────────────────────────────────────────
|
||||
private sealed record CardPickEntry(Guid Id, string Name, int? Tier);
|
||||
private List<CardPickEntry> _archSpiritCards = [];
|
||||
private string _prevTierSearch = string.Empty;
|
||||
private bool _showPrevTierDropdown;
|
||||
|
||||
private IEnumerable<CardPickEntry> 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<string>();
|
||||
// Ensure any card-specific tags appear in the available list.
|
||||
foreach (var tag in _selectedGenus)
|
||||
|
||||
Reference in New Issue
Block a user