Enabling restoration of removed content from audit trail history view.

This commit is contained in:
Sipke Schoorstra
2014-10-26 17:37:43 -07:00
parent 10ee9e1057
commit 7c2f8e07cb
4 changed files with 43 additions and 1 deletions

View File

@@ -324,6 +324,12 @@
<ItemGroup>
<Content Include="Views\RecycleBin\Index.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\AuditTrailEventActions-Content-Removed.SummaryAdmin.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\AuditTrailEvent-Content-Restored.SummaryAdmin.cshtml" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

View File

@@ -0,0 +1,22 @@
@using Orchard.AuditTrail.Helpers
@using Orchard.AuditTrail.Services.Models
@using Orchard.ContentManagement
@{
var descriptor = (AuditTrailEventDescriptor)Model.Descriptor;
var eventData = (IDictionary<string, object>) Model.EventData;
var eventPastTense = descriptor.Name.Text.ToLower();
var contentItemId = (int)Model.ContentItemId;
var contentItem = (ContentItem) Model.ContentItem;
var eventVersionNumber = eventData.Get<int>("VersionNumber");
var itemDisplayText = contentItem != null ? Html.ItemDisplayText(contentItem) : default(IHtmlString);
var title = itemDisplayText != null ? itemDisplayText.ToString() : eventData.Get<string>("Title") ?? "[untitled]";
}
<section class="audittrail-content-eventsummary">
@if (contentItem != null) {
var contentType = contentItem.ContentType;
@T("The {1} {2} was {3} as {0}.", Html.ActionLink(T("Version {0}", eventVersionNumber).Text, "Detail", "Content", new { area = "Orchard.AuditTrail", id = contentItemId, version = eventVersionNumber }, null), contentType.ToLower(), Html.ItemEditLink(title, contentItemId).ToString(), eventPastTense)
}
else {
@T("Content item <strong>{1}</strong> was {2} as <strong>Version {0}</strong>.", eventVersionNumber, title, eventPastTense)
}
</section>

View File

@@ -0,0 +1,14 @@
@using Orchard.AuditTrail.Helpers
@using Orchard.AuditTrail.Models
@using Orchard.ContentManagement
@{
var record = (AuditTrailEventRecord)Model.Record;
var eventData = (IDictionary<string, object>) Model.EventData;
var versionNumber = eventData.Get<int>("VersionNumber");
var contentItem = (ContentItem) Model.ContentItem;
}
@Html.ActionLink(T("Details").Text, "Detail", "Admin", new { id = record.Id, area = "Orchard.AuditTrail" }, null)
@if (contentItem != null) {
@T(" | ")
@Html.ActionLink(T("Restore").Text, "Restore", "Content", new {id = contentItem.Id, version = versionNumber, area = "Orchard.AuditTrail"}, new { data_unsafe_url = T("Are you sure you want to restore this content item?", versionNumber) })
}

View File

@@ -21,7 +21,7 @@
<select name="RecycleBinCommand">
<option></option>
<option value="@RecycleBinCommand.Restore" data-unsafe-action="@T("Are you sure you want to restore the selected items?")" @if(Model.RecycleBinCommand == RecycleBinCommand.Restore){<text>selected="selected"</text>}>@T("Restore")</option>
<option value="@RecycleBinCommand.Destroy" data-unsafe-action='["@T("WARNING: This will PERMANENTLY delete the selected content items, including related content part records, never to be seen again. Are you really absolutely sure you want to do this?")", "@T("Are you absolutely sure? You will not be able to restore permanenly deleted items. You should seriously consider making a DB backup first. This is your last chance to back out my friend. Are you sure you wish to proceed?")"]' @if (Model.RecycleBinCommand == RecycleBinCommand.Destroy) { <text> selected="selected" </text> }>@T("Remove Permanently ☠")</option>
<option value="@RecycleBinCommand.Destroy" data-unsafe-action='["@T("WARNING: This will PERMANENTLY delete the selected content items, including related content part records, never to be seen again. Are you really absolutely sure you want to do this?")", "@T("Are you sure? You will not be able to restore permanenly deleted items. You should seriously consider making a DB backup first. This is your last chance to back out my friend. Are you sure you wish to proceed?")"]' @if (Model.RecycleBinCommand == RecycleBinCommand.Destroy) { <text> selected="selected" </text> }>@T("Remove Permanently ☠")</option>
</select>
</div>
<div class="filter-control-group">