Cleaned up a few uses of the DateTime shape.

This commit is contained in:
Daniel Stolt
2014-08-03 01:21:42 +02:00
parent 2dbf6f9b2b
commit 3cdfd6848b
4 changed files with 11 additions and 17 deletions

View File

@@ -37,7 +37,7 @@
<td class="category-column">@record.CategoryDescriptor.Name</td> <td class="category-column">@record.CategoryDescriptor.Name</td>
<td class="event-column">@record.EventDescriptor.Name</td> <td class="event-column">@record.EventDescriptor.Name</td>
<td class="user-column">@record.Record.UserName</td> <td class="user-column">@record.Record.UserName</td>
<td class="timestamp-column">@Display.DateTime(DateTimeUtc: record.Record.CreatedUtc, CustomFormat: T("g"))</td> <td class="timestamp-column">@Display.DateTime(DateTimeUtc: record.Record.CreatedUtc)</td>
<td class="summary-column">@Display(record.SummaryShape)</td> <td class="summary-column">@Display(record.SummaryShape)</td>
<td class="comment-column">@record.Record.Comment</td> <td class="comment-column">@record.Record.Comment</td>
<td class="actions-column">@Html.ActionLink(T("Details").Text, "Detail", "Admin", new { id = record.Record.Id, area = "Orchard.AuditTrail" }, null)</td> <td class="actions-column">@Html.ActionLink(T("Details").Text, "Detail", "Admin", new { id = record.Record.Id, area = "Orchard.AuditTrail" }, null)</td>

View File

