feat(dashboard): UGC List view and References as sortable DataTables

The UGC page's List view (models and car/rocket assemblies) and an
assembly's References panel are server-side DataTables like the rest of
the dashboard: sort by clicking a column heading, in either direction,
with the page length and sort remembered per user. They still read
/api/ugc and /api/ugc/assembly/builds, so the prefix search and filters
above the list keep working; the gallery keeps its own pager and sort.

/api/ugc takes reverse=1 for a sort's other direction (the model list's
SQL order and the assembly sort both flip), and the references endpoint
sorts by id, owner, account or state. Tests cover the reversed orders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-27 17:37:00 -05:00
parent 728f5ef3c5
commit 58d9267acc
7 changed files with 191 additions and 81 deletions

View File

@@ -170,8 +170,19 @@ TEST_F(UgcLookupSqlTests, ListsPagesWithCounts) {
EXPECT_EQ(total, 2);
query.sort = IUgcLookup::eSort::BRICKS;
EXPECT_EQ(List(query, false).first, (std::vector<int64_t>{ 1000, 1001 }));
query.reverse = true; // the fewest bricks first
EXPECT_EQ(List(query, false).first, (std::vector<int64_t>{ 1001, 1000 }));
query.reverse = false;
query.sort = IUgcLookup::eSort::NAME; // boat before tower
EXPECT_EQ(List(query, false).first, (std::vector<int64_t>{ 1001, 1000 }));
query.reverse = true; // tower before boat
EXPECT_EQ(List(query, false).first, (std::vector<int64_t>{ 1000, 1001 }));
query.reverse = false;
query.sort = IUgcLookup::eSort::NEWEST;
query.reverse = true; // the oldest first
EXPECT_EQ(List(query, false).first, (std::vector<int64_t>{ 1000, 1001 }));
query.reverse = false;
query.sort = IUgcLookup::eSort::NAME;
query.limit = 1;
query.offset = 1;
std::tie(ids, total) = List(query, false);
@@ -251,6 +262,10 @@ TEST(UgcAssemblies, GroupsBuildsByTheirModules) {
EXPECT_EQ(list.front().key, "4713-4714-4715"); // Classic before Racing
UgcAssemblies::Sort(list, UgcAssemblies::eSort::OLDEST, modules);
EXPECT_EQ(list.front().key, "4713-4714-4715"); // build 10
UgcAssemblies::Sort(list, UgcAssemblies::eSort::REFERENCES, modules, true);
EXPECT_EQ(list.back().key, "4713-4714-4715"); // the most builds last
UgcAssemblies::Sort(list, UgcAssemblies::eSort::NAME, modules, true);
EXPECT_EQ(list.back().key, "4713-4714-4715"); // Racing before Classic
EXPECT_EQ(UgcAssemblies::ParseSort("uses"), UgcAssemblies::eSort::REFERENCES);
EXPECT_FALSE(UgcAssemblies::ParseSort("nonsense"));
}