New: Show age when grabbed on history details

This commit is contained in:
Mark McDowall 2014-07-09 22:29:40 -07:00
parent 140427c76e
commit f008d85657
4 changed files with 29 additions and 7 deletions

View File

@ -2,20 +2,18 @@
define( define(
[ [
'handlebars', 'handlebars',
'Quality/QualityProfileCollection', 'Quality/QualityProfileCollection'
'underscore' ], function (Handlebars, QualityProfileCollection) {
], function (Handlebars, QualityProfileCollection, _) {
Handlebars.registerHelper('qualityProfile', function (profileId) { Handlebars.registerHelper('qualityProfile', function (profileId) {
var profile = QualityProfileCollection.get(profileId); var profile = QualityProfileCollection.get(profileId);
if (profile) { if (profile) {
return new Handlebars.SafeString('<span class="label label-default quality-profile-label">' + profile.get("name") + '</span>'); return new Handlebars.SafeString('<span class="label label-default quality-profile-label">' + profile.get('name') + '</span>');
} }
return undefined; return undefined;
}); });
}); });

View File

@ -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('<dt>Age (when grabbed):</dt><dd>{0} {1}</dd>'.format(age, unit));
});
});

View File

@ -1,10 +1,11 @@
'use strict'; 'use strict';
define( define(
[ [
'jquery',
'vent', 'vent',
'marionette', 'marionette',
'jquery' 'History/Details/HistoryDetailsAge'
], function (vent, Marionette, $) { ], function ($, vent, Marionette) {
return Marionette.ItemView.extend({ return Marionette.ItemView.extend({
template: 'History/Details/HistoryDetailsViewTemplate', template: 'History/Details/HistoryDetailsViewTemplate',

View File

@ -43,6 +43,10 @@
<dt>Download Client ID:</dt> <dt>Download Client ID:</dt>
<dd>{{downloadClientId}}</dd> <dd>{{downloadClientId}}</dd>
{{/if}} {{/if}}
{{#if age}}
{{historyAge}}
{{/if}}
{{/with}} {{/with}}
</dl> </dl>
{{/if_eq}} {{/if_eq}}