4
Vote

Admin Content browser "Show: All" displays pager

description

And obviously, the pager does nothing

file attachments

comments

sebastienros wrote Feb 18, 2014 at 8:36 PM

todo: remove the page links and prev/next but display only the DDL with page count

CraigLittlewood wrote Nov 26, 2014 at 12:39 PM

I have the same problem.

jtkech wrote Dec 3, 2014 at 1:39 AM

@jchenga you're right but I have seen others drawbacks and inconsistencies

The site.PageSize setting = 0, go to content list, select the ALL option, it fails
A zero size option has been added and selected, the ALL option is also selected but with no link data


In Pager.cshtml, replace (line 36 in 1.8.x)
    if (!pageSizes.Contains(defaultPageSize)) {
        pageSizes.Add(defaultPageSize);
    }
With
    if (defaultPageSize > 0 && !pageSizes.Contains(defaultPageSize)) {
        pageSizes.Add(defaultPageSize);
    }
Select a low size option, go to the last page, select a much higher size, the pager is inconsistent
It displays too many page links, with some text like: Showing items 431 - 15 of 15


We need to adapt the page number of the size ActionLink to retrieve the 1st item of the current page
In Pager.cshtml, after currently line 49, we can add these variable initializations
@{
  var pageId = String.IsNullOrEmpty(Model.PagerId) ? "page" : Model.PagerId;
  var nPage = Math.Max(1, Convert.ToInt32(routeData[pageId]));
  var firstItem = ((nPage - 1) * Model.PageSize) + 1;
}
Before the ALL option action link, currently line 54 in 1.8.x, add
  routeData[pageId] = 1;
And before the size option action link in the foreach loop, currently line 63, add
  routeData[pageId] = size > 0 ? Math.Ceiling((double)firstItem / size) : 1;
If only one page, to completely remove page links (even page 1), only display the items count

In CoreShape.cs, , currently line 519, replace
 if (numberOfPagesToShow > 0) {
With
  if (numberOfPagesToShow > 0 && lastPage > 1) {
To be more consistent, prevent totalPageCount to have an infinite negative value

In Pager.cshtml, currently line 20, replace
  var totalPageCount = (int)Math.Ceiling((double)Model.TotalItemCount / Model.PageSize);
With
  var totalPageCount = Model.PageSize > 0 ? (int)Math.Ceiling((double)Model.TotalItemCount / Model.PageSize) : 1;
Same logic in CoreShape.cs, currently line 446, replace
  var totalPageCount = (int)Math.Ceiling(TotalItemCount / pageSize);
With
  var totalPageCount = pageSize > 0 ? (int)Math.Ceiling(TotalItemCount / pageSize) : 1;
With the previous replacement, in CoreShape.cs we no longer need to test the pageSize line 439

We can comment or remove these 2 lines, line 439 and 440
  // if (pageSize < 1)
  //   pageSize = _workContext.Value.CurrentSite.PageSize;
Finally, with the ALL option, do we have to consider the site.MaxPageSize setting (not the site.PageSize) ?
If so, we need others update as in the pager constructor, but here it depends what is by design

Thank you

jchenga wrote Dec 16, 2014 at 5:12 AM

@jtkech Thanks for the suggestions. I have created another PR request incorporating your codes: https://orchard.codeplex.com/SourceControl/network/forks/jchenga/orchardfork/contribution/7824

jchenga wrote Dec 16, 2014 at 5:23 AM

jchenga wrote Jan 3 at 5:55 PM

sorry about another PR. my fork was corrupted and the links to the PRs were no longer working.

Here is the link to the correct and hopefully last PR on this issue:
https://orchard.codeplex.com/SourceControl/network/forks/jchenga/orchard/contribution/7868

sebastienros wrote Jan 22 at 8:44 PM

As jtkech mentioned we need to handle the All option differently when MaxPageSize is smaller than the total number of items. In this case we still display the page.

We also need to take MaxPagedCount into account to limit the number of pages displayed in the Pager (this should already be done).

jchenga wrote Jan 31 at 12:37 AM

@sebastienros the MaxPagedCount change is done in 1.x branch but not in 1.8.x branch. My pull request is based on the 1.8.x branch. Do I send two pull requests for this issue, one for 1.8.x and another for 1.x?

jchenga wrote Feb 20 at 3:34 PM

I have made more changes as requested on the 1.x branch.

Here is the pull request:
https://orchard.codeplex.com/SourceControl/network/forks/jchenga/orchard/contribution/8049