Skip to content

Commit

Permalink
Reapply "Add prev/next ID buttons for game groups (#2000)"
Browse files Browse the repository at this point in the history
This reverts commit 34e13d2.
  • Loading branch information
adelikat committed Oct 1, 2024
1 parent 34e13d2 commit bb3b872
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
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

0 comments on commit bb3b872

Please sign in to comment.