New: show number of items in queue over history icon

This commit is contained in:
Mark McDowall
2014-08-30 17:15:39 -07:00
parent 8bb2659fcd
commit 47b132360c
6 changed files with 55 additions and 12 deletions
+37
View File
@@ -0,0 +1,37 @@
'use strict';
define(
[
'underscore',
'marionette',
'History/Queue/QueueCollection'
], function (_, Marionette, QueueCollection) {
return Marionette.ItemView.extend({
tagName: 'span',
initialize: function () {
this.listenTo(QueueCollection, 'sync', this.render);
QueueCollection.fetch();
},
render: function () {
this.$el.empty();
if (QueueCollection.length === 0) {
return this;
}
var count = QueueCollection.length;
var label = 'label-info';
var errors = QueueCollection.some(function (model) {
return model.get('errorMessage') !== '';
});
if (errors) {
label = 'label-danger';
}
this.$el.html('<span class="label {0}">{1}</span>'.format(label, count));
return this;
}
});
});