From 9cfd296fde7ef33defda9b3155b9455f8118992b Mon Sep 17 00:00:00 2001 From: Nathan Heskew Date: Sat, 17 Jul 2010 09:20:16 -0700 Subject: [PATCH] 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 --- .../Contents/Controllers/AdminController.cs | 7 ++-- .../Core/Contents/Views/Admin/List.ascx | 18 +++++----- .../Orchard.Blogs/Drivers/BlogDriver.cs | 19 ++++++++--- .../Items/Blogs.Blog.DetailAdmin.ascx | 2 +- .../Parts/Blogs.BlogPost.List.ascx | 33 ++++++++++++++++--- 5 files changed, 57 insertions(+), 22 deletions(-) diff --git a/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs b/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs index 15be6713b..f4bd49b43 100644 --- a/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs +++ b/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs @@ -7,7 +7,6 @@ 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; @@ -76,7 +75,7 @@ namespace Orchard.Core.Contents.Controllers { [HttpPost, ActionName("List")] [FormValueRequired("submit.BulkEdit")] - public ActionResult ListPOST(ContentOptions options, IEnumerable itemIds) { + public ActionResult ListPOST(ContentOptions options, IEnumerable itemIds, string returnUrl) { switch (options.BulkAction) { case ContentsBulkAction.None: break; @@ -114,7 +113,9 @@ namespace Orchard.Core.Contents.Controllers { throw new ArgumentOutOfRangeException(); } - // todo: persist filter & order + if (!String.IsNullOrEmpty(returnUrl)) + return Redirect(returnUrl); + return RedirectToAction("List"); } diff --git a/src/Orchard.Web/Core/Contents/Views/Admin/List.ascx b/src/Orchard.Web/Core/Contents/Views/Admin/List.ascx index 06ea66f69..9444bdf13 100644 --- a/src/Orchard.Web/Core/Contents/Views/Admin/List.ascx +++ b/src/Orchard.Web/Core/Contents/Views/Admin/List.ascx @@ -1,17 +1,17 @@ <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> <%@ Import Namespace="Orchard.Core.Contents.ViewModels" %> -

<%:Html.TitleForPage((string.IsNullOrEmpty(Model.TypeDisplayName) ? T("Manage Content") : T("Manage {0} Content", Model.TypeDisplayName)).ToString())%>

+

<%:Html.TitleForPage((string.IsNullOrEmpty(Model.TypeDisplayName) ? T("Manage Content") : T("Manage {0} Content", Model.TypeDisplayName)).ToString()) %>

- <%:Html.ActionLink(!string.IsNullOrEmpty(Model.TypeDisplayName) ? T("Add new {0} content", Model.TypeDisplayName).Text : T("Add new content").Text, "Create", new { }, new { @class = "button primaryAction" })%> + <%:Html.ActionLink(!string.IsNullOrEmpty(Model.TypeDisplayName) ? T("Add new {0} content", Model.TypeDisplayName).Text : T("Add new content").Text, "Create", new { }, new { @class = "button primaryAction" }) %>
<% -using (Html.BeginFormAntiForgeryPost()) { %> +using (Html.BeginFormAntiForgeryPost()) { %>
- +
@@ -35,6 +35,6 @@ using (Html.BeginFormAntiForgeryPost()) { %> <%:Html.UnorderedList( Model.Entries, (entry, i) => Html.DisplayForItem(entry.ViewModel), - "")%> + "") %> <% } %> \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/BlogDriver.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/BlogDriver.cs index 0bca103ca..3a5451ec0 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/BlogDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Drivers/BlogDriver.cs @@ -6,6 +6,7 @@ using Orchard.Blogs.Models; using Orchard.Blogs.Services; using Orchard.ContentManagement; using Orchard.ContentManagement.Drivers; +using Orchard.Core.Contents.ViewModels; using Orchard.Localization; using Orchard.Mvc.ViewModels; @@ -20,13 +21,11 @@ namespace Orchard.Blogs.Drivers { }; private readonly IContentManager _contentManager; - private readonly IBlogService _blogService; private readonly IBlogPostService _blogPostService; - public BlogDriver(IOrchardServices services, IContentManager contentManager, IBlogService blogService, IBlogPostService blogPostService) { + public BlogDriver(IOrchardServices services, IContentManager contentManager, IBlogPostService blogPostService) { Services = services; _contentManager = contentManager; - _blogService = blogService; _blogPostService = blogPostService; T = NullLocalizer.Instance; } @@ -78,7 +77,19 @@ namespace Orchard.Blogs.Drivers { ContentPartTemplate(blog, "Parts/Blogs.Blog.Manage").Location("manage"), ContentPartTemplate(blog, "Parts/Blogs.Blog.Metadata").Location("metadata"), 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) { diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Items/Blogs.Blog.DetailAdmin.ascx b/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Items/Blogs.Blog.DetailAdmin.ascx index f939466ae..d4aab5af5 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Items/Blogs.Blog.DetailAdmin.ascx +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Items/Blogs.Blog.DetailAdmin.ascx @@ -16,6 +16,6 @@ --%> - + <% Html.Zone("primary"); Html.ZonesAny(); %> \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx b/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx index 83b8bc199..e60031c58 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx @@ -1,5 +1,28 @@ -<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl>>" %> -<%@ Import Namespace="Orchard.Mvc.ViewModels"%> -<%@ Import Namespace="Orchard.Blogs.Models"%> -<%: Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp), "blogPosts contentItems") %> -<% if (Model.Count() < 1) { %>
<%: T("There are no posts for this blog.") %>
<% } %> \ No newline at end of file +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> +<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %> +<%@ Import Namespace="Orchard.Utility.Extensions" %> +<% +if (Model.Entries.Count() < 1) { %> +
<%:T("There are no posts for this blog.") %>
<% +} +else { + using (Html.BeginFormAntiForgeryPost(Url.Action("List", "Admin", new { area = "Contents", id = "" }))) { %> +
+ + + <%:Html.Hidden("returnUrl", ViewContext.RequestContext.HttpContext.Request.ToUrlString()) %> + +
+
+ <%:Html.UnorderedList( + Model.Entries, + (entry, i) => Html.DisplayForItem(entry.ViewModel), + "") %> +
<% + } +} %> \ No newline at end of file