From f008d856578d6efcf33544323466e4c1c6b8c5e2 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 9 Jul 2014 22:29:40 -0700 Subject: [PATCH] New: Show age when grabbed on history details --- src/UI/Handlebars/Helpers/Quality.js | 8 +++----- src/UI/History/Details/HistoryDetailsAge.js | 19 +++++++++++++++++++ src/UI/History/Details/HistoryDetailsView.js | 5 +++-- .../Details/HistoryDetailsViewTemplate.html | 4 ++++ 4 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 src/UI/History/Details/HistoryDetailsAge.js diff --git a/src/UI/Handlebars/Helpers/Quality.js b/src/UI/Handlebars/Helpers/Quality.js index d0050f577..292c04937 100644 --- a/src/UI/Handlebars/Helpers/Quality.js +++ b/src/UI/Handlebars/Helpers/Quality.js @@ -2,20 +2,18 @@ define( [ 'handlebars', - 'Quality/QualityProfileCollection', - 'underscore' - ], function (Handlebars, QualityProfileCollection, _) { + 'Quality/QualityProfileCollection' + ], function (Handlebars, QualityProfileCollection) { Handlebars.registerHelper('qualityProfile', function (profileId) { var profile = QualityProfileCollection.get(profileId); if (profile) { - return new Handlebars.SafeString('' + profile.get("name") + ''); + return new Handlebars.SafeString('' + profile.get('name') + ''); } return undefined; }); - }); diff --git a/src/UI/History/Details/HistoryDetailsAge.js b/src/UI/History/Details/HistoryDetailsAge.js new file mode 100644 index 000000000..d28dd317a --- /dev/null +++ b/src/UI/History/Details/HistoryDetailsAge.js @@ -0,0 +1,19 @@ +'use strict'; +define( + [ + 'handlebars' + ], function (Handlebars) { + + Handlebars.registerHelper('historyAge', function () { + + var unit = 'days'; + var age = this.age; + + if (age < 2) { + unit = 'hours'; + age = parseFloat(this.ageHours).toFixed(1); + } + + return new Handlebars.SafeString('
Age (when grabbed):
{0} {1}
'.format(age, unit)); + }); + }); diff --git a/src/UI/History/Details/HistoryDetailsView.js b/src/UI/History/Details/HistoryDetailsView.js index ba2177ac5..045189137 100644 --- a/src/UI/History/Details/HistoryDetailsView.js +++ b/src/UI/History/Details/HistoryDetailsView.js @@ -1,10 +1,11 @@ 'use strict'; define( [ + 'jquery', 'vent', 'marionette', - 'jquery' - ], function (vent, Marionette, $) { + 'History/Details/HistoryDetailsAge' + ], function ($, vent, Marionette) { return Marionette.ItemView.extend({ template: 'History/Details/HistoryDetailsViewTemplate', diff --git a/src/UI/History/Details/HistoryDetailsViewTemplate.html b/src/UI/History/Details/HistoryDetailsViewTemplate.html index 3cc969e84..19b6d3794 100644 --- a/src/UI/History/Details/HistoryDetailsViewTemplate.html +++ b/src/UI/History/Details/HistoryDetailsViewTemplate.html @@ -43,6 +43,10 @@
Download Client ID:
{{downloadClientId}}
{{/if}} + + {{#if age}} + {{historyAge}} + {{/if}} {{/with}} {{/if_eq}}