feat(admin): filter card report by specific prebuilt deck
Prebuilt Decks filter now lists each deck by name in addition to the existing "In any deck" / "Not in any deck" options, allowing the report to be narrowed to cards belonging to a single specific deck. 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:
@@ -137,8 +137,12 @@
|
|||||||
<label class="form-label form-label-sm mb-1">Prebuilt Decks</label>
|
<label class="form-label form-label-sm mb-1">Prebuilt Decks</label>
|
||||||
<select @bind="_filterInDeck" @bind:after="Filter" class="form-select form-select-sm">
|
<select @bind="_filterInDeck" @bind:after="Filter" class="form-select form-select-sm">
|
||||||
<option value="">All</option>
|
<option value="">All</option>
|
||||||
<option value="yes">In a deck</option>
|
<option value="yes">In any deck</option>
|
||||||
<option value="no">Not in any deck</option>
|
<option value="no">Not in any deck</option>
|
||||||
|
@foreach (var deck in _decks)
|
||||||
|
{
|
||||||
|
<option value="@deck.Id">@deck.Name</option>
|
||||||
|
}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -316,6 +320,7 @@
|
|||||||
private List<CardRow>? _rows;
|
private List<CardRow>? _rows;
|
||||||
private List<CardRow> _filtered = new();
|
private List<CardRow> _filtered = new();
|
||||||
private List<CardSet> _sets = new();
|
private List<CardSet> _sets = new();
|
||||||
|
private List<(Guid Id, string Name)> _decks = new();
|
||||||
|
|
||||||
private string _search = string.Empty;
|
private string _search = string.Empty;
|
||||||
private string _filterType = string.Empty;
|
private string _filterType = string.Empty;
|
||||||
@@ -346,8 +351,11 @@
|
|||||||
|
|
||||||
var prebuiltDecks = await BazaarDb.PrebuiltDecks
|
var prebuiltDecks = await BazaarDb.PrebuiltDecks
|
||||||
.Include(d => d.Cards)
|
.Include(d => d.Cards)
|
||||||
|
.OrderBy(d => d.Name)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
_decks = prebuiltDecks.Select(d => (d.Id, d.Name)).ToList();
|
||||||
|
|
||||||
// Build card → [deck] lookup.
|
// Build card → [deck] lookup.
|
||||||
var cardToDecks = new Dictionary<Guid, List<(Guid, string)>>();
|
var cardToDecks = new Dictionary<Guid, List<(Guid, string)>>();
|
||||||
foreach (var deck in prebuiltDecks)
|
foreach (var deck in prebuiltDecks)
|
||||||
@@ -438,6 +446,10 @@
|
|||||||
|
|
||||||
if (_filterInDeck == "yes" && row.InDecks.Count == 0) return false;
|
if (_filterInDeck == "yes" && row.InDecks.Count == 0) return false;
|
||||||
if (_filterInDeck == "no" && row.InDecks.Count > 0) return false;
|
if (_filterInDeck == "no" && row.InDecks.Count > 0) return false;
|
||||||
|
if (_filterInDeck != "" && _filterInDeck != "yes" && _filterInDeck != "no"
|
||||||
|
&& Guid.TryParse(_filterInDeck, out var deckId)
|
||||||
|
&& !row.InDecks.Any(d => d.Id == deckId))
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|||||||
Reference in New Issue
Block a user