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:
Nathan Heskew
2010-07-17 09:20:16 -07:00
parent 4988dbff06
commit 9cfd296fde
5 changed files with 57 additions and 22 deletions

View File

@@ -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");
} }

View File

@@ -1,17 +1,17 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Core.Contents.ViewModels.ListContentsViewModel>" %> <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Core.Contents.ViewModels.ListContentsViewModel>" %>
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %> <%@ Import Namespace="Orchard.Core.Contents.ViewModels" %>
<h1><%:Html.TitleForPage((string.IsNullOrEmpty(Model.TypeDisplayName) ? T("Manage Content") : T("Manage {0} Content", Model.TypeDisplayName)).ToString())%></h1> <h1><%:Html.TitleForPage((string.IsNullOrEmpty(Model.TypeDisplayName) ? T("Manage Content") : T("Manage {0} Content", Model.TypeDisplayName)).ToString()) %></h1>
<div class="manage"> <div class="manage">
<%: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" }) %>
</div><% </div><%
using (Html.BeginFormAntiForgeryPost()) { %> using (Html.BeginFormAntiForgeryPost()) { %>
<fieldset class="bulk-actions"> <fieldset class="bulk-actions">
<label for="publishActions"><%:T("Actions:")%></label> <label for="publishActions"><%:T("Actions:") %></label>
<select id="publishActions" name="<%:Html.NameOf(m => m.Options.BulkAction) %>"> <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.None, T("Choose action...").ToString()) %>
<%:Html.SelectOption(Model.Options.BulkAction, ContentsBulkAction.PublishNow, T("Publish Now").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.Unpublish, T("Unpublish").ToString()) %>
<%:Html.SelectOption(Model.Options.BulkAction, ContentsBulkAction.Remove, T("Remove").ToString())%> <%:Html.SelectOption(Model.Options.BulkAction, ContentsBulkAction.Remove, T("Remove").ToString()) %>
</select> </select>
<button type="submit" name="submit.BulkEdit" value="yes"><%:T("Apply") %></button> <button type="submit" name="submit.BulkEdit" value="yes"><%:T("Apply") %></button>
</fieldset> </fieldset>
@@ -35,6 +35,6 @@ using (Html.BeginFormAntiForgeryPost()) { %>
<%:Html.UnorderedList( <%:Html.UnorderedList(
Model.Entries, Model.Entries,
(entry, i) => Html.DisplayForItem(entry.ViewModel), (entry, i) => Html.DisplayForItem(entry.ViewModel),
"")%> "") %>
</fieldset><% </fieldset><%
} %> } %>

View File

@@ -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) {

View File

@@ -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(); %>

View File

@@ -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><%
}
} %>