mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +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;
|
||||||
using Orchard.ContentManagement.Aspects;
|
using Orchard.ContentManagement.Aspects;
|
||||||
using Orchard.ContentManagement.MetaData;
|
using Orchard.ContentManagement.MetaData;
|
||||||
|
using Orchard.ContentManagement.Records;
|
||||||
|
using Orchard.Core.Common.Models;
|
||||||
using Orchard.Core.Contents.ViewModels;
|
using Orchard.Core.Contents.ViewModels;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
@@ -43,6 +45,9 @@ namespace Orchard.Core.Contents.Controllers {
|
|||||||
public ILogger Logger { get; set; }
|
public ILogger Logger { get; set; }
|
||||||
|
|
||||||
public ActionResult List(ListContentsViewModel model) {
|
public ActionResult List(ListContentsViewModel model) {
|
||||||
|
if (model.ContainerId != null && _contentManager.GetLatest((int)model.ContainerId) == null)
|
||||||
|
return new NotFoundResult();
|
||||||
|
|
||||||
const int pageSize = 20;
|
const int pageSize = 20;
|
||||||
var skip = (Math.Max(model.Page ?? 0, 1) - 1) * pageSize;
|
var skip = (Math.Max(model.Page ?? 0, 1) - 1) * pageSize;
|
||||||
|
|
||||||
@@ -59,6 +64,9 @@ namespace Orchard.Core.Contents.Controllers {
|
|||||||
query = query.ForType(model.TypeName);
|
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);
|
var contentItems = query.Slice(skip, pageSize);
|
||||||
|
|
||||||
model.Entries = contentItems.Select(BuildEntry).ToList();
|
model.Entries = contentItems.Select(BuildEntry).ToList();
|
||||||
|
|||||||
38
src/Orchard.Web/Core/Contents/Routes.cs
Normal file
38
src/Orchard.Web/Core/Contents/Routes.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using System.Web.Routing;
|
||||||
|
using Orchard.Mvc.Routes;
|
||||||
|
|
||||||
|
namespace Orchard.Core.Contents {
|
||||||
|
public class Routes : IRouteProvider {
|
||||||
|
#region IRouteProvider Members
|
||||||
|
|
||||||
|
public void GetRoutes(ICollection<RouteDescriptor> routes) {
|
||||||
|
foreach (RouteDescriptor routeDescriptor in GetRoutes()) {
|
||||||
|
routes.Add(routeDescriptor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<RouteDescriptor> GetRoutes() {
|
||||||
|
return new[] {
|
||||||
|
new RouteDescriptor {
|
||||||
|
Priority = 5,
|
||||||
|
Route = new Route(
|
||||||
|
"Admin/Contents/List/{id}/InContainer/{containerId}",
|
||||||
|
new RouteValueDictionary {
|
||||||
|
{"area", "Contents"},
|
||||||
|
{"controller", "Admin"},
|
||||||
|
{"action", "List"}
|
||||||
|
},
|
||||||
|
new RouteValueDictionary(),
|
||||||
|
new RouteValueDictionary {
|
||||||
|
{"area", "Contents"}
|
||||||
|
},
|
||||||
|
new MvcRouteHandler())
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ namespace Orchard.Core.Contents.ViewModels {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
|
public int? ContainerId { get; set; }
|
||||||
|
|
||||||
public string TypeName {
|
public string TypeName {
|
||||||
get { return Id; }
|
get { return Id; }
|
||||||
|
|||||||
@@ -78,6 +78,7 @@
|
|||||||
<Compile Include="Contents\Drivers\ContentsDriver.cs" />
|
<Compile Include="Contents\Drivers\ContentsDriver.cs" />
|
||||||
<Compile Include="Contents\Handlers\ContentsHandler.cs" />
|
<Compile Include="Contents\Handlers\ContentsHandler.cs" />
|
||||||
<Compile Include="Contents\Permissions.cs" />
|
<Compile Include="Contents\Permissions.cs" />
|
||||||
|
<Compile Include="Contents\Routes.cs" />
|
||||||
<Compile Include="Contents\ViewModels\PublishContentViewModel.cs" />
|
<Compile Include="Contents\ViewModels\PublishContentViewModel.cs" />
|
||||||
<Compile Include="PublishLater\Drivers\PublishLaterPartDriver.cs" />
|
<Compile Include="PublishLater\Drivers\PublishLaterPartDriver.cs" />
|
||||||
<Compile Include="PublishLater\Models\PublishLaterPart.cs" />
|
<Compile Include="PublishLater\Models\PublishLaterPart.cs" />
|
||||||
|
|||||||
@@ -2,4 +2,4 @@
|
|||||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||||
<%: Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp), "blogPosts contentItems") %>
|
<%: Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp), "blogPosts contentItems") %>
|
||||||
<% if (Model.Count() < 1) { %><div class="info message"><%: T("There are no posts for this blog.") %></div><% } %>
|
<% if (Model.Count() < 1) { %><div class="info message"><%: T("There are no posts for this blog.") %></div><% } %>
|
||||||
Reference in New Issue
Block a user