Making content item titles, content types and content parts clickable.

This commit is contained in:
Sipke Schoorstra
2014-07-28 19:12:51 -07:00
parent 703390de47
commit 02441b2520
22 changed files with 38 additions and 28 deletions

View File

@@ -0,0 +1,15 @@
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;
namespace Orchard.AuditTrail.Helpers {
public static class HtmlExtensions {
public static IHtmlString ContentPartEditLink(this HtmlHelper html, string contentPartName) {
return html.ActionLink(contentPartName, "EditPart", "Admin", new {id = contentPartName, area = "Orchard.ContentTypes"}, null);
}
public static IHtmlString ContentTypeEditLink(this HtmlHelper html, string contentTypeName) {
return html.ActionLink(contentTypeName, "Edit", "Admin", new { id = contentTypeName, area = "Orchard.ContentTypes" }, null);
}
}
}

View File

@@ -182,6 +182,7 @@
<Compile Include="Helpers\FiltersExtensions.cs" />
<Compile Include="Helpers\DateTimeExtensions.cs" />
<Compile Include="Helpers\SettingsDictionaryExtensions.cs" />
<Compile Include="Helpers\HtmlExtensions.cs" />
<Compile Include="Helpers\XmlHelper.cs" />
<Compile Include="Helpers\StringExtensions.cs" />
<Compile Include="ImportExport\AuditTrailExportStep.cs" />

View File

@@ -7,17 +7,11 @@
var eventVersionNumber = eventData.Get<int>("VersionNumber");
var eventIsPublished = eventData.Get<bool>("Published");
var contentType = contentItem.ContentType;
var title = Html.ItemDisplayText(contentItem);
var isLatest = contentItem.VersionRecord.Number == eventVersionNumber;
}
<section class="audittrail-content-eventsummary">
@T("{0} - {1} (version {2})", contentType, title, eventVersionNumber)
@T("{0} - {1} (version {2})", contentType, Html.ItemEditLink(contentItem), eventVersionNumber)
@if (eventIsPublished) {
@T(" - ")
<a href="@Url.Action("Detail", "Content", new { area = "Orchard.AuditTrail", id = contentItemId, version = eventVersionNumber })">@T("View")</a>
}
else if (isLatest) {
@T(" - ")
<a href="@Url.Action("Edit", "Admin", new {area = "Contents", id = contentItemId})">@T("Edit")</a>
}
</section>

View File

@@ -13,7 +13,7 @@
}
<section class="audittrail-content-eventmetadata">
@T("ID:") <strong>@contentItem.Id</strong><br />
@contentItem.ContentType: <strong>@Html.ItemDisplayText(contentItem)</strong><br />
@contentItem.ContentType: <strong>@Html.ItemEditLink(contentItem)</strong><br />
@T("Version:") <strong>@contentItem.Version</strong>
@if (!String.IsNullOrWhiteSpace(record.Comment)) {
<br />

View File

@@ -4,5 +4,5 @@
var contentPartName = eventData.Get<string>("ContentPartName");
}
<section class="audittrail-contentpart-eventsummary">
@T("The content part <strong>{0}</strong> was created.", contentPartName)
@T("The content part {0} was created.", Html.ContentPartEditLink(contentPartName))
</section>

View File

@@ -6,5 +6,5 @@
var newDescription = eventData.Get<string>("NewDescription");
}
<section class="audittrail-contentpart-eventsummary">
@T("The description of content part <strong>{0}</strong> was changed from <strong>{1}</strong> to <strong>{2}</strong>.", contentPartName, oldDescription.OrIfEmpty(T("[Empty]")), newDescription.OrIfEmpty(T("[Empty]")))
@T("The description of content part {0} was changed from <strong>{1}</strong> to <strong>{2}</strong>.", Html.ContentPartEditLink(contentPartName), oldDescription.OrIfEmpty(T("[Empty]")), newDescription.OrIfEmpty(T("[Empty]")))
</section>

View File

@@ -7,5 +7,5 @@
var contentDisplayName = eventData.Get<string>("ContentDisplayName");
}
<section class="audittrail-contentpart-eventsummary">
@T("The content field <strong>{0}</strong> of type <strong>{1}</strong> was added to the content part <strong>{2}</strong>.", contentFieldName, contentFieldTypeName, contentPartName)
@T("The content field <strong>{0}</strong> of type <strong>{1}</strong> was added to the content part {2}.", contentFieldName, contentFieldTypeName, Html.ContentPartEditLink(contentPartName))
</section>

