mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Added a view for 'Orphaned' content items. Fixed routes to use 'Lists' instead of 'Orchard.Lists'
--HG-- branch : dev
This commit is contained in:
@@ -59,25 +59,26 @@ namespace Lists.Controllers {
|
||||
|
||||
public ActionResult List(ListContentsViewModel model, PagerParameters pagerParameters) {
|
||||
var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
|
||||
var container = _contentManager.GetLatest((int)model.ContainerId);
|
||||
if (container == null) {
|
||||
var container = model.ContainerId.HasValue ? _contentManager.GetLatest((int)model.ContainerId) : null;
|
||||
if (container == null && model.ContainerId.HasValue) {
|
||||
return HttpNotFound();
|
||||
}
|
||||
var restrictedContentType = container.As<ContainerPart>().Record.ItemContentType;
|
||||
var restrictedContentType = container == null ? null : container.As<ContainerPart>().Record.ItemContentType;
|
||||
var hasRestriction = !string.IsNullOrEmpty(restrictedContentType);
|
||||
|
||||
var metadata = container.ContentManager.GetItemMetadata(container);
|
||||
model.ContainerDisplayName = metadata.DisplayText;
|
||||
if (string.IsNullOrEmpty(model.ContainerDisplayName)) {
|
||||
model.ContainerDisplayName = container.ContentType;
|
||||
}
|
||||
|
||||
var query = _contentManager.Query(VersionOptions.Latest);
|
||||
|
||||
if (hasRestriction) {
|
||||
model.FilterByContentType = restrictedContentType;
|
||||
}
|
||||
|
||||
if (container != null) {
|
||||
var metadata = container.ContentManager.GetItemMetadata(container);
|
||||
model.ContainerDisplayName = metadata.DisplayText;
|
||||
if (string.IsNullOrEmpty(model.ContainerDisplayName)) {
|
||||
model.ContainerDisplayName = container.ContentType;
|
||||
}
|
||||
}
|
||||
|
||||
var query = _contentManager.Query<ContainablePart>(VersionOptions.Latest);
|
||||
|
||||
if (!string.IsNullOrEmpty(model.FilterByContentType)) {
|
||||
var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(model.FilterByContentType);
|
||||
if (contentTypeDefinition == null)
|
||||
@@ -119,7 +120,7 @@ namespace Lists.Controllers {
|
||||
.Options(model.Options)
|
||||
.HasRestriction(hasRestriction)
|
||||
.ContainerDisplayName(model.ContainerDisplayName)
|
||||
.ContainerContentType(container.ContentType)
|
||||
.ContainerContentType(container == null ? null : container.ContentType)
|
||||
.ContainerItemContentType(hasRestriction ? restrictedContentType : (model.FilterByContentType ?? ""))
|
||||
.OtherLists(_contentManager.Query<ContainerPart>(VersionOptions.Latest).List()
|
||||
.Select(part => part.ContentItem)
|
||||
@@ -190,7 +191,7 @@ namespace Lists.Controllers {
|
||||
}
|
||||
// ensure the item can be in that container.
|
||||
if (!string.IsNullOrEmpty(itemContentType) && item.ContentType != itemContentType) {
|
||||
Services.Notifier.Information(T("One or more items could not be moved to the '{0}' list because it is restricted to containing items of type '{1}'.", _contentManager.GetItemMetadata(item).DisplayText, itemContentType));
|
||||
Services.Notifier.Information(T("One or more items could not be moved to '{0}' because it is restricted to containing items of type '{1}'.", _contentManager.GetItemMetadata(targetContainer).DisplayText, itemContentType));
|
||||
return true; // todo: transactions
|
||||
}
|
||||
|
||||
|
@@ -16,9 +16,9 @@ namespace Orchard.Lists {
|
||||
new RouteDescriptor {
|
||||
Priority = 5,
|
||||
Route = new Route(
|
||||
"Admin/Orchard.Lists/{containerId}/{filterByContentType}",
|
||||
"Admin/Lists/{containerId}/{filterByContentType}",
|
||||
new RouteValueDictionary {
|
||||
{"area", "Contents"},
|
||||
{"area", "Orchard.Lists"},
|
||||
{"controller", "Admin"},
|
||||
{"action", "List"},
|
||||
{"filterByContentType", ""}
|
||||
@@ -35,7 +35,7 @@ namespace Orchard.Lists {
|
||||
new RouteDescriptor {
|
||||
Priority = 5,
|
||||
Route = new Route(
|
||||
"Admin/Orchard.Lists/{containerId}",
|
||||
"Admin/Lists/{containerId}",
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Lists"},
|
||||
{"controller", "Admin"},
|
||||
@@ -48,7 +48,42 @@ namespace Orchard.Lists {
|
||||
{"area", "Orchard.Lists"}
|
||||
},
|
||||
new MvcRouteHandler())
|
||||
}
|
||||
},
|
||||
|
||||
new RouteDescriptor {
|
||||
Priority = 5,
|
||||
Route = new Route(
|
||||
"Admin/Lists/Orphaned/{filterByContentType}",
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Lists"},
|
||||
{"controller", "Admin"},
|
||||
{"action", "List"},
|
||||
{"filterByContentType", ""},
|
||||
},
|
||||
new RouteValueDictionary{
|
||||
{"filterByContentType", @"\w+"},
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Lists"}
|
||||
},
|
||||
new MvcRouteHandler())
|
||||
},
|
||||
new RouteDescriptor {
|
||||
Priority = 5,
|
||||
Route = new Route(
|
||||
"Admin/Lists/Orphaned",
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Lists"},
|
||||
{"controller", "Admin"},
|
||||
{"action", "List"},
|
||||
},
|
||||
null,
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Lists"}
|
||||
},
|
||||
new MvcRouteHandler())
|
||||
},
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,16 @@
|
||||
jQuery("#publishActions").bind("change", function () {
|
||||
var value = jQuery(this).val(),
|
||||
target = jQuery("#TargetContainerId");
|
||||
if (value === "MoveToList") {
|
||||
target.css("display", "inline");
|
||||
(function ($) {
|
||||
|
||||
function sync() {
|
||||
var value = $(this).val(),
|
||||
target = $("#TargetContainerId");
|
||||
if (value === "MoveToList") {
|
||||
target.css("display", "inline");
|
||||
}
|
||||
else {
|
||||
target.css("display", "none");
|
||||
}
|
||||
}
|
||||
else {
|
||||
target.css("display", "none");
|
||||
}
|
||||
});
|
||||
|
||||
$("#publishActions").bind("change", sync).each(sync);
|
||||
|
||||
})(jQuery);
|
||||
|
@@ -1,12 +1,15 @@
|
||||
@using Orchard.Lists.ViewModels;
|
||||
@using Orchard.ContentManagement;
|
||||
@{
|
||||
Script.Include("orchard-lists-admin.js");
|
||||
|
||||
int? containerId = (int?)Model.ContainerId;
|
||||
|
||||
string createLinkText = string.IsNullOrEmpty(Model.ContainerItemContentType) ? T("Create New Content").ToString() : T("Create New {0}", Model.ContainerItemContentType).ToString();
|
||||
|
||||
Layout.Title = T("Manage Content for {0}", Model.ContainerDisplayName);
|
||||
Layout.Title = containerId.HasValue ? T("Manage Content for {0}", Model.ContainerDisplayName) : T("Orphaned Content Items");
|
||||
|
||||
var lists = ((IEnumerable<dynamic>)Model.OtherLists).Select(
|
||||
var lists = ((IEnumerable<ContentItem>)Model.OtherLists).Select(
|
||||
contentItem => new SelectListItem {
|
||||
Text = contentItem.ContentType + ": " + contentItem.ContentManager.GetItemMetadata(contentItem).DisplayText,
|
||||
Value = contentItem.Id.ToString(System.Globalization.CultureInfo.InvariantCulture)
|
||||
@@ -20,20 +23,23 @@
|
||||
</style>
|
||||
|
||||
<div> </div>
|
||||
@Display.Parts_Container_Manage(ContainerDisplayName: Model.ContainerDisplayName, ContainerContentType: Model.ContainerContentType, ContainerId: Model.ContainerId)
|
||||
|
||||
@Display.Parts_Container_Manage(ContainerDisplayName: Model.ContainerDisplayName, ContainerContentType: Model.ContainerContentType, ContainerId: containerId)
|
||||
@if (containerId.HasValue) {
|
||||
<div class="manage">
|
||||
@Html.ActionLink(createLinkText, "Create", new { Area = "Contents", Id = (string)Model.Options.SelectedFilter, ContainerId = Model.ContainerId, ReturnUrl = Html.ViewContext.HttpContext.Request.RawUrl }, new { @class = "button primaryAction" })
|
||||
@Html.ActionLink(createLinkText, "Create", new { Area = "Contents", Id = (string)Model.Options.SelectedFilter, ContainerId = (int)containerId, ReturnUrl = Html.ViewContext.HttpContext.Request.RawUrl }, new { @class = "button primaryAction" })
|
||||
</div>
|
||||
}
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
<fieldset class="bulk-actions">
|
||||
<label for="publishActions">@T("Actions:")</label>
|
||||
<select id="publishActions" name="Options.BulkAction">
|
||||
@if (containerId.HasValue) {
|
||||
@Html.SelectOption((ContentsBulkAction)Model.Options.BulkAction, ContentsBulkAction.None, T("Choose action...").ToString())
|
||||
@Html.SelectOption((ContentsBulkAction)Model.Options.BulkAction, ContentsBulkAction.PublishNow, T("Publish Now").ToString())
|
||||
@Html.SelectOption((ContentsBulkAction)Model.Options.BulkAction, ContentsBulkAction.Unpublish, T("Unpublish").ToString())
|
||||
@Html.SelectOption((ContentsBulkAction)Model.Options.BulkAction, ContentsBulkAction.Remove, T("Delete").ToString())
|
||||
@Html.SelectOption((ContentsBulkAction)Model.Options.BulkAction, ContentsBulkAction.RemoveFromList, T("Remove from List").ToString())
|
||||
}
|
||||
@Html.SelectOption((ContentsBulkAction)Model.Options.BulkAction, ContentsBulkAction.MoveToList, T("Move to List...").ToString())
|
||||
</select>
|
||||
@Html.DropDownList("TargetContainerId", lists, new { id = "TargetContainerId" })
|
||||
|
@@ -1,8 +1,10 @@
|
||||
<div class="item-properties actions">
|
||||
<p>
|
||||
@Html.ActionLink(T("Show Other Lists").ToString(), "List", new { Area = "Contents", Id = Model.ContainerContentType }) |
|
||||
@Html.ActionLink(T("Show Orphaned Content Items").ToString(), "Orphaned") |
|
||||
@Html.ActionLink(T("{0} Properties", (string)Model.ContainerContentType).ToString(), "Edit", new { Area = "Contents", Id = Model.ContainerId })
|
||||
|
||||
@Html.ActionLink(T("Show Orphaned Content Items").ToString(), "Orphaned", new { Area = "Orchard.Lists" })
|
||||
@if (((int?)Model.ContainerId).HasValue) {
|
||||
<text>|</text>
|
||||
@Html.ActionLink(T("{0} Properties", (string)Model.ContainerContentType).ToString(), "Edit", new { Area = "Contents", Id = (int)Model.ContainerId })
|
||||
}
|
||||
</p>
|
||||
</div>
|
Reference in New Issue
Block a user