mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-13 08:13:46 +00:00
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:
@@ -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"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user