-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@model PublicationsByPlatform | ||
<table> | ||
@foreach (var platform in Model.Platforms.OrderBy(res => res.DisplayName)) | ||
{ | ||
<tr> | ||
<td>@platform.DisplayName</td> | ||
<td><a href="/[email protected]">All Publications</a></td> | ||
@foreach (var pubClass in Model.PubClasses.OrderBy(t => t.Id)) | ||
{ | ||
<td><a href="/[email protected]@pubClass.Link">@pubClass.Name</a></td> | ||
} | ||
</tr> | ||
} | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using TASVideos.WikiEngine; | ||
|
||
namespace TASVideos.WikiModules; | ||
|
||
[WikiModule(ModuleNames.PublicationsByPlatform)] | ||
public class PublicationsByPlatform(IGameSystemService platforms, IClassService classes) : WikiViewComponent | ||
{ | ||
public IReadOnlyList<(string DisplayName, string Code)> Platforms { get; private set; } = null!; | ||
|
||
public IReadOnlyCollection<PublicationClass> PubClasses { get; set; } = null!; | ||
|
||
public async Task<IViewComponentResult> InvokeAsync(IList<string> groupings) | ||
{ | ||
var extant = (await platforms.GetAll()).ToList(); | ||
List<IReadOnlyList<SystemsResponse>> rows = []; | ||
void ProcessGroup(string groupStr) | ||
{ | ||
List<SystemsResponse> row = []; | ||
foreach (var idStr in groupStr.Split('-')) | ||
{ | ||
var found = extant.FirstOrDefault(sys => sys.Code.Equals(idStr, StringComparison.OrdinalIgnoreCase)); | ||
if (found is null) | ||
{ | ||
// ignore, TODO log? | ||
return; | ||
} | ||
|
||
extant.Remove(found); | ||
row.Add(found); | ||
} | ||
|
||
rows.Add(row); | ||
} | ||
|
||
foreach (var groupStr in groupings) | ||
{ | ||
ProcessGroup(groupStr); | ||
} | ||
|
||
Platforms = extant.Select(static sys => (sys.DisplayName, sys.Code)) | ||
.Concat(rows.Select(static row => ( | ||
DisplayName: string.Join(" / ", row.Select(static sys => sys.DisplayName)), | ||
Code: string.Join("-", row.Select(static sys => sys.Code)) | ||
))) | ||
.OrderBy(static tuple => tuple.DisplayName) | ||
.ToArray(); | ||
PubClasses = await classes.GetAll(); | ||
return View(); | ||
} | ||
} |