Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prev/next ID buttons for game groups #2000

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions TASVideos/Extensions/ViewDataDictionaryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public static string GetHeading(this ViewDataDictionary viewData)
public static void SetWikiPage(this ViewDataDictionary viewData, IWikiPage wikiPage)
=> viewData["WikiPage"] = wikiPage;

public static void SetNavigation(this ViewDataDictionary viewData, int id, string suffix)
public static void SetNavigation(this ViewDataDictionary viewData, int id, string fmtStr = "{0}")
{
viewData["NavigationId"] = id;
viewData["NavigationSuffix"] = suffix;
viewData["NavigationFmtStr"] = fmtStr;
}

public static string ActivePageClass(this ViewDataDictionary viewData, string page)
Expand Down
4 changes: 4 additions & 0 deletions TASVideos/Pages/GameGroups/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
@model IndexModel
@{
ViewData.SetTitle($"Games for Group: {Model.Name}");
if (int.TryParse(Model.Id, out var id))
{
ViewData.SetNavigation(id, "/GameGroups/{0}");
}
}

<warning-alert condition="!Model.Games.Any()">
Expand Down
2 changes: 1 addition & 1 deletion TASVideos/Pages/Games/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

if (int.TryParse(Model.Id, out int id))
{
ViewData.SetNavigation(id, "G");
ViewData.SetNavigation(id, "/{0}G");
}
}

Expand Down
5 changes: 3 additions & 2 deletions TASVideos/Pages/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
var heading = ViewData.GetHeading();
int? prev = null;
int? next = null;
string? fmtStr = ViewData["NavigationFmtStr"] as string;
if (User.Has(PermissionTo.CatalogMovies))
{
var id = ViewData.Int("NavigationId");
Expand All @@ -101,7 +102,7 @@

<div class="container mb-2">
<h1 class="page-title card card-body d-block">
<a condition="prev.HasValue" href="@(prev + ViewData["NavigationSuffix"]?.ToString())"><i class="fa fa-arrow-left"></i></a>
<a condition="prev.HasValue" href="@string.Format(fmtStr!, prev)"><i class="fa fa-arrow-left"></i></a>
@if (IsSectionDefined("PageTitle"))
{
@await RenderSectionAsync("PageTitle")
Expand All @@ -110,7 +111,7 @@
{
@heading
}
<a condition="next.HasValue" class="float-end" href="@(next + ViewData["NavigationSuffix"]?.ToString())"><i class="fa fa-arrow-right"></i></a>
<a condition="next.HasValue" class="float-end" href="@string.Format(fmtStr!, next)"><i class="fa fa-arrow-right"></i></a>
</h1>
</div>
}
Expand Down
2 changes: 1 addition & 1 deletion TASVideos/Pages/Submissions/View.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@{
ViewData.SetTitle($"{Model.Submission.Title} - Submission #{Model.Id}");
ViewData.SetHeading($"Submission {Model.Submission.Title}");
ViewData.SetNavigation(Model.Id, "S");
ViewData.SetNavigation(Model.Id, "/{0}S");
bool hasEncode = !string.IsNullOrWhiteSpace(Model.Submission.EncodeEmbedLink);
bool canEdit = User.Has(PermissionTo.EditSubmissions)
|| (Model.CanEdit && User.Has(PermissionTo.SubmitMovies));
Expand Down
Loading