#20931: [PATCH] Tag Pagianation

Work Item: 20931
This commit is contained in:
urbanit
2014-09-12 11:35:49 +03:00
committed by Nicholas Mayne
parent 12d3eb66dc
commit 6e8a3dc109
3 changed files with 15 additions and 5 deletions

View File

@@ -10,6 +10,7 @@ using Orchard.Tags.Drivers;
using Orchard.Tags.Models;
using Orchard.Tags.ViewModels;
using Orchard.Tags.Services;
using Orchard.UI.Navigation;
namespace Orchard.Tags.Controllers {
[ValidateInput(false)]
@@ -26,20 +27,27 @@ namespace Orchard.Tags.Controllers {
public Localizer T { get; set; }
public ActionResult Index() {
public ActionResult Index(PagerParameters pagerParameters) {
if (!Services.Authorizer.Authorize(Permissions.ManageTags, T("Can't manage tags")))
return new HttpUnauthorizedResult();
IEnumerable<TagRecord> tags = _tagService.GetTags();
var pager = new Pager(Services.WorkContext.CurrentSite, pagerParameters);
var pagerShape = Services.New.Pager(pager).TotalItemCount(tags.Count());
if (pager.PageSize != 0) {
tags = tags.Skip(pager.GetStartIndex()).Take(pager.PageSize);
}
var entries = tags.Select(CreateTagEntry).ToList();
var model = new TagsAdminIndexViewModel { Tags = entries };
var model = new TagsAdminIndexViewModel { Pager = pagerShape, Tags = entries };
return View(model);
}
[HttpPost]
[FormValueRequired("submit.BulkEdit")]
public ActionResult Index(FormCollection input)
{
public ActionResult Index(FormCollection input) {
var viewModel = new TagsAdminIndexViewModel {Tags = new List<TagEntry>(), BulkAction = new TagAdminIndexBulkAction()};
if ( !TryUpdateModel(viewModel) ) {
@@ -82,7 +90,7 @@ namespace Orchard.Tags.Controllers {
if(!ModelState.IsValid) {
ViewData["CreateTag"] = viewModel;
return Index();
return RedirectToAction("Index");
}
_tagService.CreateTag(viewModel.TagName);

View File

@@ -4,6 +4,7 @@ using Orchard.Tags.Models;
namespace Orchard.Tags.ViewModels {
public class TagsAdminIndexViewModel {
public IList<TagEntry> Tags { get; set; }
public dynamic Pager { get; set; }
public TagAdminIndexBulkAction BulkAction { get; set; }
}

View File

@@ -50,5 +50,6 @@
tagIndex = tagIndex + 1;
}
</table>
@Display(Model.Pager)
</fieldset>
}