mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#187 Displaying changes only for the trimmin settings that actually changed. Improved some display texts and renamed some classes.
This commit is contained in:
@@ -55,8 +55,8 @@ namespace Orchard.AuditTrail.Handlers {
|
||||
if (newEventSettings == _oldEventSettings)
|
||||
return;
|
||||
|
||||
_auditTrailManager.CreateRecord<SettingsAuditTrailEventProvider>(
|
||||
eventName: SettingsAuditTrailEventProvider.EventsChanged,
|
||||
_auditTrailManager.CreateRecord<AuditTrailSettingsEventProvider>(
|
||||
eventName: AuditTrailSettingsEventProvider.EventsChanged,
|
||||
eventData: new Dictionary<string, object> {
|
||||
{"OldSettings", _oldEventSettings},
|
||||
{"NewSettings", newEventSettings}
|
||||
|
@@ -43,8 +43,8 @@ namespace Orchard.AuditTrail.Handlers {
|
||||
if (newRetentionPeriod == _oldRetentionPeriod && newMinimumRunInterval == _oldMinimumRunInterval)
|
||||
return;
|
||||
|
||||
_auditTrailManager.CreateRecord<TrimmingSettingsAuditTrailEventProvider>(
|
||||
eventName: TrimmingSettingsAuditTrailEventProvider.TrimmingSettingsChanged,
|
||||
_auditTrailManager.CreateRecord<AuditTrailTrimmingSettingsEventProvider>(
|
||||
eventName: AuditTrailTrimmingSettingsEventProvider.TrimmingSettingsChanged,
|
||||
user: _wca.GetContext().CurrentUser,
|
||||
eventData: new Dictionary<string, object> {
|
||||
{"OldRetentionPeriod", _oldRetentionPeriod},
|
||||
|
@@ -184,8 +184,8 @@
|
||||
<Compile Include="ImportExport\AuditTrailImportHandler.cs" />
|
||||
<Compile Include="Models\AuditTrailEventRecordResult.cs" />
|
||||
<Compile Include="Models\AuditTrailTrimmingSettingsPart.cs" />
|
||||
<Compile Include="Providers\AuditTrail\TrimmingSettingsAuditTrailEventProvider.cs" />
|
||||
<Compile Include="Providers\AuditTrail\SettingsAuditTrailEventProvider.cs" />
|
||||
<Compile Include="Providers\AuditTrail\AuditTrailTrimmingSettingsEventProvider.cs" />
|
||||
<Compile Include="Providers\AuditTrail\AuditTrailSettingsEventProvider.cs" />
|
||||
<Compile Include="Services\Models\AuditTrailSettingsContext.cs" />
|
||||
<Compile Include="Services\CommonAuditTrailEventHandler.cs" />
|
||||
<Compile Include="Services\AuditTrailEventHandlerBase.cs" />
|
||||
|
@@ -2,13 +2,13 @@
|
||||
using Orchard.AuditTrail.Services.Models;
|
||||
|
||||
namespace Orchard.AuditTrail.Providers.AuditTrail {
|
||||
public class SettingsAuditTrailEventProvider : AuditTrailEventProviderBase {
|
||||
public class AuditTrailSettingsEventProvider : AuditTrailEventProviderBase {
|
||||
|
||||
public const string EventsChanged = "EventsChanged";
|
||||
|
||||
public override void Describe(DescribeContext context) {
|
||||
context.For("AuditTrailSettings", T("Audit Trail Settings"))
|
||||
.Event(this, EventsChanged, T("Events changed"), T("Audit trail event settings were changed."), enableByDefault: true, isMandatory: true);
|
||||
.Event(this, EventsChanged, T("Events changed"), T("The audit trail event settings were changed."), enableByDefault: true, isMandatory: true);
|
||||
}
|
||||
}
|
||||
}
|
@@ -8,14 +8,15 @@ using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.Environment;
|
||||
|
||||
namespace Orchard.AuditTrail.Providers.AuditTrail {
|
||||
public class AuditTrailSettingsEventShape : AuditTrailEventShapeAlteration<SettingsAuditTrailEventProvider> {
|
||||
public class AuditTrailSettingsEventShape : AuditTrailEventShapeAlteration<AuditTrailSettingsEventProvider> {
|
||||
private readonly Work<IAuditTrailManager> _auditTrailManager;
|
||||
|
||||
public AuditTrailSettingsEventShape(Work<IAuditTrailManager> auditTrailManager) {
|
||||
_auditTrailManager = auditTrailManager;
|
||||
}
|
||||
|
||||
protected override string EventName {
|
||||
get { return SettingsAuditTrailEventProvider.EventsChanged; }
|
||||
get { return AuditTrailSettingsEventProvider.EventsChanged; }
|
||||
}
|
||||
|
||||
protected override void OnAlterShape(ShapeDisplayingContext context) {
|
||||
@@ -31,14 +32,15 @@ namespace Orchard.AuditTrail.Providers.AuditTrail {
|
||||
|
||||
private IEnumerable<AuditTrailEventDescriptorSettingViewModel> GetDiffQuery(IEnumerable<AuditTrailEventSetting> oldSettings, IEnumerable<AuditTrailEventSetting> newSettings) {
|
||||
var oldDictionary = oldSettings.ToDictionary(x => x.EventName);
|
||||
|
||||
return from newSetting in newSettings
|
||||
let oldSetting = oldDictionary.ContainsKey(newSetting.EventName) ? oldDictionary[newSetting.EventName] : default(AuditTrailEventSetting)
|
||||
where oldSetting == null || oldSetting.IsEnabled != newSetting.IsEnabled
|
||||
select new AuditTrailEventDescriptorSettingViewModel {
|
||||
Setting = newSetting,
|
||||
Descriptor = _auditTrailManager.Value.DescribeEvent(newSetting.EventName)
|
||||
};
|
||||
|
||||
return
|
||||
from newSetting in newSettings
|
||||
let oldSetting = oldDictionary.ContainsKey(newSetting.EventName) ? oldDictionary[newSetting.EventName] : default(AuditTrailEventSetting)
|
||||
where oldSetting == null || oldSetting.IsEnabled != newSetting.IsEnabled
|
||||
select new AuditTrailEventDescriptorSettingViewModel {
|
||||
Setting = newSetting,
|
||||
Descriptor = _auditTrailManager.Value.DescribeEvent(newSetting.EventName)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -4,13 +4,13 @@ using Orchard.Environment.Extensions;
|
||||
|
||||
namespace Orchard.AuditTrail.Providers.AuditTrail {
|
||||
[OrchardFeature("Orchard.AuditTrail.Trimming")]
|
||||
public class TrimmingSettingsAuditTrailEventProvider : AuditTrailEventProviderBase {
|
||||
public class AuditTrailTrimmingSettingsEventProvider : AuditTrailEventProviderBase {
|
||||
|
||||
public const string TrimmingSettingsChanged = "TrimmingSettingsChanged";
|
||||
|
||||
public override void Describe(DescribeContext context) {
|
||||
context.For("AuditTrailSettings", T("Audit Trail Settings"))
|
||||
.Event(this, TrimmingSettingsChanged, T("Trimming settings changed"), T("Audit trail trimming settings were changed."), enableByDefault: true);
|
||||
.Event(this, TrimmingSettingsChanged, T("Trimming settings changed"), T("The audit trail trimming settings were changed."), enableByDefault: true);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
@using Orchard.AuditTrail.ViewModels
|
||||
@{
|
||||
var diff = (IList<AuditTrailEventDescriptorSettingViewModel>)Model.Diff;
|
||||
var descriptions = String.Join("<br/>", diff.Select(x => T("<strong>{0}</strong> ({1}) was <strong>{2}</strong>", x.Descriptor.Name, x.Descriptor.CategoryDescriptor.Name, x.Setting.IsEnabled ? "enabled" : "disabled").Text));
|
||||
var descriptions = String.Join("<br/>", diff.Select(x => T("The <strong>{0}</strong> event in category <strong>{1}</strong> was <strong>{2}</strong>.", x.Descriptor.Name, x.Descriptor.CategoryDescriptor.Name, x.Setting.IsEnabled ? "enabled" : "disabled").Text));
|
||||
}
|
||||
<section>
|
||||
@Html.Raw(descriptions)
|
||||
|
@@ -8,6 +8,10 @@
|
||||
}
|
||||
|
||||
<section class="audittrail-settings-summary">
|
||||
<div>@T("Trimming retention period changed from <strong>{0}</strong> to <strong>{1}</strong>", T.Plural("1 day", "{0} days", oldRetentionPeriod), T.Plural("1 day", "{0} days", newRetentionPeriod))</div>
|
||||
<div>@T("Minimum run interval changed from <strong>{0}</strong> to <strong>{1}</strong>", T.Plural("1 hour", "{0} hours", oldMinimumRunInterval), T.Plural("1 hour", "{0} hours", newMinimumRunInterval))</div>
|
||||
@if (newRetentionPeriod != oldRetentionPeriod) {
|
||||
<div>@T("The trimming retention period was changed from <strong>{0}</strong> to <strong>{1}</strong>.", T.Plural("1 day", "{0} days", oldRetentionPeriod), T.Plural("1 day", "{0} days", newRetentionPeriod))</div>
|
||||
}
|
||||
@if (newMinimumRunInterval != oldMinimumRunInterval) {
|
||||
<div>@T("The minimum trimming run interval was changed from <strong>{0}</strong> to <strong>{1}</strong>.", T.Plural("1 hour", "{0} hours", oldMinimumRunInterval), T.Plural("1 hour", "{0} hours", newMinimumRunInterval))</div>
|
||||
}
|
||||
</section>
|
Reference in New Issue
Block a user