mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#194: Implemented the missing ContentPart.DescriptionChanged event.
This commit is contained in:
@@ -139,6 +139,7 @@
|
||||
<Content Include="Views\AuditTrailEvent-Role-Removed.cshtml" />
|
||||
<Content Include="Views\AuditTrailEvent-Role-UserAdded.cshtml" />
|
||||
<Content Include="Views\AuditTrailEvent-Role-UserRemoved.cshtml" />
|
||||
<Content Include="Views\AuditTrailEvent-ContentPart-DescriptionChanged.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
|
||||
|
@@ -15,6 +15,7 @@ using Orchard.Environment.Extensions;
|
||||
namespace Orchard.AuditTrail.Providers.ContentDefinition {
|
||||
[OrchardFeature("Orchard.AuditTrail.ContentDefinition")]
|
||||
public class GlobalContentDefinitionEditorEvents : ContentDefinitionEditorEventsBase {
|
||||
private const string _contentPartSettingsDescriptionName = "ContentPartSettings.Description";
|
||||
private readonly IAuditTrailManager _auditTrailManager;
|
||||
private readonly IWorkContextAccessor _wca;
|
||||
private readonly IContentDefinitionService _contentDefinitionService;
|
||||
@@ -118,13 +119,30 @@ namespace Orchard.AuditTrail.Providers.ContentDefinition {
|
||||
|
||||
public override void PartEditorUpdated(ContentPartDefinitionBuilder builder) {
|
||||
var contentPartDefinition = builder.Build();
|
||||
var newSettings = contentPartDefinition.Settings;
|
||||
var newPartSettings = contentPartDefinition.Settings;
|
||||
|
||||
if (!AreEqual(newSettings, _oldPartSettings)) {
|
||||
if (newPartSettings.ContainsKey(_contentPartSettingsDescriptionName)) {
|
||||
var oldDescription = _oldPartSettings.Get(_contentPartSettingsDescriptionName);
|
||||
var newDescription = newPartSettings.Get(_contentPartSettingsDescriptionName);
|
||||
if (oldDescription != newDescription) {
|
||||
var eventData = new Dictionary<string, object> {
|
||||
{"ContentPartName", builder.Name},
|
||||
{"OldDescription", oldDescription},
|
||||
{"NewDescription", newDescription}
|
||||
};
|
||||
RecordContentPartAuditTrail(ContentPartAuditTrailEventProvider.DescriptionChanged, eventData, builder.Name);
|
||||
}
|
||||
}
|
||||
|
||||
// Description change should not be re-recorded as general settings change.
|
||||
var remainingOldPartSettings = new SettingsDictionary(_oldPartSettings.Where(item => item.Key != _contentPartSettingsDescriptionName).ToDictionary(item => item.Key, item => item.Value));
|
||||
var remainingNewPartSettings = new SettingsDictionary(newPartSettings.Where(item => item.Key != _contentPartSettingsDescriptionName).ToDictionary(item => item.Key, item => item.Value));
|
||||
|
||||
if (!AreEqual(remainingNewPartSettings, remainingOldPartSettings)) {
|
||||
var eventData = new Dictionary<string, object> {
|
||||
{"ContentPartName", builder.Name},
|
||||
{"OldSettings", ToXml(_oldPartSettings)},
|
||||
{"NewSettings", ToXml(newSettings)}
|
||||
{"OldSettings", ToXml(remainingOldPartSettings)},
|
||||
{"NewSettings", ToXml(remainingNewPartSettings)}
|
||||
};
|
||||
RecordContentPartAuditTrail(ContentPartAuditTrailEventProvider.PartSettingsUpdated, eventData, builder.Name);
|
||||
}
|
||||
|
@@ -0,0 +1,11 @@
|
||||
@using Orchard.AuditTrail.Helpers
|
||||
@{
|
||||
var eventData = (IDictionary<string, object>) Model.EventData;
|
||||
var contentPartName = eventData.Get<string>("ContentPartName");
|
||||
var oldDescription = eventData.Get<string>("OldDescription");
|
||||
var newDescription = eventData.Get<string>("NewDescription");
|
||||
}
|
||||
|
||||
<section class="audittrail-contentpart-summary">
|
||||
@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]")))
|
||||
</section>
|
@@ -7,5 +7,5 @@
|
||||
}
|
||||
|
||||
<section>
|
||||
@T("The display name for the content type <strong>{0}</strong> was changed from <strong>{1}</strong> to <strong>{2}</strong>.", contentTypeName, oldDisplayName, newDisplayName)
|
||||
@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]")))
|
||||
</section>
|
Reference in New Issue
Block a user