Starting missing conversion to backgrid

This commit is contained in:
Mark McDowall 2013-04-30 20:04:06 -07:00
commit 00276041ad
18 changed files with 148 additions and 204 deletions

View file

@ -1,6 +1,6 @@
"use strict";
define(['app', 'Series/EpisodeModel'], function () {
NzbDrone.Missing.MissingCollection = Backbone.Collection.extend({
define(['app'], function () {
NzbDrone.Missing.Collection = Backbone.PageableCollection.extend({
url : NzbDrone.Constants.ApiRoot + '/missing',
model : NzbDrone.Series.EpisodeModel,
comparator: function (model) {

View file

@ -0,0 +1 @@
<i class="icon-search x-search" title="Search"></i>

View file

@ -0,0 +1,2 @@

{{seasonNumber}}x{{paddedEpisodeNumber}}

View file

@ -1,37 +0,0 @@
<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>
<div class="x-missing-table-pager">
<div class="row">
<div class="pagination span8">
<ul>
<li class="first">
<a href="#"><i class="icon-fast-backward"></i></a>
</li>
<li class="prev">
<a href="#"><i class="icon-backward"></i></a></li>
<li>
<span class="page-number">0</span>
</li>
<li class="next">
<a href="#"><i class="icon-forward"></i></a>
</li>
<li class="last">
<a href="#"><i class="icon-fast-forward"></i></a>
</li>
</ul>
</div>
<div class="pull-right pagedisplay-container">
<span class="pagedisplay"></span>
</div>
</div>
</div>

View file

@ -1,87 +0,0 @@
'use strict';
define(['app', 'Missing/MissingItemView'], function () {
NzbDrone.Missing.MissingCollectionView = Backbone.Marionette.CompositeView.extend({
itemView : NzbDrone.Missing.MissingItemView,
itemViewContainer: 'tbody',
template : 'Missing/MissingCollectionTemplate',
ui: {
table: '.x-missing-table',
pager: '.x-missing-table-pager'
},
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
}
}
});
this.ui.table.bind('pagerComplete pagerInitialized', function (event, c) {
c.container.find('.page-number').text(c.page + 1);
});
this.ui.table.tablesorterPager({
container: this.ui.pager,
output : 'Displaying {startRow} to {endRow} of {totalRows} episodes'
});
this.applySortIcons();
this.ui.table.bind("sortEnd", function () {
this.applySortIcons();
});
}
else {
this.ui.table.trigger('update');
}
},
//Todo: Remove this from each view that requires it
applySortIcons : function () {
$(this.ui.table).find('th.tablesorter-header .tablesorter-header-inner i').each(function () {
$(this).remove();
});
$(this.ui.table).find('th.tablesorter-header').each(function () {
if ($(this).hasClass('tablesorter-headerDesc')) {
$(this).children('.tablesorter-header-inner').append('<i class="icon-sort-up pull-right">');
}
else if ($(this).hasClass('tablesorter-headerAsc')) {
$(this).children('.tablesorter-header-inner').append('<i class="icon-sort-down pull-right">');
}
else if (!$(this).hasClass('sorter-false')) {
$(this).children('.tablesorter-header-inner').append('<i class="icon-sort pull-right">');
}
});
},
updatePageNumber : function (event, stuff) {
}
});
});

View file

@ -1,5 +0,0 @@
<td><a href="/series/details/{{seriesId}}">{{seriesTitle}}</a></td>
<td>{{seasonNumber}}x{{paddedEpisodeNumber}}</td>
<td name="title"></td>
<td><span title="{{formatedDateString}}" data-date="{{airDate}}">{{bestDateString}}</span></td>
<td><i class="icon-search x-search" title="Search for Episode"></i></td>

View file

@ -1,12 +0,0 @@
'use strict';
define([
'app',
'Missing/MissingCollection'
], function () {
NzbDrone.Missing.MissingItemView = Backbone.Marionette.ItemView.extend({
template: 'Missing/MissingItemTemplate',
tagName : 'tr',
});
});

View file

@ -0,0 +1,84 @@
"use strict";
define([
'app',
'Missing/Collection',
'Series/Index/Table/AirDateCell',
'Series/Index/Table/SeriesStatusCell',
'Shared/Toolbar/ToolbarView',
'Shared/Toolbar/ToolbarLayout'
],
function () {
NzbDrone.Missing.MissingLayout = Backbone.Marionette.Layout.extend({
template: 'Missing/MissingLayoutTemplate',
regions: {
missing: '#x-missing',
toolbar: '#x-toolbar'
},
showTable: function () {
var columns = [
{
name : 'seriesTitle',
label : 'Series Title',
editable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Missing/SeriesTitleTemplate' }),
headerCell: 'nzbDrone'
},
{
name : 'episode',
label : 'Episode',
editable : false,
sortable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Missing/EpisodeColumnTemplate' }),
headerCell: 'nzbDrone'
},
{
name : 'title',
label : 'Episode Title',
editable : false,
sortable : false,
cell : 'string',
headerCell: 'nzbDrone'
},
{
name : 'airDate',
label : 'Air Date',
editable : false,
cell : 'airDate',
headerCell: 'nzbDrone'
},
{
name : 'edit',
label : '',
editable : false,
sortable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Missing/ControlsColumnTemplate' }),
headerCell: 'nzbDrone'
}
];
this.missing.show(new Backgrid.Grid(
{
row : NzbDrone.Missing.Row,
columns : columns,
collection: this.missingCollection,
className : 'table table-hover'
}));
},
initialize: function () {
this.missingCollection = new NzbDrone.Missing.Collection();
this.missingCollection.fetch();
},
onShow: function () {
this.showTable();
//this.toolbar.show(new NzbDrone.Shared.Toolbar.ToolbarLayout({right: [ viewButtons], context: this}));
}
})
;
})
;

View file

@ -0,0 +1,6 @@
<div id="x-toolbar"></div>
<div class="row">
<div class="span12">
<div id="x-missing"></div>
</div>
</div>

9
UI/Missing/Row.js Normal file
View file

@ -0,0 +1,9 @@
NzbDrone.Missing.Row = Backgrid.Row.extend({
events: {
'click .x-search' : 'search'
},
search: function () {
window.alert('Episode Search');
}
});

View file

@ -0,0 +1 @@
<a href="series/details/{{series.titleSlug}}">{{series.title}}</a>