Added missing view

This commit is contained in:
Mark McDowall
2013-03-20 20:02:57 -07:00
parent 9ff7aa1bf7
commit 05c7b4f4ef
17 changed files with 205 additions and 6 deletions
@@ -0,0 +1,9 @@
define(['app', 'Missing/MissingModel'], function () {
NzbDrone.Missing.MissingCollection = Backbone.Collection.extend({
url: NzbDrone.Constants.ApiRoot + '/missing',
model: NzbDrone.Missing.MissingModel,
comparator: function(model) {
return model.get('airDate');
}
});
});
@@ -0,0 +1,12 @@
<table class="table table-hover x-missing-table">
<thead>
<tr>
<th>Series Title</th>
<th>Episode</th>
<th>Episode Title</th>
<th>Air Date</th>
<th></th>
</tr>
</thead>
<tbody></tbody>
</table>
@@ -0,0 +1,75 @@
'use strict';
define(['app', 'Missing/MissingItemView'], function (app) {
NzbDrone.Missing.MissingCollectionView = Backbone.Marionette.CompositeView.extend({
itemView: NzbDrone.Missing.MissingItemView,
itemViewContainer: 'tbody',
template: 'Missing/MissingCollectionTemplate',
ui:{
table : '.x-missing-table'
},
initialize: function (context, action, query, collection) {
this.collection = collection;
},
onCompositeCollectionRendered: function() {
this.ui.table.trigger('update');
if(!this.tableSorter && this.collection.length > 0)
{
this.tableSorter = this.ui.table.tablesorter({
textExtraction: function (node) {
return node.innerHTML;
},
sortList: [[3,1]],
headers: {
0: {
sorter: 'innerHtml'
},
1: {
sorter: false
},
2: {
sorter: false
},
3: {
sorter: 'date'
},
4: {
sorter: false
}
}
});
//Todo: We should extract these common settings out
this.ui.table.find('th.header').each(function(){
$(this).append('<i class="icon-sort pull-right">');
});
this.ui.table.bind("sortEnd", function() {
$(this).find('th.header i').each(function(){
$(this).remove();
});
$(this).find('th.header').each(function () {
if (!$(this).hasClass('headerSortDown') && !$(this).hasClass('headerSortUp'))
$(this).append('<i class="icon-sort pull-right">');
});
$(this).find('th.headerSortDown').each(function(){
$(this).append('<i class="icon-sort-up pull-right">');
});
$(this).find('th.headerSortUp').each(function(){
$(this).append('<i class="icon-sort-down pull-right">');
});
});
}
else
{
this.ui.table.trigger('update');
}
}
});
});
@@ -0,0 +1,5 @@
<td><a href="/series/details/{{seriesId}}">{{seriesTitle}}</a></td>
<td>{{seasonNumber}}x{{paddedEpisodeNumber}}</td>
<td name="episodeTitle"></td>
<td><span title="{{formatedDateString}}" data-date="{{airDate}}">{{bestDateString}}</span></td>
<td><i class="icon-search x-search" title="Search for Episode"></i></td>
@@ -0,0 +1,16 @@
'use strict';
define([
'app',
'Missing/MissingCollection'
], function () {
NzbDrone.Missing.MissingItemView = Backbone.Marionette.ItemView.extend({
template: 'Missing/MissingItemTemplate',
tagName: 'tr',
onRender: function () {
NzbDrone.ModelBinder.bind(this.model, this.el);
}
})
})
+12
View File
@@ -0,0 +1,12 @@
define(['app'], function (app) {
NzbDrone.Missing.MissingModel = Backbone.Model.extend({
mutators: {
bestDateString: function () {
return bestDateString(this.get('airDate'));
},
paddedEpisodeNumber: function(){
return this.get('episodeNumber');
}
}
});
});