View File

@@ -5,5 +5,5 @@
var contentFieldName = eventData.Get<string>("ContentFieldName");
}
<section class="audittrail-contentpart-eventsummary">
@T("The content field <strong>{0}</strong> was removed from the content part <strong>{1}</strong>.", contentFieldName, contentPartName)
@T("The content field <strong>{0}</strong> was removed from the content part {1}.", contentFieldName, Html.ContentPartEditLink(contentPartName))
</section>

View File

@@ -12,7 +12,7 @@
var diff = (DiffDictionary<string, string>)Model.Diff;
}
<section class="audittrail-contentpart-eventsummary">
@T("Settings for the field <strong>{0}</strong> attached to the <strong>{1}</strong> content type were updated:", contentFieldName, contentPartName)
@T("Settings for the field <strong>{0}</strong> attached to the {1} content part were updated:", contentFieldName, Html.ContentPartEditLink(contentPartName))
<ul>
@foreach (var setting in diff) {
<li>

View File

@@ -12,7 +12,7 @@
var diff = (DiffDictionary<string, string>)Model.Diff;
}
<section class="audittrail-contentpart-eventsummary">
@T("Settings for the field <strong>{0}</strong> attached to the <strong>{1}</strong> content type were updated:", contentFieldName, contentPartName)
@T("Settings for the field <strong>{0}</strong> attached to the {1} content part were updated:", contentFieldName, Html.ContentPartEditLink(contentPartName))
<table class="items">
<thead>
<tr>

View File

@@ -9,7 +9,7 @@
var diff = (DiffDictionary<string, string>)Model.Diff;
}
<section class="audittrail-contentpart-eventsummary">
@T("Settings for the content part <strong>{0}</strong> were changed:", contentPartName)
@T("Settings for the content part {0} were changed:", Html.ContentPartEditLink(contentPartName))
<ul>
@foreach (var setting in diff) {
<li>

View File

@@ -9,7 +9,7 @@
var diff = (DiffDictionary<string, string>)Model.Diff;
}
<section class="audittrail-contentpart-eventsummary">
@T("Settings for the content part <strong>{0}</strong> were changed:", contentPartName)
@T("Settings for the content part {0} were changed:", Html.ContentPartEditLink(contentPartName))
<table class="items">
<thead>
<tr>

View File

@@ -5,5 +5,5 @@
var contentTypeDisplayName = eventData.Get<string>("ContentTypeDisplayName");
}
<section class="audittrail-contenttype-eventsummary">
@T("The content type <strong>{0}</strong> was created.", contentTypeName)
@T("The content type {0} was created.", Html.ContentTypeEditLink(contentTypeName))
</section>

View File

@@ -10,10 +10,10 @@
var contentFieldName = eventData.Get<string>("ContentFieldName");
var diff = (DiffDictionary<string, string>)Model.Diff;
var isImplicitPart = contentTypeName == contentPartName;
var captionTemplate = isImplicitPart ? "Settings for the field <strong>{0}</strong> attached to the content type <strong>{1}</strong> were updated:" : "Settings for the field <strong>{0}</strong> attached to content part <strong>{1}</strong> of the content type <strong>{2}</strong> were updated:";
var captionTemplate = isImplicitPart ? "Settings for the field <strong>{0}</strong> attached to the content type {1} were updated:" : "Settings for the field <strong>{0}</strong> attached to content part {1} of the content type {2} were updated:";
}
<section class="audittrail-contenttype-eventsummary">
@T(captionTemplate, contentFieldName, contentPartName, contentTypeName)
@T(captionTemplate, contentFieldName, Html.ContentPartEditLink(contentPartName), Html.ContentTypeEditLink(contentTypeName))
<ul>
@foreach (var setting in diff) {
<li>

View File

@@ -10,10 +10,10 @@
var contentFieldName = eventData.Get<string>("ContentFieldName");
var diff = (DiffDictionary<string, string>)Model.Diff;
var isImplicitPart = contentTypeName == contentPartName;
var captionTemplate = isImplicitPart ? "Settings for the field <strong>{0}</strong> attached to the content type <strong>{1}</strong> were updated:" : "Settings for the field <strong>{0}</strong> attached to content part <strong>{1}</strong> of the content type <strong>{2}</strong> were updated:";
var captionTemplate = isImplicitPart ? "Settings for the field <strong>{0}</strong> attached to the content type {1} were updated:" : "Settings for the field <strong>{0}</strong> attached to content part {1} of the content type {2} were updated:";
}
<section class="audittrail-contenttype-eventsummary">
@T(captionTemplate, contentFieldName, contentPartName, contentTypeName)
@T(captionTemplate, contentFieldName, Html.ContentPartEditLink(contentPartName), Html.ContentTypeEditLink(contentTypeName))
<table class="items">
<thead>
<tr>

