mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-20 02:37:55 +08:00
Getting bulk actions hooked up for the admin blog post list
- publish/unpublish and remove links in the item summary admin template are still broken. they need to be constructed with all routing info --HG-- branch : dev
This commit is contained in:
@@ -7,7 +7,6 @@ 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.Common.Models;
|
||||||
using Orchard.Core.Contents.ViewModels;
|
using Orchard.Core.Contents.ViewModels;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
@@ -76,7 +75,7 @@ namespace Orchard.Core.Contents.Controllers {
|
|||||||
|
|
||||||
[HttpPost, ActionName("List")]
|
[HttpPost, ActionName("List")]
|
||||||
[FormValueRequired("submit.BulkEdit")]
|
[FormValueRequired("submit.BulkEdit")]
|
||||||
public ActionResult ListPOST(ContentOptions options, IEnumerable<int> itemIds) {
|
public ActionResult ListPOST(ContentOptions options, IEnumerable<int> itemIds, string returnUrl) {
|
||||||
switch (options.BulkAction) {
|
switch (options.BulkAction) {
|
||||||
case ContentsBulkAction.None:
|
case ContentsBulkAction.None:
|
||||||
break;
|
break;
|
||||||
@@ -114,7 +113,9 @@ namespace Orchard.Core.Contents.Controllers {
|
|||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: persist filter & order
|
if (!String.IsNullOrEmpty(returnUrl))
|
||||||
|
return Redirect(returnUrl);
|
||||||
|
|
||||||
return RedirectToAction("List");
|
return RedirectToAction("List");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,6 +6,7 @@ using Orchard.Blogs.Models;
|
|||||||
using Orchard.Blogs.Services;
|
using Orchard.Blogs.Services;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.Drivers;
|
using Orchard.ContentManagement.Drivers;
|
||||||
|
using Orchard.Core.Contents.ViewModels;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.Mvc.ViewModels;
|
using Orchard.Mvc.ViewModels;
|
||||||
|
|
||||||
@@ -20,13 +21,11 @@ namespace Orchard.Blogs.Drivers {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private readonly IContentManager _contentManager;
|
private readonly IContentManager _contentManager;
|
||||||
private readonly IBlogService _blogService;
|
|
||||||
private readonly IBlogPostService _blogPostService;
|
private readonly IBlogPostService _blogPostService;
|
||||||
|
|
||||||
public BlogDriver(IOrchardServices services, IContentManager contentManager, IBlogService blogService, IBlogPostService blogPostService) {
|
public BlogDriver(IOrchardServices services, IContentManager contentManager, IBlogPostService blogPostService) {
|
||||||
Services = services;
|
Services = services;
|
||||||
_contentManager = contentManager;
|
_contentManager = contentManager;
|
||||||
_blogService = blogService;
|
|
||||||
_blogPostService = blogPostService;
|
_blogPostService = blogPostService;
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
@@ -78,7 +77,19 @@ namespace Orchard.Blogs.Drivers {
|
|||||||
ContentPartTemplate(blog, "Parts/Blogs.Blog.Manage").Location("manage"),
|
ContentPartTemplate(blog, "Parts/Blogs.Blog.Manage").Location("manage"),
|
||||||
ContentPartTemplate(blog, "Parts/Blogs.Blog.Metadata").Location("metadata"),
|
ContentPartTemplate(blog, "Parts/Blogs.Blog.Metadata").Location("metadata"),
|
||||||
ContentPartTemplate(blog, "Parts/Blogs.Blog.Description").Location("primary"),
|
ContentPartTemplate(blog, "Parts/Blogs.Blog.Description").Location("primary"),
|
||||||
blogPosts == null ? null : ContentPartTemplate(blogPosts, "Parts/Blogs.BlogPost.List", "").Location("primary"));
|
blogPosts == null
|
||||||
|
? null
|
||||||
|
: ContentPartTemplate(
|
||||||
|
new ListContentsViewModel {
|
||||||
|
ContainerId = blog.Id,
|
||||||
|
Entries = blogPosts.Select(bp => new ListContentsViewModel.Entry {
|
||||||
|
ContentItem = bp.Item.ContentItem,
|
||||||
|
ContentItemMetadata = _contentManager.GetItemMetadata(bp.Item.ContentItem),
|
||||||
|
ViewModel = bp
|
||||||
|
}).ToList()
|
||||||
|
},
|
||||||
|
"Parts/Blogs.BlogPost.List",
|
||||||
|
"").Location("primary"));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DriverResult Editor(Blog blog) {
|
protected override DriverResult Editor(Blog blog) {
|
||||||
|
@@ -16,6 +16,6 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
</form>--%>
|
</form>--%>
|
||||||
<div class="actions"><a href="<%: Url.BlogPostCreate(Model.Item) %>" class="add button primaryAction"><%: T("New Post")%></a></div>
|
<div class="manage"><a href="<%: Url.BlogPostCreate(Model.Item) %>" class="add button primaryAction"><%: T("New Post")%></a></div>
|
||||||
<% Html.Zone("primary");
|
<% Html.Zone("primary");
|
||||||
Html.ZonesAny(); %>
|
Html.ZonesAny(); %>
|
@@ -1,5 +1,28 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<ContentItemViewModel<BlogPost>>>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ListContentsViewModel>" %>
|
||||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %>
|
||||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
<%@ Import Namespace="Orchard.Utility.Extensions" %>
|
||||||
<%: 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.Entries.Count() < 1) { %>
|
||||||
|
<div class="info message"><%:T("There are no posts for this blog.") %></div><%
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
using (Html.BeginFormAntiForgeryPost(Url.Action("List", "Admin", new { area = "Contents", id = "" }))) { %>
|
||||||
|
<fieldset class="bulk-actions">
|
||||||
|
<label for="publishActions"><%:T("Actions:") %></label>
|
||||||
|
<select id="publishActions" name="<%:Html.NameOf(m => m.Options.BulkAction) %>">
|
||||||
|
<%:Html.SelectOption(Model.Options.BulkAction, ContentsBulkAction.None, T("Choose action...").ToString()) %>
|
||||||
|
<%:Html.SelectOption(Model.Options.BulkAction, ContentsBulkAction.PublishNow, T("Publish Now").ToString()) %>
|
||||||
|
<%:Html.SelectOption(Model.Options.BulkAction, ContentsBulkAction.Unpublish, T("Unpublish").ToString()) %>
|
||||||
|
<%:Html.SelectOption(Model.Options.BulkAction, ContentsBulkAction.Remove, T("Remove").ToString()) %>
|
||||||
|
</select>
|
||||||
|
<%:Html.Hidden("returnUrl", ViewContext.RequestContext.HttpContext.Request.ToUrlString()) %>
|
||||||
|
<button type="submit" name="submit.BulkEdit" value="yes"><%:T("Apply") %></button>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset class="contentItems bulk-items">
|
||||||
|
<%:Html.UnorderedList(
|
||||||
|
Model.Entries,
|
||||||
|
(entry, i) => Html.DisplayForItem(entry.ViewModel),
|
||||||
|
"") %>
|
||||||
|
</fieldset><%
|
||||||
|
}
|
||||||
|
} %>
|
Reference in New Issue
Block a user