#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
This commit is contained in:
Dave Reed
2011-04-05 15:01:43 -07:00
parent 02e4dbdb66
commit e964798de2
4 changed files with 12 additions and 11 deletions

View File

@@ -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<IRoutableAspect>().Title,
Text = x.ContentItem.TypeDefinition.DisplayName + ": " + _contentManager.GetItemMetadata(x.ContentItem).DisplayText,
Selected = x.Id == model.ContainerId,
}))
.ToList();

View File

@@ -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 <a href=\"{0}\">{1}</a>.",
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;
}

View File

@@ -8,14 +8,14 @@
var targetContainers = ((IEnumerable<ContentItem>)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<ContentItem>)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();

View File

@@ -31,15 +31,16 @@
</div>
@using (Html.BeginFormAntiForgeryPost()) {
var options = (ContentOptions) Model.Options;
<fieldset class="bulk-actions">
<label for="publishActions">@T("Actions:")</label>
<select id="publishActions" name="Options.BulkAction">
@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())
@Html.SelectOption(options.BulkAction, ContentsBulkAction.None, T("Choose action...").ToString())
@Html.SelectOption(options.BulkAction, ContentsBulkAction.PublishNow, T("Publish Now").ToString())
@Html.SelectOption(options.BulkAction, ContentsBulkAction.Unpublish, T("Unpublish").ToString())
@Html.SelectOption(options.BulkAction, ContentsBulkAction.Remove, T("Delete").ToString())
@Html.SelectOption(options.BulkAction, ContentsBulkAction.RemoveFromList, T("Remove from List").ToString())
@Html.SelectOption(options.BulkAction, ContentsBulkAction.MoveToList, T("Move to List...").ToString())
</select>
@Html.DropDownList("TargetContainerId", lists, new { id = "TargetContainerId" })
<button type="submit" name="submit.BulkEdit" value="yes">@T("Apply")</button>