mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
@@ -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);
|
||||
|
@@ -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; }
|
||||
}
|
||||
|
||||
|
@@ -50,5 +50,6 @@
|
||||
tagIndex = tagIndex + 1;
|
||||
}
|
||||
</table>
|
||||
@Display(Model.Pager)
|
||||
</fieldset>
|
||||
}
|
Reference in New Issue
Block a user