View File

@@ -5,5 +5,5 @@
var contentPartName = eventData.Get<string>("ContentPartName");
}
<section class="audittrail-contenttype-eventsummary">
@T("The content part <strong>{0}</strong> was added to the content type <strong>{1}</strong>.", contentPartName, contentTypeName)
@T("The content part {0} was added to the content type {1}.", Html.ContentPartEditLink(contentPartName), Html.ContentTypeEditLink(contentTypeName))
</section>

View File

@@ -5,5 +5,5 @@
var contentPartName = eventData.Get<string>("ContentPartName");
}
<section class="audittrail-contenttype-eventsummary">
@T("The content part <strong>{0}</strong> was removed from the content type <strong>{1}</strong>.", contentPartName, contentTypeName)
@T("The content part {0} was removed from the content type {1}.", Html.ContentPartEditLink(contentPartName), Html.ContentTypeEditLink(contentTypeName))
</section>

View File

@@ -10,7 +10,7 @@
var diff = (DiffDictionary<string, string>)Model.Diff;
}
<section class="audittrail-contenttype-eventsummary">
@T("Settings for the content part <strong>{0}</strong> attached to the content type <strong>{1}</strong> were changed:", contentPartName, contentTypeName)
@T("Settings for the content part {0} attached to the content type {1} were changed:", Html.ContentPartEditLink(contentPartName), Html.ContentTypeEditLink(contentTypeName))
<ul>
@foreach (var setting in diff) {
<li>

View File

@@ -10,7 +10,7 @@
var diff = (DiffDictionary<string, string>)Model.Diff;
}
<section class="audittrail-contenttype-eventsummary">
@T("Settings for the content part <strong>{0}</strong> attached to the content type <strong>{1}</strong> were changed:", contentPartName, contentTypeName)
@T("Settings for the content part {0} attached to the content type {1} were changed:", Html.ContentPartEditLink(contentPartName), Html.ContentTypeEditLink(contentTypeName))
<table class="items">
<thead>
<tr>

View File

@@ -6,5 +6,5 @@
var newDisplayName = eventData.Get<string>("NewDisplayName");
}
<section class="audittrail-contenttype-eventsummary">
@T("The display name for the content type <strong>{0}</strong> was changed from <strong>{1}</strong> to <strong>{2}</strong>.", contentTypeName, oldDisplayName.OrIfEmpty(T("[Empty]")), newDisplayName.OrIfEmpty(T("[Empty]")))
@T("The display name for the content type {0} was changed from <strong>{1}</strong> to <strong>{2}</strong>.", Html.ContentTypeEditLink(contentTypeName), oldDisplayName.OrIfEmpty(T("[Empty]")), newDisplayName.OrIfEmpty(T("[Empty]")))
</section>

View File

@@ -9,7 +9,7 @@
var diff = (DiffDictionary<string, string>) Model.Diff;
}
<section class="audittrail-contenttype-eventsummary">
@T("Settings for the content type <strong>{0}</strong> were changed:", contentTypeName)
@T("Settings for the content type {0} were changed:", Html.ContentTypeEditLink(contentTypeName))
<ul>
@foreach (var setting in diff) {
<li>

View File

@@ -9,7 +9,7 @@
var diff = (DiffDictionary<string, string>) Model.Diff;
}
<section class="audittrail-contenttype-eventsummary">
@T("Settings for the content type <strong>{0}</strong> were changed:", contentTypeName)
@T("Settings for the content type {0} were changed:", Html.ContentTypeEditLink(contentTypeName))
<table class="items">
<thead>
<tr>