@@ -2,7 +2,6 @@
@using Orchard.Azure.MediaServices.Models @using Orchard.Azure.MediaServices.Models
@using Orchard.Azure.MediaServices.Models.Assets @using Orchard.Azure.MediaServices.Models.Assets
@using Orchard.Azure.MediaServices.Models.Jobs @using Orchard.Azure.MediaServices.Models.Jobs
@using Orchard.Localization.Services
@{ @{
Style.Include("cloudmedia-edit-jobs.css", "cloudmedia-edit-jobs.min.css"); Style.Include("cloudmedia-edit-jobs.css", "cloudmedia-edit-jobs.min.css");
Style.Include("cloudmedia-progress.css", "cloudmedia-progress.min.css"); Style.Include("cloudmedia-progress.css", "cloudmedia-progress.min.css");
@@ -13,11 +12,10 @@
var isUploaded = !isCreatingItem && cloudVideoPart.MezzanineAsset.UploadState.Status == AssetUploadStatus.Uploaded; var isUploaded = !isCreatingItem && cloudVideoPart.MezzanineAsset.UploadState.Status == AssetUploadStatus.Uploaded;
var jobsToDisplay = cloudVideoPart != null ? cloudVideoPart.Jobs.Where(x => x.Status != JobStatus.Archived).ToArray() : Enumerable.Empty<Job>(); var jobsToDisplay = cloudVideoPart != null ? cloudVideoPart.Jobs.Where(x => x.Status != JobStatus.Archived).ToArray() : Enumerable.Empty<Job>();
var authorizedToManageJobs = AuthorizedFor(Permissions.ManageCloudMediaJobs); var authorizedToManageJobs = AuthorizedFor(Permissions.ManageCloudMediaJobs);
var dateTimeFormatProvider = WorkContext.Resolve<IDateTimeFormatProvider>();
} }
@helper ShortDateTime(DateTime? value, IDateTimeFormatProvider dateTimeFormatProvider) { @helper ShortDateTime(DateTime? value) {
if (value != null) { if (value != null) {
@Display.DateTime(DateTimeUtc: value, CustomFormat: T(dateTimeFormatProvider.ShortDateTimeFormat)) @Display.DateTime(DateTimeUtc: value)
} }
} }
@if (!isCreatingItem && jobsToDisplay.Any()) { @if (!isCreatingItem && jobsToDisplay.Any()) {
@@ -41,7 +39,7 @@
<tr> <tr>
<td>@job.Name</td> <td>@job.Name</td>
<td>@job.Description</td> <td>@job.Description</td>
<td>@ShortDateTime(job.CreatedUtc, dateTimeFormatProvider)</td> <td>@ShortDateTime(job.CreatedUtc)</td>
<td> <td>
@if (job.Status == JobStatus.Processing) { @if (job.Status == JobStatus.Processing) {
var percentComplete = Convert.ToInt32(job.PercentComplete); var percentComplete = Convert.ToInt32(job.PercentComplete);
@@ -57,8 +55,8 @@
} }
</td> </td>
<td>@ShortDateTime(job.StartedUtc, dateTimeFormatProvider)</td> <td>@ShortDateTime(job.StartedUtc)</td>
<td>@ShortDateTime(job.FinishedUtc, dateTimeFormatProvider)</td> <td>@ShortDateTime(job.FinishedUtc)</td>
<td>@job.ErrorMessage</td> <td>@job.ErrorMessage</td>
<td> <td>
@if (authorizedToManageJobs) { @if (authorizedToManageJobs) {

View File

@@ -1,5 +1,4 @@
@using Orchard.Azure.MediaServices.Models.Jobs @using Orchard.Azure.MediaServices.Models.Jobs
@using Orchard.Localization.Services
@{ @{
Style.Include("cloudmedia-progress.css", "cloudmedia-progress.min.css"); Style.Include("cloudmedia-progress.css", "cloudmedia-progress.min.css");
Script.Require("ShapesBase"); Script.Require("ShapesBase");
@@ -7,11 +6,10 @@
Layout.Title = "Manage Microsoft Azure Media Jobs"; Layout.Title = "Manage Microsoft Azure Media Jobs";
var jobs = (IEnumerable<Job>)Model.Jobs; var jobs = (IEnumerable<Job>)Model.Jobs;
var dateTimeFormatProvider = WorkContext.Resolve<IDateTimeFormatProvider>();
} }
@helper ShortDateTime(DateTime? value, IDateTimeFormatProvider dateTimeFormatProvider) { @helper ShortDateTime(DateTime? value) {
if (value != null) { if (value != null) {
@Display.DateTime(DateTimeUtc: value, CustomFormat: T(dateTimeFormatProvider.ShortDateTimeFormat)) @Display.DateTime(DateTimeUtc: value)
} }
} }
<table class="items" style="width: auto"> <table class="items" style="width: auto">
@@ -42,7 +40,7 @@
<td>@job.Name</td> <td>@job.Name</td>
<td>@job.Description</td> <td>@job.Description</td>
<td>@Html.ItemEditLinkWithReturnUrl(Html.ItemDisplayText(job.CloudVideoPart).ToString(), job.CloudVideoPart)</td> <td>@Html.ItemEditLinkWithReturnUrl(Html.ItemDisplayText(job.CloudVideoPart).ToString(), job.CloudVideoPart)</td>
<td>@ShortDateTime(job.CreatedUtc, dateTimeFormatProvider)</td> <td>@ShortDateTime(job.CreatedUtc)</td>
<td> <td>
@if (job.Status == JobStatus.Processing) { @if (job.Status == JobStatus.Processing) {
var percentComplete = Convert.ToInt32(job.PercentComplete); var percentComplete = Convert.ToInt32(job.PercentComplete);
@@ -57,8 +55,8 @@
@T(job.Status.ToString()) @T(job.Status.ToString())
} }
</td> </td>
<td>@ShortDateTime(job.StartedUtc, dateTimeFormatProvider)</td> <td>@ShortDateTime(job.StartedUtc)</td>
<td>@ShortDateTime(job.FinishedUtc, dateTimeFormatProvider)</td> <td>@ShortDateTime(job.FinishedUtc)</td>
<td>@job.ErrorMessage</td> <td>@job.ErrorMessage</td>
<td> <td>
@if (job.CanArchive) { @if (job.CanArchive) {

View File

@@ -2,11 +2,9 @@ TODO:
* Test for proper handling of fraction (f) format specifier - suspect it does not work properly in current state * Test for proper handling of fraction (f) format specifier - suspect it does not work properly in current state
* Add formatting and parsing of time zone information (add timezone properties to TimeParts structure) * Add formatting and parsing of time zone information (add timezone properties to TimeParts structure)
* Write unit tests for DefaultDateLocalizationServices * Write unit tests for DefaultDateLocalizationServices
* Add warning message when saving unsupported combination in settings
* Add support for the different Gregorian calendar types * Add support for the different Gregorian calendar types
* Make sure DateTimeField, ArchiveLaterPart and PublishLaterPart handle Persian dates correctly. * Make sure DateTimeField, ArchiveLaterPart and PublishLaterPart handle Persian dates correctly.
* Improve CultureDateTimeFormatProvider to return correct information for fa-IR culture when PersianCalendar is in use. * Improve CultureDateTimeFormatProvider to return correct information for fa-IR culture when PersianCalendar is in use.
* Check for all uses of Display.DateTime that use a standard format string - no can do!
BREAKING: BREAKING:
* DateTokens "Date.Format:<formatString>" and "Date.Local.Format:<formatString>" only supports custom date/time format strings. * DateTokens "Date.Format:<formatString>" and "Date.Local.Format:<formatString>" only supports custom date/time format strings.