Skip to content

Commit

Permalink
Merge pull request #196 from ivangrek/195
Browse files Browse the repository at this point in the history
Change pager rendering to consistent for MVC and MVC Core
  • Loading branch information
ernado-x authored Oct 5, 2020
2 parents f208e25 + 6834517 commit f69356e
Show file tree
Hide file tree
Showing 32 changed files with 663 additions and 760 deletions.
2 changes: 1 addition & 1 deletion X.PagedList.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "X.PagedList.EF", "src\X.Pag
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "X.PagedList.EF.Tests", "tests\X.PagedList.EF.Tests\X.PagedList.EF.Tests.csproj", "{75367B5D-FB8B-4B1C-884C-DB52B316EB7C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "X.PagedList.Mvc.Example.Core", "examples\X.PagedList.Mvc.Example.Core\X.PagedList.Mvc.Example.Core.csproj", "{288F5726-904F-48B8-8363-EA1A22D331D1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "X.PagedList.Mvc.Example.Core", "examples\X.PagedList.Mvc.Example.Core\X.PagedList.Mvc.Example.Core.csproj", "{288F5726-904F-48B8-8363-EA1A22D331D1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</section>

<!-- output a paging control that lets the user navigation to the previous page, next page, etc -->
@Html.PagedListPager((IPagedList)ViewBag.Names, page => Url.Action("Index", new { page }), new PagedListRenderOptionsBase
@Html.PagedListPager((IPagedList)ViewBag.Names, page => Url.Action("Index", new { page }), new PagedListRenderOptions
{
PageClasses = new string[] { "page-link" },
UlElementClasses = new string[] { "pagination" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@*import this so we can cast our list to IPagedList (only necessary because ViewBag is dynamic)*@
@using X.PagedList;
@using X.PagedList.Mvc.Core.Common
@using X.PagedList.Web.Common

<ul>
@foreach (var name in Model)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@*import this so we can cast our list to IPagedList (only necessary because ViewBag is dynamic)*@
@using X.PagedList;
@using X.PagedList.Mvc.Core.Common
@using X.PagedList.Web.Common

<ul>
@foreach (var name in Model)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@model X.PagedList.IPagedList

@{
var options = (PagedListRenderOptionsBase)ViewData["Options"];
var options = (PagedListRenderOptions)ViewData["Options"];
var generatePageUrl = (Func<int, string>)ViewData["GeneratePageUrl"];
var containerDivClasses = (options.ContainerDivClasses ?? Enumerable.Empty<string>()).Aggregate(new StringBuilder(), (c, n) => c.Append(n).Append(" "));
var ulElementClasses = (options.UlElementClasses ?? Enumerable.Empty<string>()).Aggregate(new StringBuilder(), (c, n) => c.Append(n).Append(" "));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@model X.PagedList.IPagedList

@{
var options = (PagedListRenderOptionsBase)ViewData["Options"];
var options = (PagedListRenderOptions)ViewData["Options"];
var generatePageUrl = (Func<int, string>)ViewData["GeneratePageUrl"];
var containerDivClasses = (options.ContainerDivClasses ?? Enumerable.Empty<string>()).Aggregate(new StringBuilder(), (c, n) => c.Append(n).Append(" "));
var ulElementClasses = (options.UlElementClasses ?? Enumerable.Empty<string>()).Aggregate(new StringBuilder(), (c, n) => c.Append(n).Append(" "));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
@using System.Text
@using X.PagedList.Mvc.Common
@using X.PagedList.Web.Common

@model X.PagedList.IPagedList

@{
var options = (PagedListRenderOptionsBase)ViewData["Options"];
var options = (PagedListRenderOptions)ViewData["Options"];
var generatePageUrl = (Func<int, string>)ViewData["GeneratePageUrl"];
var containerDivClasses = (options.ContainerDivClasses ?? Enumerable.Empty<string>()).Aggregate(new StringBuilder(), (c, n) => c.Append(n).Append(" "));
var ulElementClasses = (options.UlElementClasses ?? Enumerable.Empty<string>()).Aggregate(new StringBuilder(), (c, n) => c.Append(n).Append(" "));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
@using System.Text
@using X.PagedList.Mvc.Common
@using X.PagedList.Web.Common

@model X.PagedList.IPagedList

@{
var options = (PagedListRenderOptionsBase)ViewData["Options"];
var options = (PagedListRenderOptions)ViewData["Options"];
var generatePageUrl = (Func<int, string>)ViewData["GeneratePageUrl"];
var containerDivClasses = (options.ContainerDivClasses ?? Enumerable.Empty<string>()).Aggregate(new StringBuilder(), (c, n) => c.Append(n).Append(" "));
var ulElementClasses = (options.UlElementClasses ?? Enumerable.Empty<string>()).Aggregate(new StringBuilder(), (c, n) => c.Append(n).Append(" "));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
@using System.Web.Optimization
@using X.PagedList
@using X.PagedList.Mvc
@using X.PagedList.Mvc.Common
@using X.PagedList.Mvc.Fluent
@using X.PagedList.Web.Common

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@using X.PagedList
@using X.PagedList.Mvc
@using X.PagedList.Mvc.Common
@using X.PagedList.Web.Common
@using AjaxOptions = X.PagedList.Web.Common.AjaxOptions

@Html.PagedListGoToPageForm((IPagedList)ViewBag.Names, Url.Action("Index"))

Expand Down
1 change: 1 addition & 0 deletions examples/X.PagedList.Mvc.Example/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<assemblies>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add assembly="System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add assembly="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"/>
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5.2"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@
<Project>{cfbaecec-9581-47dd-a5f0-fcbd0be4398e}</Project>
<Name>X.PagedList.Mvc</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\X.PagedList.Web.Common\X.PagedList.Web.Common.csproj">
<Project>{A83A2188-D9AB-4A53-9888-D00EBCAC5160}</Project>
<Name>X.PagedList.Web.Common</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\X.PagedList\X.PagedList.csproj">
<Project>{49f86df5-728f-4f22-986e-38dfc9c2432a}</Project>
<Name>X.PagedList</Name>
Expand Down
77 changes: 0 additions & 77 deletions src/X.PagedList.Mvc.Core/Common/PagedListRenderOptions.cs

This file was deleted.

17 changes: 8 additions & 9 deletions src/X.PagedList.Mvc.Core/Fluent/HtmlPagerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace X.PagedList.Mvc.Core.Fluent
{
using System;
using Common;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc.Rendering;

Expand All @@ -13,7 +12,7 @@ internal sealed class HtmlPagerBuilder : IHtmlPagerBuilder
private readonly IPagedList _pagedList;

private Func<int, string> _generatePageUrl;
private PagedListRenderOptionsBase _options;
private PagedListRenderOptions _options;
private string _partialViewName;

public HtmlPagerBuilder(IHtmlHelper htmlHelper, IPagedList pagedList)
Expand Down Expand Up @@ -89,49 +88,49 @@ public IHtmlPagerBuilder MaximumPageNumbersToDisplay(int pageNumbers)

public IHtmlContent Classic()
{
this._options = PagedListRenderOptionsBase.Classic;
this._options = PagedListRenderOptions.Classic;

return Build();
}

public IHtmlContent ClassicPlusFirstAndLast()
{
this._options = PagedListRenderOptionsBase.ClassicPlusFirstAndLast;
this._options = PagedListRenderOptions.ClassicPlusFirstAndLast;

return Build();
}

public IHtmlContent Minimal()
{
this._options = PagedListRenderOptionsBase.Minimal;
this._options = PagedListRenderOptions.Minimal;

return Build();
}

public IHtmlContent MinimalWithPageCountText()
{
this._options = PagedListRenderOptionsBase.MinimalWithPageCountText;
this._options = PagedListRenderOptions.MinimalWithPageCountText;

return Build();
}

public IHtmlContent MinimalWithItemCountText()
{
this._options = PagedListRenderOptionsBase.MinimalWithItemCountText;
this._options = PagedListRenderOptions.MinimalWithItemCountText;

return Build();
}

public IHtmlContent PageNumbersOnly()
{
this._options = PagedListRenderOptionsBase.PageNumbersOnly;
this._options = PagedListRenderOptions.PageNumbersOnly;

return Build();
}

public IHtmlContent OnlyShowFivePagesAtATime()
{
this._options = PagedListRenderOptionsBase.OnlyShowFivePagesAtATime;
this._options = PagedListRenderOptions.OnlyShowFivePagesAtATime;

return Build();
}
Expand Down
1 change: 0 additions & 1 deletion src/X.PagedList.Mvc.Core/Fluent/IHtmlPagerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace X.PagedList.Mvc.Core.Fluent
{
using System;
using Common;
using Microsoft.AspNetCore.Html;

public interface IHtmlPagerBuilder
Expand Down
Loading

0 comments on commit f69356e

Please sign in to comment.