Lists no longer need to specialize the entire Content.SummaryAdmin shape by using the new AdminLink metadata.

--HG--
branch : dev
This commit is contained in:
Dave Reed
2011-03-07 11:04:48 -08:00
parent c158caba49
commit 0d92ef27fa
5 changed files with 20 additions and 40 deletions

View File

@@ -1,4 +1,5 @@
using System.Linq;
using System.Web.Routing;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Handlers;
@@ -70,5 +71,20 @@ namespace Orchard.Core.Containers.Drivers {
part.Record.OrderByDirection = (int)OrderByDirection.Descending;
});
}
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
var container = context.ContentItem.As<ContainerPart>();
if (container == null)
return;
// containers link to their contents in admin screens
context.Metadata.AdminRouteValues = new RouteValueDictionary {
{"Area", "Contents"},
{"Controller", "Admin"},
{"Action", "List"},
{"containerId", container.Id}
};
}
}
}

View File

@@ -66,10 +66,6 @@
<ItemGroup>
<Content Include="Styles\images\menu.list.png" />
<Content Include="Styles\menu.list-admin.css" />
<Content Include="Views\Items\Content-List.SummaryAdmin.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Placement.info" />
</ItemGroup>
<ItemGroup>
<Content Include="Web.config" />
@@ -79,6 +75,9 @@
<SubType>Designer</SubType>
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="Views\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -1,7 +0,0 @@
<Placement>
<Match ContentType="List">
<Match DisplayType="SummaryAdmin">
<Place Parts_Container_Contained_SummaryAdmin="-"/>
</Match>
</Match>
</Placement>

View File

@@ -1,28 +0,0 @@
@using Orchard.ContentManagement;
@using Orchard.Utility.Extensions;
@{
ContentItem contentItem = Model.ContentItem;
string returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString();
ContentItemMetadata contentItemMetadata = contentItem.ContentManager.GetItemMetadata(contentItem);
}
<div class="summary" itemscope="itemscope" itemid="@contentItem.Id" itemtype="http://orchardproject.net/data/ContentItem">
<div class="properties">
<input type="checkbox" value="@contentItem.Id" name="itemIds"/>
<h3>@Html.Link(contentItemMetadata.DisplayText, Url.Action("List", "Admin", new { area = "Contents", containerId = contentItem.Id, id = "" }))</h3>
@if (Model.Header != null) {
<div class="header">@Display(Model.Header)</div>
}
@if (Model.Meta != null) {
<div class="metadata">@Display(Model.Meta)</div>
}
</div>
<div class="related">
@Display(Model.Actions)
@Html.Link(T("List Items").Text, Url.Action("List", "Admin", new { area = "Contents", containerId = contentItem.Id, id = "" }))@T(" | ")
@Html.ItemEditLink(T("Edit").Text, contentItem) @T(" | ")
@Html.Link(T("Remove").Text, Url.Action("Remove", "Admin", new { area = "Contents", id = contentItem.Id, returnUrl }), new { itemprop = "RemoveUrl UnsafeUrl" })
</div>
@if (Model.Content != null) {
<div class="primary">@Display(Model.Content)</div>
}
</div>

View File

@@ -49,7 +49,7 @@ namespace Orchard.Mvc.Html {
}
public static MvcHtmlString ItemAdminLink(this HtmlHelper html, IContent content) {
return ItemEditLink(html, null, content);
return ItemAdminLink(html, null, content);
}
public static MvcHtmlString ItemAdminLink(this HtmlHelper html, string linkText, IContent content) {