From e964798de2b540e46698c00f1d1b8aac2eaf43d5 Mon Sep 17 00:00:00 2001 From: Dave Reed Date: Tue, 5 Apr 2011 15:01:43 -0700 Subject: [PATCH] #17666: having 1 (or more) content types containing ContainerPart but not RoutePart brings down entire ContainablePart - Containable does not rely on RoutePart to get the title, it just uses metadata. - Better display when a container is not routable. --HG-- branch : 1.x --- .../Containers/Drivers/ContainablePartDriver.cs | 2 +- .../Orchard.Lists/Controllers/AdminController.cs | 4 ++-- .../Modules/Orchard.Lists/Views/Admin/Choose.cshtml | 4 ++-- .../Modules/Orchard.Lists/Views/Admin/List.cshtml | 13 +++++++------ 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Orchard.Web/Core/Containers/Drivers/ContainablePartDriver.cs b/src/Orchard.Web/Core/Containers/Drivers/ContainablePartDriver.cs index 65666c63f..d56e148d3 100644 --- a/src/Orchard.Web/Core/Containers/Drivers/ContainablePartDriver.cs +++ b/src/Orchard.Web/Core/Containers/Drivers/ContainablePartDriver.cs @@ -50,7 +50,7 @@ namespace Orchard.Core.Containers.Drivers { var listItems = new[] { new SelectListItem { Text = T("(None)").Text, Value = "0" } } .Concat(containers.Select(x => new SelectListItem { Value = Convert.ToString(x.Id), - Text = x.ContentItem.TypeDefinition.DisplayName + ": " + x.As().Title, + Text = x.ContentItem.TypeDefinition.DisplayName + ": " + _contentManager.GetItemMetadata(x.ContentItem).DisplayText, Selected = x.Id == model.ContainerId, })) .ToList(); diff --git a/src/Orchard.Web/Modules/Orchard.Lists/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Lists/Controllers/AdminController.cs index 2b895ee47..f8f607cff 100644 --- a/src/Orchard.Web/Modules/Orchard.Lists/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Lists/Controllers/AdminController.cs @@ -311,7 +311,7 @@ namespace Lists.Controllers { // ensure the item can be in that container. if (!string.IsNullOrEmpty(itemContentType) && item.ContentType != itemContentType) { Services.TransactionManager.Cancel(); - 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)); + 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 ?? targetContainer.ContentItem.ContentType, itemContentType)); return true; // todo: transactions } @@ -319,7 +319,7 @@ namespace Lists.Controllers { FixItemPath(item); } Services.Notifier.Information(T("Content successfully moved to {1}.", - Url.Action("List", new { containerId = targetContainerId }), _contentManager.GetItemMetadata(targetContainer).DisplayText)); + Url.Action("List", new { containerId = targetContainerId }), _contentManager.GetItemMetadata(targetContainer).DisplayText ?? targetContainer.ContentItem.ContentType)); return true; } diff --git a/src/Orchard.Web/Modules/Orchard.Lists/Views/Admin/Choose.cshtml b/src/Orchard.Web/Modules/Orchard.Lists/Views/Admin/Choose.cshtml index 392854f5c..1dd634cbe 100644 --- a/src/Orchard.Web/Modules/Orchard.Lists/Views/Admin/Choose.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Lists/Views/Admin/Choose.cshtml @@ -8,14 +8,14 @@ var targetContainers = ((IEnumerable)Model.Containers).Select( contentItem => new SelectListItem { - Text = T("Move to {0}", contentItem.ContentManager.GetItemMetadata(contentItem).DisplayText).ToString(), + Text = T("Move to {0}", contentItem.ContentManager.GetItemMetadata(contentItem).DisplayText ?? contentItem.ContentType).ToString(), Value = contentItem.Id.ToString(System.Globalization.CultureInfo.InvariantCulture), Selected = contentItem.Id == targetContainerId }).ToList(); var sourceContainers = ((IEnumerable)Model.Containers).Select( contentItem => new SelectListItem { - Text = contentItem.ContentManager.GetItemMetadata(contentItem).DisplayText, + Text = contentItem.ContentManager.GetItemMetadata(contentItem).DisplayText ?? contentItem.ContentType, Value = contentItem.Id.ToString(System.Globalization.CultureInfo.InvariantCulture), Selected = contentItem.Id == sourceContainerId }).ToList(); diff --git a/src/Orchard.Web/Modules/Orchard.Lists/Views/Admin/List.cshtml b/src/Orchard.Web/Modules/Orchard.Lists/Views/Admin/List.cshtml index 152acb3e1..6b915120f 100644 --- a/src/Orchard.Web/Modules/Orchard.Lists/Views/Admin/List.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Lists/Views/Admin/List.cshtml @@ -31,15 +31,16 @@ @using (Html.BeginFormAntiForgeryPost()) { + var options = (ContentOptions) Model.Options;
@Html.DropDownList("TargetContainerId", lists, new { id = "TargetContainerId" })