mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-20 10:47:56 +08:00
Added container scoping to the admin content item list
--HG-- branch : dev
This commit is contained in:
@@ -7,6 +7,8 @@ using System.Web.Routing;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Contents.ViewModels;
|
||||
using Orchard.Data;
|
||||
using Orchard.Localization;
|
||||
@@ -43,6 +45,9 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public ActionResult List(ListContentsViewModel model) {
|
||||
if (model.ContainerId != null && _contentManager.GetLatest((int)model.ContainerId) == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
const int pageSize = 20;
|
||||
var skip = (Math.Max(model.Page ?? 0, 1) - 1) * pageSize;
|
||||
|
||||
@@ -59,6 +64,9 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
query = query.ForType(model.TypeName);
|
||||
}
|
||||
|
||||
if (model.ContainerId != null)
|
||||
query = query.Join<CommonRecord>().Where(cr => cr.Container.Id == model.ContainerId);
|
||||
|
||||
var contentItems = query.Slice(skip, pageSize);
|
||||
|
||||
model.Entries = contentItems.Select(BuildEntry).ToList();
|
||||
|
Reference in New Issue
Block a user